Scene Gamma / Exposure

This commit is contained in:
2026-09-13 23:34:36 -07:00
parent 67d5e6b2c7
commit 73e4a0ad30
4 changed files with 23 additions and 3 deletions

View File

@ -69,6 +69,7 @@ uniform vec4 PPComp15;
uniform vec4 PPComp16; uniform vec4 PPComp16;
uniform vec4 PPComp18; uniform vec4 PPComp18;
uniform vec4 PPComp19; uniform vec4 PPComp19;
uniform vec4 PPComp20;
#endif #endif
// #ifdef _CPos // #ifdef _CPos
@ -499,14 +500,15 @@ void main() {
#ifdef _CExposure #ifdef _CExposure
#ifdef _CPostprocess #ifdef _CPostprocess
fragColor.rgb+=fragColor.rgb*PPComp8.x; fragColor.rgb *= pow(2.0, PPComp8.x);
#else #else
fragColor.rgb+= fragColor.rgb*compoExposureStrength; fragColor.rgb *= pow(2.0, compoExposureStrength);
#endif #endif
#endif #endif
#ifdef _CPostprocess #ifdef _CPostprocess
fragColor.rgb *= ComputeEV(0.0); fragColor.rgb *= ComputeEV(0.0);
fragColor.rgb *= pow(2.0, PPComp20.x); // exposure and gamma
#endif #endif
#ifdef _AutoExposure #ifdef _AutoExposure
@ -582,7 +584,9 @@ fragColor.rgb = min(fragColor.rgb, 65504 * 0.5);
fragColor.rgb = tonemapAgXFull(fragColor.rgb); fragColor.rgb = tonemapAgXFull(fragColor.rgb);
} //else { fragColor.rgb = vec3(0,1,0); //ERROR} } //else { fragColor.rgb = vec3(0,1,0); //ERROR}
#endif #endif
#ifdef _CGamma
fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / PPComp20.y));
#endif
#else #else
#ifdef _CToneFilmic #ifdef _CToneFilmic
fragColor.rgb = tonemapFilmic(fragColor.rgb); // With gamma fragColor.rgb = tonemapFilmic(fragColor.rgb); // With gamma
@ -615,6 +619,10 @@ fragColor.rgb = min(fragColor.rgb, 65504 * 0.5);
#endif #endif
#endif #endif
#ifdef _CGamma
fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / compoGammaStrength));
#endif
#ifdef _CBW #ifdef _CBW
// fragColor.rgb = vec3(clamp(dot(fragColor.rgb, fragColor.rgb), 0.0, 1.0)); // 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; fragColor.rgb = vec3((fragColor.r * 0.3 + fragColor.g * 0.59 + fragColor.b * 0.11) / 3.0) * 2.5;

View File

@ -116,6 +116,11 @@ class Postprocess {
1 //0: Exposure 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 = [ public static var auto_exposure_uniforms = [
1, //0: Auto Exposure Strength 1, //0: Auto Exposure Strength
1 //1: Auto Exposure Speed 1 //1: Auto Exposure Speed
@ -406,6 +411,10 @@ class Postprocess {
v.x = auto_focus[0]; v.x = auto_focus[0];
v.y = auto_focus[1]; v.y = auto_focus[1];
v.z = auto_focus[2]; 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; return v;

View File

@ -267,6 +267,8 @@ def build():
wrd.compo_defs += '_CSharpen' wrd.compo_defs += '_CSharpen'
if lnx.utils.get_active_scene().view_settings.exposure != 0.0: if lnx.utils.get_active_scene().view_settings.exposure != 0.0:
wrd.compo_defs += '_CExposure' wrd.compo_defs += '_CExposure'
if lnx.utils.get_active_scene().view_settings.gamma != 1.0:
wrd.compo_defs += '_CGamma'
if rpdat.lnx_fog: if rpdat.lnx_fog:
wrd.compo_defs += '_CFog' wrd.compo_defs += '_CFog'
compo_depth = True compo_depth = True

View File

@ -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: if lnx.utils.get_active_scene().view_settings.exposure != 0.0:
f.write( f.write(
"""const float compoExposureStrength = """ + str(round(lnx.utils.get_active_scene().view_settings.exposure * 100) / 100) + """; """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: if rpdat.lnx_fog: