- GL_Color(1,1,1,1);
- colorscale = r_shadow_rtlight->diffusescale;
- // colorscale accounts for how much we multiply the brightness
- // during combine.
- //
- // mult is how many times the final pass of the lighting will be
- // performed to get more brightness than otherwise possible.
- //
- // Limit mult to 64 for sanity sake.
- if (r_shadow_texture3d.integer && r_textureunits.integer >= 4)
- {
- // 3/2 3D combine path (Geforce3, Radeon 8500)
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = texcoord2f;
- m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, svector3f + 3 * firstvertex, tvector3f + 3 * firstvertex, normal3f + 3 * firstvertex, r_shadow_entitylightorigin);
- m.tex3d[2] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[2] = vertex3f;
- m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[2] = varray_texcoord3f[2];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[2] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
- R_Mesh_State(&m);
- GL_ColorMask(0,0,0,1);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = texcoord2f;
- if (r_shadow_lightcubemap != r_texture_whitecube)
- {
- m.texcubemap[1] = R_GetTexture(r_shadow_lightcubemap);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[1] = vertex3f;
- m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytolight);
-#endif
- }
- GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
- }
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_lightcubemap != r_texture_whitecube)
- {
- // 1/2/2 3D combine path (original Radeon)
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[0] = vertex3f;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[0] = varray_texcoord3f[0];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
- R_Mesh_State(&m);
- GL_ColorMask(0,0,0,1);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = texcoord2f;
- m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, svector3f + 3 * firstvertex, tvector3f + 3 * firstvertex, normal3f + 3 * firstvertex, r_shadow_entitylightorigin);
- R_Mesh_State(&m);
- GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = texcoord2f;
- if (r_shadow_lightcubemap != r_texture_whitecube)
- {
- m.texcubemap[1] = R_GetTexture(r_shadow_lightcubemap);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[1] = vertex3f;
- m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytolight);
-#endif
- }
- GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
- }
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_lightcubemap == r_texture_whitecube)
- {
- // 2/2 3D combine path (original Radeon)
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = texcoord2f;
- m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, svector3f + 3 * firstvertex, tvector3f + 3 * firstvertex, normal3f + 3 * firstvertex, r_shadow_entitylightorigin);
- R_Mesh_State(&m);
- GL_ColorMask(0,0,0,1);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = texcoord2f;
- m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[1] = vertex3f;
- m.texmatrix[1] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
- GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
- }
- else if (r_textureunits.integer >= 4)
- {
- // 4/2 2D combine path (Geforce3, Radeon 8500)
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = texcoord2f;
- m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, svector3f + 3 * firstvertex, tvector3f + 3 * firstvertex, normal3f + 3 * firstvertex, r_shadow_entitylightorigin);
- m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[2] = vertex3f;
- m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[2] = varray_texcoord2f[2];
- R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[2] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
- m.tex[3] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[3] = vertex3f;
- m.texmatrix[3] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[3] = varray_texcoord2f[3];
- R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[3] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationz);
-#endif
- R_Mesh_State(&m);
- GL_ColorMask(0,0,0,1);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = texcoord2f;
- if (r_shadow_lightcubemap != r_texture_whitecube)
- {
- m.texcubemap[1] = R_GetTexture(r_shadow_lightcubemap);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[1] = vertex3f;
- m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytolight);
-#endif
- }
- GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
- }
- else
- {
- // 2/2/2 2D combine path (any dot3 card)
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[0] = vertex3f;
- m.texmatrix[0] = r_shadow_entitytoattenuationxyz;
-#else
- m.pointer_texcoord[0] = varray_texcoord2f[0];
- R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[0] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationxyz);
-#endif
- m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[1] = vertex3f;
- m.texmatrix[1] = r_shadow_entitytoattenuationz;
-#else
- m.pointer_texcoord[1] = varray_texcoord2f[1];
- R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytoattenuationz);
-#endif
- R_Mesh_State(&m);
- GL_ColorMask(0,0,0,1);
- GL_BlendFunc(GL_ONE, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.pointer_texcoord[0] = texcoord2f;
- m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, svector3f + 3 * firstvertex, tvector3f + 3 * firstvertex, normal3f + 3 * firstvertex, r_shadow_entitylightorigin);
- R_Mesh_State(&m);
- GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- GL_LockArrays(0, 0);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- memset(&m, 0, sizeof(m));
- m.pointer_vertex = vertex3f;
- m.tex[0] = R_GetTexture(basetexture);
- m.pointer_texcoord[0] = texcoord2f;
- if (r_shadow_lightcubemap != r_texture_whitecube)
- {
- m.texcubemap[1] = R_GetTexture(r_shadow_lightcubemap);
-#ifdef USETEXMATRIX
- m.pointer_texcoord3f[1] = vertex3f;
- m.texmatrix[1] = r_shadow_entitytolight;
-#else
- m.pointer_texcoord3f[1] = varray_texcoord3f[1];
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1] + 3 * firstvertex, numvertices, vertex3f + 3 * firstvertex, &r_shadow_entitytolight);
-#endif
- }
- GL_BlendFunc(GL_DST_ALPHA, GL_ONE);
- }
- // this final code is shared
- R_Mesh_State(&m);
- GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 0);
- VectorScale(lightcolorbase, colorscale, color2);
- GL_LockArrays(firstvertex, numvertices);
- for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
- {
- GL_Color(bound(0, color2[0], 1), bound(0, color2[1], 1), bound(0, color2[2], 1), 1);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- }
- GL_LockArrays(0, 0);