There are 2 bits in the polyheader labelled discard. When both are set ie in sega rally, the polygons are totally discarded. Scud seems to set bit 1 which seems halve the opacity.

This commit is contained in:
Ian Curtis 2017-04-15 19:00:46 +00:00
parent 21836c088c
commit 3c78571615
3 changed files with 22 additions and 6 deletions

View file

@ -1118,6 +1118,10 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
}
p.faceColour[3] = ph.Transparency() / 255.f;
if (ph.Discard1() && !ph.Discard2()) {
p.faceColour[3] *= 0.5f;
}
// if we have flat shading, we can't re-use normals from shared vertices
for (i = 0; i < p.number && !ph.SmoothShading(); i++) {
@ -1200,7 +1204,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
}
// check if we need double up vertices for two sided lighting
if (ph.DoubleSided() && !ph.Disabled()) {
if (ph.DoubleSided() && !ph.Discard()) {
R3DPoly tempP = p;
@ -1215,7 +1219,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
}
// Copy this polygon into the model buffer
if (!ph.Disabled()) {
if (!ph.Discard()) {
CopyVertexData(p, currentMesh->polys);
}

View file

@ -91,7 +91,7 @@ int PolyHeader::PolyNumber()
return (header[0] & 0x000FFFC00) >> 10; // not all programs pass this, instead they are set to 0
}
bool PolyHeader::Disabled()
bool PolyHeader::Discard()
{
if ((header[0] & 0x100) && (header[0] & 0x200)) {
return true;
@ -100,6 +100,16 @@ bool PolyHeader::Disabled()
return false;
}
bool PolyHeader::Discard1()
{
return (header[0] & 0x200) > 0;
}
bool PolyHeader::Discard2()
{
return (header[0] & 0x100) > 0;
}
int PolyHeader::NumVerts()
{
return (header[0] & 0x40) ? 4 : 3;

View file

@ -10,7 +10,7 @@ Polygon Data
xxxxxx-- -------- -------- -------- Specular
------x- -------- -------- -------- Clockwise winding
-------x xxxxxxxx xxxxxx-- -------- Polygon number (not always present)
-------- -------- ------xx -------- Discard polys
-------- -------- ------xx -------- Discard
-------- -------- -------- x------- Enable specular
-------- -------- -------- -x------ 0 = Triangle, 1 = Quad
-------- -------- -------- --x----- Poly is points
@ -90,7 +90,9 @@ public:
float SpecularValue();
bool Clockwise();
int PolyNumber();
bool Disabled();
bool Discard(); // both bits
bool Discard1(); // bit 1 only
bool Discard2(); // bit 2 only
int NumVerts();
int NumSharedVerts();
bool SharedVertex(int vertex);
@ -100,7 +102,7 @@ public:
float UVScale();
bool DoubleSided();
bool LastPoly();
bool PolyColor(); // if false uses LUT from ram
bool PolyColor(); // if false uses LUT from ram
bool FixedShading();
bool SmoothShading();