Page 1 of 1

Incorrect darkness in GZdoom 2.x "software" sector light mode (still broken, but easy fix included)

Posted: Fri Jun 17, 2016 11:54
by Doom_user
This is a necessary followup to the previous thread about this issue.
Graf Zahl wrote:Ok, added the new value. But since the shader in GZdoom 2.x has changed, the results can be a bit different.
There's a problem with the way you implemented the darkness fix in GZdoom 2.x. You implemented the 0.03 value in the wrong section. As a result, the absolute darkness in front of the player remains.

Image

To fix this, in "gzdoom.pk3" -> "shaders" -> "glsl" -> "main.fp" change this section



/* L in the range 0 to 63 */
float L = light * 63.0/31.0;

float min_L = clamp(36.0/31.0 - L, 0.03, 1.0);

// Fix objects getting totally black when close.
if (dist < 0.0001)
dist = 0.0001;



back to this



/* L in the range 0 to 63 */
float L = light * 63.0/31.0;

float min_L = clamp(36.0/31.0 - L, 0.0, 1.0);

// Fix objects getting totally black when close.
if (dist < 0.0001)
dist = 0.0001;



and change this section



#endif
color.rgb = clamp(color.rgb + desaturate(dynlight).rgb, 0.0, 1.4);

// prevent any unintentional messing around with the alpha.
return vec4(color.rgb, vColor.a);



to this



#endif
color.rgb = clamp(color.rgb + desaturate(dynlight).rgb, 0.03, 1.4);

// prevent any unintentional messing around with the alpha.
return vec4(color.rgb, vColor.a);



which results in this

Image

which is 100% identical to the software renderer and the GZdoom 1.x fix from the first post in the previous thread.