+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+
+ m.tex[0] = R_GetTexture(basetexture);
+ m.texcubemap[1] = R_GetTexture(lightcubemap);
+ m.texcombinergb[0] = GL_MODULATE;
+ m.texcombinergb[1] = GL_MODULATE;
+ R_Mesh_TextureState(&m);
+ qglColorMask(1,1,1,0);
+ qglBlendFunc(GL_DST_ALPHA, GL_ONE);
+
+ VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ {
+ color[0] = bound(0, color2[0], 1);
+ color[1] = bound(0, color2[1], 1);
+ color[2] = bound(0, color2[2], 1);
+ GL_Color(color[0], color[1], color[2], 1);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ if (lightcubemap)
+ R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltofilter);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+ }
+ }
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && !lightcubemap)
+ {
+ // 2/2 3D combine path (original Radeon)
+ m.tex[0] = R_GetTexture(bumptexture);
+ m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture);
+ m.texcombinergb[0] = GL_REPLACE;
+ m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
+ R_Mesh_TextureState(&m);
+ GL_Color(1,1,1,1);
+ qglColorMask(0,0,0,1);
+ qglDisable(GL_BLEND);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+
+ m.tex[0] = R_GetTexture(basetexture);
+ m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
+ m.texcubemap[1] = 0;
+ m.texcombinergb[0] = GL_MODULATE;
+ m.texcombinergb[1] = GL_MODULATE;
+ R_Mesh_TextureState(&m);
+ qglColorMask(1,1,1,0);
+ qglBlendFunc(GL_DST_ALPHA, GL_ONE);
+ qglEnable(GL_BLEND);
+
+ VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ {
+ color[0] = bound(0, color2[0], 1);
+ color[1] = bound(0, color2[1], 1);
+ color[2] = bound(0, color2[2], 1);
+ GL_Color(color[0], color[1], color[2], 1);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltoattenuationxyz);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+ }
+ }
+ else if (r_textureunits.integer >= 4)
+ {
+ // 4/2 2D combine path (Geforce3, Radeon 8500)
+ m.tex[0] = R_GetTexture(bumptexture);
+ m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture);
+ m.texcombinergb[0] = GL_REPLACE;
+ m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
+ m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
+ m.tex[3] = R_GetTexture(r_shadow_attenuation2dtexture);
+ R_Mesh_TextureState(&m);
+ qglColorMask(0,0,0,1);
+ qglDisable(GL_BLEND);
+ GL_Color(1,1,1,1);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin);
+ R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[2], numverts, vertex3f, matrix_modeltoattenuationxyz);
+ R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[3], numverts, vertex3f, matrix_modeltoattenuationz);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+
+ m.tex[0] = R_GetTexture(basetexture);
+ m.texcubemap[1] = R_GetTexture(lightcubemap);
+ m.texcombinergb[0] = GL_MODULATE;
+ m.texcombinergb[1] = GL_MODULATE;
+ m.tex[2] = 0;
+ m.tex[3] = 0;
+ R_Mesh_TextureState(&m);
+ qglColorMask(1,1,1,0);
+ qglBlendFunc(GL_DST_ALPHA, GL_ONE);
+ qglEnable(GL_BLEND);
+
+ VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ {
+ color[0] = bound(0, color2[0], 1);
+ color[1] = bound(0, color2[1], 1);
+ color[2] = bound(0, color2[2], 1);
+ GL_Color(color[0], color[1], color[2], 1);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ if (lightcubemap)
+ R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltofilter);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+ }
+ }
+ else
+ {
+ // 2/2/2 2D combine path (any dot3 card)
+ m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
+ m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
+ R_Mesh_TextureState(&m);
+ qglColorMask(0,0,0,1);
+ qglDisable(GL_BLEND);
+ GL_Color(1,1,1,1);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[0], numverts, vertex3f, matrix_modeltoattenuationxyz);
+ R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[1], numverts, vertex3f, matrix_modeltoattenuationz);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+
+ m.tex[0] = R_GetTexture(bumptexture);
+ m.tex[1] = 0;
+ m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture);
+ m.texcombinergb[0] = GL_REPLACE;
+ m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
+ R_Mesh_TextureState(&m);
+ qglBlendFunc(GL_DST_ALPHA, GL_ZERO);
+ qglEnable(GL_BLEND);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+
+ m.tex[0] = R_GetTexture(basetexture);
+ m.texcubemap[1] = R_GetTexture(lightcubemap);
+ m.texcombinergb[0] = GL_MODULATE;
+ m.texcombinergb[1] = GL_MODULATE;
+ R_Mesh_TextureState(&m);
+ qglColorMask(1,1,1,0);
+ qglBlendFunc(GL_DST_ALPHA, GL_ONE);
+
+ VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ {
+ color[0] = bound(0, color2[0], 1);
+ color[1] = bound(0, color2[1], 1);
+ color[2] = bound(0, color2[2], 1);
+ GL_Color(color[0], color[1], color[2], 1);
+ R_Mesh_GetSpace(numverts);
+ R_Mesh_CopyVertex3f(vertex3f, numverts);
+ R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
+ if (lightcubemap)
+ R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltofilter);
+ R_Mesh_Draw(numverts, numtriangles, elements);
+ c_rt_lightmeshes++;
+ c_rt_lighttris += numtriangles;
+ }
+ }