- // 2/0/0/1/2 3D combine blendsquare path
- //R_Mesh_EndBatch();
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- R_Mesh_TextureState(&m);
- qglColorMask(0,0,0,1);
- // this squares the result
- qglEnable(GL_BLEND);
- qglBlendFunc(GL_SRC_ALPHA, GL_ZERO);
- GL_Color(1,1,1,1);
- R_Mesh_GetSpace(numverts);
- R_Mesh_CopyVertex3f(vertex3f, numverts);
- R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin, relativeeyeorigin);
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- //R_Mesh_EndBatch();
- m.tex[0] = 0;
- m.texcubemap[1] = 0;
- m.texcombinergb[1] = GL_MODULATE;
- R_Mesh_TextureState(&m);
- // square alpha in framebuffer a few times to make it shiny
- qglBlendFunc(GL_ZERO, GL_DST_ALPHA);
- // these comments are a test run through this math for intensity 0.5
- // 0.5 * 0.5 = 0.25 (done by the BlendFunc earlier)
- // 0.25 * 0.25 = 0.0625 (this is another pass)
- // 0.0625 * 0.0625 = 0.00390625 (this is another pass)
- R_Mesh_GetSpace(numverts);
- R_Mesh_CopyVertex3f(vertex3f, numverts);
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- //R_Mesh_EndBatch();
- m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture);
- R_Mesh_TextureState(&m);
- qglBlendFunc(GL_DST_ALPHA, GL_ZERO);
- R_Mesh_GetSpace(numverts);
- R_Mesh_CopyVertex3f(vertex3f, numverts);
- R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0], numverts, vertex3f, matrix_modeltoattenuationxyz);
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- //R_Mesh_EndBatch();
- m.tex3d[0] = 0;
- m.tex[0] = R_GetTexture(glosstexture);
- m.texcubemap[1] = R_GetTexture(lightcubemap);
- R_Mesh_TextureState(&m);
- qglColorMask(1,1,1,0);
- qglBlendFunc(GL_DST_ALPHA, GL_ONE);
- 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);
- VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value * 0.25f, 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_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- }
- }
- else if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && !lightcubemap /*&& gl_support_blendsquare*/) // FIXME: detect blendsquare!
- {
- // 2/0/0/2 3D combine blendsquare path
- //R_Mesh_EndBatch();
- m.tex[0] = R_GetTexture(bumptexture);
- m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture);
- m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- R_Mesh_TextureState(&m);
- qglColorMask(0,0,0,1);
- // this squares the result
- qglEnable(GL_BLEND);
- qglBlendFunc(GL_SRC_ALPHA, GL_ZERO);
- GL_Color(1,1,1,1);
- R_Mesh_GetSpace(numverts);
- R_Mesh_CopyVertex3f(vertex3f, numverts);
- R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin, relativeeyeorigin);
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- //R_Mesh_EndBatch();
- m.tex[0] = 0;
- m.texcubemap[1] = 0;
- m.texcombinergb[1] = GL_MODULATE;
- R_Mesh_TextureState(&m);
- // square alpha in framebuffer a few times to make it shiny
- qglBlendFunc(GL_ZERO, GL_DST_ALPHA);
- // these comments are a test run through this math for intensity 0.5
- // 0.5 * 0.5 = 0.25 (done by the BlendFunc earlier)
- // 0.25 * 0.25 = 0.0625 (this is another pass)
- // 0.0625 * 0.0625 = 0.00390625 (this is another pass)
- R_Mesh_GetSpace(numverts);
- R_Mesh_CopyVertex3f(vertex3f, numverts);
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
- R_Mesh_Draw_NoBatching(numverts, numtriangles, elements);
- c_rt_lightmeshes++;
- c_rt_lighttris += numtriangles;
-
- //R_Mesh_EndBatch();
- R_Mesh_GetSpace(numverts);
- R_Mesh_CopyVertex3f(vertex3f, numverts);
- R_Mesh_CopyTexCoord2f(0, texcoord2f, numverts);
- m.tex[0] = R_GetTexture(glosstexture);
- m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
- R_Mesh_TextureState(&m);
- qglColorMask(1,1,1,0);
- qglBlendFunc(GL_DST_ALPHA, GL_ONE);
- 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);
- VectorScale(lightcolor, r_colorscale * r_shadow_lightintensityscale.value * 0.25f, color2);
- for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--)