mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-04-24 00:21:06 +00:00
Remove some more branching in fp shader
This commit is contained in:
parent
3f69dfd808
commit
5308747a32
5 changed files with 39 additions and 25 deletions
|
@ -161,10 +161,10 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
|
||||
SetViewportRects(nullptr);
|
||||
|
||||
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight(), screen->mPipelineNbr);
|
||||
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight(), mPipelineNbr);
|
||||
mSkyData = new FSkyVertexBuffer;
|
||||
mViewpoints = new HWViewpointBuffer(screen->mPipelineNbr);
|
||||
mLights = new FLightBuffer(screen->mPipelineNbr);
|
||||
mViewpoints = new HWViewpointBuffer(mPipelineNbr);
|
||||
mLights = new FLightBuffer(mPipelineNbr);
|
||||
GLRenderer = new FGLRenderer(this);
|
||||
GLRenderer->Initialize(GetWidth(), GetHeight());
|
||||
static_cast<GLDataBuffer*>(mLights->GetBuffer())->BindBase();
|
||||
|
|
|
@ -90,24 +90,6 @@ void FGLRenderState::Reset()
|
|||
bool FGLRenderState::ApplyShader()
|
||||
{
|
||||
static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f };
|
||||
|
||||
int fogset = 0;
|
||||
|
||||
if (mFogEnabled)
|
||||
{
|
||||
if (mFogEnabled == 2)
|
||||
{
|
||||
fogset = -3; // 2D rendering with 'foggy' overlay.
|
||||
}
|
||||
else if ((GetFogColor() & 0xffffff) == 0)
|
||||
{
|
||||
fogset = gl_fogmode;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogset = -gl_fogmode;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to calc light data now in order to select correct shader
|
||||
float* lightPtr = NULL;
|
||||
|
@ -168,6 +150,11 @@ bool FGLRenderState::ApplyShader()
|
|||
flavour.dynLightsSub = (subLights > 0);
|
||||
flavour.dynLightsAdd = (addLights > 0);
|
||||
|
||||
flavour.useObjectColor2 = (mStreamData.uObjectColor2.a > 0);
|
||||
flavour.useGlowTopColor = mGlowEnabled && (mStreamData.uGlowTopColor[3] > 0);
|
||||
flavour.useGlowBottomColor = mGlowEnabled && (mStreamData.uGlowBottomColor[3] > 0);
|
||||
|
||||
|
||||
if (mSpecialEffect > EFF_NONE)
|
||||
{
|
||||
activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect, mPassType, flavour);
|
||||
|
|
|
@ -688,10 +688,17 @@ bool FShader::Bind(ShaderFlavourData& flavour)
|
|||
variantConfig.AppendFormat("#define DEF_USE_U_LIGHT_LEVEL %d\n", flavour.useULightLevel);
|
||||
|
||||
variantConfig.AppendFormat("#define DEF_DO_DESATURATE %d\n", flavour.doDesaturate);
|
||||
|
||||
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_MOD %d\n", flavour.dynLightsMod);
|
||||
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_SUB %d\n", flavour.dynLightsSub);
|
||||
variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_ADD %d\n", flavour.dynLightsAdd);
|
||||
|
||||
variantConfig.AppendFormat("#define DEF_USE_OBJECT_COLOR_2 %d\n", flavour.useObjectColor2);
|
||||
variantConfig.AppendFormat("#define DEF_USE_GLOW_TOP_COLOR %d\n", flavour.useGlowTopColor);
|
||||
variantConfig.AppendFormat("#define DEF_USE_GLOW_BOTTOM_COLOR %d\n", flavour.useGlowBottomColor);
|
||||
|
||||
|
||||
|
||||
Printf("Shader: %s, %08x %s", mFragProg2.GetChars(), tag, variantConfig.GetChars());
|
||||
|
||||
Load(mName.GetChars(), mVertProg, mFragProg, mFragProg2, mLightProg, mDefinesBase + variantConfig);
|
||||
|
|
|
@ -264,6 +264,9 @@ public:
|
|||
bool dynLightsSub;
|
||||
bool dynLightsAdd;
|
||||
bool useULightLevel;
|
||||
bool useObjectColor2;
|
||||
bool useGlowTopColor;
|
||||
bool useGlowBottomColor;
|
||||
};
|
||||
|
||||
class FShader
|
||||
|
@ -391,6 +394,9 @@ public:
|
|||
tag |= (flavour.dynLightsSub & 1) << 13;
|
||||
tag |= (flavour.dynLightsAdd & 1) << 14;
|
||||
tag |= (flavour.useULightLevel & 1) << 15;
|
||||
tag |= (flavour.useObjectColor2 & 1) << 16;
|
||||
tag |= (flavour.useGlowTopColor & 1) << 17;
|
||||
tag |= (flavour.useGlowBottomColor & 1) << 18;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
|
|
@ -207,9 +207,14 @@ vec4 getTexel(vec2 st)
|
|||
|
||||
// Apply the Doom64 style material colors on top of everything from the texture modification settings.
|
||||
// This may be a bit redundant in terms of features but the data comes from different sources so this is unavoidable.
|
||||
|
||||
texel.rgb += uAddColor.rgb;
|
||||
if (uObjectColor2.a == 0.0) texel *= uObjectColor;
|
||||
else texel *= mix(uObjectColor, uObjectColor2, gradientdist.z);
|
||||
|
||||
#if (DEF_USE_OBJECT_COLOR_2 == 1)
|
||||
texel *= mix(uObjectColor, uObjectColor2, gradientdist.z);
|
||||
#else
|
||||
texel *= uObjectColor;
|
||||
#endif
|
||||
|
||||
// Last but not least apply the desaturation from the sector's light.
|
||||
return desaturate(texel);
|
||||
|
@ -340,17 +345,26 @@ vec4 getLightColor(Material material, float fogdist, float fogfactor)
|
|||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// handle glowing walls
|
||||
//
|
||||
if (uGlowTopColor.a > 0.0 && glowdist.x < uGlowTopColor.a)
|
||||
#if (DEF_USE_GLOW_TOP_COLOR)
|
||||
if (glowdist.x < uGlowTopColor.a)
|
||||
{
|
||||
color.rgb += desaturate(uGlowTopColor * (1.0 - glowdist.x / uGlowTopColor.a)).rgb;
|
||||
}
|
||||
if (uGlowBottomColor.a > 0.0 && glowdist.y < uGlowBottomColor.a)
|
||||
#endif
|
||||
|
||||
|
||||
#if (DEF_USE_GLOW_BOTTOM_COLOR)
|
||||
if (glowdist.y < uGlowBottomColor.a)
|
||||
{
|
||||
color.rgb += desaturate(uGlowBottomColor * (1.0 - glowdist.y / uGlowBottomColor.a)).rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
color = min(color, 1.0);
|
||||
|
||||
// these cannot be safely applied by the legacy format where the implementation cannot guarantee that the values are set.
|
||||
|
|
Loading…
Reference in a new issue