OpenGL2: Don't interleave texCoords and lightCoords in tess.

This commit is contained in:
SmileTheory 2016-11-25 01:17:46 -08:00
parent 1c1e1f61f1
commit 2349ef038e
9 changed files with 74 additions and 84 deletions

View file

@ -135,17 +135,17 @@ void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4],
VectorCopy4(iNormal, tess.normal[ndx + 3]);
// standard square texture coordinates
VectorSet2(tess.texCoords[ndx ][0], s1, t1);
VectorSet2(tess.texCoords[ndx ][1], s1, t1);
VectorSet2(tess.texCoords[ndx], s1, t1);
VectorSet2(tess.lightCoords[ndx], s1, t1);
VectorSet2(tess.texCoords[ndx+1][0], s2, t1);
VectorSet2(tess.texCoords[ndx+1][1], s2, t1);
VectorSet2(tess.texCoords[ndx+1], s2, t1);
VectorSet2(tess.lightCoords[ndx+1], s2, t1);
VectorSet2(tess.texCoords[ndx+2][0], s2, t2);
VectorSet2(tess.texCoords[ndx+2][1], s2, t2);
VectorSet2(tess.texCoords[ndx+2], s2, t2);
VectorSet2(tess.lightCoords[ndx+2], s2, t2);
VectorSet2(tess.texCoords[ndx+3][0], s1, t2);
VectorSet2(tess.texCoords[ndx+3][1], s1, t2);
VectorSet2(tess.texCoords[ndx+3], s1, t2);
VectorSet2(tess.lightCoords[ndx+3], s1, t2);
// constant color all the way around
// should this be identity and let the shader specify from entity?
@ -187,19 +187,19 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4])
tess.firstIndex = 0;
VectorCopy4(quadVerts[0], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes][0]);
VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
VectorCopy4(quadVerts[1], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes][0]);
VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
VectorCopy4(quadVerts[2], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes][0]);
VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
VectorCopy4(quadVerts[3], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes][0]);
VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
@ -298,8 +298,8 @@ static void RB_SurfacePolychain( srfPoly_t *p ) {
numv = tess.numVertexes;
for ( i = 0; i < p->numVerts; i++ ) {
VectorCopy( p->verts[i].xyz, tess.xyz[numv] );
tess.texCoords[numv][0][0] = p->verts[i].st[0];
tess.texCoords[numv][0][1] = p->verts[i].st[1];
tess.texCoords[numv][0] = p->verts[i].st[0];
tess.texCoords[numv][1] = p->verts[i].st[1];
tess.color[numv][0] = (int)p->verts[i].modulate[0] * 257;
tess.color[numv][1] = (int)p->verts[i].modulate[1] * 257;
tess.color[numv][2] = (int)p->verts[i].modulate[2] * 257;
@ -369,16 +369,16 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn
if ( tess.shader->vertexAttribs & ATTR_TEXCOORD )
{
dv = verts;
texCoords = tess.texCoords[ tess.numVertexes ][0];
for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=4 )
texCoords = tess.texCoords[tess.numVertexes];
for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=2 )
VectorCopy2(dv->st, texCoords);
}
if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD )
{
dv = verts;
lightCoords = tess.texCoords[ tess.numVertexes ][1];
for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=4 )
lightCoords = tess.lightCoords[ tess.numVertexes ];
for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=2 )
VectorCopy2(dv->lightmap, lightCoords);
}
@ -641,16 +641,16 @@ static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, f
// FIXME: use quad stamp?
VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.texCoords[tess.numVertexes][0] = 0;
tess.texCoords[tess.numVertexes][1] = 0;
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25f * 257.0f;
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25f * 257.0f;
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25f * 257.0f;
tess.numVertexes++;
VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.texCoords[tess.numVertexes][0] = 0;
tess.texCoords[tess.numVertexes][1] = 1;
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
@ -658,16 +658,16 @@ static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, f
VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = t;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.texCoords[tess.numVertexes][0] = t;
tess.texCoords[tess.numVertexes][1] = 0;
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
tess.numVertexes++;
VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = t;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.texCoords[tess.numVertexes][0] = t;
tess.texCoords[tess.numVertexes][1] = 1;
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
@ -725,8 +725,8 @@ static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, cons
for ( j = 0; j < 4; j++ )
{
VectorCopy( pos[j], tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = ( j < 2 );
tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 );
tess.texCoords[tess.numVertexes][0] = (j < 2);
tess.texCoords[tess.numVertexes][1] = (j && j != 3);
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
@ -944,8 +944,8 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) {
numVerts = surface->numVerts;
for ( j = 0; j < numVerts; j++ ) {
tess.texCoords[Doug + j][0][0] = texCoords[j].st[0];
tess.texCoords[Doug + j][0][1] = texCoords[j].st[1];
tess.texCoords[Doug + j][0] = texCoords[j].st[0];
tess.texCoords[Doug + j][1] = texCoords[j].st[1];
// FIXME: fill in lightmapST for completeness?
}
@ -1102,8 +1102,8 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
xyz = tess.xyz[numVertexes];
normal = tess.normal[numVertexes];
tangent = tess.tangent[numVertexes];
texCoords = tess.texCoords[numVertexes][0];
lightCoords = tess.texCoords[numVertexes][1];
texCoords = tess.texCoords[numVertexes];
lightCoords = tess.lightCoords[numVertexes];
color = tess.color[numVertexes];
lightdir = tess.lightdir[numVertexes];
//vDlightBits = &tess.vertexDlightBits[numVertexes];
@ -1134,13 +1134,13 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
if ( tess.shader->vertexAttribs & ATTR_TEXCOORD )
{
VectorCopy2(dv->st, texCoords);
texCoords += 4;
texCoords += 2;
}
if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD )
{
VectorCopy2(dv->lightmap, lightCoords);
lightCoords += 4;
lightCoords += 2;
}
if ( tess.shader->vertexAttribs & ATTR_COLOR )