diff options
Diffstat (limited to 'src/renderergl2/tr_model.c')
-rw-r--r-- | src/renderergl2/tr_model.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/renderergl2/tr_model.c b/src/renderergl2/tr_model.c index 2627afc4..7ac9f149 100644 --- a/src/renderergl2/tr_model.c +++ b/src/renderergl2/tr_model.c @@ -684,9 +684,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; @@ -703,11 +703,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; @@ -726,18 +726,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 } @@ -766,14 +765,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); |