mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- don't use uniforms related to fixed colormaps for other things.
The fixed colormap is a per-scene global setting that normally does not need to change ever during rendering of a scene so it's easily shoved aside into a static uniform buffer. Having to change this buffer for inconsequential stuff should be avoided, especially when there's other uniforms that are just as good to hold these values.
This commit is contained in:
parent
0643b2b1aa
commit
612fb40f3a
6 changed files with 32 additions and 47 deletions
|
@ -565,7 +565,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
|
|||
{
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
gl_RenderState.Set2DOverlayColor(cmd.mColor1);
|
||||
gl_RenderState.SetFog(cmd.mColor1, 0);
|
||||
gl_RenderState.SetFixedColormap(CM_PLAIN2D);
|
||||
}
|
||||
else if (cmd.mDesaturate > 0)
|
||||
|
|
|
@ -221,25 +221,9 @@ bool FRenderState::ApplyShader()
|
|||
activeShader->currentcliplinestate = 0;
|
||||
}
|
||||
|
||||
if (mColormapState < -1) // 2D operations
|
||||
if (mColormapState == CM_PLAIN2D) // 2D operations
|
||||
{
|
||||
if (mColormapState != CM_SPECIAL2D)
|
||||
{
|
||||
activeShader->muColormapStart.Set(m2DColors[0]);
|
||||
activeShader->muFixedColormap.Set(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
float startr = m2DColors[0].r / 255.f;
|
||||
float startg = m2DColors[0].g / 255.f;
|
||||
float startb = m2DColors[0].b / 255.f;
|
||||
float ranger = m2DColors[1].r / 255.f - startr;
|
||||
float rangeg = m2DColors[1].g / 255.f - startg;
|
||||
float rangeb = m2DColors[1].b / 255.f - startb;
|
||||
activeShader->muColormapStart.Set(startr, startg, startb, 0.f);
|
||||
activeShader->muColormapRange.Set(ranger, rangeg, rangeb, 0.f);
|
||||
activeShader->muFixedColormap.Set(1);
|
||||
}
|
||||
activeShader->muFixedColormap.Set(4);
|
||||
activeShader->currentfixedcolormap = mColormapState;
|
||||
}
|
||||
else if (mColormapState != activeShader->currentfixedcolormap)
|
||||
|
|
|
@ -112,7 +112,6 @@ class FRenderState
|
|||
PalEntry mFogColor;
|
||||
PalEntry mObjectColor;
|
||||
PalEntry mObjectColor2;
|
||||
PalEntry m2DColors[2]; // in the shader these will reuse the colormap ramp uniforms.
|
||||
FStateVec4 mDynColor;
|
||||
float mClipSplit[2];
|
||||
|
||||
|
@ -402,11 +401,6 @@ public:
|
|||
mObjectColor2 = pe;
|
||||
}
|
||||
|
||||
void Set2DOverlayColor(PalEntry pe)
|
||||
{
|
||||
m2DColors[0] = pe;
|
||||
}
|
||||
|
||||
void SetSpecular(float glossiness, float specularLevel)
|
||||
{
|
||||
mGlossiness = glossiness;
|
||||
|
|
|
@ -266,12 +266,12 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
{
|
||||
// If we get here we know that we have colored fog and no fixed colormap.
|
||||
mDrawer->SetFog(sprite->foglevel, rel, &sprite->Colormap, additivefog);
|
||||
gl_RenderState.SetFixedColormap(CM_FOGLAYER);
|
||||
gl_RenderState.SetTextureMode(TM_FOGLAYER);
|
||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_RenderState.Apply();
|
||||
qd.Render(GL_TRIANGLE_STRIP);
|
||||
gl_RenderState.SetFixedColormap(CM_DEFAULT);
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -21,6 +21,7 @@ enum TexMode
|
|||
TM_REDTOALPHA, // (1, 1, 1, r)
|
||||
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)
|
||||
};
|
||||
|
||||
enum ELightMethod
|
||||
|
|
|
@ -89,6 +89,9 @@ vec4 getTexel(vec2 st)
|
|||
case 6: // TM_OPAQUEINVERSE
|
||||
texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, 1.0);
|
||||
break;
|
||||
|
||||
case 7: //TM_FOGLAYER
|
||||
return texel;
|
||||
}
|
||||
if (uObjectColor2.a == 0.0) texel *= uObjectColor;
|
||||
else texel *= mix(uObjectColor, uObjectColor2, glowdist.z);
|
||||
|
@ -428,7 +431,27 @@ void main()
|
|||
if (frag.a <= uAlphaThreshold) discard;
|
||||
#endif
|
||||
|
||||
switch (uFixedColormap)
|
||||
if (uTextureMode == 7)
|
||||
{
|
||||
float fogdist;
|
||||
float fogfactor;
|
||||
|
||||
//
|
||||
// calculate fog factor
|
||||
//
|
||||
if (uFogEnabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz));
|
||||
}
|
||||
fogfactor = exp2 (uFogDensity * fogdist);
|
||||
|
||||
frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * vColor.a);
|
||||
}
|
||||
else switch (uFixedColormap)
|
||||
{
|
||||
case 0: // in-game rendering.
|
||||
{
|
||||
|
@ -480,32 +503,15 @@ void main()
|
|||
break;
|
||||
}
|
||||
|
||||
case 3: // fog layer
|
||||
case 3: // unused
|
||||
{
|
||||
float fogdist;
|
||||
float fogfactor;
|
||||
|
||||
//
|
||||
// calculate fog factor
|
||||
//
|
||||
if (uFogEnabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz));
|
||||
}
|
||||
fogfactor = exp2 (uFogDensity * fogdist);
|
||||
|
||||
frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * vColor.a);
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: // simple 2D (reuses a uniform for the special colormap for the color overlay.)
|
||||
{
|
||||
frag = frag * ProcessLight(vColor);
|
||||
frag.rgb = frag.rgb + uFixedColormapStart.rgb;
|
||||
frag.rgb = frag.rgb + uFogColor.rgb;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue