Fixed shading also works with untextured polys. Fixes some shading issues in La machineguns. (Harry Tuttle)

This commit is contained in:
Ian Curtis 2017-11-07 00:15:57 +00:00
parent df44ad458b
commit bc7f1e9fac

View file

@ -950,7 +950,7 @@ void CNew3D::SetMeshValues(SortingMesh *currentMesh, PolyHeader &ph)
currentMesh->textureAlpha = ph.TextureAlpha(); currentMesh->textureAlpha = ph.TextureAlpha();
currentMesh->polyAlpha = ph.PolyAlpha(); currentMesh->polyAlpha = ph.PolyAlpha();
currentMesh->lighting = ph.LightEnabled(); currentMesh->lighting = ph.LightEnabled();
currentMesh->fixedShading = ph.FixedShading() && ph.TexEnabled() && !ph.SmoothShading(); currentMesh->fixedShading = ph.FixedShading() && !ph.SmoothShading();
currentMesh->highPriority = ph.HighPriority(); currentMesh->highPriority = ph.HighPriority();
if (ph.Layered() || (!ph.TexEnabled() && ph.PolyAlpha())) { if (ph.Layered() || (!ph.TexEnabled() && ph.PolyAlpha())) {
@ -1128,14 +1128,14 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
p.v[j].normal[2] = BYTE_TO_FLOAT((INT8)(iz & 0xFF)); p.v[j].normal[2] = BYTE_TO_FLOAT((INT8)(iz & 0xFF));
} }
if (ph.FixedShading() && ph.TexEnabled() && !ph.SmoothShading()) { // fixed shading seems to be disabled if actual normals are set if (ph.FixedShading() && !ph.SmoothShading()) { // fixed shading seems to be disabled if actual normals are set
//========== //==========
float shade; float shade;
//========== //==========
if (!m_shadeIsSigned) { if (!m_shadeIsSigned) {
shade = (ix & 0xFF) / 255.f; // Star wars is the only game to use unsigned fixed shaded values. It's also the only game to set the specular flag on these polys shade = (ix & 0xFF) / 255.f;
} }
else { else {
shade = BYTE_TO_FLOAT((INT8)(ix & 0xFF)); shade = BYTE_TO_FLOAT((INT8)(ix & 0xFF));