From 5bc6231f75923291e67a4b88bedd1dd013d62e91 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 3 Jul 2005 09:01:09 +0000 Subject: [PATCH] fix bug that made pants/shirt not render in rtlighting (logic was backwards on the fullbright color range checks) 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 | 4 ++-- r_shadow.c | 32 ++++++++++++++------------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index 50d3f2db..27f6d6db 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -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); diff --git a/r_shadow.c b/r_shadow.c index 81f23d48..08a69c5b 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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) -- 2.39.2