implemented tcmod (all forms)
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 24 May 2007 05:55:41 +0000 (05:55 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 24 May 2007 05:55:41 +0000 (05:55 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7362 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
model_brush.h
model_shared.c
model_shared.h
r_shadow.c
render.h

index d8470c0..b653cac 100644 (file)
@@ -3138,10 +3138,45 @@ static void R_Texture_AddLayer(texture_t *t, qboolean depthmask, int blendfunc1,
        layer->color[3] = a;
 }
 
+static float R_EvaluateQ3WaveFunc(q3wavefunc_t func, const float *parms)
+{
+       double index, f;
+       index = parms[2] + r_refdef.time * parms[3];
+       index -= floor(index);
+       switch (func)
+       {
+       default:
+       case Q3WAVEFUNC_NONE:
+       case Q3WAVEFUNC_NOISE:
+       case Q3WAVEFUNC_COUNT:
+               f = 0;
+               break;
+       case Q3WAVEFUNC_SIN: f = sin(index * M_PI * 2);break;
+       case Q3WAVEFUNC_SQUARE: f = index < 0.5 ? 1 : -1;break;
+       case Q3WAVEFUNC_SAWTOOTH: f = index;break;
+       case Q3WAVEFUNC_INVERSESAWTOOTH: f = 1 - index;break;
+       case Q3WAVEFUNC_TRIANGLE:
+               index *= 4;
+               f = index - floor(index);
+               if (index < 1)
+                       f = f;
+               else if (index < 2)
+                       f = 1 - f;
+               else if (index < 3)
+                       f = -f;
+               else
+                       f = -(1 - f);
+               break;
+       }
+       return (float)(parms[0] + parms[1] * f);
+}
+
 void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
 {
        int i;
        model_t *model = ent->model;
+       float f;
+       float tcmat[12];
 
        // switch to an alternate material if this is a q1bsp animated material
        {
@@ -3204,13 +3239,51 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
                t->currentmaterialflags |= MATERIALFLAG_SHORTDEPTHRANGE;
        if (ent->flags & RENDER_VIEWMODEL)
                t->currentmaterialflags |= MATERIALFLAG_SHORTDEPTHRANGE;
-       if (t->currentmaterialflags & MATERIALFLAG_WATER && r_waterscroll.value != 0)
-               t->currenttexmatrix = r_waterscrollmatrix;
-       else
-               t->currenttexmatrix = identitymatrix;
        if (t->backgroundnumskinframes && !(t->currentmaterialflags & MATERIALFLAGMASK_DEPTHSORTED))
                t->currentmaterialflags |= MATERIALFLAG_VERTEXTEXTUREBLEND;
 
+       switch(t->tcmod)
+       {
+       case Q3TCMOD_COUNT:
+       case Q3TCMOD_NONE:
+               if (t->currentmaterialflags & MATERIALFLAG_WATER && r_waterscroll.value != 0)
+                       t->currenttexmatrix = r_waterscrollmatrix;
+               else
+                       t->currenttexmatrix = identitymatrix;
+               break;
+       case Q3TCMOD_ENTITYTRANSLATE:
+               // this is used in Q3 to allow the gamecode to control texcoord
+               // scrolling on the entity, which is not supported in darkplaces yet.
+               Matrix4x4_CreateTranslate(&t->currenttexmatrix, 0, 0, 0);
+               break;
+       case Q3TCMOD_ROTATE:
+               Matrix4x4_CreateTranslate(&t->currenttexmatrix, 0.5, 0.5, 0);
+               Matrix4x4_ConcatRotate(&t->currenttexmatrix, t->tcmod_parms[0] * r_refdef.time, 0, 0, 1);
+               Matrix4x4_ConcatTranslate(&t->currenttexmatrix, -0.5, -0.5, 0);
+               break;
+       case Q3TCMOD_SCALE:
+               Matrix4x4_CreateScale3(&t->currenttexmatrix, t->tcmod_parms[0], t->tcmod_parms[1], 1);
+               break;
+       case Q3TCMOD_SCROLL:
+               Matrix4x4_CreateTranslate(&t->currenttexmatrix, t->tcmod_parms[0] * r_refdef.time, t->tcmod_parms[1] * r_refdef.time, 0);
+               break;
+       case Q3TCMOD_STRETCH:
+               f = 1.0f / R_EvaluateQ3WaveFunc(t->tcmod_wavefunc, t->tcmod_parms);
+               Matrix4x4_CreateFromQuakeEntity(&t->currenttexmatrix, 0.5f * (1 - f), 0.5 * (1 - f), 0, 0, 0, 0, f);
+               break;
+       case Q3TCMOD_TRANSFORM:
+               VectorSet(tcmat +  0, t->tcmod_parms[0], t->tcmod_parms[1], 0);
+               VectorSet(tcmat +  3, t->tcmod_parms[2], t->tcmod_parms[3], 0);
+               VectorSet(tcmat +  6, 0                , 0                , 1);
+               VectorSet(tcmat +  9, t->tcmod_parms[4], t->tcmod_parms[5], 0);
+               Matrix4x4_FromArray12FloatGL(&t->currenttexmatrix, tcmat);
+               break;
+       case Q3TCMOD_TURBULENT:
+               // this is handled in the RSurf_PrepareVertices function
+               t->currenttexmatrix = identitymatrix;
+               break;
+       }
+
        t->colormapping = VectorLength2(ent->colormap_pantscolor) + VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f);
        t->basetexture = (!t->colormapping && t->currentskinframe->merged) ? t->currentskinframe->merged : t->currentskinframe->base;
        t->glosstexture = r_texture_white;
@@ -3343,7 +3416,7 @@ void R_Mesh_ResizeArrays(int newvertices)
        if (rsurface.array_modelvertex3f)
                Mem_Free(rsurface.array_modelvertex3f);
        rsurface.array_size = (newvertices + 1023) & ~1023;
-       base = (float *)Mem_Alloc(r_main_mempool, rsurface.array_size * sizeof(float[31]));
+       base = (float *)Mem_Alloc(r_main_mempool, rsurface.array_size * sizeof(float[33]));
        rsurface.array_modelvertex3f     = base + rsurface.array_size * 0;
        rsurface.array_modelsvector3f    = base + rsurface.array_size * 3;
        rsurface.array_modeltvector3f    = base + rsurface.array_size * 6;
@@ -3354,6 +3427,7 @@ void R_Mesh_ResizeArrays(int newvertices)
        rsurface.array_deformednormal3f  = base + rsurface.array_size * 21;
        rsurface.array_texcoord3f        = base + rsurface.array_size * 24;
        rsurface.array_color4f           = base + rsurface.array_size * 27;
+       rsurface.array_generatedtexcoordtexture2f = base + rsurface.array_size * 31;
 }
 
 void RSurf_CleanUp(void)
@@ -3432,6 +3506,7 @@ void RSurf_ActiveWorldEntity(void)
        rsurface.normal3f  = rsurface.modelnormal3f;
        rsurface.normal3f_bufferobject = rsurface.modelnormal3f_bufferobject;
        rsurface.normal3f_bufferoffset = rsurface.modelnormal3f_bufferoffset;
+       rsurface.texcoordtexture2f = rsurface.modeltexcoordtexture2f;
 }
 
 void RSurf_ActiveModelEntity(const entity_render_t *ent, qboolean wantnormals, qboolean wanttangents)
@@ -3532,6 +3607,7 @@ void RSurf_ActiveModelEntity(const entity_render_t *ent, qboolean wantnormals, q
        rsurface.normal3f  = rsurface.modelnormal3f;
        rsurface.normal3f_bufferobject = rsurface.modelnormal3f_bufferobject;
        rsurface.normal3f_bufferoffset = rsurface.modelnormal3f_bufferoffset;
+       rsurface.texcoordtexture2f = rsurface.modeltexcoordtexture2f;
 }
 
 static const int quadedges[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};
@@ -3693,6 +3769,37 @@ void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generateta
                rsurface.normal3f_bufferobject = rsurface.modelnormal3f_bufferobject;
                rsurface.normal3f_bufferoffset = rsurface.modelnormal3f_bufferoffset;
        }
+       if (rsurface.texture->tcmod == Q3TCMOD_TURBULENT)
+       {
+               // make turbulent versions of only the texcoords used by the specified surfaces
+               int texturesurfaceindex;
+               float amplitude = rsurface.texture->tcmod_parms[1];
+               float animpos = rsurface.texture->tcmod_parms[2] + r_refdef.time * rsurface.texture->tcmod_parms[3];
+               for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
+               {
+                       int j;
+                       const float *v1, *in_tc;
+                       float *out_tc;
+                       const msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+                       for (j = 0, v1 = rsurface.modelvertex3f + 3 * surface->num_firstvertex, in_tc = rsurface.modeltexcoordtexture2f + 2 * surface->num_firstvertex, out_tc = rsurface.array_generatedtexcoordtexture2f + 2 * surface->num_firstvertex;j < surface->num_vertices;j++, v1 += 3, in_tc += 2, out_tc += 2)
+                       {
+                               out_tc[0] = in_tc[0] + amplitude * sin(((v1[0] + v1[2]) * 1.0 / 1024.0f + animpos) * M_PI * 2);
+                               out_tc[1] = in_tc[1] + amplitude * sin(((v1[1]        ) * 1.0 / 1024.0f + animpos) * M_PI * 2);
+                       }
+               }
+               rsurface.texcoordtexture2f               = rsurface.array_generatedtexcoordtexture2f;
+               rsurface.texcoordtexture2f_bufferobject  = 0;
+               rsurface.texcoordtexture2f_bufferoffset  = 0;
+       }
+       else
+       {
+               rsurface.texcoordtexture2f               = rsurface.modeltexcoordtexture2f;
+               rsurface.texcoordtexture2f_bufferobject  = rsurface.modeltexcoordtexture2f_bufferobject;
+               rsurface.texcoordtexture2f_bufferoffset  = rsurface.modeltexcoordtexture2f_bufferoffset;
+       }
+       rsurface.texcoordlightmap2f              = rsurface.modeltexcoordlightmap2f;
+       rsurface.texcoordlightmap2f_bufferobject = rsurface.modeltexcoordlightmap2f_bufferobject;
+       rsurface.texcoordlightmap2f_bufferoffset = rsurface.modeltexcoordlightmap2f_bufferoffset;
        R_Mesh_VertexPointer(rsurface.vertex3f, rsurface.vertex3f_bufferobject, rsurface.vertex3f_bufferoffset);
 }
 
@@ -4210,7 +4317,7 @@ static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, msurface_t **t
                RSurf_PrepareVerticesForBatch(true, r_glsl_permutation->loc_Texture_Normal >= 0, texturenumsurfaces, texturesurfacelist);
        else
                RSurf_PrepareVerticesForBatch(r_glsl_permutation->loc_Texture_Normal >= 0, r_glsl_permutation->loc_Texture_Normal >= 0, texturenumsurfaces, texturesurfacelist);
-       R_Mesh_TexCoordPointer(0, 2, rsurface.modeltexcoordtexture2f, rsurface.modeltexcoordtexture2f_bufferobject, rsurface.modeltexcoordtexture2f_bufferoffset);
+       R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
        R_Mesh_TexCoordPointer(1, 3, rsurface.svector3f, rsurface.svector3f_bufferobject, rsurface.svector3f_bufferoffset);
        R_Mesh_TexCoordPointer(2, 3, rsurface.tvector3f, rsurface.tvector3f_bufferobject, rsurface.tvector3f_bufferoffset);
        R_Mesh_TexCoordPointer(3, 3, rsurface.normal3f, rsurface.normal3f_bufferobject, rsurface.normal3f_bufferoffset);
@@ -4306,9 +4413,9 @@ static void R_DrawTextureSurfaceList_GL13(int texturenumsurfaces, msurface_t **t
                        m.tex[1] = R_GetTexture(layer->texture);
                        m.texmatrix[1] = layer->texmatrix;
                        m.texrgbscale[1] = layertexrgbscale;
-                       m.pointer_texcoord[1] = rsurface.modeltexcoordtexture2f;
-                       m.pointer_texcoord_bufferobject[1] = rsurface.modeltexcoordtexture2f_bufferobject;
-                       m.pointer_texcoord_bufferoffset[1] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                       m.pointer_texcoord[1] = rsurface.texcoordtexture2f;
+                       m.pointer_texcoord_bufferobject[1] = rsurface.texcoordtexture2f_bufferobject;
+                       m.pointer_texcoord_bufferoffset[1] = rsurface.texcoordtexture2f_bufferoffset;
                        R_Mesh_TextureState(&m);
                        if (rsurface.lightmode == 2)
                                RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
@@ -4322,9 +4429,9 @@ static void R_DrawTextureSurfaceList_GL13(int texturenumsurfaces, msurface_t **t
                        m.tex[0] = R_GetTexture(layer->texture);
                        m.texmatrix[0] = layer->texmatrix;
                        m.texrgbscale[0] = layertexrgbscale;
-                       m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-                       m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-                       m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                       m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+                       m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+                       m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                        R_Mesh_TextureState(&m);
                        RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
                        break;
@@ -4335,9 +4442,9 @@ static void R_DrawTextureSurfaceList_GL13(int texturenumsurfaces, msurface_t **t
                        {
                                m.tex[0] = R_GetTexture(layer->texture);
                                m.texmatrix[0] = layer->texmatrix;
-                               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-                               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-                               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+                               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+                               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                        }
                        R_Mesh_TextureState(&m);
                        // generate a color array for the fog pass
@@ -4423,9 +4530,9 @@ static void R_DrawTextureSurfaceList_GL11(int texturenumsurfaces, msurface_t **t
                                memset(&m, 0, sizeof(m));
                                m.tex[0] = R_GetTexture(layer->texture);
                                m.texmatrix[0] = layer->texmatrix;
-                               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-                               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-                               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+                               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+                               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                                R_Mesh_TextureState(&m);
                                RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layer->color[0] * 0.5f, layer->color[1] * 0.5f, layer->color[2] * 0.5f, layer->color[3], layer->color[0] != 2 || layer->color[1] != 2 || layer->color[2] != 2 || layer->color[3] != 1, false);
                        }
@@ -4435,9 +4542,9 @@ static void R_DrawTextureSurfaceList_GL11(int texturenumsurfaces, msurface_t **t
                                memset(&m, 0, sizeof(m));
                                m.tex[0] = R_GetTexture(layer->texture);
                                m.texmatrix[0] = layer->texmatrix;
-                               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-                               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-                               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+                               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+                               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                                R_Mesh_TextureState(&m);
                                if (rsurface.lightmode == 2)
                                        RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, layer->color[0], layer->color[1], layer->color[2], layer->color[3], layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1, applyfog);
@@ -4450,9 +4557,9 @@ static void R_DrawTextureSurfaceList_GL11(int texturenumsurfaces, msurface_t **t
                        memset(&m, 0, sizeof(m));
                        m.tex[0] = R_GetTexture(layer->texture);
                        m.texmatrix[0] = layer->texmatrix;
-                       m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-                       m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-                       m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                       m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+                       m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+                       m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                        R_Mesh_TextureState(&m);
                        RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layer->color[0], layer->color[1], layer->color[2], layer->color[3], layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1, applyfog);
                        break;
@@ -4464,9 +4571,9 @@ static void R_DrawTextureSurfaceList_GL11(int texturenumsurfaces, msurface_t **t
                                memset(&m, 0, sizeof(m));
                                m.tex[0] = R_GetTexture(layer->texture);
                                m.texmatrix[0] = layer->texmatrix;
-                               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-                               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-                               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+                               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+                               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+                               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                                R_Mesh_TextureState(&m);
                        }
                        else
index 9d29e4d..b17ba53 100644 (file)
@@ -29,7 +29,6 @@ BRUSH MODELS
 ==============================================================================
 */
 
-#define Q3PATHLENGTH 64
 
 
 //
index 064ead9..e573c12 100644 (file)
@@ -1301,7 +1301,7 @@ void Mod_LoadQ3Shaders(void)
                                                        else if (!strcasecmp(parameter[1], "vector"))      layer->tcgen = Q3TCGEN_VECTOR;
                                                        else Con_DPrintf("%s parsing warning: unknown tcgen mode %s\n", search->filenames[fileindex], parameter[1]);
                                                }
-                                               else if (numparameters == 2 && !strcasecmp(parameter[0], "tcmod"))
+                                               else if (numparameters >= 2 && !strcasecmp(parameter[0], "tcmod"))
                                                {
                                                        int i;
                                                        // observed values:
@@ -1328,7 +1328,7 @@ void Mod_LoadQ3Shaders(void)
                                                                layer->tcmod_wavefunc = Mod_LoadQ3Shaders_EnumerateWaveFunc(parameter[2]);
                                                        }
                                                        else if (!strcasecmp(parameter[1], "transform"))       layer->tcmod = Q3TCMOD_TRANSFORM;
-                                                       else if (!strcasecmp(parameter[1], "turb"))            layer->tcmod = Q3TCMOD_TURB;
+                                                       else if (!strcasecmp(parameter[1], "turb"))            layer->tcmod = Q3TCMOD_TURBULENT;
                                                        else Con_DPrintf("%s parsing warning: unknown tcmod mode %s\n", search->filenames[fileindex], parameter[1]);
                                                }
                                                // break out a level if it was }
@@ -1589,6 +1589,17 @@ nothing                GL_ZERO GL_ONE
                        texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
                if (shader->primarylayer)
                {
+                       // copy over many shader->primarylayer parameters
+                       texture->rgbgen   = shader->primarylayer->rgbgen;
+                       texture->alphagen = shader->primarylayer->alphagen;
+                       texture->tcgen    = shader->primarylayer->tcgen;
+                       texture->tcmod    = shader->primarylayer->tcmod;
+                       memcpy(texture->rgbgen_parms  , shader->primarylayer->rgbgen_parms  , sizeof(texture->rgbgen_parms));
+                       memcpy(texture->alphagen_parms, shader->primarylayer->alphagen_parms, sizeof(texture->alphagen_parms));
+                       memcpy(texture->tcgen_parms   , shader->primarylayer->tcgen_parms   , sizeof(texture->tcgen_parms));
+                       memcpy(texture->tcmod_parms   , shader->primarylayer->tcmod_parms   , sizeof(texture->tcmod_parms));
+                       texture->tcmod_wavefunc = shader->primarylayer->tcmod_wavefunc;
+                       // load the textures
                        texture->numskinframes = shader->primarylayer->numframes;
                        texture->skinframerate = shader->primarylayer->framerate;
                        for (j = 0;j < shader->primarylayer->numframes;j++)
index 95826bd..ba863c3 100644 (file)
@@ -182,7 +182,117 @@ typedef struct shadowmesh_s
 }
 shadowmesh_t;
 
+#define Q3PATHLENGTH 64
 #define TEXTURE_MAXFRAMES 64
+#define Q3SHADER_MAXLAYERS 8
+#define Q3RGBGEN_MAXPARMS 3
+#define Q3ALPHAGEN_MAXPARMS 1
+#define Q3TCGEN_MAXPARMS 6
+#define Q3TCMOD_MAXPARMS 6
+
+typedef enum q3wavefunc_e
+{
+       Q3WAVEFUNC_NONE,
+       Q3WAVEFUNC_INVERSESAWTOOTH,
+       Q3WAVEFUNC_NOISE,
+       Q3WAVEFUNC_SAWTOOTH,
+       Q3WAVEFUNC_SIN,
+       Q3WAVEFUNC_SQUARE,
+       Q3WAVEFUNC_TRIANGLE,
+       Q3WAVEFUNC_COUNT
+}
+q3wavefunc_t;
+
+typedef enum q3rgbgen_e
+{
+       Q3RGBGEN_IDENTITY,
+       Q3RGBGEN_CONST,
+       Q3RGBGEN_ENTITY,
+       Q3RGBGEN_EXACTVERTEX,
+       Q3RGBGEN_IDENTITYLIGHTING,
+       Q3RGBGEN_LIGHTINGDIFFUSE,
+       Q3RGBGEN_ONEMINUSENTITY,
+       Q3RGBGEN_ONEMINUSVERTEX,
+       Q3RGBGEN_VERTEX,
+       Q3RGBGEN_WAVE,
+       Q3RGBGEN_COUNT
+}
+q3rgbgen_t;
+
+typedef enum q3alphagen_e
+{
+       Q3ALPHAGEN_IDENTITY,
+       Q3ALPHAGEN_CONST,
+       Q3ALPHAGEN_ENTITY,
+       Q3ALPHAGEN_LIGHTINGSPECULAR,
+       Q3ALPHAGEN_ONEMINUSENTITY,
+       Q3ALPHAGEN_ONEMINUSVERTEX,
+       Q3ALPHAGEN_PORTAL,
+       Q3ALPHAGEN_VERTEX,
+       Q3ALPHAGEN_WAVE,
+       Q3ALPHAGEN_COUNT
+}
+q3alphagen_t;
+
+typedef enum q3tcgen_e
+{
+       Q3TCGEN_NONE,
+       Q3TCGEN_TEXTURE, // very common
+       Q3TCGEN_ENVIRONMENT, // common
+       Q3TCGEN_LIGHTMAP,
+       Q3TCGEN_VECTOR,
+       Q3TCGEN_COUNT
+}
+q3tcgen_t;
+
+typedef enum q3tcmod_e
+{
+       Q3TCMOD_NONE,
+       Q3TCMOD_ENTITYTRANSLATE,
+       Q3TCMOD_ROTATE,
+       Q3TCMOD_SCALE,
+       Q3TCMOD_SCROLL,
+       Q3TCMOD_STRETCH,
+       Q3TCMOD_TRANSFORM,
+       Q3TCMOD_TURBULENT,
+       Q3TCMOD_COUNT
+}
+q3tcmod_t;
+
+typedef struct q3shaderinfo_layer_s
+{
+       int alphatest;
+       int clampmap;
+       float framerate;
+       int numframes;
+       char texturename[TEXTURE_MAXFRAMES][Q3PATHLENGTH];
+       int blendfunc[2];
+       q3rgbgen_t rgbgen;
+       q3alphagen_t alphagen;
+       q3tcgen_t tcgen;
+       q3tcmod_t tcmod;
+       float rgbgen_parms[Q3RGBGEN_MAXPARMS];
+       float alphagen_parms[Q3ALPHAGEN_MAXPARMS];
+       float tcgen_parms[Q3TCGEN_MAXPARMS];
+       float tcmod_parms[Q3TCMOD_MAXPARMS];
+       q3wavefunc_t tcmod_wavefunc;
+}
+q3shaderinfo_layer_t;
+
+typedef struct q3shaderinfo_s
+{
+       char name[Q3PATHLENGTH];
+       int surfaceparms;
+       int textureflags;
+       int numlayers;
+       qboolean lighting;
+       qboolean vertexalpha;
+       qboolean textureblendalpha;
+       q3shaderinfo_layer_t *primarylayer, *backgroundlayer;
+       q3shaderinfo_layer_t layers[Q3SHADER_MAXLAYERS];
+       char skyboxname[Q3PATHLENGTH];
+}
+q3shaderinfo_t;
 
 typedef enum texturelayertype_e
 {
@@ -258,6 +368,17 @@ typedef struct texture_s
        // current texture transform matrix (used for water scrolling)
        matrix4x4_t currenttexmatrix;
 
+       // various q3 shader features
+       q3rgbgen_t rgbgen;
+       q3alphagen_t alphagen;
+       q3tcgen_t tcgen;
+       q3tcmod_t tcmod;
+       float rgbgen_parms[Q3RGBGEN_MAXPARMS];
+       float alphagen_parms[Q3ALPHAGEN_MAXPARMS];
+       float tcgen_parms[Q3TCGEN_MAXPARMS];
+       float tcmod_parms[Q3TCMOD_MAXPARMS];
+       q3wavefunc_t tcmod_wavefunc;
+
        qboolean colormapping;
        rtexture_t *basetexture;
        rtexture_t *glosstexture;
@@ -693,116 +814,6 @@ shadowmesh_t *Mod_ShadowMesh_Finish(mempool_t *mempool, shadowmesh_t *firstmesh,
 void Mod_ShadowMesh_CalcBBox(shadowmesh_t *firstmesh, vec3_t mins, vec3_t maxs, vec3_t center, float *radius);
 void Mod_ShadowMesh_Free(shadowmesh_t *mesh);
 
-#define Q3SHADER_MAXLAYERS 8
-#define Q3RGBGEN_MAXPARMS 3
-#define Q3ALPHAGEN_MAXPARMS 1
-#define Q3TCGEN_MAXPARMS 6
-#define Q3TCMOD_MAXPARMS 6
-
-typedef enum q3wavefunc_e
-{
-       Q3WAVEFUNC_NONE,
-       Q3WAVEFUNC_INVERSESAWTOOTH,
-       Q3WAVEFUNC_NOISE,
-       Q3WAVEFUNC_SAWTOOTH,
-       Q3WAVEFUNC_SIN,
-       Q3WAVEFUNC_SQUARE,
-       Q3WAVEFUNC_TRIANGLE,
-       Q3WAVEFUNC_COUNT
-}
-q3wavefunc_t;
-
-typedef enum q3rgbgen_e
-{
-       Q3RGBGEN_IDENTITY,
-       Q3RGBGEN_CONST,
-       Q3RGBGEN_ENTITY,
-       Q3RGBGEN_EXACTVERTEX,
-       Q3RGBGEN_IDENTITYLIGHTING,
-       Q3RGBGEN_LIGHTINGDIFFUSE,
-       Q3RGBGEN_ONEMINUSENTITY,
-       Q3RGBGEN_ONEMINUSVERTEX,
-       Q3RGBGEN_VERTEX,
-       Q3RGBGEN_WAVE,
-       Q3RGBGEN_COUNT
-}
-q3rgbgen_t;
-
-typedef enum q3alphagen_e
-{
-       Q3ALPHAGEN_IDENTITY,
-       Q3ALPHAGEN_CONST,
-       Q3ALPHAGEN_ENTITY,
-       Q3ALPHAGEN_LIGHTINGSPECULAR,
-       Q3ALPHAGEN_ONEMINUSENTITY,
-       Q3ALPHAGEN_ONEMINUSVERTEX,
-       Q3ALPHAGEN_PORTAL,
-       Q3ALPHAGEN_VERTEX,
-       Q3ALPHAGEN_WAVE,
-       Q3ALPHAGEN_COUNT
-}
-q3alphagen_t;
-
-typedef enum q3tcgen_e
-{
-       Q3TCGEN_NONE,
-       Q3TCGEN_TEXTURE, // very common
-       Q3TCGEN_ENVIRONMENT, // common
-       Q3TCGEN_LIGHTMAP,
-       Q3TCGEN_VECTOR,
-       Q3TCGEN_COUNT
-}
-q3tcgen_t;
-
-typedef enum q3tcmod_e
-{
-       Q3TCMOD_NONE,
-       Q3TCMOD_ENTITYTRANSLATE,
-       Q3TCMOD_ROTATE,
-       Q3TCMOD_SCALE,
-       Q3TCMOD_SCROLL,
-       Q3TCMOD_STRETCH,
-       Q3TCMOD_TRANSFORM,
-       Q3TCMOD_TURB,
-       Q3TCMOD_COUNT
-}
-q3tcmod_t;
-
-typedef struct q3shaderinfo_layer_s
-{
-       int alphatest;
-       int clampmap;
-       float framerate;
-       int numframes;
-       char texturename[TEXTURE_MAXFRAMES][Q3PATHLENGTH];
-       int blendfunc[2];
-       q3rgbgen_t rgbgen;
-       q3alphagen_t alphagen;
-       q3tcgen_t tcgen;
-       q3tcmod_t tcmod;
-       float rgbgen_parms[Q3RGBGEN_MAXPARMS];
-       float alphagen_parms[Q3ALPHAGEN_MAXPARMS];
-       float tcgen_parms[Q3TCGEN_MAXPARMS];
-       float tcmod_parms[Q3TCMOD_MAXPARMS];
-       q3wavefunc_t tcmod_wavefunc;
-}
-q3shaderinfo_layer_t;
-
-typedef struct q3shaderinfo_s
-{
-       char name[Q3PATHLENGTH];
-       int surfaceparms;
-       int textureflags;
-       int numlayers;
-       qboolean lighting;
-       qboolean vertexalpha;
-       qboolean textureblendalpha;
-       q3shaderinfo_layer_t *primarylayer, *backgroundlayer;
-       q3shaderinfo_layer_t layers[Q3SHADER_MAXLAYERS];
-       char skyboxname[Q3PATHLENGTH];
-}
-q3shaderinfo_t;
-
 void Mod_LoadQ3Shaders(void);
 q3shaderinfo_t *Mod_LookupQ3Shader(const char *name);
 qboolean Mod_LoadTextureFromQ3Shader(texture_t *texture, const char *name, qboolean q1bsp, qboolean q3bsp, qboolean md3);
index cc5b4bd..b04f357 100644 (file)
@@ -1463,7 +1463,7 @@ static void R_Shadow_RenderLighting_Light_GLSL(int firstvertex, int numvertices,
 {
        // ARB2 GLSL shader path (GFFX5200, Radeon 9500)
        R_SetupSurfaceShader(lightcolorbase, false, ambientscale, diffusescale, specularscale);
-       R_Mesh_TexCoordPointer(0, 2, rsurface.modeltexcoordtexture2f, rsurface.modeltexcoordtexture2f_bufferobject, rsurface.modeltexcoordtexture2f_bufferoffset);
+       R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
        R_Mesh_TexCoordPointer(1, 3, rsurface.svector3f, rsurface.svector3f_bufferobject, rsurface.svector3f_bufferoffset);
        R_Mesh_TexCoordPointer(2, 3, rsurface.tvector3f, rsurface.tvector3f_bufferobject, rsurface.tvector3f_bufferoffset);
        R_Mesh_TexCoordPointer(3, 3, rsurface.normal3f, rsurface.normal3f_bufferobject, rsurface.normal3f_bufferoffset);
@@ -1511,9 +1511,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
                m.texmatrix[0] = rsurface.entitytoattenuationxyz;
                m.tex[1] = R_GetTexture(basetexture);
-               m.pointer_texcoord[1] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[1] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[1] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[1] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[1] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[1] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[1] = rsurface.texture->currenttexmatrix;
                m.texcubemap[2] = R_GetTexture(rsurface.rtlight->currentcubemap);
                m.pointer_texcoord3f[2] = rsurface.vertex3f;
@@ -1532,9 +1532,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                m.pointer_texcoord_bufferoffset[0] = rsurface.vertex3f_bufferoffset;
                m.texmatrix[0] = rsurface.entitytoattenuationxyz;
                m.tex[1] = R_GetTexture(basetexture);
-               m.pointer_texcoord[1] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[1] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[1] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[1] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[1] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[1] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[1] = rsurface.texture->currenttexmatrix;
                GL_BlendFunc(GL_ONE, GL_ONE);
        }
@@ -1553,9 +1553,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
                m.texmatrix[1] = rsurface.entitytoattenuationz;
                m.tex[2] = R_GetTexture(basetexture);
-               m.pointer_texcoord[2] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[2] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[2] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[2] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[2] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[2] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[2] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1582,9 +1582,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
                m.texmatrix[1] = rsurface.entitytoattenuationz;
                m.tex[2] = R_GetTexture(basetexture);
-               m.pointer_texcoord[2] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[2] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[2] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[2] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[2] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[2] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[2] = rsurface.texture->currenttexmatrix;
                GL_BlendFunc(GL_ONE, GL_ONE);
        }
@@ -1610,9 +1610,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_AmbientPass(int firstvertex, int
                // second pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(basetexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1648,9 +1648,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
                m.texcombinergb[0] = GL_REPLACE;
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1670,9 +1670,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                // second pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(basetexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1702,9 +1702,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
                m.texcombinergb[0] = GL_REPLACE;
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1718,9 +1718,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                // second pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(basetexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1738,9 +1738,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
                m.texcombinergb[0] = GL_REPLACE;
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1755,9 +1755,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                // second pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(basetexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
                m.pointer_texcoord3f[1] = rsurface.vertex3f;
@@ -1772,9 +1772,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
                m.texcombinergb[0] = GL_REPLACE;
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1799,9 +1799,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                // second pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(basetexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1836,9 +1836,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
                m.texcombinergb[0] = GL_REPLACE;
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1852,9 +1852,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_DiffusePass(int firstvertex, int
                // second pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(basetexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1886,9 +1886,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                // 2/0/0/1/2 3D combine blendsquare path
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1922,9 +1922,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                // fifth pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(glosstexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -1941,9 +1941,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                // 2/0/0/2 3D combine blendsquare path
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -1966,9 +1966,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                // fourth pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(glosstexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
                m.pointer_texcoord3f[1] = rsurface.vertex3f;
@@ -1982,9 +1982,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                // 2/0/0/2/2 2D combine blendsquare path
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(normalmaptexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
                m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
@@ -2023,9 +2023,9 @@ static void R_Shadow_RenderLighting_Light_Dot3_SpecularPass(int firstvertex, int
                // fifth pass
                memset(&m, 0, sizeof(m));
                m.tex[0] = R_GetTexture(glosstexture);
-               m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-               m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-               m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+               m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+               m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+               m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
                m.texmatrix[0] = rsurface.texture->currenttexmatrix;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
                {
@@ -2183,9 +2183,9 @@ static void R_Shadow_RenderLighting_Light_Vertex(int firstvertex, int numvertice
        memset(&m, 0, sizeof(m));
        m.tex[0] = R_GetTexture(basetexture);
        m.texmatrix[0] = rsurface.texture->currenttexmatrix;
-       m.pointer_texcoord[0] = rsurface.modeltexcoordtexture2f;
-       m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordtexture2f_bufferobject;
-       m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordtexture2f_bufferoffset;
+       m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
+       m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
+       m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
        if (r_textureunits.integer >= 2)
        {
                // voodoo2 or TNT
index be0cf47..72d93f3 100644 (file)
--- a/render.h
+++ b/render.h
@@ -214,6 +214,7 @@ typedef struct rsurfacestate_s
        float *array_deformedsvector3f;
        float *array_deformedtvector3f;
        float *array_deformednormal3f;
+       float *array_generatedtexcoordtexture2f;
        float *array_color4f;
        float *array_texcoord3f;
 
@@ -284,6 +285,12 @@ typedef struct rsurfacestate_s
        float *lightmapcolor4f;
        int lightmapcolor4f_bufferobject;
        size_t lightmapcolor4f_bufferoffset;
+       float *texcoordtexture2f;
+       int texcoordtexture2f_bufferobject;
+       size_t texcoordtexture2f_bufferoffset;
+       float *texcoordlightmap2f;
+       int texcoordlightmap2f_bufferobject;
+       size_t texcoordlightmap2f_bufferoffset;
        // transform matrices to render this entity and effects on this entity
        matrix4x4_t matrix;
        matrix4x4_t inversematrix;