mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Enable multisampling in RTTs to support A2C
This commit is contained in:
parent
54d465e3dc
commit
54853380cd
3 changed files with 35 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <components/fallback/fallback.hpp>
|
||||
#include <components/sceneutil/lightmanager.hpp>
|
||||
#include <components/sceneutil/shadow.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -135,7 +136,7 @@ namespace MWRender
|
|||
mCamera->setProjectionMatrixAsPerspective(fovYDegrees, sizeX/static_cast<float>(sizeY), 0.1f, 10000.f); // zNear and zFar are autocomputed
|
||||
mCamera->setViewport(0, 0, sizeX, sizeY);
|
||||
mCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture);
|
||||
mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture, 0, 0, false, Settings::Manager::getInt("antialiasing", "Video"));
|
||||
mCamera->setName("CharacterPreview");
|
||||
mCamera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
|
||||
mCamera->setCullMask(~(Mask_UpdateVisitor));
|
||||
|
|
|
@ -233,7 +233,17 @@ 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);
|
||||
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, texture);
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("convert alpha test to alpha-to-coverage", "Shaders"))
|
||||
{
|
||||
// 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);
|
||||
|
||||
camera->addChild(mSceneRoot);
|
||||
mRoot->addChild(camera);
|
||||
|
|
|
@ -271,7 +271,17 @@ public:
|
|||
mRefractionTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||
mRefractionTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
||||
|
||||
attach(osg::Camera::COLOR_BUFFER, mRefractionTexture);
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("convert alpha test to alpha-to-coverage", "Shaders"))
|
||||
{
|
||||
// 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);
|
||||
|
||||
mRefractionDepthTexture = new osg::Texture2D;
|
||||
mRefractionDepthTexture->setTextureSize(rttSize, rttSize);
|
||||
|
@ -356,7 +366,17 @@ public:
|
|||
mReflectionTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||
mReflectionTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||
|
||||
attach(osg::Camera::COLOR_BUFFER, mReflectionTexture);
|
||||
unsigned int samples = 0;
|
||||
unsigned int colourSamples = 0;
|
||||
if (Settings::Manager::getBool("convert alpha test to alpha-to-coverage", "Shaders"))
|
||||
{
|
||||
// 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);
|
||||
|
||||
// XXX: should really flip the FrontFace on each renderable instead of forcing clockwise.
|
||||
osg::ref_ptr<osg::FrontFace> frontFace (new osg::FrontFace);
|
||||
|
|
Loading…
Reference in a new issue