mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-12 22:03:49 +00:00
memory saving: store the normals in a signed char[4]
This commit is contained in:
parent
f4cd8e8e5f
commit
8fc1bb9d98
3 changed files with 12 additions and 6 deletions
|
@ -537,9 +537,13 @@ void GLMesh_LoadVertexBuffers (void)
|
|||
xyz[v].xyz[2] = trivert.v[2];
|
||||
xyz[v].xyz[3] = 1; // need w 1 for 4 byte vertex compression
|
||||
|
||||
xyz[v].normal[0] = r_avertexnormals[trivert.lightnormalindex][0];
|
||||
xyz[v].normal[1] = r_avertexnormals[trivert.lightnormalindex][1];
|
||||
xyz[v].normal[2] = r_avertexnormals[trivert.lightnormalindex][2];
|
||||
// map the normal coordinates in [-1..1] to [-127..127] and store in an unsigned char.
|
||||
// this introduces some error (less than 0.004), but the normals were very coarse
|
||||
// to begin with
|
||||
xyz[v].normal[0] = 127 * r_avertexnormals[trivert.lightnormalindex][0];
|
||||
xyz[v].normal[1] = 127 * r_avertexnormals[trivert.lightnormalindex][1];
|
||||
xyz[v].normal[2] = 127 * r_avertexnormals[trivert.lightnormalindex][2];
|
||||
xyz[v].normal[3] = 0; // unused; for 4-byte alignment
|
||||
}
|
||||
|
||||
GL_BufferSubDataFunc (GL_ARRAY_BUFFER,
|
||||
|
|
|
@ -293,7 +293,7 @@ typedef struct aliasmesh_s
|
|||
typedef struct meshxyz_s
|
||||
{
|
||||
byte xyz[4];
|
||||
float normal[3];
|
||||
signed char normal[4];
|
||||
} meshxyz_t;
|
||||
|
||||
typedef struct meshst_s
|
||||
|
|
|
@ -233,10 +233,12 @@ void GL_DrawAliasFrame_GLSL (aliashdr_t *paliashdr, lerpdata_t lerpdata)
|
|||
GL_ClientActiveTextureFunc (GL_TEXTURE2_ARB);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
GL_VertexAttribPointerFunc (pose1NormalAttrIndex, 3, GL_FLOAT, GL_FALSE, sizeof (meshxyz_t), GLARB_GetNormalOffset (paliashdr, lerpdata.pose1));
|
||||
|
||||
// GL_TRUE to normalize the signed bytes to [-1 .. 1]
|
||||
GL_VertexAttribPointerFunc (pose1NormalAttrIndex, 3, GL_BYTE, GL_TRUE, sizeof (meshxyz_t), GLARB_GetNormalOffset (paliashdr, lerpdata.pose1));
|
||||
GL_EnableVertexAttribArrayFunc (pose1NormalAttrIndex);
|
||||
|
||||
GL_VertexAttribPointerFunc (pose2NormalAttrIndex, 3, GL_FLOAT, GL_FALSE, sizeof (meshxyz_t), GLARB_GetNormalOffset (paliashdr, lerpdata.pose2));
|
||||
GL_VertexAttribPointerFunc (pose2NormalAttrIndex, 3, GL_BYTE, GL_TRUE, sizeof (meshxyz_t), GLARB_GetNormalOffset (paliashdr, lerpdata.pose2));
|
||||
GL_EnableVertexAttribArrayFunc (pose2NormalAttrIndex);
|
||||
|
||||
// set uniforms
|
||||
|
|
Loading…
Reference in a new issue