mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 09:20:51 +00:00
- fraqment shader cleanup part one.
This commit is contained in:
parent
734d8b7d1e
commit
7185bbad81
1 changed files with 29 additions and 16 deletions
|
@ -136,16 +136,30 @@ vec4 convertColor(vec4 color, int effect, vec3 tint)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float coordY = mix(v_texCoord.y,v_texCoord.x,u_usePalette);
|
float coordX = v_texCoord.x;
|
||||||
float coordX = mix(v_texCoord.x,v_texCoord.y,u_usePalette);
|
float coordY = v_texCoord.y;
|
||||||
float period = floor(coordY/u_npotEmulationFactor);
|
vec2 newCoord;
|
||||||
coordX += u_npotEmulationXOffset*floor(mod(coordY,u_npotEmulationFactor));
|
|
||||||
coordY = period+mod(coordY,u_npotEmulationFactor);
|
// Coordinate adjustment for NPOT textures (something must have gone very wrong to make this necessary...)
|
||||||
vec2 newCoord = mix(v_texCoord.xy,mix(vec2(coordX,coordY),vec2(coordY,coordX),u_usePalette),u_npotEmulation);
|
if (u_npotEmulation != 0.0)
|
||||||
vec2 transitionBlend = fwidth(floor(newCoord.xy));
|
{
|
||||||
transitionBlend = fwidth(transitionBlend)+transitionBlend;
|
float period = floor(coordY / u_npotEmulationFactor);
|
||||||
vec2 texCoord = mix(mix(fract(newCoord.xy), abs(c_one-mod(newCoord.xy+c_one, c_two)), transitionBlend), clamp(newCoord.xy, c_zero, c_one), u_clamp);
|
coordX += u_npotEmulationXOffset * floor(mod(coordY, u_npotEmulationFactor));
|
||||||
vec4 color = texture2D(s_texture, texCoord);
|
coordY = period + mod(coordY, u_npotEmulationFactor);
|
||||||
|
}
|
||||||
|
newCoord = vec2(coordX, coordY);
|
||||||
|
#if 1
|
||||||
|
if (u_clamp != 0.0) newCoord = clamp(newCoord.xy, 0.0, 1.0);
|
||||||
|
#else
|
||||||
|
// what is this for? The only effect I could observe was a significant degradation of anisotropic filtering.
|
||||||
|
vec2 transitionBlend = fwidth(floor(newCoord.xy));
|
||||||
|
transitionBlend = fwidth(transitionBlend) + transitionBlend;
|
||||||
|
|
||||||
|
vec2 val1 = mix(fract(newCoord.xy), abs(1.0-mod(newCoord.xy+1.0, 2.0)), transitionBlend);
|
||||||
|
vec2 clampedCoord = clamp(newCoord.xy, 0.0, 1.0);
|
||||||
|
newCoord = mix(val1, clampedCoord, u_clamp);
|
||||||
|
#endif
|
||||||
|
vec4 color = texture2D(s_texture, newCoord);
|
||||||
|
|
||||||
float shade = clamp((u_shade+max(u_visFactor*v_distance-0.5*u_shadeInterpolate,c_zero)), c_zero, u_numShades-c_one);
|
float shade = clamp((u_shade+max(u_visFactor*v_distance-0.5*u_shadeInterpolate,c_zero)), c_zero, u_numShades-c_one);
|
||||||
float shadeFrac = mod(shade, c_one);
|
float shadeFrac = mod(shade, c_one);
|
||||||
|
@ -168,10 +182,10 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// should be an 'else' to all the above.
|
// should be an 'else' to all the above.
|
||||||
color = mix(color, c_vec4_one, u_useColorOnly);
|
color = mix(color, c_vec4_one, u_useColorOnly);
|
||||||
|
|
||||||
// only relevant for paletted rendering - in true color this requires a fifth color channel (i.e. an external brightmap - work for later) or an overlay (current implementation)
|
// only relevant for paletted rendering - in true color this requires a fifth color channel (i.e. an external brightmap - work for later) or an overlay (current implementation)
|
||||||
color.rgb = mix(v_color.rgb*color.rgb, color.rgb, fullbright);
|
color.rgb = mix(v_color.rgb*color.rgb, color.rgb, fullbright);
|
||||||
|
|
||||||
if (u_usePalette == 0.0 && u_fogEnabled != 0.0)// the following would make sense if 'fullbright' could ever be true in non-paletted rendering: && (fullbright != 0.0 || u_fogColor.rgb != vec3(0.0) ))
|
if (u_usePalette == 0.0 && u_fogEnabled != 0.0)// the following would make sense if 'fullbright' could ever be true in non-paletted rendering: && (fullbright != 0.0 || u_fogColor.rgb != vec3(0.0) ))
|
||||||
{
|
{
|
||||||
|
@ -190,8 +204,7 @@ void main()
|
||||||
color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a);
|
color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
color.a *= v_color.a;
|
color.a *= v_color.a;
|
||||||
color.rgb = pow(color.rgb, vec3(u_brightness));
|
color.rgb = pow(color.rgb, vec3(u_brightness));
|
||||||
|
fragColor = color;
|
||||||
fragColor = color;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue