mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
gl: Treat PF_Masked as lower priority than other modes
This commit is contained in:
parent
38274046a9
commit
3c881597c9
1 changed files with 67 additions and 48 deletions
|
|
@ -1673,41 +1673,59 @@ static void SetBlendEquation(GLenum mode)
|
||||||
|
|
||||||
static void SetBlendMode(FBITFIELD flags)
|
static void SetBlendMode(FBITFIELD flags)
|
||||||
{
|
{
|
||||||
|
// It is unfortunately valid for flags like PF_Fog, PF_Occluded and PF_Masked to come in in addition to
|
||||||
|
// the exclusive blend types like PF_Additive. So we have to treat them as a special case.
|
||||||
|
// PF_Masked in particular often comes joined with PF_Additive, with Additive needing to take priority.
|
||||||
|
|
||||||
// Set blending function
|
// Set blending function
|
||||||
switch (flags)
|
if (flags & PF_Fog)
|
||||||
{
|
{
|
||||||
case PF_Translucent & PF_Blending:
|
// Sryder: Fog
|
||||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency
|
// multiplies input colour by input alpha, and destination colour by input colour, then adds them
|
||||||
break;
|
pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
|
||||||
case PF_Masked & PF_Blending:
|
}
|
||||||
// Hurdler: does that mean lighting is only made by alpha src?
|
else
|
||||||
// it sounds ok, but not for polygonsmooth
|
{
|
||||||
pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture
|
boolean blending = true;
|
||||||
break;
|
switch (flags & (PF_Blending & ~(PF_Masked | PF_Occlude)))
|
||||||
case PF_Additive & PF_Blending:
|
{
|
||||||
case PF_Subtractive & PF_Blending:
|
case PF_Translucent:
|
||||||
case PF_ReverseSubtract & PF_Blending:
|
pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency
|
||||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
|
break;
|
||||||
break;
|
case PF_Additive:
|
||||||
case PF_Environment & PF_Blending:
|
case PF_Subtractive:
|
||||||
pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
case PF_ReverseSubtract:
|
||||||
break;
|
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
|
||||||
case PF_Multiplicative & PF_Blending:
|
break;
|
||||||
pglBlendFunc(GL_DST_COLOR, GL_ZERO);
|
case PF_Environment:
|
||||||
break;
|
pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
case PF_Fog & PF_Fog:
|
break;
|
||||||
// Sryder: Fog
|
case PF_Multiplicative:
|
||||||
// multiplies input colour by input alpha, and destination colour by input colour, then adds them
|
pglBlendFunc(GL_DST_COLOR, GL_ZERO);
|
||||||
pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
|
break;
|
||||||
break;
|
default:
|
||||||
default: // must be 0, otherwise it's an error
|
blending = false;
|
||||||
// No blending
|
break;
|
||||||
pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending
|
}
|
||||||
break;
|
|
||||||
|
if (!blending)
|
||||||
|
{
|
||||||
|
if (flags & PF_Masked)
|
||||||
|
{
|
||||||
|
// Hurdler: does that mean lighting is only made by alpha src?
|
||||||
|
// it sounds ok, but not for polygonsmooth
|
||||||
|
pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No blending
|
||||||
|
pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set blending equation
|
// Set blending equation
|
||||||
switch (flags)
|
switch (flags & (PF_Blending & ~(PF_Masked | PF_Occlude)))
|
||||||
{
|
{
|
||||||
case PF_Subtractive & PF_Blending:
|
case PF_Subtractive & PF_Blending:
|
||||||
SetBlendEquation(GL_FUNC_SUBTRACT);
|
SetBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
|
|
@ -1723,25 +1741,26 @@ static void SetBlendMode(FBITFIELD flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alpha test
|
// Alpha test
|
||||||
switch (flags)
|
if (flags & PF_Fog)
|
||||||
{
|
{
|
||||||
case PF_Masked & PF_Blending:
|
pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments
|
||||||
pglAlphaFunc(GL_GREATER, 0.5f);
|
}
|
||||||
break;
|
else
|
||||||
case PF_Translucent & PF_Blending:
|
{
|
||||||
case PF_Additive & PF_Blending:
|
switch (flags & (PF_Blending & ~(PF_Masked | PF_Occlude)))
|
||||||
case PF_Subtractive & PF_Blending:
|
{
|
||||||
case PF_ReverseSubtract & PF_Blending:
|
case PF_Translucent:
|
||||||
case PF_Environment & PF_Blending:
|
case PF_Additive:
|
||||||
case PF_Multiplicative & PF_Blending:
|
case PF_Subtractive:
|
||||||
pglAlphaFunc(GL_NOTEQUAL, 0.0f);
|
case PF_ReverseSubtract:
|
||||||
break;
|
case PF_Environment:
|
||||||
case PF_Fog & PF_Fog:
|
case PF_Multiplicative:
|
||||||
pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments
|
pglAlphaFunc(GL_NOTEQUAL, 0.0f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pglAlphaFunc(GL_GREATER, 0.5f);
|
pglAlphaFunc(GL_GREATER, 0.5f);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue