@@ -225,9 +225,6 @@ vec3 tonemap_agx(vec3 color) {
225225}
226226
227227vec3 linear_to_srgb(vec3 color) {
228- // Clamping is not strictly necessary for floating point nonlinear sRGB encoding,
229- // but many cases that call this function need the result clamped.
230- color = clamp (color, vec3 (0.0 ), vec3 (1.0 ));
231228 const vec3 a = vec3 (0 .055f);
232229 return mix ((vec3 (1 .0f) + a) * pow (color.rgb, vec3 (1 .0f / 2 .4f)) - a, 12 .92f * color.rgb, lessThan (color.rgb, vec3 (0 .0031308f)));
233230}
@@ -248,20 +245,20 @@ vec3 apply_tonemapping(vec3 color, float white) { // inputs are LINEAR
248245 return tonemap_filmic(max (vec3 (0 .0f), color), white);
249246 } else if (tonemapper_aces) {
250247 return tonemap_aces(max (vec3 (0 .0f), color), white);
251- } else { // FLAG_TONEMAPPER_AGX
248+ } else { // tonemapper_agx
252249 return tonemap_agx(color);
253250 }
254251}
255252
256253#ifdef USE_MULTIVIEW
257254vec3 gather_glow() {
258255 vec2 uv = gl_FragCoord .xy * params.dest_pixel_size;
259- return textureLod(source_glow, vec3 (uv, ViewIndex), 0.0 ).rgb;
256+ return textureLod(source_glow, vec3 (uv, ViewIndex), 0.0 ).rgb * params.luminance_multiplier ;
260257}
261258#else
262259vec3 gather_glow() {
263260 vec2 uv = gl_FragCoord .xy * params.dest_pixel_size;
264- return textureLod(source_glow, uv, 0.0 ).rgb;
261+ return textureLod(source_glow, uv, 0.0 ).rgb * params.luminance_multiplier ;
265262}
266263#endif // !USE_MULTIVIEW
267264
@@ -728,15 +725,15 @@ void main() {
728725
729726 color.rgb *= params.exposure;
730727
731- // Early Tonemap & SRGB Conversion
732728#ifndef SUBPASS
729+ // Single-pass FXAA and pre-tonemap glow.
733730 if (use_fxaa) {
734731 // FXAA must be performed before glow to preserve the "bleed" effect of glow.
735732 color.rgb = do_fxaa(color.rgb, params.exposure, uv_interp);
736733 }
737734
738735 if (use_glow && ! glow_mode_softlight) {
739- vec3 glow = gather_glow() * params.luminance_multiplier * params. glow_intensity;
736+ vec3 glow = gather_glow() * params.glow_intensity;
740737 if (use_glow_map) {
741738 glow = mix (glow, texture(glow_map, uv_interp).rgb * glow, params.glow_map_strength);
742739 }
@@ -749,25 +746,27 @@ void main() {
749746 }
750747#endif
751748
749+ // Tonemap to lower dynamic range.
750+
752751 color.rgb = apply_tonemapping(color.rgb, params.white);
753752
754753#ifndef SUBPASS
755- // Glow
754+ // Post-tonemap glow.
755+
756756 if (use_glow && glow_mode_softlight) {
757757 // Apply soft light after tonemapping to mitigate the issue of discontinuity
758758 // at 1.0 and higher. This makes the issue only appear with HDR output that
759759 // can exceed a 1.0 output value.
760- vec3 glow = gather_glow() * params.glow_intensity * params.luminance_multiplier ;
760+ vec3 glow = gather_glow() * params.glow_intensity;
761761 if (use_glow_map) {
762762 glow = mix (glow, texture(glow_map, uv_interp).rgb * glow, params.glow_map_strength);
763763 }
764-
765764 glow = apply_tonemapping(glow, params.white);
766765 color.rgb = apply_glow(color.rgb, glow, params.white);
767766 }
768767#endif
769768
770- // Additional effects
769+ // Additional effects.
771770
772771 if (use_bcs) {
773772 // Apply brightness:
0 commit comments