+ {
+ if (r_shadow_gloss.integer >= 2)
+ {
+ glosstexture = r_texture_white;
+ specularscale *= r_shadow_gloss2intensity.value;
+ }
+ else
+ {
+ glosstexture = r_texture_black;
+ specularscale = 0;
+ }
+ }
+ if (r_shadow_gloss.integer < 1)
+ specularscale = 0;
+ if (!lightcubemap)
+ lightcubemap = r_shadow_blankwhitecubetexture;
+ if ((ambientscale + diffusescale) * (VectorLength2(lightcolorbase) + VectorLength2(lightcolorpants) + VectorLength2(lightcolorshirt)) + specularscale * VectorLength2(lightcolorbase) <= 0.001)
+ return;
+ if (visiblelighting)
+ {
+ int passes = 0;
+ if (r_shadow_glsl.integer && r_shadow_program_light[0])
+ passes++; // GLSL shader path (GFFX5200, Radeon 9500)
+ else if (gl_dot3arb && gl_texturecubemap && gl_combine.integer && gl_stencil)
+ {
+ // TODO: add direct pants/shirt rendering
+ if (pantstexture && (ambientscale + diffusescale) * VectorLength2(lightcolorpants) > 0.001)
+ R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, relativelightorigin, relativeeyeorigin, lightcolorpants, NULL, NULL, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, pantstexture, NULL, NULL, bumptexture, NULL, lightcubemap, ambientscale, diffusescale, specularscale, visiblelighting);
+ if (shirttexture && (ambientscale + diffusescale) * VectorLength2(lightcolorshirt) > 0.001)
+ R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, relativelightorigin, relativeeyeorigin, lightcolorshirt, NULL, NULL, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, shirttexture, NULL, NULL, bumptexture, NULL, lightcubemap, ambientscale, diffusescale, specularscale, visiblelighting);
+ if (!bumptexture)
+ bumptexture = r_texture_blanknormalmap;
+ if (!glosstexture)
+ glosstexture = r_texture_white;
+ if (ambientscale)
+ {
+ colorscale = ambientscale;
+ if (r_shadow_texture3d.integer && lightcubemap && r_textureunits.integer >= 4)
+ {
+ }
+ else if (r_shadow_texture3d.integer && !lightcubemap && r_textureunits.integer >= 2)
+ {
+ }
+ else if (r_textureunits.integer >= 4 && lightcubemap)
+ {
+ }
+ else if (r_textureunits.integer >= 3 && !lightcubemap)
+ {
+ }
+ else
+ passes++;
+ VectorScale(lightcolorbase, colorscale, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ passes++;
+ }
+ if (diffusescale)
+ {
+ colorscale = diffusescale;
+ if (r_shadow_texture3d.integer && r_textureunits.integer >= 4)
+ {
+ // 3/2 3D combine path (Geforce3, Radeon 8500)
+ passes++;
+ }
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && lightcubemap)
+ {
+ // 1/2/2 3D combine path (original Radeon)
+ passes += 2;
+ }
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && !lightcubemap)
+ {
+ // 2/2 3D combine path (original Radeon)
+ passes++;
+ }
+ else if (r_textureunits.integer >= 4)
+ {
+ // 4/2 2D combine path (Geforce3, Radeon 8500)
+ passes++;
+ }
+ else
+ {
+ // 2/2/2 2D combine path (any dot3 card)
+ passes += 2;
+ }
+ VectorScale(lightcolorbase, colorscale, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ passes++;
+ }
+ if (specularscale && glosstexture != r_texture_black)
+ {
+ //if (gl_support_blendsquare)
+ {
+ colorscale = specularscale;
+ if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && lightcubemap /*&& gl_support_blendsquare*/) // FIXME: detect blendsquare!
+ passes += 4;
+ else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && !lightcubemap /*&& gl_support_blendsquare*/) // FIXME: detect blendsquare!
+ passes += 3;
+ else
+ passes += 4;
+ VectorScale(lightcolorbase, colorscale, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ passes++;
+ }
+ }
+ }
+ else
+ {
+ // TODO: add direct pants/shirt rendering
+ if (pantstexture && (ambientscale + diffusescale) * VectorLength2(lightcolorpants) > 0.001)
+ R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, relativelightorigin, relativeeyeorigin, lightcolorpants, NULL, NULL, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, pantstexture, NULL, NULL, bumptexture, NULL, lightcubemap, ambientscale, diffusescale, specularscale, visiblelighting);
+ if (shirttexture && (ambientscale + diffusescale) * VectorLength2(lightcolorshirt) > 0.001)
+ R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, relativelightorigin, relativeeyeorigin, lightcolorshirt, NULL, NULL, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, shirttexture, NULL, NULL, bumptexture, NULL, lightcubemap, ambientscale, diffusescale, specularscale, visiblelighting);
+ if (ambientscale)
+ {
+ VectorScale(lightcolorbase, ambientscale, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ passes++;
+ }
+ if (diffusescale)
+ {
+ VectorScale(lightcolorbase, diffusescale, color2);
+ for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)
+ passes++;
+ }
+ }
+ if (passes)
+ {
+ GL_Color(0.1*passes, 0.025*passes, 0, 1);
+ memset(&m, 0, sizeof(m));
+ m.pointer_vertex = vertex3f;
+ R_Mesh_State(&m);
+ GL_LockArrays(firstvertex, numvertices);
+ R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
+ GL_LockArrays(0, 0);
+ }
+ return;
+ }