mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 11:50:49 +00:00
- switched NPOT emulation to the renamed uniforms.
This was the last feature that needed to be mapped to a GZDoom compatible render state
This commit is contained in:
parent
5cbe9fc49c
commit
17e1e4175e
7 changed files with 22 additions and 20 deletions
|
@ -135,9 +135,8 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
|
||||||
if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, VIEWPOINT_BINDINGPOINT);
|
if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, VIEWPOINT_BINDINGPOINT);
|
||||||
|
|
||||||
Flags.Init(hShader, "u_flags");
|
Flags.Init(hShader, "u_flags");
|
||||||
NPOTEmulationFactor.Init(hShader, "u_npotEmulationFactor");
|
|
||||||
NPOTEmulationXOffset.Init(hShader, "u_npotEmulationXOffset");
|
NPOTEmulation.Init(hShader, "uNpotEmulation");
|
||||||
|
|
||||||
TextureMode.Init(hShader, "uTextureMode");
|
TextureMode.Init(hShader, "uTextureMode");
|
||||||
FogColor.Init(hShader, "uFogColor");
|
FogColor.Init(hShader, "uFogColor");
|
||||||
muFogEnabled.Init(hShader, "uFogEnabled");
|
muFogEnabled.Init(hShader, "uFogEnabled");
|
||||||
|
|
|
@ -27,9 +27,8 @@ class PolymostShader : public FShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FBufferedUniform1i Flags;
|
FBufferedUniform1i Flags;
|
||||||
FBufferedUniform1f NPOTEmulationFactor;
|
FBufferedUniform2f NPOTEmulation;
|
||||||
FBufferedUniform1f NPOTEmulationXOffset;
|
FBufferedUniformPalEntry FogColor;
|
||||||
FBufferedUniformPalEntry FogColor;
|
|
||||||
|
|
||||||
FBufferedUniform1i TextureMode;
|
FBufferedUniform1i TextureMode;
|
||||||
FBufferedUniform4f DetailParms;
|
FBufferedUniform4f DetailParms;
|
||||||
|
|
|
@ -138,6 +138,7 @@ auto i_data = R"(
|
||||||
uniform int uFogEnabled;
|
uniform int uFogEnabled;
|
||||||
uniform vec4 uFogColor;
|
uniform vec4 uFogColor;
|
||||||
uniform int uTextureMode;
|
uniform int uTextureMode;
|
||||||
|
uniform vec2 uNpotEmulation;
|
||||||
|
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
@ -543,8 +544,7 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState& oldState)
|
||||||
|
|
||||||
shader->Flags.Set(Flags);
|
shader->Flags.Set(Flags);
|
||||||
shader->TextureMode.Set(LayerFlags);
|
shader->TextureMode.Set(LayerFlags);
|
||||||
shader->NPOTEmulationFactor.Set(NPOTEmulationFactor);
|
shader->NPOTEmulation.Set(&NPOTEmulation.X);
|
||||||
shader->NPOTEmulationXOffset.Set(NPOTEmulationXOffset);
|
|
||||||
shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f);
|
shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f);
|
||||||
shader->FogColor.Set((Flags& RF_MapFog)? PalEntry(0x999999) : FogColor);
|
shader->FogColor.Set((Flags& RF_MapFog)? PalEntry(0x999999) : FogColor);
|
||||||
float lightattr[] = { ShadeDiv / (numshades - 2), VisFactor, (Flags & RF_MapFog) ? -5.f : 0.f , ShadeDiv >= 1 / 1000.f? Shade : 0 };
|
float lightattr[] = { ShadeDiv / (numshades - 2), VisFactor, (Flags & RF_MapFog) ? -5.f : 0.f , ShadeDiv >= 1 / 1000.f? Shade : 0 };
|
||||||
|
|
|
@ -391,8 +391,8 @@ public:
|
||||||
|
|
||||||
void SetNpotEmulation(float factor, float xOffset)
|
void SetNpotEmulation(float factor, float xOffset)
|
||||||
{
|
{
|
||||||
renderState.NPOTEmulationFactor = factor;
|
renderState.NPOTEmulation.Y = factor;
|
||||||
renderState.NPOTEmulationXOffset = xOffset;
|
renderState.NPOTEmulation.X = xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetShadeInterpolate(int32_t yes)
|
void SetShadeInterpolate(int32_t yes)
|
||||||
|
|
|
@ -55,8 +55,7 @@ struct PolymostRenderState
|
||||||
float VisFactor = 128.f;
|
float VisFactor = 128.f;
|
||||||
int Flags = 0;
|
int Flags = 0;
|
||||||
int LayerFlags = 0;
|
int LayerFlags = 0;
|
||||||
float NPOTEmulationFactor = 1.f;
|
FVector2 NPOTEmulation = { 0.f, 0.f };
|
||||||
float NPOTEmulationXOffset;
|
|
||||||
float AlphaThreshold = 0.5f;
|
float AlphaThreshold = 0.5f;
|
||||||
bool AlphaTest = true;
|
bool AlphaTest = true;
|
||||||
float Color[4] = { 1,1,1,1 };
|
float Color[4] = { 1,1,1,1 };
|
||||||
|
|
|
@ -33,9 +33,6 @@ uniform sampler2D s_palette;
|
||||||
|
|
||||||
uniform int u_flags;
|
uniform int u_flags;
|
||||||
|
|
||||||
uniform float u_npotEmulationFactor;
|
|
||||||
uniform float u_npotEmulationXOffset;
|
|
||||||
|
|
||||||
in vec4 v_color;
|
in vec4 v_color;
|
||||||
in float v_distance;
|
in float v_distance;
|
||||||
in vec4 v_texCoord;
|
in vec4 v_texCoord;
|
||||||
|
@ -161,12 +158,12 @@ void main()
|
||||||
float coordY = v_texCoord.y;
|
float coordY = v_texCoord.y;
|
||||||
vec2 newCoord;
|
vec2 newCoord;
|
||||||
|
|
||||||
// Coordinate adjustment for NPOT textures (something must have gone very wrong to make this necessary...)
|
// Coordinate adjustment for NPOT textures. It is somehow fitting that Build games exploited this texture wrapping quirk of the software rendering engine...
|
||||||
if (u_npotEmulationFactor != 0.0)
|
if (uNpotEmulation.y != 0.0)
|
||||||
{
|
{
|
||||||
float period = floor(coordY / u_npotEmulationFactor);
|
float period = floor(coordY / uNpotEmulation.y);
|
||||||
coordX += u_npotEmulationXOffset * floor(mod(coordY, u_npotEmulationFactor));
|
coordX += uNpotEmulation.x * floor(mod(coordY, uNpotEmulation.y));
|
||||||
coordY = period + mod(coordY, u_npotEmulationFactor);
|
coordY = period + mod(coordY, uNpotEmulation.y);
|
||||||
}
|
}
|
||||||
newCoord = vec2(coordX, coordY);
|
newCoord = vec2(coordX, coordY);
|
||||||
|
|
||||||
|
|
|
@ -540,6 +540,14 @@ vec3 ApplyNormalMap(vec2 texcoord)
|
||||||
|
|
||||||
void SetMaterialProps(inout Material material, vec2 texCoord)
|
void SetMaterialProps(inout Material material, vec2 texCoord)
|
||||||
{
|
{
|
||||||
|
#ifdef NPOT_EMULATION
|
||||||
|
if (uNpotEmulation.y != 0.0)
|
||||||
|
{
|
||||||
|
float period = floor(texCoord.t / uNpotEmulation.y);
|
||||||
|
texCoord.s += uNpotEmulation.x * floor(mod(texCoord.t, uNpotEmulation.y));
|
||||||
|
texCoord.t = period + mod(texCoord.t, uNpotEmulation.y);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
material.Base = getTexel(texCoord.st);
|
material.Base = getTexel(texCoord.st);
|
||||||
material.Normal = ApplyNormalMap(texCoord.st);
|
material.Normal = ApplyNormalMap(texCoord.st);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue