mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-12 23:54:17 +00:00
- cleanup of the revised y-clamping feature.
This integrates better with the existing features.
This commit is contained in:
parent
6e2aef617c
commit
da806b354d
9 changed files with 32 additions and 25 deletions
|
@ -51,12 +51,10 @@ enum ETexMode
|
||||||
TM_OPAQUE, // (r, g, b, 1)
|
TM_OPAQUE, // (r, g, b, 1)
|
||||||
TM_INVERSE, // (1-r, 1-g, 1-b, a)
|
TM_INVERSE, // (1-r, 1-g, 1-b, a)
|
||||||
TM_ALPHATEXTURE, // (1, 1, 1, r)
|
TM_ALPHATEXTURE, // (1, 1, 1, r)
|
||||||
TM_INVERTOPAQUE = 6, // (1-r, 1-g, 1-b, 1)
|
TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0)
|
||||||
|
TM_INVERTOPAQUE, // (1-r, 1-g, 1-b, 1)
|
||||||
TM_FOGLAYER, // (renders a fog layer in the shape of the active texture)
|
TM_FOGLAYER, // (renders a fog layer in the shape of the active texture)
|
||||||
TM_FIXEDCOLORMAP = TM_FOGLAYER, // repurposes the objectcolor uniforms to render a fixed colormap range. (Same constant because they cannot be used in the same context.
|
TM_FIXEDCOLORMAP = TM_FOGLAYER, // repurposes the objectcolor uniforms to render a fixed colormap range. (Same constant because they cannot be used in the same context.
|
||||||
|
|
||||||
TM_CLAMPY = 0x1000, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0)
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Legacy render styles
|
// Legacy render styles
|
||||||
|
|
|
@ -124,9 +124,7 @@ bool FGLRenderState::ApplyShader()
|
||||||
activeShader->muDesaturation.Set(mStreamData.uDesaturationFactor);
|
activeShader->muDesaturation.Set(mStreamData.uDesaturationFactor);
|
||||||
activeShader->muFogEnabled.Set(fogset);
|
activeShader->muFogEnabled.Set(fogset);
|
||||||
|
|
||||||
int f = mTextureModeFlags;
|
activeShader->muTextureMode.Set(GetTextureModeAndFlags(mTempTM));
|
||||||
if (!mBrightmapEnabled) f &= ~(TEXF_Brightmap | TEXF_Glowmap);
|
|
||||||
activeShader->muTextureMode.Set((mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) | f);
|
|
||||||
activeShader->muLightParms.Set(mLightParms);
|
activeShader->muLightParms.Set(mLightParms);
|
||||||
activeShader->muFogColor.Set(mStreamData.uFogColor);
|
activeShader->muFogColor.Set(mStreamData.uFogColor);
|
||||||
activeShader->muObjectColor.Set(mStreamData.uObjectColor);
|
activeShader->muObjectColor.Set(mStreamData.uObjectColor);
|
||||||
|
|
|
@ -144,14 +144,15 @@ bool FGLRenderState::ApplyShader()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
flavour.textureMode = (mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) & 0xff;
|
int tm = GetTextureModeAndFlags(mTempTM);
|
||||||
if (mTextureClamp && flavour.textureMode == TM_NORMAL) flavour.textureMode = 5; // fixme. Clamp can now be combined with all modes.
|
flavour.textureMode = tm & 0xffff;
|
||||||
|
flavour.texFlags = tm >> 16; //Move flags to start of word
|
||||||
|
|
||||||
|
if (mTextureClamp && flavour.textureMode == TM_NORMAL) flavour.textureMode = TM_CLAMPY; // fixme. Clamp can now be combined with all modes.
|
||||||
|
|
||||||
if (flavour.textureMode == -1)
|
if (flavour.textureMode == -1)
|
||||||
flavour.textureMode = 0;
|
flavour.textureMode = 0;
|
||||||
|
|
||||||
flavour.texFlags = mTextureModeFlags; if (!mBrightmapEnabled) flavour.texFlags &= ~(TEXF_Brightmap | TEXF_Glowmap);
|
|
||||||
flavour.texFlags >>= 16; //Move flags to start of word
|
|
||||||
|
|
||||||
flavour.blendFlags = (int)(mStreamData.uTextureAddColor.a + 0.01);
|
flavour.blendFlags = (int)(mStreamData.uTextureAddColor.a + 0.01);
|
||||||
|
|
||||||
|
@ -238,9 +239,6 @@ bool FGLRenderState::ApplyShader()
|
||||||
activeShader->cur->muDesaturation.Set(mStreamData.uDesaturationFactor);
|
activeShader->cur->muDesaturation.Set(mStreamData.uDesaturationFactor);
|
||||||
//activeShader->cur->muFogEnabled.Set(fogset);
|
//activeShader->cur->muFogEnabled.Set(fogset);
|
||||||
|
|
||||||
int f = mTextureModeFlags;
|
|
||||||
if (!mBrightmapEnabled) f &= ~(TEXF_Brightmap | TEXF_Glowmap);
|
|
||||||
//activeShader->cur->muTextureMode.Set((mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) | f);
|
|
||||||
activeShader->cur->muLightParms.Set(mLightParms);
|
activeShader->cur->muLightParms.Set(mLightParms);
|
||||||
activeShader->cur->muFogColor.Set(mStreamData.uFogColor);
|
activeShader->cur->muFogColor.Set(mStreamData.uFogColor);
|
||||||
activeShader->cur->muObjectColor.Set(mStreamData.uObjectColor);
|
activeShader->cur->muObjectColor.Set(mStreamData.uObjectColor);
|
||||||
|
|
|
@ -378,6 +378,14 @@ public:
|
||||||
return mTextureMode;
|
return mTextureMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetTextureModeAndFlags(int tempTM)
|
||||||
|
{
|
||||||
|
int f = mTextureModeFlags;
|
||||||
|
if (!mBrightmapEnabled) f &= ~(TEXF_Brightmap | TEXF_Glowmap);
|
||||||
|
if (mTextureClamp) f |= TEXF_ClampY;
|
||||||
|
return (mTextureMode == TM_NORMAL && tempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) | f;
|
||||||
|
}
|
||||||
|
|
||||||
void EnableTexture(bool on)
|
void EnableTexture(bool on)
|
||||||
{
|
{
|
||||||
mTextureEnabled = on;
|
mTextureEnabled = on;
|
||||||
|
|
|
@ -287,7 +287,7 @@ void PolyRenderState::Apply()
|
||||||
|
|
||||||
PolyPushConstants constants;
|
PolyPushConstants constants;
|
||||||
constants.uFogEnabled = fogset;
|
constants.uFogEnabled = fogset;
|
||||||
constants.uTextureMode = (mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
|
constants.uTextureMode = GetTextureModeAndFlags(mTempTM);
|
||||||
constants.uLightDist = mLightParms[0];
|
constants.uLightDist = mLightParms[0];
|
||||||
constants.uLightFactor = mLightParms[1];
|
constants.uLightFactor = mLightParms[1];
|
||||||
constants.uFogDensity = mLightParms[2];
|
constants.uFogDensity = mLightParms[2];
|
||||||
|
|
|
@ -380,11 +380,7 @@ static void ProcessMaterial(int x0, int x1, PolyTriangleThreadData* thread)
|
||||||
{
|
{
|
||||||
auto constants = thread->PushConstants;
|
auto constants = thread->PushConstants;
|
||||||
|
|
||||||
if (constants->uTextureMode == TM_CLAMPY)
|
switch (constants->uTextureMode)
|
||||||
{
|
|
||||||
FuncNormal_ClampY(x0, x1, thread);
|
|
||||||
}
|
|
||||||
else switch (constants->uTextureMode & 0xff)
|
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case TM_NORMAL:
|
case TM_NORMAL:
|
||||||
|
@ -393,6 +389,7 @@ static void ProcessMaterial(int x0, int x1, PolyTriangleThreadData* thread)
|
||||||
case TM_OPAQUE: FuncNormal_Opaque(x0, x1, thread); break;
|
case TM_OPAQUE: FuncNormal_Opaque(x0, x1, thread); break;
|
||||||
case TM_INVERSE: FuncNormal_Inverse(x0, x1, thread); break;
|
case TM_INVERSE: FuncNormal_Inverse(x0, x1, thread); break;
|
||||||
case TM_ALPHATEXTURE: FuncNormal_AlphaTexture(x0, x1, thread); break;
|
case TM_ALPHATEXTURE: FuncNormal_AlphaTexture(x0, x1, thread); break;
|
||||||
|
case TM_CLAMPY: FuncNormal_ClampY(x0, x1, thread); break;
|
||||||
case TM_INVERTOPAQUE: FuncNormal_InvertOpaque(x0, x1, thread); break;
|
case TM_INVERTOPAQUE: FuncNormal_InvertOpaque(x0, x1, thread); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,9 +371,7 @@ void VkRenderState::ApplyPushConstants()
|
||||||
tempTM = TM_OPAQUE;
|
tempTM = TM_OPAQUE;
|
||||||
|
|
||||||
mPushConstants.uFogEnabled = fogset;
|
mPushConstants.uFogEnabled = fogset;
|
||||||
int f = mTextureModeFlags;
|
mPushConstants.uTextureMode = GetTextureModeAndFlags(tempTM);
|
||||||
if (!mBrightmapEnabled) f &= ~(TEXF_Brightmap|TEXF_Glowmap);
|
|
||||||
mPushConstants.uTextureMode = (mTextureMode == TM_NORMAL && tempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) | f;
|
|
||||||
mPushConstants.uLightDist = mLightParms[0];
|
mPushConstants.uLightDist = mLightParms[0];
|
||||||
mPushConstants.uLightFactor = mLightParms[1];
|
mPushConstants.uLightFactor = mLightParms[1];
|
||||||
mPushConstants.uFogDensity = mLightParms[2];
|
mPushConstants.uFogDensity = mLightParms[2];
|
||||||
|
|
|
@ -92,6 +92,7 @@ enum texflags
|
||||||
TEXF_Brightmap = 0x10000,
|
TEXF_Brightmap = 0x10000,
|
||||||
TEXF_Detailmap = 0x20000,
|
TEXF_Detailmap = 0x20000,
|
||||||
TEXF_Glowmap = 0x40000,
|
TEXF_Glowmap = 0x40000,
|
||||||
|
TEXF_ClampY = 0x80000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ vec2 GetTexCoord();
|
||||||
const int TEXF_Brightmap = 0x10000;
|
const int TEXF_Brightmap = 0x10000;
|
||||||
const int TEXF_Detailmap = 0x20000;
|
const int TEXF_Detailmap = 0x20000;
|
||||||
const int TEXF_Glowmap = 0x40000;
|
const int TEXF_Glowmap = 0x40000;
|
||||||
|
const int TEXF_ClampY = 0x80000;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
|
@ -166,7 +167,7 @@ vec4 getTexel(vec2 st)
|
||||||
//
|
//
|
||||||
// Apply texture modes
|
// Apply texture modes
|
||||||
//
|
//
|
||||||
switch (uTextureMode & 0xfff)
|
switch (uTextureMode & 0xffff)
|
||||||
{
|
{
|
||||||
case 1: // TM_STENCIL
|
case 1: // TM_STENCIL
|
||||||
texel.rgb = vec3(1.0,1.0,1.0);
|
texel.rgb = vec3(1.0,1.0,1.0);
|
||||||
|
@ -187,6 +188,13 @@ vec4 getTexel(vec2 st)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 5: // TM_CLAMPY
|
||||||
|
if (st.t < 0.0 || st.t > 1.0)
|
||||||
|
{
|
||||||
|
texel.a = 0.0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 6: // TM_OPAQUEINVERSE
|
case 6: // TM_OPAQUEINVERSE
|
||||||
texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, 1.0);
|
texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, 1.0);
|
||||||
break;
|
break;
|
||||||
|
@ -195,7 +203,8 @@ vec4 getTexel(vec2 st)
|
||||||
return texel;
|
return texel;
|
||||||
|
|
||||||
}
|
}
|
||||||
if ((uTextureMode & 0x1000) != 0) // TM_CLAMPY
|
|
||||||
|
if (uTextureMode & TEXF_ClampY)
|
||||||
{
|
{
|
||||||
if (st.t < 0.0 || st.t > 1.0)
|
if (st.t < 0.0 || st.t > 1.0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue