From b69c16e682c618371fc60cb5ced92e51650997a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Wed, 6 Dec 2017 20:39:09 +0100 Subject: [PATCH 01/29] Add setting option to scale water refractions --- apps/openmw/mwrender/water.cpp | 6 ++++++ files/settings-default.cfg | 3 +++ 2 files changed, 9 insertions(+) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index c4dffb7a4..dbfee05df 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -272,6 +272,12 @@ public: void setWaterLevel(float waterLevel) { + const float refractionScale = std::min(1.0f,std::max(0.0f, + Settings::Manager::getFloat("refraction scale", "Water"))); + + setViewMatrix(osg::Matrix::scale(1,1,refractionScale) * + osg::Matrix::translate(0,0,(1.0 - refractionScale) * waterLevel)); + mClipCullNode->setPlane(osg::Plane(osg::Vec3d(0,0,-1), osg::Vec3d(0,0, waterLevel))); } diff --git a/files/settings-default.cfg b/files/settings-default.cfg index aec667a9c..35748d516 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -376,6 +376,9 @@ reflect actors = false # Overrides the value in '[Camera] small feature culling pixel size' specifically for water reflection/refraction textures. small feature culling pixel size = 20.0 +# By what factor water downscales objects. Only works with water shader and refractions on. +refraction scale = 1.0 + [Windows] # Location and sizes of windows as a fraction of the OpenMW window or From d13fc06baf90b816dcea03c7c4948c49c2379e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 9 Dec 2017 12:52:28 +0100 Subject: [PATCH 02/29] Add basic refraction scale documentation --- .../source/reference/modding/settings/water.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/source/reference/modding/settings/water.rst b/docs/source/reference/modding/settings/water.rst index a1c6c2068..aceecc630 100644 --- a/docs/source/reference/modding/settings/water.rst +++ b/docs/source/reference/modding/settings/water.rst @@ -88,3 +88,20 @@ This setting will have no effect if the shader setting is false, or the 'small feature culling' (in the 'Camera' section) is disabled. This setting can only be configured by editing the settings configuration file. + +refraction scale +---------------- + +:Type: floating point +:Range: 0 to 1 +:Default: 1.0 + +Simulates light rays refracting when transitioning from air to water, which causes the space under water look scaled down +in height when viewed from above the water surface. Though adding realism, the setting can cause distortion which can +make for example aiming at enemies in water more challenging, so it is off by default (i.e. set to 1.0). + +This setting only applies if water shader is on and refractions are enabled. Note that if refractions are enabled and this +setting if off, there will still be small refractions caused by the water waves, which however do not cause such significant +distortion. + +TODO: setting via GUI? Interation with rttsize? From ee40b41285cce4af6a49e6c91f98dac75afaaa0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 9 Dec 2017 14:03:56 +0100 Subject: [PATCH 03/29] Add slider for refraction size in settings window --- apps/openmw/mwrender/water.cpp | 2 +- .../reference/modding/settings/water.rst | 2 +- files/mygui/openmw_settings_window.layout | 24 ++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index dbfee05df..043f1f697 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -272,7 +272,7 @@ public: void setWaterLevel(float waterLevel) { - const float refractionScale = std::min(1.0f,std::max(0.0f, + const float refractionScale = std::min(1.0f,std::max(0.01f, // 0.0 crashes the game Settings::Manager::getFloat("refraction scale", "Water"))); setViewMatrix(osg::Matrix::scale(1,1,refractionScale) * diff --git a/docs/source/reference/modding/settings/water.rst b/docs/source/reference/modding/settings/water.rst index aceecc630..ab87c77e5 100644 --- a/docs/source/reference/modding/settings/water.rst +++ b/docs/source/reference/modding/settings/water.rst @@ -104,4 +104,4 @@ This setting only applies if water shader is on and refractions are enabled. Not setting if off, there will still be small refractions caused by the water waves, which however do not cause such significant distortion. -TODO: setting via GUI? Interation with rttsize? +This setting can be edited with the 'Refraction scale' slider in the Water tab of the Video panel of the Options menu. diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 8ff850cae..6e377b284 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -394,8 +394,30 @@ + + + + + + + + + + + + + + + + + + + + + + + -