Skip to content

Commit

Permalink
Fix tonemapping effect
Browse files Browse the repository at this point in the history
  • Loading branch information
rollerozxa authored and sfan5 committed Jan 3, 2024
1 parent 0b423dd commit de4cc5c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions client/shaders/second_stage/opengl_fragment.glsl
Expand Up @@ -68,13 +68,15 @@ vec3 uncharted2Tonemap(vec3 x)

vec4 applyToneMapping(vec4 color)
{
const float exposureBias = 2.0;
color = vec4(pow(color.rgb, vec3(2.2)), color.a);
const float gamma = 1.6;
const float exposureBias = 5.5;
color.rgb = uncharted2Tonemap(exposureBias * color.rgb);
// Precalculated white_scale from
//vec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W));
vec3 whiteScale = vec3(1.036015346);
color.rgb *= whiteScale;
return color;
return vec4(pow(color.rgb, vec3(1.0 / gamma)), color.a);
}

vec3 applySaturation(vec3 color, float factor)
Expand Down Expand Up @@ -130,6 +132,12 @@ void main(void)
color = applyBloom(color, uv);
#endif


color.rgb = clamp(color.rgb, vec3(0.), vec3(1.));

// return to sRGB colorspace (approximate)
color.rgb = pow(color.rgb, vec3(1.0 / 2.2));

#ifdef ENABLE_BLOOM_DEBUG
if (uv.x > 0.5 || uv.y > 0.5)
#endif
Expand All @@ -140,11 +148,6 @@ void main(void)
#endif
}

color.rgb = clamp(color.rgb, vec3(0.), vec3(1.));

// return to sRGB colorspace (approximate)
color.rgb = pow(color.rgb, vec3(1.0 / 2.2));

#ifdef ENABLE_DITHERING
// Apply dithering just before quantisation
color.rgb += screen_space_dither(gl_FragCoord.xy);
Expand Down

0 comments on commit de4cc5c

Please sign in to comment.