GFX3D: Opaque polygons using A3I5/A5I3 textures are no longer considered transparent if the polygon is a Decal or Shadow polygon.

- Fixes the edge marking of blocks in Picross 3D when running
SoftRasterizer.
This commit is contained in:
rogerman 2017-02-27 15:20:58 -08:00
parent 3b74861fc2
commit 68958a7a08
3 changed files with 13 additions and 11 deletions

View File

@ -2749,7 +2749,7 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D &engine)
} }
else else
{ {
const GLfloat thePolyAlpha = (!thePoly->isWireframe() && thePoly->isTranslucent()) ? divide5bitBy31_LUT[thePoly->getAttributeAlpha()] : 1.0f; const GLfloat thePolyAlpha = (thePoly->isWireframe()) ? 1.0f : divide5bitBy31_LUT[thePoly->getAttributeAlpha()];
for (size_t j = 0; j < polyType; j++) for (size_t j = 0; j < polyType; j++)
{ {
@ -3086,7 +3086,6 @@ void OpenGLRenderer_1_2::SetPolygonIndex(const size_t index)
Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly) Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly)
{ {
const PolygonAttributes attr = thePoly.getAttributes(); const PolygonAttributes attr = thePoly.getAttributes();
const bool isOpaqueDecal = ((attr.polygonMode == POLYGON_MODE_DECAL) && attr.isOpaque);
// Set up depth test mode // Set up depth test mode
static const GLenum oglDepthFunc[2] = {GL_LESS, GL_EQUAL}; static const GLenum oglDepthFunc[2] = {GL_LESS, GL_EQUAL};
@ -3137,11 +3136,11 @@ Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly)
else else
{ {
glStencilFunc(GL_ALWAYS, attr.polygonID, 0x3F); glStencilFunc(GL_ALWAYS, attr.polygonID, 0x3F);
glStencilOp(GL_KEEP, GL_KEEP, (attr.isTranslucent && !isOpaqueDecal) ? GL_KEEP : GL_REPLACE); glStencilOp(GL_KEEP, GL_KEEP, (attr.isTranslucent) ? GL_KEEP : GL_REPLACE);
glStencilMask(0xFF); // Drawing non-shadow polygons will implicitly reset the stencil buffer bits glStencilMask(0xFF); // Drawing non-shadow polygons will implicitly reset the stencil buffer bits
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask((!attr.isTranslucent || isOpaqueDecal || attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE); glDepthMask((!attr.isTranslucent || attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE);
} }
// Set up polygon attributes // Set up polygon attributes

View File

@ -1817,14 +1817,12 @@ Render3DError OpenGLRenderer_3_2::SetupPolygon(const POLY &thePoly)
} }
else else
{ {
const bool isOpaqueDecal = ((attr.polygonMode == POLYGON_MODE_DECAL) && attr.isOpaque);
glStencilFunc(GL_ALWAYS, attr.polygonID, 0x3F); glStencilFunc(GL_ALWAYS, attr.polygonID, 0x3F);
glStencilOp(GL_KEEP, GL_KEEP, (attr.isTranslucent && !isOpaqueDecal) ? GL_KEEP : GL_REPLACE); glStencilOp(GL_KEEP, GL_KEEP, (attr.isTranslucent) ? GL_KEEP : GL_REPLACE);
glStencilMask(0xFF); // Drawing non-shadow polygons will implicitly reset the stencil buffer bits glStencilMask(0xFF); // Drawing non-shadow polygons will implicitly reset the stencil buffer bits
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask((!attr.isTranslucent || isOpaqueDecal || attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE); glDepthMask((!attr.isTranslucent || attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE);
} }
return OGLERROR_NOERR; return OGLERROR_NOERR;

View File

@ -452,19 +452,24 @@ struct POLY {
bool isTranslucent() const bool isTranslucent() const
{ {
const bool isOpaque = this->isOpaque();
// First, check if the polygon is wireframe or opaque. // First, check if the polygon is wireframe or opaque.
// If neither, then it must be translucent. // If neither, then it must be translucent.
if (!this->isWireframe() && !this->isOpaque()) if (!this->isWireframe() && !isOpaque)
{ {
return true; return true;
} }
// Also check for translucent texture format. // Also check for translucent texture format.
u8 texFormat = this->getTexParamTexFormat(); const u8 texFormat = this->getTexParamTexFormat();
const PolygonMode mode = this->getAttributePolygonMode();
//a5i3 or a3i5 -> translucent //a5i3 or a3i5 -> translucent
if(texFormat == TEXMODE_A3I5 || texFormat == TEXMODE_A5I3) if ( (texFormat == TEXMODE_A3I5 || texFormat == TEXMODE_A5I3) && !(isOpaque && (mode == POLYGON_MODE_DECAL || mode == POLYGON_MODE_SHADOW)) )
{
return true; return true;
}
return false; return false;
} }