mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-26 15:45:41 +00:00
support flat shading
This commit is contained in:
parent
3693a51cbb
commit
b2da849d90
|
@ -869,7 +869,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
||||||
currentMesh->height = ph.TexHeight();
|
currentMesh->height = ph.TexHeight();
|
||||||
currentMesh->mirrorU = ph.TexUMirror();
|
currentMesh->mirrorU = ph.TexUMirror();
|
||||||
currentMesh->mirrorV = ph.TexVMirror();
|
currentMesh->mirrorV = ph.TexVMirror();
|
||||||
currentMesh->microTexture = ph.MicroTexture();
|
currentMesh->microTexture = ph.MicroTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,9 +912,16 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
||||||
p.v[j].pos[1] = (GLfloat)(((INT32)iy) >> 8) * m_vertexFactor;
|
p.v[j].pos[1] = (GLfloat)(((INT32)iy) >> 8) * m_vertexFactor;
|
||||||
p.v[j].pos[2] = (GLfloat)(((INT32)iz) >> 8) * m_vertexFactor;
|
p.v[j].pos[2] = (GLfloat)(((INT32)iz) >> 8) * m_vertexFactor;
|
||||||
|
|
||||||
p.v[j].normal[0] = (INT8)(ix & 0xFF) / 128.f;
|
if (ph.SmoothShading()) {
|
||||||
p.v[j].normal[1] = (INT8)(iy & 0xFF) / 128.f;
|
p.v[j].normal[0] = (INT8)(ix & 0xFF) / 128.f;
|
||||||
p.v[j].normal[2] = (INT8)(iz & 0xFF) / 128.f;
|
p.v[j].normal[1] = (INT8)(iy & 0xFF) / 128.f;
|
||||||
|
p.v[j].normal[2] = (INT8)(iz & 0xFF) / 128.f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.v[j].normal[0] = p.faceNormal[0];
|
||||||
|
p.v[j].normal[1] = p.faceNormal[1];
|
||||||
|
p.v[j].normal[2] = p.faceNormal[2];
|
||||||
|
}
|
||||||
|
|
||||||
if ((ph.header[1] & 2) == 0) {
|
if ((ph.header[1] & 2) == 0) {
|
||||||
UINT32 colorIdx = ((ph.header[4] >> 8) & 0x7FF);
|
UINT32 colorIdx = ((ph.header[4] >> 8) & 0x7FF);
|
||||||
|
@ -940,7 +947,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
||||||
p.v[j].color[0] = (UINT8)(p.v[j].color[0] * shade);
|
p.v[j].color[0] = (UINT8)(p.v[j].color[0] * shade);
|
||||||
p.v[j].color[1] = (UINT8)(p.v[j].color[1] * shade);
|
p.v[j].color[1] = (UINT8)(p.v[j].color[1] * shade);
|
||||||
p.v[j].color[2] = (UINT8)(p.v[j].color[2] * shade);
|
p.v[j].color[2] = (UINT8)(p.v[j].color[2] * shade);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ph.header[6] & 0x00800000)) { // if set, polygon is opaque
|
if ((ph.header[6] & 0x00800000)) { // if set, polygon is opaque
|
||||||
p.v[j].color[3] = 255;
|
p.v[j].color[3] = 255;
|
||||||
|
|
|
@ -149,6 +149,11 @@ bool PolyHeader::FixedShading()
|
||||||
return (header[1] & 0x20) > 0;
|
return (header[1] & 0x20) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PolyHeader::SmoothShading()
|
||||||
|
{
|
||||||
|
return (header[1] & 0x8) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// header 2
|
// header 2
|
||||||
//
|
//
|
||||||
|
|
|
@ -23,16 +23,17 @@ xxxxxxxx xxxxxxxx xxxxxxxx-------- Polygon normal X coordinate(2.22 fixed point
|
||||||
-------- -------- -------- -x------ UV scale (0 = 13.3, 1 = 16.0)
|
-------- -------- -------- -x------ UV scale (0 = 13.3, 1 = 16.0)
|
||||||
-------- -------- -------- --x----- Fixed shading (seems to only be enabled if lighting is enabled)
|
-------- -------- -------- --x----- Fixed shading (seems to only be enabled if lighting is enabled)
|
||||||
-------- -------- -------- ---x---- 1 = Double-sided polygon
|
-------- -------- -------- ---x---- 1 = Double-sided polygon
|
||||||
|
-------- -------- -------- ----x--- 1 = smooth shading, 0 = flat shading
|
||||||
-------- -------- -------- -----x-- If set, this is the last polygon
|
-------- -------- -------- -----x-- If set, this is the last polygon
|
||||||
-------- -------- -------- ------x- Poly color, 1 = RGB, 0 = color table
|
-------- -------- -------- ------x- Poly color, 1 = RGB, 0 = color table
|
||||||
-------- -------- -------- x---x--x ?
|
-------- -------- -------- x------x ?
|
||||||
|
|
||||||
0x02:
|
0x02:
|
||||||
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate(2.22 fixed point)
|
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate(2.22 fixed point)
|
||||||
-------- -------- -------- ---x---- Microtexture (aka multitexture)
|
-------- -------- -------- ---x---- Microtexture (aka multitexture)
|
||||||
-------- -------- -------- ------x- Texture U mirror enable
|
-------- -------- -------- ------x- Texture U mirror enable
|
||||||
-------- -------- -------- -------x Texture V mirror enable
|
-------- -------- -------- -------x Texture V mirror enable
|
||||||
-------- -------- -------- xxx-xx-- I think first 3 bits might be microtex number 0-7, next 2 maybe UV un-smooth wrap
|
-------- -------- -------- xxx-xx-- ?
|
||||||
|
|
||||||
0x03:
|
0x03:
|
||||||
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate(2.22 fixed point)
|
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate(2.22 fixed point)
|
||||||
|
@ -97,6 +98,7 @@ public:
|
||||||
bool LastPoly();
|
bool LastPoly();
|
||||||
bool PolyColor(); // if false uses LUT from ram
|
bool PolyColor(); // if false uses LUT from ram
|
||||||
bool FixedShading();
|
bool FixedShading();
|
||||||
|
bool SmoothShading();
|
||||||
|
|
||||||
//header 2
|
//header 2
|
||||||
bool TexUMirror();
|
bool TexUMirror();
|
||||||
|
|
Loading…
Reference in a new issue