mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-26 15:45:41 +00:00
fixed shading code
This commit is contained in:
parent
57d5bc8367
commit
c499e6640c
|
@ -906,12 +906,6 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
|||
p.v[j].color[1] = (m_polyRAM[0x400 + colorIdx] >> 8) & 0xFF;
|
||||
p.v[j].color[0] = (m_polyRAM[0x400 + colorIdx] >> 16) & 0xFF;
|
||||
}
|
||||
else if (0 /* fixed shading bit as of yet unknown */) {
|
||||
UINT8 shade = (UINT8)((ix & 0xFF) + 128);
|
||||
p.v[j].color[0] = shade;
|
||||
p.v[j].color[1] = shade;
|
||||
p.v[j].color[2] = shade;
|
||||
}
|
||||
else {
|
||||
if (ph.ColorDisabled()) { // no colours were set
|
||||
p.v[j].color[0] = 255;
|
||||
|
@ -925,6 +919,14 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
|||
}
|
||||
}
|
||||
|
||||
if (ph.FixedShading() && ph.LightEnabled()) {
|
||||
float shade = ((ix & 0xFF) + 128) / 255.f;
|
||||
UINT8 colour = (UINT8)(p.v[j].color[0] * shade); // green & blue values seem not to be valid
|
||||
p.v[j].color[0] = colour;
|
||||
p.v[j].color[1] = colour;
|
||||
p.v[j].color[2] = colour;
|
||||
}
|
||||
|
||||
if ((ph.header[6] & 0x00800000)) { // if set, polygon is opaque
|
||||
p.v[j].color[3] = 255;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,11 @@ bool PolyHeader::PolyColor()
|
|||
return (header[1] & 2) > 0;
|
||||
}
|
||||
|
||||
bool PolyHeader::FixedShading()
|
||||
{
|
||||
return (header[1] & 0x20) > 0;
|
||||
}
|
||||
|
||||
//
|
||||
// header 2
|
||||
//
|
||||
|
@ -255,11 +260,6 @@ UINT8 PolyHeader::Transparency()
|
|||
return (UINT8)(((header[6] >> 18) & 0x1F) * 255.f / 0x1F);
|
||||
}
|
||||
|
||||
bool PolyHeader::FixedShading()
|
||||
{
|
||||
return (header[6] & 0x2000000) > 0;
|
||||
}
|
||||
|
||||
bool PolyHeader::PolyAlpha()
|
||||
{
|
||||
return (header[6] & 0x00800000) == 0;
|
||||
|
|
|
@ -21,10 +21,11 @@ x------- -------- -------- -------- Specular enable
|
|||
0x01:
|
||||
xxxxxxxx xxxxxxxx xxxxxxxx-------- Polygon normal X coordinate(2.22 fixed point)
|
||||
-------- -------- -------- -x------ UV scale (0 = 13.3, 1 = 16.0)
|
||||
-------- -------- -------- --x----- Fixed shading (seems to only be enabled if lighting is enabled)
|
||||
-------- -------- -------- ---x---- 1 = Double-sided polygon
|
||||
-------- -------- -------- -----x-- If set, this is the last polygon
|
||||
-------- -------- -------- ------x- Poly color, 1 = RGB, 0 = color table
|
||||
-------- -------- -------- x-x-x--x ?
|
||||
-------- -------- -------- x---x--x ?
|
||||
|
||||
0x02:
|
||||
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate(2.22 fixed point)
|
||||
|
@ -41,8 +42,8 @@ xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate(2.22 fixed poin
|
|||
xxxxxxxx xxxxxxxx xxxxxxxx -------- Color(RGB888)
|
||||
-------- -------- -------- x------- Color disabled
|
||||
-------- -------- -------- -x------ Texture page
|
||||
-------- -------- -------- --x----- ?
|
||||
-------- -------- -------- ---xxxxx Upper 5 bits of texture U coordinate
|
||||
-------- -------- -------- --x----- ?
|
||||
|
||||
0x05 :
|
||||
xxxxxxxx xxxxxxxx xxxxxxxx -------- Specular color ?
|
||||
|
@ -94,6 +95,7 @@ public:
|
|||
bool DoubleSided();
|
||||
bool LastPoly();
|
||||
bool PolyColor(); // if false uses LUT from ram
|
||||
bool FixedShading();
|
||||
|
||||
//header 2
|
||||
bool TexUMirror();
|
||||
|
@ -118,7 +120,6 @@ public:
|
|||
bool LightEnabled();
|
||||
bool AlphaTest();
|
||||
UINT8 Transparency(); // 0-255
|
||||
bool FixedShading();
|
||||
bool PolyAlpha();
|
||||
bool TextureAlpha();
|
||||
bool StencilPoly();
|
||||
|
|
Loading…
Reference in a new issue