From 0720ad5fd5488a0d2b8f632be5c31e8b9189d592 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Oct 2019 10:29:17 +0200 Subject: [PATCH] - make all varyings in the polymost shader explicit and declare the surface shader as v3.30 as it already used modern syntax. --- .../demolition/shaders/glsl/glsurface.fp | 4 ++-- .../demolition/shaders/glsl/glsurface.vp | 4 ++-- .../static/demolition/shaders/glsl/polymost.fp | 18 +++++++++++------- .../static/demolition/shaders/glsl/polymost.vp | 12 ++++++++---- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/wadsrc/static/demolition/shaders/glsl/glsurface.fp b/wadsrc/static/demolition/shaders/glsl/glsurface.fp index 4197f3fe4..39f92c6fb 100644 --- a/wadsrc/static/demolition/shaders/glsl/glsurface.fp +++ b/wadsrc/static/demolition/shaders/glsl/glsurface.fp @@ -1,11 +1,11 @@ -#version 110 +#version 330 //s_texture points to an indexed color texture uniform sampler2D s_texture; //s_palette is the palette texture uniform sampler2D s_palette; -varying vec2 v_texCoord; +in vec2 v_texCoord; const float c_paletteScale = 255.0/256.0; const float c_paletteOffset = 0.5/256.0; diff --git a/wadsrc/static/demolition/shaders/glsl/glsurface.vp b/wadsrc/static/demolition/shaders/glsl/glsurface.vp index ddea2ef5c..db576f546 100644 --- a/wadsrc/static/demolition/shaders/glsl/glsurface.vp +++ b/wadsrc/static/demolition/shaders/glsl/glsurface.vp @@ -1,9 +1,9 @@ -#version 110 +#version 330 attribute vec4 i_vertPos; attribute vec2 i_texCoord; -varying vec2 v_texCoord; +out vec2 v_texCoord; void main() { diff --git a/wadsrc/static/demolition/shaders/glsl/polymost.fp b/wadsrc/static/demolition/shaders/glsl/polymost.fp index f1e830848..76525d912 100644 --- a/wadsrc/static/demolition/shaders/glsl/polymost.fp +++ b/wadsrc/static/demolition/shaders/glsl/polymost.fp @@ -38,6 +38,10 @@ uniform vec3 u_tintcolor; varying vec4 v_color; 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_basepalOffset = 0.5/256.0; @@ -130,12 +134,12 @@ vec4 convertColor(vec4 color, int effect, vec3 tint) void main() { - float coordY = mix(gl_TexCoord[0].y,gl_TexCoord[0].x,u_usePalette); - float coordX = mix(gl_TexCoord[0].x,gl_TexCoord[0].y,u_usePalette); + float coordY = mix(v_texCoord.y,v_texCoord.x,u_usePalette); + float coordX = mix(v_texCoord.x,v_texCoord.y,u_usePalette); float period = floor(coordY/u_npotEmulationFactor); coordX += u_npotEmulationXOffset*floor(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)); 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); @@ -156,7 +160,7 @@ void main() 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); color.rgb *= detailColor.rgb; } @@ -167,13 +171,13 @@ void main() float fogEnabled = mix(u_fogEnabled, c_zero, u_usePalette); fullbright = max(c_one-fogEnabled, fullbright); - float fogFactor = clamp((gl_Fog.end-gl_FogFragCoord)*gl_Fog.scale, fullbright, c_one); - //float fogFactor = clamp(gl_FogFragCoord, fullbright, c_one); + float fogFactor = clamp((gl_Fog.end-v_fogCoord)*gl_Fog.scale, fullbright, c_one); + //float fogFactor = clamp(v_fogCoord, fullbright, c_one); color.rgb = mix(gl_Fog.color.rgb, color.rgb, fogFactor); 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)); } diff --git a/wadsrc/static/demolition/shaders/glsl/polymost.vp b/wadsrc/static/demolition/shaders/glsl/polymost.vp index dd311db61..f85059917 100644 --- a/wadsrc/static/demolition/shaders/glsl/polymost.vp +++ b/wadsrc/static/demolition/shaders/glsl/polymost.vp @@ -2,6 +2,10 @@ varying vec4 v_color; 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 mat4 u_rotMatrix; @@ -21,13 +25,13 @@ void main() 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[3] = u_detailMatrix * gl_MultiTexCoord0; - gl_TexCoord[4] = u_glowMatrix * gl_MultiTexCoord0; + v_detailCoord = u_detailMatrix * gl_MultiTexCoord0; + v_glowCoord = u_glowMatrix * gl_MultiTexCoord0; - gl_FogFragCoord = abs(eyeCoordPosition.z); + v_fogCoord = abs(eyeCoordPosition.z); v_color = gl_Color; v_distance = gl_Vertex.z;