- 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 && (r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorpants) > 0.001)
- R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, NULL, NULL, bumptexture, NULL);
- if (shirttexture && (r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorshirt) > 0.001)
- R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, NULL, NULL, bumptexture, NULL);
- if (r_shadow_rtlight->ambientscale)
- {
- colorscale = r_shadow_rtlight->ambientscale;
- if (r_shadow_texture3d.integer && r_shadow_lightcubemap != r_texture_whitecube && r_textureunits.integer >= 4)
- {
- }
- else if (r_shadow_texture3d.integer && r_shadow_lightcubemap == r_texture_whitecube && r_textureunits.integer >= 2)
- {
- }
- else if (r_textureunits.integer >= 4 && r_shadow_lightcubemap != r_texture_whitecube)
- {
- }
- else if (r_textureunits.integer >= 3 && r_shadow_lightcubemap == r_texture_whitecube)
- {
- }
- 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 (r_shadow_rtlight->diffusescale)
- {
- colorscale = r_shadow_rtlight->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 && r_shadow_lightcubemap != r_texture_whitecube)
- {
- // 1/2/2 3D combine path (original Radeon)
- passes += 2;
- }
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_lightcubemap == r_texture_whitecube)
- {
- // 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 && r_shadow_lightcubemap != r_texture_whitecube /* && gl_support_blendsquare*/) // FIXME: detect blendsquare!
- passes += 4;
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && r_shadow_lightcubemap == r_texture_whitecube /* && 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 && (r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorpants) > 0.001)
- R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, NULL, NULL, bumptexture, NULL);
- if (shirttexture && (r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorshirt) > 0.001)
- R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, NULL, NULL, bumptexture, NULL);
- if (r_shadow_rtlight->ambientscale)
- {
- VectorScale(lightcolorbase, r_shadow_rtlight->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 (r_shadow_rtlight->diffusescale)
- {
- VectorScale(lightcolorbase, r_shadow_rtlight->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;
- }
- else if (r_shadowstage == R_SHADOWSTAGE_LIGHT_GLSL)
- {
- // GLSL shader path (GFFX5200, Radeon 9500)
- R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, texcoord2f);
- R_Mesh_TexCoordPointer(1, 3, svector3f);
- R_Mesh_TexCoordPointer(2, 3, tvector3f);
- R_Mesh_TexCoordPointer(3, 3, normal3f);
- R_Mesh_TexBind(0, R_GetTexture(bumptexture));
- R_Mesh_TexBind(1, R_GetTexture(basetexture));
- R_Mesh_TexBind(2, R_GetTexture(glosstexture));
- if (r_shadow_lightpermutation & SHADERPERMUTATION_SPECULAR)
- {
- qglUniform1fARB(qglGetUniformLocationARB(r_shadow_lightprog, "SpecularScale"), specularscale);CHECKGLERROR
- }
- qglUniform3fARB(qglGetUniformLocationARB(r_shadow_lightprog, "LightColor"), lightcolorbase[0], lightcolorbase[1], lightcolorbase[2]);CHECKGLERROR
- GL_LockArrays(firstvertex, numvertices);
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- // TODO: add direct pants/shirt rendering
- if (pantstexture && (r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorpants) > 0.001)
- {
- R_Mesh_TexBind(1, R_GetTexture(pantstexture));
- qglUniform3fARB(qglGetUniformLocationARB(r_shadow_lightprog, "LightColor"), lightcolorpants[0], lightcolorpants[1], lightcolorpants[2]);CHECKGLERROR
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- }
- if (shirttexture && (r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorshirt) > 0.001)
- {
- R_Mesh_TexBind(1, R_GetTexture(shirttexture));
- qglUniform3fARB(qglGetUniformLocationARB(r_shadow_lightprog, "LightColor"), lightcolorshirt[0], lightcolorshirt[1], lightcolorshirt[2]);CHECKGLERROR
- R_Mesh_Draw(firstvertex, numvertices, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- }