diff --git a/apps/openmw/mwrender/renderconst.hpp b/apps/openmw/mwrender/renderconst.hpp index 4445ffe6b..ab411a6cb 100644 --- a/apps/openmw/mwrender/renderconst.hpp +++ b/apps/openmw/mwrender/renderconst.hpp @@ -18,6 +18,8 @@ enum RenderQueueGroups RQG_Alpha = Ogre::RENDER_QUEUE_7, + RQG_UnderWater = Ogre::RENDER_QUEUE_7+1, + RQG_OcclusionQuery = Ogre::RENDER_QUEUE_8, // Sky late (sun & sun flare) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 4b38cb148..2f85d3599 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -54,6 +54,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const if (caps->getNumMultiRenderTargets() < 2) Settings::Manager::setBool("shader", "Water", false); + // note that the order is important here if (useMRT()) { CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "gbuffer"); @@ -61,6 +62,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "gbufferFinalizer"); CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbufferFinalizer", true); } + CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "Water"); // Turn the entire scene (represented by the 'root' node) -90 // degrees around the x axis. This makes Z go upwards, and Y go into diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index dd06e2181..89b40cf63 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -16,7 +16,6 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : try { - CompositorManager::getSingleton().addCompositor(mViewport, "Water", -1); CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false); } catch(...) {} @@ -76,7 +75,7 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : void Water::setActive(bool active) { mActive = active; - if (mReflectionTarget) mReflectionTarget->setActive(active); + if (mReflectionTarget) mReflectionTarget->setActive(active && !mIsUnderwater); mWater->setVisible(active); } @@ -130,6 +129,8 @@ void Water::checkUnderwater(float y) if (mReflectionTarget) mReflectionTarget->setActive(mActive); + mWater->setRenderQueueGroup(RQG_Water); + mIsUnderwater = false; } @@ -147,6 +148,8 @@ void Water::checkUnderwater(float y) if (mReflectionTarget) mReflectionTarget->setActive(false); + mWater->setRenderQueueGroup(RQG_UnderWater); + mIsUnderwater = true; } }