- make all varyings in the polymost shader explicit and declare the surface shader as v3.30 as it already used modern syntax.

This commit is contained in:
Christoph Oelckers 2019-10-06 10:29:17 +02:00
parent 71d132b470
commit 0720ad5fd5
4 changed files with 23 additions and 15 deletions

View file

@ -1,11 +1,11 @@
#version 110 #version 330
//s_texture points to an indexed color texture //s_texture points to an indexed color texture
uniform sampler2D s_texture; uniform sampler2D s_texture;
//s_palette is the palette texture //s_palette is the palette texture
uniform sampler2D s_palette; uniform sampler2D s_palette;
varying vec2 v_texCoord; in vec2 v_texCoord;
const float c_paletteScale = 255.0/256.0; const float c_paletteScale = 255.0/256.0;
const float c_paletteOffset = 0.5/256.0; const float c_paletteOffset = 0.5/256.0;

View file

@ -1,9 +1,9 @@
#version 110 #version 330
attribute vec4 i_vertPos; attribute vec4 i_vertPos;
attribute vec2 i_texCoord; attribute vec2 i_texCoord;
varying vec2 v_texCoord; out vec2 v_texCoord;
void main() void main()
{ {

View file

@ -38,6 +38,10 @@ uniform vec3 u_tintcolor;
varying vec4 v_color; varying vec4 v_color;
varying float v_distance; varying float v_distance;
varying vec4 v_texCoord;
varying vec4 v_detailCoord;
varying vec4 v_glowCoord;
varying float v_fogCoord;
const float c_basepalScale = 255.0/256.0; const float c_basepalScale = 255.0/256.0;
const float c_basepalOffset = 0.5/256.0; const float c_basepalOffset = 0.5/256.0;
@ -130,12 +134,12 @@ vec4 convertColor(vec4 color, int effect, vec3 tint)
void main() void main()
{ {
float coordY = mix(gl_TexCoord[0].y,gl_TexCoord[0].x,u_usePalette); float coordY = mix(v_texCoord.y,v_texCoord.x,u_usePalette);
float coordX = mix(gl_TexCoord[0].x,gl_TexCoord[0].y,u_usePalette); float coordX = mix(v_texCoord.x,v_texCoord.y,u_usePalette);
float period = floor(coordY/u_npotEmulationFactor); float period = floor(coordY/u_npotEmulationFactor);
coordX += u_npotEmulationXOffset*floor(mod(coordY,u_npotEmulationFactor)); coordX += u_npotEmulationXOffset*floor(mod(coordY,u_npotEmulationFactor));
coordY = period+mod(coordY,u_npotEmulationFactor); coordY = period+mod(coordY,u_npotEmulationFactor);
vec2 newCoord = mix(gl_TexCoord[0].xy,mix(vec2(coordX,coordY),vec2(coordY,coordX),u_usePalette),u_npotEmulation); vec2 newCoord = mix(v_texCoord.xy,mix(vec2(coordX,coordY),vec2(coordY,coordX),u_usePalette),u_npotEmulation);
vec2 transitionBlend = fwidth(floor(newCoord.xy)); vec2 transitionBlend = fwidth(floor(newCoord.xy));
transitionBlend = fwidth(transitionBlend)+transitionBlend; transitionBlend = fwidth(transitionBlend)+transitionBlend;
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); 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);
@ -156,7 +160,7 @@ void main()
if (u_useDetailMapping != 0.0) if (u_useDetailMapping != 0.0)
{ {
vec4 detailColor = texture2D(s_detail, gl_TexCoord[3].xy); vec4 detailColor = texture2D(s_detail, v_detailCoord.xy);
detailColor = mix(c_vec4_one, 2.0*detailColor, detailColor.a); detailColor = mix(c_vec4_one, 2.0*detailColor, detailColor.a);
color.rgb *= detailColor.rgb; color.rgb *= detailColor.rgb;
} }
@ -167,13 +171,13 @@ void main()
float fogEnabled = mix(u_fogEnabled, c_zero, u_usePalette); float fogEnabled = mix(u_fogEnabled, c_zero, u_usePalette);
fullbright = max(c_one-fogEnabled, fullbright); fullbright = max(c_one-fogEnabled, fullbright);
float fogFactor = clamp((gl_Fog.end-gl_FogFragCoord)*gl_Fog.scale, fullbright, c_one); float fogFactor = clamp((gl_Fog.end-v_fogCoord)*gl_Fog.scale, fullbright, c_one);
//float fogFactor = clamp(gl_FogFragCoord, fullbright, c_one); //float fogFactor = clamp(v_fogCoord, fullbright, c_one);
color.rgb = mix(gl_Fog.color.rgb, color.rgb, fogFactor); color.rgb = mix(gl_Fog.color.rgb, color.rgb, fogFactor);
if (u_useGlowMapping != 0.0) if (u_useGlowMapping != 0.0)
{ {
vec4 glowColor = texture2D(s_glow, gl_TexCoord[4].xy); vec4 glowColor = texture2D(s_glow, v_glowCoord.xy);
color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a*(c_one-u_useColorOnly)); color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a*(c_one-u_useColorOnly));
} }

View file

@ -2,6 +2,10 @@
varying vec4 v_color; varying vec4 v_color;
varying float v_distance; varying float v_distance;
varying vec4 v_texCoord;
varying vec4 v_detailCoord;
varying vec4 v_glowCoord;
varying float v_fogCoord;
uniform float u_usePalette; uniform float u_usePalette;
uniform mat4 u_rotMatrix; uniform mat4 u_rotMatrix;
@ -21,13 +25,13 @@ void main()
eyeCoordPosition.xyz /= eyeCoordPosition.w; eyeCoordPosition.xyz /= eyeCoordPosition.w;
gl_TexCoord[0] = gl_MultiTexCoord0; v_texCoord = gl_MultiTexCoord0;
//gl_TexCoord[0] = mix(gl_TexCoord[0].xyzw, gl_TexCoord[0].yxzw, u_usePalette); WTF is this??? //gl_TexCoord[0] = mix(gl_TexCoord[0].xyzw, gl_TexCoord[0].yxzw, u_usePalette); WTF is this???
gl_TexCoord[3] = u_detailMatrix * gl_MultiTexCoord0; v_detailCoord = u_detailMatrix * gl_MultiTexCoord0;
gl_TexCoord[4] = u_glowMatrix * gl_MultiTexCoord0; v_glowCoord = u_glowMatrix * gl_MultiTexCoord0;
gl_FogFragCoord = abs(eyeCoordPosition.z); v_fogCoord = abs(eyeCoordPosition.z);
v_color = gl_Color; v_color = gl_Color;
v_distance = gl_Vertex.z; v_distance = gl_Vertex.z;