diff --git a/source/glbackend/gl_shader.cpp b/source/glbackend/gl_shader.cpp index fe592d8a0..7b6ad7bfd 100644 --- a/source/glbackend/gl_shader.cpp +++ b/source/glbackend/gl_shader.cpp @@ -138,8 +138,9 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char NPOTEmulationFactor.Init(hShader, "u_npotEmulationFactor"); NPOTEmulationXOffset.Init(hShader, "u_npotEmulationXOffset"); Brightness.Init(hShader, "u_brightness"); - FogColor.Init(hShader, "u_fogColor"); + TextureMode.Init(hShader, "uTextureMode"); + FogColor.Init(hShader, "uFogColor"); muFogEnabled.Init(hShader, "uFogEnabled"); muLightParms.Init(hShader, "uLightAttr"); AlphaThreshold.Init(hShader, "uAlphaThreshold"); @@ -160,11 +161,11 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char int SamplerLoc; SamplerLoc = glGetUniformLocation(hShader, "s_texture"); glUniform1i(SamplerLoc, 0); - SamplerLoc = glGetUniformLocation(hShader, "s_brightmap"); + SamplerLoc = glGetUniformLocation(hShader, "brighttexture"); glUniform1i(SamplerLoc, 1); - SamplerLoc = glGetUniformLocation(hShader, "s_detail"); + SamplerLoc = glGetUniformLocation(hShader, "detailtexture"); glUniform1i(SamplerLoc, 2); - SamplerLoc = glGetUniformLocation(hShader, "s_glow"); + SamplerLoc = glGetUniformLocation(hShader, "glowtexture"); glUniform1i(SamplerLoc, 3); SamplerLoc = glGetUniformLocation(hShader, "s_palette"); glUniform1i(SamplerLoc, 4); diff --git a/source/glbackend/gl_shader.h b/source/glbackend/gl_shader.h index 8873ec6a6..10860632b 100644 --- a/source/glbackend/gl_shader.h +++ b/source/glbackend/gl_shader.h @@ -32,6 +32,7 @@ public: FBufferedUniform1f Brightness; FBufferedUniformPalEntry FogColor; + FBufferedUniform1i TextureMode; FBufferedUniform4f DetailParms; FBufferedUniform1f AlphaThreshold; FBufferedUniform1i muFogEnabled; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 9dd44d7ad..8ccb4059c 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -116,6 +116,10 @@ auto i_data = R"( float uClipHeightDirection; int uShadowmapFilter; }; + uniform sampler2D detailtexture; + uniform sampler2D glowtexture; + uniform sampler2D brighttexture; + uniform mat4 ModelMatrix; uniform mat4 NormalModelMatrix; uniform mat4 TextureMatrix; @@ -132,6 +136,8 @@ auto i_data = R"( #define uLightFactor uLightAttr.g #define uLightDist uLightAttr.r uniform int uFogEnabled; + uniform vec4 uFogColor; + uniform int uTextureMode; )"; @@ -543,7 +549,7 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState& oldState) shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f); shader->Brightness.Set(Brightness); shader->FogColor.Set(FogColor); - float lightattr[] = { ShadeDiv / (numshades - 2), VisFactor, (Flags & RF_MapFog) ? -5.f : 0.f , Shade }; + float lightattr[] = { ShadeDiv / (numshades - 2), VisFactor, (Flags & RF_MapFog) ? -5.f : 0.f , ShadeDiv >= 1 / 1000.f? Shade : 0 }; shader->muLightParms.Set(lightattr); FVector4 addcol(0, 0, 0, 0); diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index 81874d2bd..dc2a1759c 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -13,16 +13,11 @@ uniform sampler2D s_palswap; //s_palette is the base palette texture where u is the color index uniform sampler2D s_palette; -uniform sampler2D s_detail; -uniform sampler2D s_glow; -uniform sampler2D s_brightmap; - uniform int u_flags; uniform float u_npotEmulationFactor; uniform float u_npotEmulationXOffset; uniform float u_brightness; -uniform vec4 u_fogColor; in vec4 v_color; in float v_distance; @@ -165,7 +160,7 @@ void main() vec4 detailColor = vec4(1.0); if ((u_flags & RF_DetailMapping) != 0) { - detailColor = texture(s_detail, newCoord * uDetailParms.xy) * uDetailParms.z; + detailColor = texture(detailtexture, newCoord * uDetailParms.xy) * uDetailParms.z; detailColor = mix(vec4(1.0), 2.0 * detailColor, detailColor.a); // Application of this differs based on render mode because for paletted rendering with palettized shade tables it can only be done after processing the shade table. We only have a palette index before. } @@ -217,10 +212,10 @@ void main() if ((u_flags & RF_Brightmapping) != 0) { - lightcolor = clamp(lightcolor + texture(s_brightmap, v_texCoord.xy).rgb, 0.0, 1.0); + lightcolor = clamp(lightcolor + texture(brighttexture, v_texCoord.xy).rgb, 0.0, 1.0); } color.rgb *= lightcolor; - if (uFogDensity == 0.0) color.rgb += u_fogColor.rgb * shade; + if (uFogDensity == 0.0) color.rgb += uFogColor.rgb * shade; } else color.rgb *= v_color.rgb; } @@ -241,7 +236,7 @@ void main() if ((u_flags & (RF_ColorOnly|RF_GlowMapping)) == RF_GlowMapping) { - vec4 glowColor = texture(s_glow, v_texCoord.xy); + vec4 glowColor = texture(glowtexture, v_texCoord.xy); color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a); }