forked from teamnwah/openmw-tes3coop
gamma correct rendering & adjustment setting
This commit is contained in:
parent
32de090079
commit
d9f6072f02
5 changed files with 27 additions and 11 deletions
|
@ -129,6 +129,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
||||||
sh::Factory::getInstance ().setSharedParameter ("waterTimer", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
|
sh::Factory::getInstance ().setSharedParameter ("waterTimer", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
|
||||||
sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5, -0.8, 0.2)));
|
sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5, -0.8, 0.2)));
|
||||||
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6)));
|
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6)));
|
||||||
|
sh::Factory::getInstance ().setSharedParameter ("gammaCorrection", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(
|
||||||
|
Settings::Manager::getFloat ("gamma", "Video"))));
|
||||||
|
|
||||||
applyCompositors();
|
applyCompositors();
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#define gammaCorrectRead(v) pow(v, float3(gammaCorrection,gammaCorrection,gammaCorrection))
|
||||||
|
#define gammaCorrectOutput(v) pow(v, float3(1.f/gammaCorrection,1.f/gammaCorrection,1.f/gammaCorrection))
|
||||||
|
|
||||||
|
|
||||||
#if SH_HLSL == 1 || SH_CG == 1
|
#if SH_HLSL == 1 || SH_CG == 1
|
||||||
|
|
||||||
#define shTexture2D sampler2D
|
#define shTexture2D sampler2D
|
||||||
|
|
|
@ -112,6 +112,8 @@
|
||||||
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
shUniform(float, gammaCorrection) @shSharedParameter(gammaCorrection, gammaCorrection)
|
||||||
|
|
||||||
#if LIGHTING
|
#if LIGHTING
|
||||||
shInput(float3, normalPassthrough)
|
shInput(float3, normalPassthrough)
|
||||||
shInput(float3, objSpacePositionPassthrough)
|
shInput(float3, objSpacePositionPassthrough)
|
||||||
|
@ -173,6 +175,7 @@
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
shOutputColour(0) = shSample(diffuseMap, UV);
|
shOutputColour(0) = shSample(diffuseMap, UV);
|
||||||
|
shOutputColour(0).xyz = gammaCorrectRead(shOutputColour(0).xyz);
|
||||||
|
|
||||||
#if LIGHTING
|
#if LIGHTING
|
||||||
float3 normal = normalize(normalPassthrough);
|
float3 normal = normalize(normalPassthrough);
|
||||||
|
@ -259,7 +262,7 @@
|
||||||
// regular fog only if fragment is above water
|
// regular fog only if fragment is above water
|
||||||
if (worldPos.y > waterLevel)
|
if (worldPos.y > waterLevel)
|
||||||
#endif
|
#endif
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, gammaCorrectRead(fogColour), fogValue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// prevent negative colour output (for example with negative lights)
|
// prevent negative colour output (for example with negative lights)
|
||||||
|
@ -274,12 +277,11 @@
|
||||||
|
|
||||||
float waterSunGradient = dot(eyeVec, -normalize(lightDirectionWS0.xyz));
|
float waterSunGradient = dot(eyeVec, -normalize(lightDirectionWS0.xyz));
|
||||||
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
||||||
float3 waterSunColour = float3(0.0,1.0,0.85)*waterSunGradient * 0.5;
|
float3 waterSunColour = gammaCorrectRead(float3(0.0,1.0,0.85)) *waterSunGradient * 0.5;
|
||||||
|
|
||||||
float waterGradient = dot(eyeVec, float3(0.0,-1.0,0.0));
|
float waterGradient = dot(eyeVec, float3(0.0,-1.0,0.0));
|
||||||
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
||||||
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
float3 watercolour = ( gammaCorrectRead(float3(0.0078, 0.5176, 0.700))+waterSunColour)*waterGradient*2.0;
|
||||||
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
|
||||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||||
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
||||||
|
|
||||||
|
@ -292,6 +294,8 @@
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater * waterEnabled);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater * waterEnabled);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
shOutputColour(0).xyz = gammaCorrectOutput(shOutputColour(0).xyz);
|
||||||
|
|
||||||
#if MRT
|
#if MRT
|
||||||
shOutputColour(1) = float4(depthPassthrough / far,1,1,1);
|
shOutputColour(1) = float4(depthPassthrough / far,1,1,1);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -137,6 +137,8 @@
|
||||||
|
|
||||||
shSampler2D(normalMap) // global normal map
|
shSampler2D(normalMap) // global normal map
|
||||||
|
|
||||||
|
shUniform(float, gammaCorrection) @shSharedParameter(gammaCorrection, gammaCorrection)
|
||||||
|
|
||||||
|
|
||||||
@shForeach(@shPropertyString(num_blendmaps))
|
@shForeach(@shPropertyString(num_blendmaps))
|
||||||
shSampler2D(blendMap@shIterator)
|
shSampler2D(blendMap@shIterator)
|
||||||
|
@ -247,9 +249,9 @@
|
||||||
|
|
||||||
#if IS_FIRST_PASS == 1 && @shIterator == 0
|
#if IS_FIRST_PASS == 1 && @shIterator == 0
|
||||||
// first layer of first pass doesn't need a blend map
|
// first layer of first pass doesn't need a blend map
|
||||||
albedo = shSample(diffuseMap0, UV * 10).rgb;
|
albedo = gammaCorrectRead(shSample(diffuseMap0, UV * 10).rgb);
|
||||||
#else
|
#else
|
||||||
albedo = shLerp(albedo, shSample(diffuseMap@shIterator, UV * 10).rgb, blendValues@shPropertyString(blendmap_component_@shIterator));
|
albedo = shLerp(albedo, gammaCorrectRead(shSample(diffuseMap@shIterator, UV * 10).rgb), blendValues@shPropertyString(blendmap_component_@shIterator));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@shEndForeach
|
@shEndForeach
|
||||||
|
@ -336,7 +338,7 @@
|
||||||
// regular fog only if fragment is above water
|
// regular fog only if fragment is above water
|
||||||
if (worldPos.y > waterLevel)
|
if (worldPos.y > waterLevel)
|
||||||
#endif
|
#endif
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, gammaCorrectRead(fogColour), fogValue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// prevent negative colour output (for example with negative lights)
|
// prevent negative colour output (for example with negative lights)
|
||||||
|
@ -351,12 +353,12 @@
|
||||||
|
|
||||||
float waterSunGradient = dot(eyeVec, -normalize(lightDirectionWS0.xyz));
|
float waterSunGradient = dot(eyeVec, -normalize(lightDirectionWS0.xyz));
|
||||||
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
waterSunGradient = shSaturate(pow(waterSunGradient*0.7+0.3,2.0));
|
||||||
float3 waterSunColour = float3(0.0,1.0,0.85)*waterSunGradient * 0.5;
|
float3 waterSunColour = gammaCorrectRead(float3(0.0,1.0,0.85))*waterSunGradient * 0.5;
|
||||||
|
|
||||||
float waterGradient = dot(eyeVec, float3(0.0,-1.0,0.0));
|
float waterGradient = dot(eyeVec, float3(0.0,-1.0,0.0));
|
||||||
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
||||||
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
float3 watercolour = (gammaCorrectRead(float3(0.0078, 0.5176, 0.700))+waterSunColour)*waterGradient*2.0;
|
||||||
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
float3 waterext = gammaCorrectRead(float3(0.6, 0.9, 1.0));//water extinction
|
||||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||||
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
||||||
|
|
||||||
|
@ -369,6 +371,8 @@
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
shOutputColour(0).xyz = gammaCorrectOutput(shOutputColour(0).xyz);
|
||||||
|
|
||||||
|
|
||||||
#if MRT
|
#if MRT
|
||||||
shOutputColour(1) = float4(depth / far,1,1,1);
|
shOutputColour(1) = float4(depth / far,1,1,1);
|
||||||
|
|
|
@ -28,6 +28,8 @@ vsync = false
|
||||||
# PBuffer, FBO, Copy
|
# PBuffer, FBO, Copy
|
||||||
opengl rtt mode = FBO
|
opengl rtt mode = FBO
|
||||||
|
|
||||||
|
gamma = 2.2
|
||||||
|
|
||||||
[GUI]
|
[GUI]
|
||||||
# 1 is fully opaque
|
# 1 is fully opaque
|
||||||
menu transparency = 0.84
|
menu transparency = 0.84
|
||||||
|
|
Loading…
Reference in a new issue