mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 08:36:43 +00:00
contrast and gamma post-processing effect added
initial values are set to approximate vanilla
This commit is contained in:
parent
49e2b14d05
commit
cee72d021d
8 changed files with 109 additions and 4 deletions
|
@ -347,6 +347,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
addResourcesDirectory(mResDir / "mygui");
|
addResourcesDirectory(mResDir / "mygui");
|
||||||
addResourcesDirectory(mResDir / "water");
|
addResourcesDirectory(mResDir / "water");
|
||||||
addResourcesDirectory(mResDir / "shadows");
|
addResourcesDirectory(mResDir / "shadows");
|
||||||
|
addResourcesDirectory(mResDir / "materials");
|
||||||
|
|
||||||
OEngine::Render::WindowSettings windowSettings;
|
OEngine::Render::WindowSettings windowSettings;
|
||||||
windowSettings.fullscreen = settings.getBool("fullscreen", "Video");
|
windowSettings.fullscreen = settings.getBool("fullscreen", "Video");
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <OgreControllerManager.h>
|
#include <OgreControllerManager.h>
|
||||||
#include <OgreMeshManager.h>
|
#include <OgreMeshManager.h>
|
||||||
#include <OgreRenderTexture.h>
|
#include <OgreRenderTexture.h>
|
||||||
|
#include <OgreCompositorManager.h> // for post-processing effects
|
||||||
|
|
||||||
#include <SDL_video.h>
|
#include <SDL_video.h>
|
||||||
|
|
||||||
|
@ -136,6 +137,9 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
|
||||||
|
|
||||||
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
||||||
|
|
||||||
|
Ogre::CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "brightness_contrast_gamma");
|
||||||
|
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "brightness_contrast_gamma", true);
|
||||||
|
|
||||||
// disable unsupported effects
|
// disable unsupported effects
|
||||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||||
Settings::Manager::setBool("enabled", "Shadows", false);
|
Settings::Manager::setBool("enabled", "Shadows", false);
|
||||||
|
@ -155,6 +159,8 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
|
||||||
sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false");
|
sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false");
|
||||||
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
|
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
|
||||||
sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
|
sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
|
||||||
|
sh::Factory::getInstance ().setSharedParameter ("contrast_invGamma", sh::makeProperty<sh::Vector2>(new sh::Vector2(
|
||||||
|
Settings::Manager::getFloat("contrast", "General"), 1.0f/Settings::Manager::getFloat("gamma", "General"))));
|
||||||
|
|
||||||
mRootNode = mRendering.getScene()->getRootSceneNode();
|
mRootNode = mRendering.getScene()->getRootSceneNode();
|
||||||
mRootNode->createChildSceneNode("player");
|
mRootNode->createChildSceneNode("player");
|
||||||
|
@ -757,6 +763,11 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
||||||
changeRes = true;
|
changeRes = true;
|
||||||
else if (it->second == "field of view" && it->first == "General")
|
else if (it->second == "field of view" && it->first == "General")
|
||||||
mRendering.setFov(Settings::Manager::getFloat("field of view", "General"));
|
mRendering.setFov(Settings::Manager::getFloat("field of view", "General"));
|
||||||
|
else if ((it->second == "gamma" || it->second == "contrast") && it->first == "General")
|
||||||
|
{
|
||||||
|
sh::Factory::getInstance ().setSharedParameter ("contrast_invGamma", sh::makeProperty<sh::Vector2>(new sh::Vector2(
|
||||||
|
Settings::Manager::getFloat("contrast", "General"), 1.0f/Settings::Manager::getFloat("gamma", "General"))));
|
||||||
|
}
|
||||||
else if ((it->second == "texture filtering" && it->first == "General")
|
else if ((it->second == "texture filtering" && it->first == "General")
|
||||||
|| (it->second == "anisotropy" && it->first == "General"))
|
|| (it->second == "anisotropy" && it->first == "General"))
|
||||||
{
|
{
|
||||||
|
|
24
files/materials/brightness_contrast_gamma.compositor
Normal file
24
files/materials/brightness_contrast_gamma.compositor
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
compositor brightness_contrast_gamma
|
||||||
|
{
|
||||||
|
technique
|
||||||
|
{
|
||||||
|
// render scene into texture
|
||||||
|
texture SceneBuffer target_width target_height PF_A8R8G8B8
|
||||||
|
|
||||||
|
target SceneBuffer
|
||||||
|
{
|
||||||
|
input previous
|
||||||
|
}
|
||||||
|
|
||||||
|
target_output
|
||||||
|
{
|
||||||
|
input none
|
||||||
|
|
||||||
|
pass render_quad
|
||||||
|
{
|
||||||
|
material mat_brightness_contrast_gamma
|
||||||
|
input 0 SceneBuffer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
files/materials/brightness_contrast_gamma.mat
Normal file
14
files/materials/brightness_contrast_gamma.mat
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
material mat_brightness_contrast_gamma
|
||||||
|
{
|
||||||
|
pass
|
||||||
|
{
|
||||||
|
vertex_program transform_vertex
|
||||||
|
fragment_program openmw_brightness_contrast_gamma_fragment
|
||||||
|
|
||||||
|
depth_check off
|
||||||
|
|
||||||
|
texture_unit SceneBuffer
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
files/materials/brightness_contrast_gamma.shader
Normal file
20
files/materials/brightness_contrast_gamma.shader
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
|
#ifdef SH_FRAGMENT_SHADER
|
||||||
|
|
||||||
|
SH_BEGIN_PROGRAM
|
||||||
|
shInput(float2, UV)
|
||||||
|
shSampler2D(SceneBuffer)
|
||||||
|
shUniform(float2, contrast_invGamma) @shSharedParameter(contrast_invGamma)
|
||||||
|
SH_START_PROGRAM
|
||||||
|
{
|
||||||
|
shOutputColour(0) = shSample(SceneBuffer, UV);
|
||||||
|
|
||||||
|
// contrast
|
||||||
|
shOutputColour(0).xyz = (shOutputColour(0).xyz - float3(0.5,0.5,0.5)) * contrast_invGamma.x + float3(0.5,0.5,0.5);
|
||||||
|
shOutputColour(0).xyz = shSaturate(shOutputColour(0).xyz);
|
||||||
|
// gamma
|
||||||
|
shOutputColour(0).xyz = pow(shOutputColour(0).xyz, contrast_invGamma.yyy);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
7
files/materials/brightness_contrast_gamma.shaderset
Normal file
7
files/materials/brightness_contrast_gamma.shaderset
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
shader_set openmw_brightness_contrast_gamma_fragment
|
||||||
|
{
|
||||||
|
source brightness_contrast_gamma.shader
|
||||||
|
type fragment
|
||||||
|
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||||
|
profiles_hlsl ps_2_0
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MyGUI type="Layout" version="3.2.0">
|
<MyGUI type="Layout" version="3.2.0">
|
||||||
<Widget type="Window" skin="MW_Window" position="0 0 400 426" layer="Windows" name="_Main">
|
<Widget type="Window" skin="MW_Window" position="0 0 400 505" layer="Windows" name="_Main">
|
||||||
<Property key="MinSize" value="430 446"/>
|
<Property key="MinSize" value="430 446"/>
|
||||||
<Widget type="TabControl" skin="TabControl" position="8 8 368 340" align="Stretch" name="SettingsTab">
|
<Widget type="TabControl" skin="TabControl" position="8 8 368 430" align="Stretch" name="SettingsTab">
|
||||||
<Property key="ButtonAutoWidth" value="true"/>
|
<Property key="ButtonAutoWidth" value="true"/>
|
||||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||||
<Property key="Caption" value=" #{sPrefs} "/>
|
<Property key="Caption" value=" #{sPrefs} "/>
|
||||||
|
@ -214,7 +214,7 @@
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||||
<Property key="Caption" value=" #{sVideo} "/>
|
<Property key="Caption" value=" #{sVideo} "/>
|
||||||
<Widget type="TabControl" skin="TabControlInner" position="4 4 352 296" align="Stretch">
|
<Widget type="TabControl" skin="TabControlInner" position="4 4 352 390" align="Stretch">
|
||||||
<Property key="ButtonAutoWidth" value="true"/>
|
<Property key="ButtonAutoWidth" value="true"/>
|
||||||
<Widget type="TabItem" skin="" position="0 28 352 268" align="Stretch">
|
<Widget type="TabItem" skin="" position="0 28 352 268" align="Stretch">
|
||||||
<Property key="Caption" value=" Video "/>
|
<Property key="Caption" value=" Video "/>
|
||||||
|
@ -292,6 +292,32 @@
|
||||||
<Property key="Caption" value="#{sHigh}"/>
|
<Property key="Caption" value="#{sHigh}"/>
|
||||||
<Property key="TextAlign" value="Right"/>
|
<Property key="TextAlign" value="Right"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 268 329 18" align="Left Top" name="GammaText">
|
||||||
|
<Property key="Caption" value="Gamma Correction"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="MWScrollBar" skin="MW_HScroll" position="0 292 329 18" align="HStretch Top" name="GammaSlider">
|
||||||
|
<Property key="Range" value="10000"/>
|
||||||
|
<Property key="Page" value="300"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingCategory" value="General"/>
|
||||||
|
<UserString key="SettingName" value="gamma"/>
|
||||||
|
<UserString key="SettingValueType" value="Float"/>
|
||||||
|
<UserString key="SettingMin" value="0.1"/>
|
||||||
|
<UserString key="SettingMax" value="3.0"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 314 329 18" align="Left Top" name="ContrastText">
|
||||||
|
<Property key="Caption" value="Contrast"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="MWScrollBar" skin="MW_HScroll" position="0 336 329 18" align="HStretch Top" name="ContrastSlider">
|
||||||
|
<Property key="Range" value="10000"/>
|
||||||
|
<Property key="Page" value="300"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingCategory" value="General"/>
|
||||||
|
<UserString key="SettingName" value="contrast"/>
|
||||||
|
<UserString key="SettingValueType" value="Float"/>
|
||||||
|
<UserString key="SettingMin" value="0.1"/>
|
||||||
|
<UserString key="SettingMax" value="2.0"/>
|
||||||
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TabItem" skin="" position="0 28 352 268">
|
<Widget type="TabItem" skin="" position="0 28 352 268">
|
||||||
<Property key="Caption" value=" Detail "/>
|
<Property key="Caption" value=" Detail "/>
|
||||||
|
@ -470,7 +496,7 @@
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="AutoSizedButton" skin="MW_Button" position="321 355 56 24" align="Right Bottom" name="OkButton">
|
<Widget type="AutoSizedButton" skin="MW_Button" position="320 440 56 24" align="Right Bottom" name="OkButton">
|
||||||
<Property key="ExpandDirection" value="Left"/>
|
<Property key="ExpandDirection" value="Left"/>
|
||||||
<Property key="Caption" value="#{sOK}"/>
|
<Property key="Caption" value="#{sOK}"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
|
@ -48,6 +48,8 @@ werewolf overlay = true
|
||||||
[General]
|
[General]
|
||||||
# Camera field of view
|
# Camera field of view
|
||||||
field of view = 55
|
field of view = 55
|
||||||
|
gamma = 0.88
|
||||||
|
contrast = 0.86
|
||||||
|
|
||||||
# Texture filtering mode. valid values:
|
# Texture filtering mode. valid values:
|
||||||
# none
|
# none
|
||||||
|
|
Loading…
Reference in a new issue