diff --git a/leenkx/Shaders/compositor_pass/compositor_pass.frag.glsl b/leenkx/Shaders/compositor_pass/compositor_pass.frag.glsl index 8118432e..b7d9d7ba 100644 --- a/leenkx/Shaders/compositor_pass/compositor_pass.frag.glsl +++ b/leenkx/Shaders/compositor_pass/compositor_pass.frag.glsl @@ -69,6 +69,7 @@ uniform vec4 PPComp15; uniform vec4 PPComp16; uniform vec4 PPComp18; uniform vec4 PPComp19; +uniform vec4 PPComp20; #endif // #ifdef _CPos @@ -499,14 +500,15 @@ void main() { #ifdef _CExposure #ifdef _CPostprocess - fragColor.rgb+=fragColor.rgb*PPComp8.x; + fragColor.rgb *= pow(2.0, PPComp8.x); #else - fragColor.rgb+= fragColor.rgb*compoExposureStrength; + fragColor.rgb *= pow(2.0, compoExposureStrength); #endif #endif #ifdef _CPostprocess fragColor.rgb *= ComputeEV(0.0); + fragColor.rgb *= pow(2.0, PPComp20.x); // exposure and gamma #endif #ifdef _AutoExposure @@ -582,7 +584,9 @@ fragColor.rgb = min(fragColor.rgb, 65504 * 0.5); fragColor.rgb = tonemapAgXFull(fragColor.rgb); } //else { fragColor.rgb = vec3(0,1,0); //ERROR} #endif - +#ifdef _CGamma + fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / PPComp20.y)); +#endif #else #ifdef _CToneFilmic fragColor.rgb = tonemapFilmic(fragColor.rgb); // With gamma @@ -615,6 +619,10 @@ fragColor.rgb = min(fragColor.rgb, 65504 * 0.5); #endif #endif +#ifdef _CGamma + fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / compoGammaStrength)); +#endif + #ifdef _CBW // fragColor.rgb = vec3(clamp(dot(fragColor.rgb, fragColor.rgb), 0.0, 1.0)); fragColor.rgb = vec3((fragColor.r * 0.3 + fragColor.g * 0.59 + fragColor.b * 0.11) / 3.0) * 2.5; diff --git a/leenkx/Sources/leenkx/renderpath/Postprocess.hx b/leenkx/Sources/leenkx/renderpath/Postprocess.hx index 83fe4e91..b758490a 100644 --- a/leenkx/Sources/leenkx/renderpath/Postprocess.hx +++ b/leenkx/Sources/leenkx/renderpath/Postprocess.hx @@ -116,6 +116,11 @@ class Postprocess { 1 //0: Exposure ]; + public static var scene_color_uniforms = [ + 0.0, //0: Scene Exposure + 1.0 //1: Scene Gamma + ]; + public static var auto_exposure_uniforms = [ 1, //0: Auto Exposure Strength 1 //1: Auto Exposure Speed @@ -406,6 +411,10 @@ class Postprocess { v.x = auto_focus[0]; v.y = auto_focus[1]; v.z = auto_focus[2]; + case "_PPComp20": + v = iron.object.Uniforms.helpVec; + v.x = scene_color_uniforms[0]; // Scene Exposure + v.y = scene_color_uniforms[1]; // Scene Gamma } return v; diff --git a/leenkx/blender/lnx/make_renderpath.py b/leenkx/blender/lnx/make_renderpath.py index 6eee2aca..8d8f3fce 100644 --- a/leenkx/blender/lnx/make_renderpath.py +++ b/leenkx/blender/lnx/make_renderpath.py @@ -267,6 +267,8 @@ def build(): wrd.compo_defs += '_CSharpen' if lnx.utils.get_active_scene().view_settings.exposure != 0.0: wrd.compo_defs += '_CExposure' + if lnx.utils.get_active_scene().view_settings.gamma != 1.0: + wrd.compo_defs += '_CGamma' if rpdat.lnx_fog: wrd.compo_defs += '_CFog' compo_depth = True diff --git a/leenkx/blender/lnx/write_data.py b/leenkx/blender/lnx/write_data.py index aadb4d95..8bccdbdf 100644 --- a/leenkx/blender/lnx/write_data.py +++ b/leenkx/blender/lnx/write_data.py @@ -1009,6 +1009,7 @@ const vec3 compoSharpenColor = vec3(""" + str(round(rpdat.lnx_sharpen_color[0] * if lnx.utils.get_active_scene().view_settings.exposure != 0.0: f.write( """const float compoExposureStrength = """ + str(round(lnx.utils.get_active_scene().view_settings.exposure * 100) / 100) + """; +const float compoGammaStrength = """ + str(round(lnx.utils.get_active_scene().view_settings.gamma * 100) / 100) + """; """) if rpdat.lnx_fog: