OpenGL2: Support GL_ARB_vertex_type_2_10_10_10_rev for normals/tangents/lightdirs
This commit is contained in:
parent
4c9d39ae6e
commit
f6f3a19f73
13 changed files with 239 additions and 198 deletions
|
@ -683,9 +683,9 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
|
|||
{
|
||||
vec3_t *verts;
|
||||
vec2_t *texcoords;
|
||||
uint8_t *normals;
|
||||
uint32_t *normals;
|
||||
#ifdef USE_VERT_TANGENT_SPACE
|
||||
uint8_t *tangents;
|
||||
uint32_t *tangents;
|
||||
#endif
|
||||
|
||||
byte *data;
|
||||
|
@ -702,11 +702,11 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
|
|||
dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*verts);
|
||||
|
||||
ofs_normal = dataSize;
|
||||
dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*normals) * 4;
|
||||
dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*normals);
|
||||
|
||||
#ifdef USE_VERT_TANGENT_SPACE
|
||||
ofs_tangent = dataSize;
|
||||
dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*tangents) * 4;
|
||||
dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*tangents);
|
||||
#endif
|
||||
|
||||
ofs_st = dataSize;
|
||||
|
@ -725,18 +725,17 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
|
|||
for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ )
|
||||
{
|
||||
vec3_t nxt;
|
||||
vec4_t tangent;
|
||||
|
||||
CrossProduct(v->normal, v->tangent, nxt);
|
||||
VectorCopy(v->xyz, verts[j]);
|
||||
normals[j*4+0] = (uint8_t)(v->normal[0] * 127.5f + 128.0f);
|
||||
normals[j*4+1] = (uint8_t)(v->normal[1] * 127.5f + 128.0f);
|
||||
normals[j*4+2] = (uint8_t)(v->normal[2] * 127.5f + 128.0f);
|
||||
normals[j*4+3] = 0;
|
||||
|
||||
normals[j] = R_VboPackNormal(v->normal);
|
||||
#ifdef USE_VERT_TANGENT_SPACE
|
||||
tangents[j*4+0] = (uint8_t)(v->tangent[0] * 127.5f + 128.0f);
|
||||
tangents[j*4+1] = (uint8_t)(v->tangent[1] * 127.5f + 128.0f);
|
||||
tangents[j*4+2] = (uint8_t)(v->tangent[2] * 127.5f + 128.0f);
|
||||
tangents[j*4+3] = (DotProduct(nxt, v->bitangent) < 0.0f) ? 0 : 255;
|
||||
CrossProduct(v->normal, v->tangent, nxt);
|
||||
VectorCopy(v->tangent, tangent);
|
||||
tangent[3] = (DotProduct(nxt, v->bitangent) < 0.0f) ? -1.0f : 1.0f;
|
||||
|
||||
tangents[j] = R_VboPackTangent(tangent);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -765,14 +764,14 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
|
|||
vboSurf->vbo->ofs_st = ofs_st;
|
||||
|
||||
vboSurf->vbo->stride_xyz = sizeof(*verts);
|
||||
vboSurf->vbo->stride_normal = sizeof(*normals) * 4;
|
||||
vboSurf->vbo->stride_normal = sizeof(*normals);
|
||||
#ifdef USE_VERT_TANGENT_SPACE
|
||||
vboSurf->vbo->stride_tangent = sizeof(*tangents) * 4;
|
||||
vboSurf->vbo->stride_tangent = sizeof(*tangents);
|
||||
#endif
|
||||
vboSurf->vbo->stride_st = sizeof(*st);
|
||||
|
||||
vboSurf->vbo->size_xyz = sizeof(*verts) * surf->numVerts;
|
||||
vboSurf->vbo->size_normal = sizeof(*normals) * surf->numVerts * 4;
|
||||
vboSurf->vbo->size_normal = sizeof(*normals) * surf->numVerts;
|
||||
|
||||
ri.Free(data);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue