From a5c6207fe76e710e30f8db6ed65ce799e2e678ca Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 8 Apr 2012 17:44:00 +0200 Subject: [PATCH 1/3] add setting to disable the underwater effect --- apps/openmw/mwrender/water.cpp | 18 +++++------------- apps/openmw/mwrender/water.hpp | 3 +-- files/settings-default.cfg | 3 +++ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 615a24a76..7981def0b 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -10,7 +10,7 @@ namespace MWRender Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()), - mIsUnderwater(false), mReflectDistance(0), mVisibilityFlags(0), mOldCameraFarClip(0), + mIsUnderwater(false), mVisibilityFlags(0), mReflectionTarget(0), mActive(1) { mSky = sky; @@ -38,7 +38,6 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : + RV_Actors * Settings::Manager::getBool("reflect actors", "Water") + RV_Misc * Settings::Manager::getBool("reflect misc", "Water") + RV_Sky; - mReflectDistance = Settings::Manager::getInt("reflect distance", "Water"); mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); mWaterNode->setPosition(0, mTop, 0); @@ -73,6 +72,8 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : createMaterial(); mWater->setMaterial(mMaterial); + + mUnderwaterEffect = Settings::Manager::getBool("underwater effect", "Water"); } void Water::setActive(bool active) @@ -120,9 +121,7 @@ void Water::checkUnderwater(float y) if (!mActive) return; if ((mIsUnderwater && y > mTop) || !mWater->isVisible() || mCamera->getPolygonMode() != Ogre::PM_SOLID) { - try { - CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false); - } catch(...) {} + CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false); // tell the shader we are not underwater Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0); @@ -139,9 +138,8 @@ void Water::checkUnderwater(float y) if (!mIsUnderwater && y < mTop && mWater->isVisible() && mCamera->getPolygonMode() == Ogre::PM_SOLID) { - try { + if (mUnderwaterEffect) CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, true); - } catch(...) {} // tell the shader we are underwater Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0); @@ -164,10 +162,6 @@ Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY) void Water::preRenderTargetUpdate(const RenderTargetEvent& evt) { - //mOldCameraFarClip = mCamera->getFarClipDistance(); - //if (mReflectDistance != 0) - // mCamera->setFarClipDistance(mReflectDistance); - if (evt.source == mReflectionTarget) { mWater->setVisible(false); @@ -189,8 +183,6 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt) { mWater->setVisible(true); - //mCamera->setFarClipDistance(mOldCameraFarClip); - if (evt.source == mReflectionTarget) { mSky->resetSkyPosition(); diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index b5aa29a5b..0e23f5b0c 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -41,9 +41,8 @@ namespace MWRender { Ogre::RenderTarget* mReflectionTarget; + bool mUnderwaterEffect; int mVisibilityFlags; - int mReflectDistance; - int mOldCameraFarClip; public: Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell); diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 6b037c06a..4b86cba92 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -71,6 +71,9 @@ reflect actors = true reflect misc = false +# Enable underwater effect. It is not resource intensive, so only disable it if you have problems. +underwater effect = true + [Sound] # Device name. Blank means default device = From 0b2dab0b5dca85d548bb29305456db3a845c31d5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 8 Apr 2012 18:17:52 +0200 Subject: [PATCH 2/3] disable water fog due to some issues --- files/water/water.cg | 4 ++-- files/water/water.material | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/water/water.cg b/files/water/water.cg index 7c7ec0780..bf6d04c5c 100644 --- a/files/water/water.cg +++ b/files/water/water.cg @@ -116,6 +116,6 @@ void main_fp oColor.xyz = lerp(oColor.xyz, float3(0, 0.65, 0.65), saturate(isUnderwater * (iDepth / 2000.f))); // underwater fog // add fog - float fogValue = saturate((iDepth - fogParams.y) * fogParams.w); - oColor.xyz = lerp(oColor.xyz, fogColour, fogValue); + //float fogValue = saturate((iDepth - fogParams.y) * fogParams.w); + //oColor.xyz = lerp(oColor.xyz, fogColour, fogValue); } diff --git a/files/water/water.material b/files/water/water.material index 1b8573c4a..7ce6e7ba2 100644 --- a/files/water/water.material +++ b/files/water/water.material @@ -59,8 +59,8 @@ material Water fragment_program_ref Water_FP { param_named_auto time time 0.1 - param_named_auto fogColour fog_colour - param_named_auto fogParams fog_params + //param_named_auto fogColour fog_colour + //param_named_auto fogParams fog_params param_named_auto renderTargetFlipping render_target_flipping param_named_auto far far_clip_distance param_named_auto lightPosObjSpace0 light_position_object_space 0 From aa8208efb97ad70f8559ad316efb7755e2bb1516 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 8 Apr 2012 22:18:56 +0200 Subject: [PATCH 3/3] changed compositor to be compatible with Ogre 1.8RC --- files/gbuffer/gbuffer.compositor | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/files/gbuffer/gbuffer.compositor b/files/gbuffer/gbuffer.compositor index 6ca35df87..316003af6 100644 --- a/files/gbuffer/gbuffer.compositor +++ b/files/gbuffer/gbuffer.compositor @@ -11,8 +11,11 @@ compositor gbuffer input none pass clear { - // make sure to set this to the viewport background color from outside - colour_value 0 0 0 1 + clear + { + // make sure to set this to the viewport background color from outside + colour_value 0 0 0 1 + } } pass render_scene { @@ -56,8 +59,11 @@ compositor gbufferFinalizer shadows off pass clear { - buffers colour - colour_value 0 0 0 0 + clear + { + buffers colour + colour_value 0 0 0 0 + } } pass render_quad { @@ -75,6 +81,9 @@ compositor gbufferFinalizer input none pass clear { + clear + { + } } pass render_quad {