]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix bug that made pants/shirt not render in rtlighting (logic was backwards on the...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 3 Jul 2005 09:01:09 +0000 (09:01 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 3 Jul 2005 09:01:09 +0000 (09:01 +0000)
fix bug that rendered specular multiple times (brighter than inended) when using GLSL shader path on colormapped entities

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5483 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c
r_shadow.c

index 50d3f2db1fb0338e395c8088463d8d94619108b9..27f6d6db4c2774aea025b5c3712e4d4e41e64689 100644 (file)
@@ -792,7 +792,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces,
                                vec3_t lightcolorpants, lightcolorshirt;
                                // 128-224 are backwards ranges
                                int b = (ent->colormap & 0xF) << 4;b += (b >= 128 && b < 224) ? 4 : 12;
-                               if (texture->skin.pants && b >= 224)
+                               if (texture->skin.pants && b < 224)
                                {
                                        qbyte *bcolor = (qbyte *) (&palette_complete[b]);
                                        lightcolorpants[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
@@ -803,7 +803,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces,
                                        VectorClear(lightcolorpants);
                                // 128-224 are backwards ranges
                                b = (ent->colormap & 0xF0);b += (b >= 128 && b < 224) ? 4 : 12;
-                               if (texture->skin.shirt && b >= 224)
+                               if (texture->skin.shirt && b < 224)
                                {
                                        qbyte *bcolor = (qbyte *) (&palette_complete[b]);
                                        lightcolorshirt[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
index 81f23d4827360b0a7165005dc7676be9c29d84c7..08a69c5beea511431e0cd5969fcd19e8575cb166 100644 (file)
@@ -1630,7 +1630,15 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
        {
                int passes = 0;
                if (r_shadow_glsl.integer && r_shadow_program_light[0])
-                       passes++; // GLSL shader path (GFFX5200, Radeon 9500)
+               {
+                       // GLSL shader path (GFFX5200, Radeon 9500)
+                       // 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);
+                       passes++;
+               }
                else if (gl_dot3arb && gl_texturecubemap && r_textureunits.integer >= 2 && gl_combine.integer && gl_stencil)
                {
                        // TODO: add direct pants/shirt rendering
@@ -1743,6 +1751,11 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
        else if (r_shadowstage == R_SHADOWSTAGE_LIGHT_GLSL)
        {
                // GLSL shader path (GFFX5200, Radeon 9500)
+               // 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);
                R_Mesh_VertexPointer(vertex3f);
                R_Mesh_TexCoordPointer(0, 2, texcoord2f);
                R_Mesh_TexCoordPointer(1, 3, svector3f);
@@ -1760,23 +1773,6 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
                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;
-               }
                GL_LockArrays(0, 0);
        }
        else if (r_shadowstage == R_SHADOWSTAGE_LIGHT_DOT3)