Legacy engine: extracting fixed shading component (but still can't use it because unsure of how to activate)

This commit is contained in:
Bart Trzynadlowski 2016-04-28 13:18:15 +00:00
parent 0ae9e8013b
commit 34e8f00382
2 changed files with 23 additions and 3 deletions

View file

@ -50,9 +50,10 @@ enum POLY_STATE
struct Vertex
{
GLfloat x,y,z; // vertex
GLfloat n[3]; // normal X, Y, Z
GLfloat u,v; // texture U, V coordinates (in texels, relative to selected texture)
GLfloat x,y,z; // vertex
GLfloat n[3]; // normal X, Y, Z
GLfloat u,v; // texture U, V coordinates (in texels, relative to selected texture)
GLfloat intensity; // shading intensity (if using per-vertex fixed shading)
};
struct Poly

View file

@ -535,6 +535,7 @@ void CLegacy3D::InsertVertex(ModelCache *Cache, const Vertex *V, const Poly *P,
* - Fighting Vipers 2 shadows are not black anymore.
* - More to follow...
*/
unsigned modulate = (step >= 0x20) ? !(P->header[4]&0x80) : (P->header[3]&0x80 && lightEnable);
if (texEnable)
{
@ -543,6 +544,23 @@ void CLegacy3D::InsertVertex(ModelCache *Cache, const Vertex *V, const Poly *P,
r = g = b = 1.0f;
}
/*
int modulate = 0;//((P->header[5]>>22) & 1);
int fixedShading = ((P->header[5]>>23) & 1);
if (texEnable)
{
if (!modulate)
r = g = b = 1.0f;
}
if (fixedShading)
{
lightEnable = 0;
r = V->intensity;
g = V->intensity;
b = V->intensity;
}
*/
// Specular shininess
int shininess = (P->header[0]>>26)&0x3F;
//shininess = (P->header[0]>>28)&0xF;
@ -928,6 +946,7 @@ struct VBORef *CLegacy3D::CacheModel(ModelCache *Cache, int lutIdx, UINT16 texOf
P.Vert[j].n[2] = (GLfloat)(INT8)(iz&0xFF);
P.Vert[j].u = (GLfloat) ((UINT16)(it>>16)) * uvScale; // TO-DO: might these be signed?
P.Vert[j].v = (GLfloat) ((UINT16)(it&0xFFFF)) * uvScale;
P.Vert[j].intensity = GLfloat((255 - (ix & 0xFF))) / 255.0;
data += 4;
// Normalize the vertex normal