- renamed a few more things in the shader.

This commit is contained in:
Christoph Oelckers 2020-06-07 08:16:04 +02:00
parent fc466849ce
commit 3adfdfcac5
4 changed files with 17 additions and 14 deletions

View file

@ -138,8 +138,9 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
NPOTEmulationFactor.Init(hShader, "u_npotEmulationFactor"); NPOTEmulationFactor.Init(hShader, "u_npotEmulationFactor");
NPOTEmulationXOffset.Init(hShader, "u_npotEmulationXOffset"); NPOTEmulationXOffset.Init(hShader, "u_npotEmulationXOffset");
Brightness.Init(hShader, "u_brightness"); Brightness.Init(hShader, "u_brightness");
FogColor.Init(hShader, "u_fogColor");
TextureMode.Init(hShader, "uTextureMode");
FogColor.Init(hShader, "uFogColor");
muFogEnabled.Init(hShader, "uFogEnabled"); muFogEnabled.Init(hShader, "uFogEnabled");
muLightParms.Init(hShader, "uLightAttr"); muLightParms.Init(hShader, "uLightAttr");
AlphaThreshold.Init(hShader, "uAlphaThreshold"); AlphaThreshold.Init(hShader, "uAlphaThreshold");
@ -160,11 +161,11 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
int SamplerLoc; int SamplerLoc;
SamplerLoc = glGetUniformLocation(hShader, "s_texture"); SamplerLoc = glGetUniformLocation(hShader, "s_texture");
glUniform1i(SamplerLoc, 0); glUniform1i(SamplerLoc, 0);
SamplerLoc = glGetUniformLocation(hShader, "s_brightmap"); SamplerLoc = glGetUniformLocation(hShader, "brighttexture");
glUniform1i(SamplerLoc, 1); glUniform1i(SamplerLoc, 1);
SamplerLoc = glGetUniformLocation(hShader, "s_detail"); SamplerLoc = glGetUniformLocation(hShader, "detailtexture");
glUniform1i(SamplerLoc, 2); glUniform1i(SamplerLoc, 2);
SamplerLoc = glGetUniformLocation(hShader, "s_glow"); SamplerLoc = glGetUniformLocation(hShader, "glowtexture");
glUniform1i(SamplerLoc, 3); glUniform1i(SamplerLoc, 3);
SamplerLoc = glGetUniformLocation(hShader, "s_palette"); SamplerLoc = glGetUniformLocation(hShader, "s_palette");
glUniform1i(SamplerLoc, 4); glUniform1i(SamplerLoc, 4);

View file

@ -32,6 +32,7 @@ public:
FBufferedUniform1f Brightness; FBufferedUniform1f Brightness;
FBufferedUniformPalEntry FogColor; FBufferedUniformPalEntry FogColor;
FBufferedUniform1i TextureMode;
FBufferedUniform4f DetailParms; FBufferedUniform4f DetailParms;
FBufferedUniform1f AlphaThreshold; FBufferedUniform1f AlphaThreshold;
FBufferedUniform1i muFogEnabled; FBufferedUniform1i muFogEnabled;

View file

@ -116,6 +116,10 @@ auto i_data = R"(
float uClipHeightDirection; float uClipHeightDirection;
int uShadowmapFilter; int uShadowmapFilter;
}; };
uniform sampler2D detailtexture;
uniform sampler2D glowtexture;
uniform sampler2D brighttexture;
uniform mat4 ModelMatrix; uniform mat4 ModelMatrix;
uniform mat4 NormalModelMatrix; uniform mat4 NormalModelMatrix;
uniform mat4 TextureMatrix; uniform mat4 TextureMatrix;
@ -132,6 +136,8 @@ auto i_data = R"(
#define uLightFactor uLightAttr.g #define uLightFactor uLightAttr.g
#define uLightDist uLightAttr.r #define uLightDist uLightAttr.r
uniform int uFogEnabled; 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->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f);
shader->Brightness.Set(Brightness); shader->Brightness.Set(Brightness);
shader->FogColor.Set(FogColor); 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); shader->muLightParms.Set(lightattr);
FVector4 addcol(0, 0, 0, 0); FVector4 addcol(0, 0, 0, 0);

View file

@ -13,16 +13,11 @@ uniform sampler2D s_palswap;
//s_palette is the base palette texture where u is the color index //s_palette is the base palette texture where u is the color index
uniform sampler2D s_palette; uniform sampler2D s_palette;
uniform sampler2D s_detail;
uniform sampler2D s_glow;
uniform sampler2D s_brightmap;
uniform int u_flags; uniform int u_flags;
uniform float u_npotEmulationFactor; uniform float u_npotEmulationFactor;
uniform float u_npotEmulationXOffset; uniform float u_npotEmulationXOffset;
uniform float u_brightness; uniform float u_brightness;
uniform vec4 u_fogColor;
in vec4 v_color; in vec4 v_color;
in float v_distance; in float v_distance;
@ -165,7 +160,7 @@ void main()
vec4 detailColor = vec4(1.0); vec4 detailColor = vec4(1.0);
if ((u_flags & RF_DetailMapping) != 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); 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. // 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) 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; 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; else color.rgb *= v_color.rgb;
} }
@ -241,7 +236,7 @@ void main()
if ((u_flags & (RF_ColorOnly|RF_GlowMapping)) == RF_GlowMapping) 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); color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a);
} }