mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-09 21:44:54 +00:00
Enable multisampling in RTTs to support A2C
This commit is contained in:
parent
54d465e3dc
commit
54853380cd
@ -17,6 +17,7 @@
|
|||||||
#include <components/fallback/fallback.hpp>
|
#include <components/fallback/fallback.hpp>
|
||||||
#include <components/sceneutil/lightmanager.hpp>
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
#include <components/sceneutil/shadow.hpp>
|
#include <components/sceneutil/shadow.hpp>
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.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->setProjectionMatrixAsPerspective(fovYDegrees, sizeX/static_cast<float>(sizeY), 0.1f, 10000.f); // zNear and zFar are autocomputed
|
||||||
mCamera->setViewport(0, 0, sizeX, sizeY);
|
mCamera->setViewport(0, 0, sizeX, sizeY);
|
||||||
mCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
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->setName("CharacterPreview");
|
||||||
mCamera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
|
mCamera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
|
||||||
mCamera->setCullMask(~(Mask_UpdateVisitor));
|
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_S, osg::Texture::CLAMP_TO_EDGE);
|
||||||
texture->setWrap(osg::Texture::WRAP_T, 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);
|
camera->addChild(mSceneRoot);
|
||||||
mRoot->addChild(camera);
|
mRoot->addChild(camera);
|
||||||
|
@ -271,7 +271,17 @@ public:
|
|||||||
mRefractionTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
mRefractionTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||||
mRefractionTexture->setFilter(osg::Texture::MAG_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 = new osg::Texture2D;
|
||||||
mRefractionDepthTexture->setTextureSize(rttSize, rttSize);
|
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_S, osg::Texture::CLAMP_TO_EDGE);
|
||||||
mReflectionTexture->setWrap(osg::Texture::WRAP_T, 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.
|
// XXX: should really flip the FrontFace on each renderable instead of forcing clockwise.
|
||||||
osg::ref_ptr<osg::FrontFace> frontFace (new osg::FrontFace);
|
osg::ref_ptr<osg::FrontFace> frontFace (new osg::FrontFace);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user