mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:15:31 +00:00
Refactor out duplicated RTT setup code
This commit is contained in:
parent
4ed67d8597
commit
f5a87ee46d
4 changed files with 25 additions and 33 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <components/settings/settings.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
#include <components/sceneutil/shadow.hpp>
|
||||
#include <components/sceneutil/util.hpp>
|
||||
#include <components/files/memorystream.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -237,17 +238,7 @@ void LocalMap::setupRenderToTexture(osg::ref_ptr<osg::Camera> camera, int x, int
|
|||
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("antialias alpha test", "Shaders") && Settings::Manager::getInt("antialiasing", "Video") > 1)
|
||||
{
|
||||
// Alpha-to-coverage requires a multisampled framebuffer.
|
||||
// OSG will set that up automatically and resolve it to the specified single-sample texture for us.
|
||||
// For some reason, two samples are needed, at least with some drivers.
|
||||
samples = 2;
|
||||
colourSamples = 1;
|
||||
}
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, 0, false, samples, colourSamples);
|
||||
SceneUtil::attachAlphaToCoverageFriendlyFramebufferToCamera(camera, osg::Camera::COLOR_BUFFER, texture);
|
||||
|
||||
camera->addChild(mSceneRoot);
|
||||
mRoot->addChild(camera);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
#include <components/sceneutil/shadow.hpp>
|
||||
#include <components/sceneutil/util.hpp>
|
||||
#include <components/sceneutil/waterutil.hpp>
|
||||
|
||||
#include <components/misc/constants.hpp>
|
||||
|
@ -271,17 +272,7 @@ public:
|
|||
mRefractionTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||
mRefractionTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
||||
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("antialias alpha test", "Shaders") && Settings::Manager::getInt("antialiasing", "Video") > 1)
|
||||
{
|
||||
// Alpha-to-coverage requires a multisampled framebuffer.
|
||||
// OSG will set that up automatically and resolve it to the specified single-sample texture for us.
|
||||
// For some reason, two samples are needed, at least with some drivers.
|
||||
samples = 2;
|
||||
colourSamples = 1;
|
||||
}
|
||||
attach(osg::Camera::COLOR_BUFFER, mRefractionTexture, 0, 0, false, samples, colourSamples);
|
||||
SceneUtil::attachAlphaToCoverageFriendlyFramebufferToCamera(this, osg::Camera::COLOR_BUFFER, mRefractionTexture);
|
||||
|
||||
mRefractionDepthTexture = new osg::Texture2D;
|
||||
mRefractionDepthTexture->setTextureSize(rttSize, rttSize);
|
||||
|
@ -366,17 +357,7 @@ public:
|
|||
mReflectionTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||
mReflectionTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("antialias alpha test", "Shaders") && Settings::Manager::getInt("antialiasing", "Video") > 1)
|
||||
{
|
||||
// Alpha-to-coverage requires a multisampled framebuffer.
|
||||
// OSG will set that up automatically and resolve it to the specified single-sample texture for us.
|
||||
// For some reason, two samples are needed, at least with some drivers.
|
||||
samples = 2;
|
||||
colourSamples = 1;
|
||||
}
|
||||
attach(osg::Camera::COLOR_BUFFER, mReflectionTexture, 0, 0, false, samples, colourSamples);
|
||||
SceneUtil::attachAlphaToCoverageFriendlyFramebufferToCamera(this, osg::Camera::COLOR_BUFFER, mReflectionTexture);
|
||||
|
||||
// XXX: should really flip the FrontFace on each renderable instead of forcing clockwise.
|
||||
osg::ref_ptr<osg::FrontFace> frontFace (new osg::FrontFace);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <components/resource/imagemanager.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
|
@ -260,4 +261,19 @@ osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resourc
|
|||
return glowUpdater;
|
||||
}
|
||||
|
||||
bool attachAlphaToCoverageFriendlyFramebufferToCamera(osg::Camera* camera, osg::Camera::BufferComponent buffer, osg::Texture * texture, unsigned int level, unsigned int face, bool mipMapGeneration)
|
||||
{
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("antialias alpha test", "Shaders") && Settings::Manager::getInt("antialiasing", "Video") > 1)
|
||||
{
|
||||
// Alpha-to-coverage requires a multisampled framebuffer.
|
||||
// OSG will set that up automatically and resolve it to the specified single-sample texture for us.
|
||||
// For some reason, two samples are needed, at least with some drivers.
|
||||
samples = 2;
|
||||
colourSamples = 1;
|
||||
}
|
||||
camera->attach(buffer, texture, level, face, mipMapGeneration, samples, colourSamples);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <osg/Matrix>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/Camera>
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Vec4f>
|
||||
|
@ -60,6 +61,9 @@ namespace SceneUtil
|
|||
bool hasUserDescription(const osg::Node* node, const std::string pattern);
|
||||
|
||||
osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resource::ResourceSystem* resourceSystem, osg::Vec4f glowColor, float glowDuration=-1);
|
||||
|
||||
// Alpha-to-coverage requires a multisampled framebuffer, so we need to set that up for RTTs
|
||||
bool attachAlphaToCoverageFriendlyFramebufferToCamera(osg::Camera* camera, osg::Camera::BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face = 0, bool mipMapGeneration = false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue