diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 97312b697..c2ad2a043 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -27,6 +27,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mTerrainManager = new TerrainManager(mRendering.getScene(), environment); + mWater = 0; + //The fog type must be set before any terrain objects are created as if the //fog type is set to FOG_NONE then the initially created terrain won't have any fog configureFog(1, ColourValue(1,1,1)); @@ -39,8 +41,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const // disable MRT if it is unsupported const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities(); - if (caps->getNumMultiRenderTargets() < 2 - || (!caps->isShaderProfileSupported("fp40") && !caps->isShaderProfileSupported("ps_3_0"))) + if (caps->getNumMultiRenderTargets() < 2) Settings::Manager::setBool("multiple render targets", "Render", false); if (Settings::Manager::getBool("multiple render targets", "Render")) @@ -73,8 +74,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode()); - mWater = 0; - mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mSun = 0; @@ -311,6 +310,8 @@ void RenderingManager::configureFog(const float density, const Ogre::ColourValue CompositorInstance* inst = CompositorManager::getSingleton().getCompositorChain(mRendering.getViewport())->getCompositor("gbuffer"); if (inst != 0) inst->getCompositor()->getTechnique(0)->getTargetPass(0)->getPass(0)->setClearColour(colour); + if (mWater) + mWater->setViewportBackground(colour); } diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 02af314a8..43ef31d86 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -913,3 +913,13 @@ Ogre::SceneNode* SkyManager::getSunNode() if (!mCreated) return 0; return mSun->getNode(); } + +void SkyManager::setSkyPosition(const Ogre::Vector3& position) +{ + mRootNode->_setDerivedPosition(position); +} + +void SkyManager::resetSkyPosition() +{ + mRootNode->setPosition(0,0,0); +} diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index baf5933cb..c18b9f484 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -168,6 +168,9 @@ namespace MWRender void setGlare(const float glare); Ogre::Vector3 getRealSunPos(); + void setSkyPosition(const Ogre::Vector3& position); + void resetSkyPosition(); + private: bool mCreated; diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 7e9dd957b..cce25d1e9 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -36,8 +36,8 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : + RV_Statics * Settings::Manager::getBool("reflect statics", "Water") + RV_StaticsSmall * Settings::Manager::getBool("reflect small statics", "Water") + RV_Actors * Settings::Manager::getBool("reflect actors", "Water") - + RV_Misc * Settings::Manager::getBool("reflect misc", "Water"); - //+ RV_Sky; + + RV_Misc * Settings::Manager::getBool("reflect misc", "Water") + + RV_Sky; mReflectDistance = Settings::Manager::getInt("reflect distance", "Water"); mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); @@ -145,11 +145,14 @@ void Water::preRenderTargetUpdate(const RenderTargetEvent& evt) if (mReflectDistance != 0) mCamera->setFarClipDistance(mReflectDistance); - if (evt.source == mReflectionTarget) - { - mCamera->enableCustomNearClipPlane(Plane(Vector3::UNIT_Y, mTop)); - mCamera->enableReflection(Plane(Vector3::UNIT_Y, mTop)); - } + if (evt.source == mReflectionTarget) + { + Vector3 pos = mCamera->getRealPosition(); + pos.y = mTop*2 - pos.y; + mSky->setSkyPosition(pos); + mCamera->enableCustomNearClipPlane(Plane(Vector3::UNIT_Y, mTop)); + mCamera->enableReflection(Plane(Vector3::UNIT_Y, mTop)); + } } void Water::postRenderTargetUpdate(const RenderTargetEvent& evt) @@ -158,11 +161,12 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt) mCamera->setFarClipDistance(mOldCameraFarClip); - if (evt.source == mReflectionTarget) - { - mCamera->disableReflection(); - mCamera->disableCustomNearClipPlane(); - } + if (evt.source == mReflectionTarget) + { + mSky->resetSkyPosition(); + mCamera->disableReflection(); + mCamera->disableCustomNearClipPlane(); + } } Ogre::MaterialPtr Water::createMaterial() @@ -199,4 +203,10 @@ Ogre::MaterialPtr Water::createMaterial() return mat; } +void Water::setViewportBackground(const ColourValue& bg) +{ + if (mReflectionTarget) + mReflectionTarget->getViewport(0)->setBackgroundColour(bg); +} + } // namespace diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index 8e9014833..964a8c735 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -50,6 +50,8 @@ namespace MWRender { void toggle(); + void setViewportBackground(const Ogre::ColourValue& bg); + void checkUnderwater(float y); void changeCell(const ESM::Cell* cell); void setHeight(const float height); diff --git a/files/water/water.cg b/files/water/water.cg index 10b42eec0..188c37709 100644 --- a/files/water/water.cg +++ b/files/water/water.cg @@ -76,7 +76,7 @@ void main_fp // fresnel float facing = 1.0 - max(abs(dot(normalize(iEyeVector.xyz), normal.xyz)), 0); - float reflectionFactor = saturate(0.3 + 0.7 * pow(facing, 2)); + float reflectionFactor = saturate(0.35 + 0.65 * pow(facing, 2)); oColor.xyz = lerp(refraction.xyz, reflection.xyz, depth1 * reflectionFactor);