mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Merge branch 'sunglare_fix' into 'master'
Fix sunglare in sky shaders See merge request OpenMW/openmw!1430
This commit is contained in:
commit
fb4c611570
@ -300,7 +300,7 @@ namespace MWRender
|
|||||||
mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager(), forceShaders);
|
mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager(), forceShaders);
|
||||||
atmosphereNight->addUpdateCallback(mAtmosphereNightUpdater);
|
atmosphereNight->addUpdateCallback(mAtmosphereNightUpdater);
|
||||||
|
|
||||||
mSun.reset(new Sun(mEarlyRenderBinRoot, *mSceneManager->getImageManager()));
|
mSun.reset(new Sun(mEarlyRenderBinRoot, *mSceneManager));
|
||||||
mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Masser_Size")/125, Moon::Type_Masser));
|
mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Masser_Size")/125, Moon::Type_Masser));
|
||||||
mSecunda.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda));
|
mSecunda.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda));
|
||||||
|
|
||||||
|
@ -694,12 +694,14 @@ namespace MWRender
|
|||||||
mTransform->setNodeMask(visible ? mVisibleMask : 0);
|
mTransform->setNodeMask(visible ? mVisibleMask : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sun::Sun(osg::Group* parentNode, Resource::ImageManager& imageManager)
|
Sun::Sun(osg::Group* parentNode, Resource::SceneManager& sceneManager)
|
||||||
: CelestialBody(parentNode, 1.0f, 1, Mask_Sun)
|
: CelestialBody(parentNode, 1.0f, 1, Mask_Sun)
|
||||||
, mUpdater(new SunUpdater)
|
, mUpdater(new SunUpdater)
|
||||||
{
|
{
|
||||||
mTransform->addUpdateCallback(mUpdater);
|
mTransform->addUpdateCallback(mUpdater);
|
||||||
|
|
||||||
|
Resource::ImageManager& imageManager = *sceneManager.getImageManager();
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> sunTex = new osg::Texture2D(imageManager.getImage("textures/tx_sun_05.dds"));
|
osg::ref_ptr<osg::Texture2D> sunTex = new osg::Texture2D(imageManager.getImage("textures/tx_sun_05.dds"));
|
||||||
sunTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
sunTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||||
sunTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
sunTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||||
@ -714,9 +716,12 @@ namespace MWRender
|
|||||||
stateset->setRenderBinDetails(RenderBin_OcclusionQuery, "RenderBin");
|
stateset->setRenderBinDetails(RenderBin_OcclusionQuery, "RenderBin");
|
||||||
stateset->setNestRenderBins(false);
|
stateset->setNestRenderBins(false);
|
||||||
// Set up alpha testing on the occlusion testing subgraph, that way we can get the occlusion tested fragments to match the circular shape of the sun
|
// Set up alpha testing on the occlusion testing subgraph, that way we can get the occlusion tested fragments to match the circular shape of the sun
|
||||||
osg::ref_ptr<osg::AlphaFunc> alphaFunc = new osg::AlphaFunc;
|
if (!sceneManager.getForceShaders())
|
||||||
alphaFunc->setFunction(osg::AlphaFunc::GREATER, 0.8);
|
{
|
||||||
stateset->setAttributeAndModes(alphaFunc);
|
osg::ref_ptr<osg::AlphaFunc> alphaFunc = new osg::AlphaFunc;
|
||||||
|
alphaFunc->setFunction(osg::AlphaFunc::GREATER, 0.8);
|
||||||
|
stateset->setAttributeAndModes(alphaFunc);
|
||||||
|
}
|
||||||
stateset->setTextureAttributeAndModes(0, sunTex);
|
stateset->setTextureAttributeAndModes(0, sunTex);
|
||||||
stateset->setAttributeAndModes(createUnlitMaterial());
|
stateset->setAttributeAndModes(createUnlitMaterial());
|
||||||
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Sunflash_Query)));
|
stateset->addUniform(new osg::Uniform("pass", static_cast<int>(Pass::Sunflash_Query)));
|
||||||
@ -816,6 +821,7 @@ namespace MWRender
|
|||||||
// without having to retrieve the current far clipping distance.
|
// without having to retrieve the current far clipping distance.
|
||||||
// We want the sun glare to be "infinitely" far away.
|
// We want the sun glare to be "infinitely" far away.
|
||||||
double far = SceneUtil::AutoDepth::isReversed() ? 0.0 : 1.0;
|
double far = SceneUtil::AutoDepth::isReversed() ? 0.0 : 1.0;
|
||||||
|
depth->setFunction(osg::Depth::LEQUAL);
|
||||||
depth->setZNear(far);
|
depth->setZNear(far);
|
||||||
depth->setZFar(far);
|
depth->setZFar(far);
|
||||||
depth->setWriteMask(false);
|
depth->setWriteMask(false);
|
||||||
@ -879,6 +885,8 @@ namespace MWRender
|
|||||||
camera->setClearMask(0);
|
camera->setClearMask(0);
|
||||||
camera->setRenderOrder(osg::Camera::NESTED_RENDER);
|
camera->setRenderOrder(osg::Camera::NESTED_RENDER);
|
||||||
camera->setAllowEventFocus(false);
|
camera->setAllowEventFocus(false);
|
||||||
|
camera->getOrCreateStateSet()->addUniform(new osg::Uniform("projectionMatrix", static_cast<osg::Matrixf>(camera->getProjectionMatrix())));
|
||||||
|
SceneUtil::setCameraClearDepth(camera);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> geom = osg::createTexturedQuadGeometry(osg::Vec3f(-1,-1,0), osg::Vec3f(2,0,0), osg::Vec3f(0,2,0));
|
osg::ref_ptr<osg::Geometry> geom = osg::createTexturedQuadGeometry(osg::Vec3f(-1,-1,0), osg::Vec3f(2,0,0), osg::Vec3f(0,2,0));
|
||||||
camera->addChild(geom);
|
camera->addChild(geom);
|
||||||
|
@ -239,7 +239,7 @@ namespace MWRender
|
|||||||
class Sun : public CelestialBody
|
class Sun : public CelestialBody
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Sun(osg::Group* parentNode, Resource::ImageManager& imageManager);
|
Sun(osg::Group* parentNode, Resource::SceneManager& sceneManager);
|
||||||
|
|
||||||
~Sun();
|
~Sun();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user