- if (r_shadow_texture3d.integer)
- {
- if (r_textureunits.integer >= 4 && !lightcubemap)
- {
- // 4 texture 3D combine path, one pass, no light cubemap support
- m.tex[0] = R_GetTexture(bumptexture);
- m.tex3d[1] = R_GetTexture(r_shadow_normalsattenuationtexture);
- m.tex[2] = R_GetTexture(basetexture);
- m.tex[3] = R_GetTexture(r_shadow_blankwhitetexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.texcombinergb[1] = GL_DOT3_RGB_ARB;
- m.texcombinergb[2] = GL_MODULATE;
- m.texcombinergb[3] = GL_MODULATE;
- R_Mesh_TextureState(&m);
- memcpy(varray_texcoord[0], texcoords, numverts * sizeof(float[4]));
- memcpy(varray_texcoord[2], texcoords, numverts * sizeof(float[4]));
- R_Shadow_GenTexCoords_Diffuse_Attenuation3D(varray_texcoord[1], numverts, varray_vertex, svectors, tvectors, normals, relativelightorigin, lightradius);
- qglActiveTexture(GL_TEXTURE3_ARB);
- qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PRIMARY_COLOR_ARB);
- colorscale = r_colorscale * r_shadow_lightintensityscale.value;
- for (mult = 1, scale = ixtable[mult];mult < 64 && (lightcolor[0] * scale * colorscale > 1 || lightcolor[1] * scale * colorscale > 1 || lightcolor[2] * scale * colorscale > 1);mult++, scale = ixtable[mult]);
- colorscale *= scale;
- GL_Color(lightcolor[0] * colorscale, lightcolor[1] * colorscale, lightcolor[2] * colorscale, 1);
- for (renders = 0;renders < mult;renders++)
- R_Mesh_Draw(numverts, numtriangles, elements);
- qglActiveTexture(GL_TEXTURE3_ARB);
- qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
- }
- else
- {
- // 2 texture no3D combine path, two pass
- m.tex[0] = R_GetTexture(bumptexture);
- m.tex3d[1] = R_GetTexture(r_shadow_normalsattenuationtexture);
- m.texcombinergb[0] = GL_REPLACE;
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- R_Mesh_TextureState(&m);
- qglColorMask(0,0,0,1);
- qglDisable(GL_BLEND);
- GL_Color(1,1,1,1);
- memcpy(varray_texcoord[0], texcoords, numverts * sizeof(float[4]));
- R_Shadow_GenTexCoords_Diffuse_Attenuation3D(varray_texcoord[1], numverts, varray_vertex, svectors, tvectors, normals, relativelightorigin, lightradius);
- R_Mesh_Draw(numverts, numtriangles, elements);
-
- m.tex[0] = R_GetTexture(basetexture);
- m.tex3d[1] = 0;
- m.texcubemap[1] = R_GetTexture(lightcubemap);
- m.texcombinergb[0] = GL_MODULATE;
- m.texcombinergb[1] = GL_MODULATE;
- R_Mesh_TextureState(&m);
- qglColorMask(1,1,1,1);
- qglBlendFunc(GL_DST_ALPHA, GL_ONE);
- qglEnable(GL_BLEND);
- if (lightcubemap)
- R_Shadow_GenTexCoords_LightCubeMap(varray_texcoord[1], numverts, varray_vertex, relativelightorigin);
-
- colorscale = r_colorscale * r_shadow_lightintensityscale.value;
- for (mult = 1, scale = ixtable[mult];mult < 64 && (lightcolor[0] * scale * colorscale > 1 || lightcolor[1] * scale * colorscale > 1 || lightcolor[2] * scale * colorscale > 1);mult++, scale = ixtable[mult]);
- colorscale *= scale;
- GL_Color(lightcolor[0] * colorscale, lightcolor[1] * colorscale, lightcolor[2] * colorscale, 1);
- for (renders = 0;renders < mult;renders++)
- R_Mesh_Draw(numverts, numtriangles, elements);
- }
- }
- else if (r_textureunits.integer >= 4)