5 mempool_t *r_shadow_mempool;
9 int maxtrianglefacinglight;
10 qbyte *trianglefacinglight;
12 rtexturepool_t *r_shadow_texturepool;
13 rtexture_t *r_shadow_normalsattenuationtexture;
14 rtexture_t *r_shadow_normalscubetexture;
15 rtexture_t *r_shadow_attenuation2dtexture;
16 rtexture_t *r_shadow_blankbumptexture;
18 cvar_t r_shadow1 = {0, "r_shadow1", "16"};
19 cvar_t r_shadow2 = {0, "r_shadow2", "2"};
20 cvar_t r_shadow3 = {0, "r_shadow3", "65536"};
21 cvar_t r_shadow4 = {0, "r_shadow4", "1"};
22 cvar_t r_shadow5 = {0, "r_shadow5", "0"};
23 cvar_t r_shadow6 = {0, "r_shadow6", "1"};
24 cvar_t r_light_realtime = {0, "r_light_realtime", "0"};
25 cvar_t r_light_quality = {0, "r_light_quality", "1"};
26 cvar_t r_light_gloss = {0, "r_light_gloss", "0"};
27 cvar_t r_light_debuglight = {0, "r_light_debuglight", "-1"};
29 void r_shadow_start(void)
31 // allocate vertex processing arrays
32 r_shadow_mempool = Mem_AllocPool("R_Shadow");
33 maxshadowelements = 0;
34 shadowelements = NULL;
35 maxtrianglefacinglight = 0;
36 trianglefacinglight = NULL;
37 r_shadow_normalsattenuationtexture = NULL;
38 r_shadow_normalscubetexture = NULL;
39 r_shadow_attenuation2dtexture = NULL;
40 r_shadow_blankbumptexture = NULL;
41 r_shadow_texturepool = NULL;
44 void r_shadow_shutdown(void)
46 r_shadow_normalsattenuationtexture = NULL;
47 r_shadow_normalscubetexture = NULL;
48 r_shadow_attenuation2dtexture = NULL;
49 r_shadow_blankbumptexture = NULL;
50 R_FreeTexturePool(&r_shadow_texturepool);
51 maxshadowelements = 0;
52 shadowelements = NULL;
53 maxtrianglefacinglight = 0;
54 trianglefacinglight = NULL;
55 Mem_FreePool(&r_shadow_mempool);
58 void r_shadow_newmap(void)
62 void R_Shadow_Init(void)
64 Cvar_RegisterVariable(&r_shadow1);
65 Cvar_RegisterVariable(&r_shadow2);
66 Cvar_RegisterVariable(&r_shadow3);
67 Cvar_RegisterVariable(&r_shadow4);
68 Cvar_RegisterVariable(&r_shadow5);
69 Cvar_RegisterVariable(&r_shadow6);
70 Cvar_RegisterVariable(&r_light_realtime);
71 Cvar_RegisterVariable(&r_light_quality);
72 Cvar_RegisterVariable(&r_light_gloss);
73 Cvar_RegisterVariable(&r_light_debuglight);
74 R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap);
77 void R_Shadow_Volume(int numverts, int numtris, float *vertex, int *elements, int *neighbors, vec3_t relativelightorigin, float lightradius, float projectdistance, int visiblevolume)
79 int i, *e, *n, *out, tris;
80 float *v0, *v1, *v2, temp[3], f;
81 if (projectdistance < 0.1)
83 Con_Printf("R_Shadow_Volume: projectdistance %f\n");
89 // a triangle facing the light source
92 // a triangle not facing the light source
95 // an extrusion of the backfaces, beginning at the original geometry and
96 // ending further from the light source than the original geometry
97 // (presumably at least as far as the light's radius, if the light has a
98 // radius at all), capped at both front and back to avoid any problems
101 // draws the shadow volumes of the model.
103 // vertex loations must already be in vertex before use.
104 // vertex must have capacity for numverts * 2.
106 // make sure trianglefacinglight is big enough for this volume
107 if (maxtrianglefacinglight < numtris)
109 maxtrianglefacinglight = numtris;
110 if (trianglefacinglight)
111 Mem_Free(trianglefacinglight);
112 trianglefacinglight = Mem_Alloc(r_shadow_mempool, maxtrianglefacinglight);
115 // make sure shadowelements is big enough for this volume
116 if (maxshadowelements < numtris * 24)
118 maxshadowelements = numtris * 24;
120 Mem_Free(shadowelements);
121 shadowelements = Mem_Alloc(r_shadow_mempool, maxshadowelements * sizeof(int));
124 // make projected vertices
125 // by clever use of elements we'll construct the whole shadow from
126 // the unprojected vertices and these projected vertices
127 for (i = 0, v0 = vertex, v1 = vertex + numverts * 4;i < numverts;i++, v0 += 4, v1 += 4)
130 v1[0] = v0[0] + 50.0f * (v0[0] - relativelightorigin[0]);
131 v1[1] = v0[1] + 50.0f * (v0[1] - relativelightorigin[1]);
132 v1[2] = v0[2] + 50.0f * (v0[2] - relativelightorigin[2]);
134 VectorSubtract(v0, relativelightorigin, temp);
135 f = lightradius / sqrt(DotProduct(temp,temp));
138 VectorMA(relativelightorigin, f, temp, v1);
140 VectorSubtract(v0, relativelightorigin, temp);
141 f = projectdistance / sqrt(DotProduct(temp,temp));
142 VectorMA(v0, f, temp, v1);
146 // check which triangles are facing the light
147 for (i = 0, e = elements;i < numtris;i++, e += 3)
149 // calculate triangle facing flag
150 v0 = vertex + e[0] * 4;
151 v1 = vertex + e[1] * 4;
152 v2 = vertex + e[2] * 4;
153 // we do not need to normalize the surface normal because both sides
154 // of the comparison use it, therefore they are both multiplied the
155 // same amount... furthermore the subtract can be done on the
156 // vectors, saving a little bit of math in the dotproducts
159 // subtracts v1 from v0 and v2, combined into a crossproduct,
160 // combined with a dotproduct of the light location relative to the
161 // first point of the triangle (any point works, since the triangle
162 // is obviously flat), and finally a comparison to determine if the
163 // light is infront of the triangle (the goal of this statement)
164 trianglefacinglight[i] =
165 (relativelightorigin[0] - v0[0]) * ((v0[1] - v1[1]) * (v2[2] - v1[2]) - (v0[2] - v1[2]) * (v2[1] - v1[1]))
166 + (relativelightorigin[1] - v0[1]) * ((v0[2] - v1[2]) * (v2[0] - v1[0]) - (v0[0] - v1[0]) * (v2[2] - v1[2]))
167 + (relativelightorigin[2] - v0[2]) * ((v0[0] - v1[0]) * (v2[1] - v1[1]) - (v0[1] - v1[1]) * (v2[0] - v1[0])) > 0;
171 float dir0[3], dir1[3];
173 // calculate two mostly perpendicular edge directions
174 VectorSubtract(v0, v1, dir0);
175 VectorSubtract(v2, v1, dir1);
177 // we have two edge directions, we can calculate a third vector from
178 // them, which is the direction of the surface normal (it's magnitude
180 CrossProduct(dir0, dir1, temp);
182 // this is entirely unnecessary, but kept for clarity
183 //VectorNormalize(temp);
185 // compare distance of light along normal, with distance of any point
186 // of the triangle along the same normal (the triangle is planar,
187 // I.E. flat, so all points give the same answer)
188 // the normal is not normalized because it is used on both sides of
189 // the comparison, so it's magnitude does not matter
190 //trianglefacinglight[i] = DotProduct(relativelightorigin, temp) >= DotProduct(v0, temp);
191 f = DotProduct(relativelightorigin, temp) - DotProduct(v0, temp);
192 trianglefacinglight[i] = f > 0 && f < lightradius * sqrt(DotProduct(temp, temp));
197 // output triangle elements
198 out = shadowelements;
201 // check each backface for bordering frontfaces,
202 // and cast shadow polygons from those edges,
203 // also create front and back caps for shadow volume
204 for (i = 0, e = elements, n = neighbors;i < numtris;i++, e += 3, n += 3)
206 if (!trianglefacinglight[i])
208 // triangle is backface and therefore casts shadow,
209 // output front and back caps for shadow volume
211 // front cap (with flipped winding order)
216 out[3] = e[0] + numverts;
217 out[4] = e[1] + numverts;
218 out[5] = e[2] + numverts;
223 out[0] = e[0] + numverts;
224 out[1] = e[1] + numverts;
225 out[2] = e[2] + numverts;
230 if (n[0] < 0 || trianglefacinglight[n[0]])
234 out[2] = e[1] + numverts;
236 out[4] = e[1] + numverts;
237 out[5] = e[0] + numverts;
241 if (n[1] < 0 || trianglefacinglight[n[1]])
245 out[2] = e[2] + numverts;
247 out[4] = e[2] + numverts;
248 out[5] = e[1] + numverts;
252 if (n[2] < 0 || trianglefacinglight[n[2]])
256 out[2] = e[0] + numverts;
258 out[4] = e[0] + numverts;
259 out[5] = e[2] + numverts;
265 R_Shadow_RenderVolume(numverts * 2, tris, shadowelements, visiblevolume);
268 void R_Shadow_RenderVolume(int numverts, int numtris, int *elements, int visiblevolume)
273 //qglDisable(GL_CULL_FACE);
274 R_Mesh_Draw(numverts, numtris, elements);
275 //qglEnable(GL_CULL_FACE);
279 // increment stencil if backface is behind depthbuffer
280 qglCullFace(GL_BACK); // quake is backwards, this culls front faces
281 qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
282 R_Mesh_Draw(numverts, numtris, elements);
283 // decrement stencil if frontface is behind depthbuffer
284 qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
285 qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
286 R_Mesh_Draw(numverts, numtris, elements);
290 float r_shadow_atten1, r_shadow_atten2, r_shadow_atten5;
291 #define ATTEN3DSIZE 64
292 static void R_Shadow_Make3DTextures(void)
295 float v[3], intensity, ilen, length;
296 qbyte data[ATTEN3DSIZE][ATTEN3DSIZE][ATTEN3DSIZE][4];
297 if (r_light_quality.integer != 1 || !gl_texture3d)
299 for (z = 0;z < ATTEN3DSIZE;z++)
301 for (y = 0;y < ATTEN3DSIZE;y++)
303 for (x = 0;x < ATTEN3DSIZE;x++)
305 v[0] = (x + 0.5f) * (2.0f / (float) ATTEN3DSIZE) - 1.0f;
306 v[1] = (y + 0.5f) * (2.0f / (float) ATTEN3DSIZE) - 1.0f;
307 v[2] = (z + 0.5f) * (2.0f / (float) ATTEN3DSIZE) - 1.0f;
308 length = sqrt(DotProduct(v, v));
309 if (DotProduct(v, v) < 1)
310 intensity = (((r_shadow_atten1 / (length*length + r_shadow_atten5)) - (r_shadow_atten1 * r_shadow_atten2))) / 256.0f;
313 ilen = 127.0f * bound(0, intensity, 1) / length;
314 data[z][y][x][0] = 128.0f + ilen * v[0];
315 data[z][y][x][1] = 128.0f + ilen * v[1];
316 data[z][y][x][2] = 128.0f + ilen * v[2];
317 data[z][y][x][3] = 255;
321 r_shadow_normalsattenuationtexture = R_LoadTexture3D(r_shadow_texturepool, "normalsattenuation", ATTEN3DSIZE, ATTEN3DSIZE, ATTEN3DSIZE, &data[0][0][0][0], TEXTYPE_RGBA, TEXF_PRECACHE | TEXF_CLAMP);
324 static void R_Shadow_MakeTextures(void)
326 int x, y, z, d, side;
327 float v[3], s, t, intensity;
328 qbyte data[6][128][128][4];
329 R_FreeTexturePool(&r_shadow_texturepool);
330 r_shadow_texturepool = R_AllocTexturePool();
331 r_shadow_atten1 = r_shadow1.value;
332 r_shadow_atten2 = r_shadow2.value;
333 r_shadow_atten5 = r_shadow5.value;
334 for (y = 0;y < 128;y++)
336 for (x = 0;x < 128;x++)
338 data[0][y][x][0] = 128;
339 data[0][y][x][1] = 128;
340 data[0][y][x][2] = 255;
341 data[0][y][x][3] = 255;
344 r_shadow_blankbumptexture = R_LoadTexture(r_shadow_texturepool, "blankbump", 128, 128, &data[0][0][0][0], TEXTYPE_RGBA, TEXF_PRECACHE);
345 for (side = 0;side < 6;side++)
347 for (y = 0;y < 128;y++)
349 for (x = 0;x < 128;x++)
351 s = (x + 0.5f) * (2.0f / 128.0f) - 1.0f;
352 t = (y + 0.5f) * (2.0f / 128.0f) - 1.0f;
386 intensity = 127.0f / sqrt(DotProduct(v, v));
387 data[side][y][x][0] = 128.0f + intensity * v[0];
388 data[side][y][x][1] = 128.0f + intensity * v[1];
389 data[side][y][x][2] = 128.0f + intensity * v[2];
390 data[side][y][x][3] = 255;
394 r_shadow_normalscubetexture = R_LoadTextureCubeMap(r_shadow_texturepool, "normalscube", 128, &data[0][0][0][0], TEXTYPE_RGBA, TEXF_PRECACHE | TEXF_CLAMP);
395 for (y = 0;y < 128;y++)
397 for (x = 0;x < 128;x++)
399 v[0] = (x + 0.5f) * (2.0f / 128.0f) - 1.0f;
400 v[1] = (y + 0.5f) * (2.0f / 128.0f) - 1.0f;
402 if (DotProduct(v, v) < 1)
403 intensity = (((r_shadow_atten1 / (DotProduct(v, v)+r_shadow_atten5)) - (r_shadow_atten1 * r_shadow_atten2))) / 256.0f;
406 d = bound(0, intensity, 255) / sqrt(DotProduct(v, v));
407 data[0][y][x][0] = d;
408 data[0][y][x][1] = d;
409 data[0][y][x][2] = d;
410 data[0][y][x][3] = 255;
413 r_shadow_attenuation2dtexture = R_LoadTexture2D(r_shadow_texturepool, "attenuation2d", 128, 128, &data[0][0][0][0], TEXTYPE_RGBA, TEXF_PRECACHE | TEXF_CLAMP);
414 R_Shadow_Make3DTextures();
417 void R_Shadow_Stage_Begin(void)
421 if (r_light_quality.integer == 1 && !gl_texture3d)
423 Con_Printf("3D texture support not detected, falling back on slower 2D + 1D + normalization lighting\n");
424 Cvar_SetValueQuick(&r_light_quality, 0);
426 //cl.worldmodel->numlights = min(cl.worldmodel->numlights, 1);
427 if (!r_shadow_attenuation2dtexture
428 || (r_light_quality.integer == 1 && !r_shadow_normalsattenuationtexture)
429 || r_shadow1.value != r_shadow_atten1
430 || r_shadow2.value != r_shadow_atten2
431 || r_shadow5.value != r_shadow_atten5)
432 R_Shadow_MakeTextures();
434 memset(&m, 0, sizeof(m));
435 m.blendfunc1 = GL_ONE;
436 m.blendfunc2 = GL_ZERO;
438 GL_Color(0, 0, 0, 1);
441 void R_Shadow_Stage_ShadowVolumes(void)
444 memset(&m, 0, sizeof(m));
445 R_Mesh_TextureState(&m);
446 GL_Color(1, 1, 1, 1);
447 qglColorMask(0, 0, 0, 0);
448 qglDisable(GL_BLEND);
450 qglDepthFunc(GL_LESS);
452 qglClear(GL_STENCIL_BUFFER_BIT);
453 qglEnable(GL_STENCIL_TEST);
454 qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
455 qglStencilFunc(GL_ALWAYS, 0, 0xFF);
458 void R_Shadow_Stage_Light(void)
461 memset(&m, 0, sizeof(m));
462 R_Mesh_TextureState(&m);
463 qglActiveTexture(GL_TEXTURE0_ARB);
466 qglBlendFunc(GL_ONE, GL_ONE);
467 GL_Color(1, 1, 1, 1);
468 qglColorMask(1, 1, 1, 1);
470 qglDepthFunc(GL_EQUAL);
471 qglEnable(GL_STENCIL_TEST);
472 qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
473 // only draw light where this geometry was already rendered AND the
474 // stencil is 0 (non-zero means shadow)
475 qglStencilFunc(GL_EQUAL, 0, 0xFF);
478 void R_Shadow_Stage_End(void)
481 // attempt to restore state to what Mesh_State thinks it is
482 qglDisable(GL_BLEND);
483 qglBlendFunc(GL_ONE, GL_ZERO);
485 // now restore the rest of the state to normal
486 GL_Color(1, 1, 1, 1);
487 qglColorMask(1, 1, 1, 1);
488 qglDepthFunc(GL_LEQUAL);
489 qglDisable(GL_STENCIL_TEST);
490 qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
491 qglStencilFunc(GL_ALWAYS, 0, 0xFF);
494 void R_Shadow_GenTexCoords_Attenuation2D(float *out, int numverts, const float *vertex, const float *svectors, const float *tvectors, const vec3_t relativelightorigin, float lightradius)
497 float lightvec[3], iradius;
498 iradius = 0.5f / lightradius;
499 for (i = 0;i < numverts;i++, vertex += 4, svectors += 4, tvectors += 4, out += 4)
501 VectorSubtract(vertex, relativelightorigin, lightvec);
502 out[0] = 0.5f + DotProduct(svectors, lightvec) * iradius;
503 out[1] = 0.5f + DotProduct(tvectors, lightvec) * iradius;
507 void R_Shadow_GenTexCoords_Attenuation1D(float *out, int numverts, const float *vertex, const float *normals, const vec3_t relativelightorigin, float lightradius)
510 float lightvec[3], iradius;
511 iradius = 0.5f / lightradius;
512 for (i = 0;i < numverts;i++, vertex += 4, normals += 4, out += 4)
514 VectorSubtract(vertex, relativelightorigin, lightvec);
515 out[0] = 0.5f + DotProduct(normals, lightvec) * iradius;
520 void R_Shadow_GenTexCoords_Diffuse_Attenuation3D(float *out, int numverts, const float *vertex, const float *svectors, const float *tvectors, const float *normals, const vec3_t relativelightorigin, float lightradius)
523 float lightvec[3], iradius;
524 iradius = 0.5f / lightradius;
525 for (i = 0;i < numverts;i++, vertex += 4, svectors += 4, tvectors += 4, normals += 4, out += 4)
527 VectorSubtract(vertex, relativelightorigin, lightvec);
528 out[0] = 0.5f + DotProduct(svectors, lightvec) * iradius;
529 out[1] = 0.5f + DotProduct(tvectors, lightvec) * iradius;
530 out[2] = 0.5f + DotProduct(normals, lightvec) * iradius;
534 void R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(float *out, int numverts, const float *vertex, const float *svectors, const float *tvectors, const float *normals, const vec3_t relativelightorigin, float lightradius)
537 float lightdir[3], iradius;
538 iradius = 0.5f / lightradius;
539 for (i = 0;i < numverts;i++, vertex += 4, svectors += 4, tvectors += 4, normals += 4, out += 4)
541 VectorSubtract(vertex, relativelightorigin, lightdir);
542 // the cubemap normalizes this for us
543 out[0] = DotProduct(svectors, lightdir);
544 out[1] = DotProduct(tvectors, lightdir);
545 out[2] = DotProduct(normals, lightdir);
549 void R_Shadow_GenTexCoords_Specular_Attenuation3D(float *out, int numverts, const float *vertex, const float *svectors, const float *tvectors, const float *normals, const vec3_t relativelightorigin, const vec3_t relativeeyeorigin, float lightradius)
552 float lightdir[3], eyedir[3], halfdir[3], lightdirlen, ilen, iradius;
553 iradius = 0.5f / lightradius;
554 for (i = 0;i < numverts;i++, vertex += 4, svectors += 4, tvectors += 4, normals += 4, out += 4)
556 VectorSubtract(vertex, relativelightorigin, lightdir);
557 // this is used later to make the attenuation correct
558 lightdirlen = sqrt(DotProduct(lightdir, lightdir)) * iradius;
559 VectorNormalizeFast(lightdir);
560 VectorSubtract(vertex, relativeeyeorigin, eyedir);
561 VectorNormalizeFast(eyedir);
562 VectorAdd(lightdir, eyedir, halfdir);
563 VectorNormalizeFast(halfdir);
564 out[0] = 0.5f + DotProduct(svectors, halfdir) * lightdirlen;
565 out[1] = 0.5f + DotProduct(tvectors, halfdir) * lightdirlen;
566 out[2] = 0.5f + DotProduct(normals, halfdir) * lightdirlen;
570 void R_Shadow_GenTexCoords_Specular_NormalCubeMap(float *out, int numverts, const float *vertex, const float *svectors, const float *tvectors, const float *normals, const vec3_t relativelightorigin, const vec3_t relativeeyeorigin, float lightradius)
573 float lightdir[3], eyedir[3], halfdir[3], lightdirlen, ilen, iradius;
574 iradius = 0.5f / lightradius;
575 for (i = 0;i < numverts;i++, vertex += 4, svectors += 4, tvectors += 4, normals += 4, out += 4)
577 VectorSubtract(vertex, relativelightorigin, lightdir);
578 VectorNormalizeFast(lightdir);
579 VectorSubtract(vertex, relativeeyeorigin, eyedir);
580 VectorNormalizeFast(eyedir);
581 VectorAdd(lightdir, eyedir, halfdir);
582 // the cubemap normalizes this for us
583 out[0] = DotProduct(svectors, halfdir);
584 out[1] = DotProduct(tvectors, halfdir);
585 out[2] = DotProduct(normals, halfdir);
589 void R_Shadow_GenTexCoords_LightCubeMap(float *out, int numverts, const float *vertex, const vec3_t relativelightorigin)
592 for (i = 0;i < numverts;i++, vertex += 4, out += 4)
593 VectorSubtract(vertex, relativelightorigin, out);
596 void R_Shadow_RenderLighting(int numverts, int numtriangles, const int *elements, const float *svectors, const float *tvectors, const float *normals, const float *texcoords, const float *relativelightorigin, const float *relativeeyeorigin, float lightradius, const float *lightcolor, rtexture_t *basetexture, rtexture_t *glosstexture, rtexture_t *bumptexture, rtexture_t *lightcubemap)
600 memset(&m, 0, sizeof(m));
602 bumptexture = r_shadow_blankbumptexture;
603 f = 1.0f / r_shadow3.value;
604 if (r_light_quality.integer == 1)
606 // 4 texture 3D path, two pass
608 //lightcolor[0] * f, lightcolor[1] * f, lightcolor[2] * f, 1);
609 memcpy(varray_texcoord[0], texcoords, numverts * sizeof(float[4]));
610 memcpy(varray_texcoord[2], texcoords, numverts * sizeof(float[4]));
611 if (r_light_gloss.integer != 2)
613 m.tex[0] = R_GetTexture(bumptexture);
614 m.tex3d[1] = R_GetTexture(r_shadow_normalsattenuationtexture);
615 m.tex[2] = R_GetTexture(basetexture);
616 m.texcubemap[3] = R_GetTexture(lightcubemap);
617 m.texcombinergb[0] = GL_REPLACE;
618 m.texcombinergb[1] = GL_DOT3_RGB_ARB;
619 m.texcombinergb[2] = GL_MODULATE;
620 m.texcombinergb[3] = GL_MODULATE;
621 R_Mesh_TextureState(&m);
622 R_Shadow_GenTexCoords_Diffuse_Attenuation3D(varray_texcoord[1], numverts, varray_vertex, svectors, tvectors, normals, relativelightorigin, lightradius);
624 R_Shadow_GenTexCoords_LightCubeMap(varray_texcoord[3], numverts, varray_vertex, relativelightorigin);
625 R_Mesh_Draw(numverts, numtriangles, elements);
627 if (r_light_gloss.integer && glosstexture)
629 m.tex[0] = R_GetTexture(bumptexture);
630 m.tex3d[1] = R_GetTexture(r_shadow_normalsattenuationtexture);
631 m.tex[2] = R_GetTexture(glosstexture);
632 m.texcubemap[3] = R_GetTexture(lightcubemap);
633 m.texcombinergb[0] = GL_REPLACE;
634 m.texcombinergb[1] = GL_DOT3_RGB_ARB;
635 m.texcombinergb[2] = GL_MODULATE;
636 m.texcombinergb[3] = GL_MODULATE;
637 R_Mesh_TextureState(&m);
638 R_Shadow_GenTexCoords_Specular_Attenuation3D(varray_texcoord[1], numverts, varray_vertex, svectors, tvectors, normals, relativelightorigin, relativeeyeorigin, lightradius);
639 R_Mesh_Draw(numverts, numtriangles, elements);
644 //R_Mesh_TextureState(&m);