migrated a lot of error handling out of R_Shadow_RenderLighting and into the loading...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 7 Sep 2005 08:40:12 +0000 (08:40 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 7 Sep 2005 08:40:12 +0000 (08:40 +0000)
0 faster than it was, still not quite as fast as compilelight 1 however

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

gl_rsurf.c
model_shared.c
r_shadow.c
r_shadow.h

index 898da1f..c2c8226 100644 (file)
@@ -729,7 +729,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
        }
 }
 
-void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces, const int *surfacelist)
+void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolorbase, int numsurfaces, const int *surfacelist)
 {
        model_t *model = ent->model;
        msurface_t *surface;
@@ -766,19 +766,83 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces,
        }
        else
        {
+               texture_t *tex;
+               vec3_t lightcolorpants, lightcolorshirt;
+               rtexture_t *basetexture = NULL;
+               rtexture_t *glosstexture = NULL;
+               float specularscale = 0;
+               qboolean skip;
                R_UpdateAllTextureInfo(ent);
                Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
+               tex = NULL;
+               texture = NULL;
+               skip = false;
                for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
                {
-                       if (ent == r_refdef.worldentity && !r_worldsurfacevisible[surfacelist[surfacelistindex]])
+                       if ((ent == r_refdef.worldentity && !r_worldsurfacevisible[surfacelist[surfacelistindex]]))
                                continue;
                        surface = model->data_surfaces + surfacelist[surfacelistindex];
-                       texture = surface->texture->currentframe;
-                       // FIXME: transparent surfaces need to be lit later
-                       if ((texture->currentmaterialflags & (MATERIALFLAG_WALL | MATERIALFLAG_TRANSPARENT)) != MATERIALFLAG_WALL || !surface->num_triangles)
+                       if (tex != surface->texture)
+                       {
+                               tex = surface->texture;
+                               texture = surface->texture->currentframe;
+                               // FIXME: transparent surfaces need to be lit later
+                               skip = (texture->currentmaterialflags & (MATERIALFLAG_WALL | MATERIALFLAG_TRANSPARENT)) != MATERIALFLAG_WALL;
+                               if (skip)
+                                       continue;
+                               if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
+                                       qglDisable(GL_CULL_FACE);
+                               else
+                                       qglEnable(GL_CULL_FACE);
+                               glosstexture = r_texture_black;
+                               specularscale = 0;
+                               if (texture->skin.gloss)
+                               {
+                                       if (r_shadow_gloss.integer >= 1 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
+                                       {
+                                               glosstexture = texture->skin.gloss;
+                                               specularscale = r_shadow_rtlight->specularscale * r_shadow_glossintensity.value;
+                                       }
+                               }
+                               else
+                               {
+                                       if (r_shadow_gloss.integer >= 2 && r_shadow_gloss2intensity.value > 0 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
+                                       {
+                                               glosstexture = r_texture_white;
+                                               specularscale = r_shadow_rtlight->specularscale * r_shadow_gloss2intensity.value;
+                                       }
+                               }
+                               VectorClear(lightcolorpants);
+                               VectorClear(lightcolorshirt);
+                               if (ent->colormap >= 0)
+                               {
+                                       // 128-224 are backwards ranges
+                                       int b = (ent->colormap & 0xF) << 4;b += (b >= 128 && b < 224) ? 4 : 12;
+                                       if (texture->skin.pants && b < 224)
+                                       {
+                                               qbyte *bcolor = (qbyte *) (&palette_complete[b]);
+                                               lightcolorpants[0] = lightcolorbase[0] * bcolor[0] * (1.0f / 255.0f);
+                                               lightcolorpants[1] = lightcolorbase[1] * bcolor[1] * (1.0f / 255.0f);
+                                               lightcolorpants[2] = lightcolorbase[2] * bcolor[2] * (1.0f / 255.0f);
+                                       }
+                                       // 128-224 are backwards ranges
+                                       b = (ent->colormap & 0xF0);b += (b >= 128 && b < 224) ? 4 : 12;
+                                       if (texture->skin.shirt && b < 224)
+                                       {
+                                               qbyte *bcolor = (qbyte *) (&palette_complete[b]);
+                                               lightcolorshirt[0] = lightcolorbase[0] * bcolor[0] * (1.0f / 255.0f);
+                                               lightcolorshirt[1] = lightcolorbase[1] * bcolor[1] * (1.0f / 255.0f);
+                                               lightcolorshirt[2] = lightcolorbase[2] * bcolor[2] * (1.0f / 255.0f);
+                                       }
+                                       basetexture = texture->skin.base;
+                               }
+                               else
+                                       basetexture = texture->skin.merged ? texture->skin.merged : texture->skin.base;
+                               if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * (VectorLength2(lightcolorbase) + VectorLength2(lightcolorpants) + VectorLength2(lightcolorshirt)) + specularscale * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
+                                       skip = true;
+                       }
+                       if (skip || !surface->num_triangles)
                                continue;
-                       if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
-                               qglDisable(GL_CULL_FACE);
                        RSurf_SetVertexPointer(ent, texture, surface, modelorg);
                        if (!rsurface_svector3f)
                        {
@@ -787,39 +851,10 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces,
                                rsurface_normal3f = varray_normal3f;
                                Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, r_smoothnormals_areaweighting.integer);
                        }
-                       if (ent->colormap >= 0)
-                       {
-                               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)
-                               {
-                                       qbyte *bcolor = (qbyte *) (&palette_complete[b]);
-                                       lightcolorpants[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
-                                       lightcolorpants[1] = lightcolor[1] * bcolor[1] * (1.0f / 255.0f);
-                                       lightcolorpants[2] = lightcolor[2] * bcolor[2] * (1.0f / 255.0f);
-                               }
-                               else
-                                       VectorClear(lightcolorpants);
-                               // 128-224 are backwards ranges
-                               b = (ent->colormap & 0xF0);b += (b >= 128 && b < 224) ? 4 : 12;
-                               if (texture->skin.shirt && b < 224)
-                               {
-                                       qbyte *bcolor = (qbyte *) (&palette_complete[b]);
-                                       lightcolorshirt[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
-                                       lightcolorshirt[1] = lightcolor[1] * bcolor[1] * (1.0f / 255.0f);
-                                       lightcolorshirt[2] = lightcolor[2] * bcolor[2] * (1.0f / 255.0f);
-                               }
-                               else
-                                       VectorClear(lightcolorshirt);
-                               R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), rsurface_vertex3f, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, surface->groupmesh->data_texcoordtexture2f, lightcolor, lightcolorpants, lightcolorshirt, texture->skin.base, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->skin.gloss);
-                       }
-                       else
-                               R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), rsurface_vertex3f, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, surface->groupmesh->data_texcoordtexture2f, lightcolor, vec3_origin, vec3_origin, texture->skin.merged ? texture->skin.merged : texture->skin.base, NULL, NULL, texture->skin.nmap, texture->skin.gloss);
-                       if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
-                               qglEnable(GL_CULL_FACE);
+                       R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), rsurface_vertex3f, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, surface->groupmesh->data_texcoordtexture2f, lightcolorbase, lightcolorpants, lightcolorshirt, basetexture, texture->skin.pants, texture->skin.shirt, texture->skin.nmap, texture->skin.gloss);
                }
        }
+       qglEnable(GL_CULL_FACE);
 }
 
 #if 0
index 2f115fd..29dcad6 100644 (file)
@@ -939,6 +939,10 @@ int Mod_LoadSkinFrame(skinframe_t *skinframe, char *basename, int textureflags,
                if (s.shirtpixels != NULL)
                        skinframe->shirt = R_LoadTexture2D (loadmodel->texturepool, va("%s_shirt", basename), s.shirtpixels_width, s.shirtpixels_height, s.shirtpixels, TEXTYPE_RGBA, textureflags, NULL);
        }
+       if (!skinframe->base)
+               skinframe->base = r_texture_notexture;
+       if (!skinframe->nmap)
+               skinframe->nmap = r_texture_blanknormalmap;
        image_freeskin(&s);
        return true;
 }
@@ -983,6 +987,8 @@ int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textu
                                skinframe->base = GL_TextureForSkinLayer(skindata, width, height, va("%s_nospecial", basename), palette_nocolormap, textureflags); // no pants or shirt
                }
        }
+       if (!skinframe->nmap)
+               skinframe->nmap = r_texture_blanknormalmap;
        return true;
 }
 
index 1e13898..3609940 100644 (file)
@@ -1055,7 +1055,7 @@ void R_Shadow_ValidateCvars(void)
 }
 
 // light currently being rendered
-static rtlight_t *r_shadow_rtlight;
+rtlight_t *r_shadow_rtlight;
 // light filter cubemap being used by the light
 static rtexture_t *r_shadow_lightcubemap;
 
@@ -1604,28 +1604,6 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
        float color[3], color2[3], colorscale, specularscale;
        rmeshstate_t m;
        // FIXME: support MATERIALFLAG_NODEPTHTEST
-       if (!basetexture)
-               basetexture = r_texture_white;
-       if (!bumptexture)
-               bumptexture = r_texture_blanknormalmap;
-       if (!pantstexture)
-               lightcolorpants = vec3_origin;
-       if (!shirttexture)
-               lightcolorshirt = vec3_origin;
-       if (glosstexture && r_shadow_gloss.integer >= 1 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
-               specularscale = r_shadow_rtlight->specularscale * r_shadow_glossintensity.value;
-       else if (!glosstexture && r_shadow_gloss.integer >= 2 && r_shadow_gloss2intensity.value > 0 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
-       {
-               glosstexture = r_texture_white;
-               specularscale = r_shadow_rtlight->specularscale * r_shadow_gloss2intensity.value;
-       }
-       else
-       {
-               glosstexture = r_texture_black;
-               specularscale = 0;
-       }
-       if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * (VectorLength2(lightcolorbase) + VectorLength2(lightcolorpants) + VectorLength2(lightcolorshirt)) + specularscale * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
-               return;
        if (r_shadowstage == R_SHADOWSTAGE_VISIBLELIGHTING)
        {
                int passes = 0;
@@ -1634,18 +1612,18 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
                        // 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);
+                               R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, r_texture_black, r_texture_black, 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_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, r_texture_black, r_texture_black, bumptexture, NULL);
                        passes++;
                }
                else if (gl_dot3arb && gl_texturecubemap && r_textureunits.integer >= 2 && 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);
+                               R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, r_texture_black, r_texture_black, 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_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, r_texture_black, r_texture_black, bumptexture, NULL);
                        if (r_shadow_rtlight->ambientscale)
                        {
                                colorscale = r_shadow_rtlight->ambientscale;
@@ -1720,9 +1698,9 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
                {
                        // 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);
+                               R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, r_texture_black, r_texture_black, 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_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, r_texture_black, r_texture_black, bumptexture, NULL);
                        if (r_shadow_rtlight->ambientscale)
                        {
                                VectorScale(lightcolorbase, r_shadow_rtlight->ambientscale, color2);
@@ -1753,9 +1731,9 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
                // 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);
+                       R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, r_texture_black, r_texture_black, 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_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, r_texture_black, r_texture_black, bumptexture, NULL);
                R_Mesh_VertexPointer(vertex3f);
                R_Mesh_TexCoordPointer(0, 2, texcoord2f);
                R_Mesh_TexCoordPointer(1, 3, svector3f);
@@ -1779,9 +1757,9 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
        {
                // 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);
+                       R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, r_texture_black, r_texture_black, 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_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, r_texture_black, r_texture_black, bumptexture, NULL);
                if (r_shadow_rtlight->ambientscale)
                {
                        GL_Color(1,1,1,1);
@@ -2472,9 +2450,9 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
        {
                // 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);
+                       R_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorpants, vec3_origin, vec3_origin, pantstexture, r_texture_black, r_texture_black, 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_Shadow_RenderLighting(firstvertex, numvertices, numtriangles, elements, vertex3f, svector3f, tvector3f, normal3f, texcoord2f, lightcolorshirt, vec3_origin, vec3_origin, shirttexture, r_texture_black, r_texture_black, bumptexture, NULL);
                if (r_shadow_rtlight->ambientscale)
                {
                        GL_BlendFunc(GL_ONE, GL_ONE);
@@ -2806,13 +2784,13 @@ void R_Shadow_DrawEntityShadow(entity_render_t *ent, rtlight_t *rtlight, int num
        }
 }
 
-void R_Shadow_DrawEntityLight(entity_render_t *ent, rtlight_t *rtlight, vec3_t lightcolor, int numsurfaces, int *surfacelist)
+void R_Shadow_DrawEntityLight(entity_render_t *ent, rtlight_t *rtlight, vec3_t lightcolorbase, int numsurfaces, int *surfacelist)
 {
        shadowmesh_t *mesh;
        // set up properties for rendering light onto this entity
-       r_shadow_entitylightcolor[0] = lightcolor[0] * ent->colormod[0] * ent->alpha;
-       r_shadow_entitylightcolor[1] = lightcolor[1] * ent->colormod[1] * ent->alpha;
-       r_shadow_entitylightcolor[2] = lightcolor[2] * ent->colormod[2] * ent->alpha;
+       r_shadow_entitylightcolor[0] = lightcolorbase[0] * ent->colormod[0] * ent->alpha;
+       r_shadow_entitylightcolor[1] = lightcolorbase[1] * ent->colormod[1] * ent->alpha;
+       r_shadow_entitylightcolor[2] = lightcolorbase[2] * ent->colormod[2] * ent->alpha;
        Matrix4x4_Concat(&r_shadow_entitytolight, &rtlight->matrix_worldtolight, &ent->matrix);
        Matrix4x4_Concat(&r_shadow_entitytoattenuationxyz, &matrix_attenuationxyz, &r_shadow_entitytolight);
        Matrix4x4_Concat(&r_shadow_entitytoattenuationz, &matrix_attenuationz, &r_shadow_entitytolight);
@@ -2834,7 +2812,29 @@ void R_Shadow_DrawEntityLight(entity_render_t *ent, rtlight_t *rtlight, vec3_t l
                if (rtlight->compiled && r_shadow_realtime_world_compile.integer && r_shadow_realtime_world_compilelight.integer)
                {
                        for (mesh = rtlight->static_meshchain_light;mesh;mesh = mesh->next)
-                               R_Shadow_RenderLighting(0, mesh->numverts, mesh->numtriangles, mesh->element3i, mesh->vertex3f, mesh->svector3f, mesh->tvector3f, mesh->normal3f, mesh->texcoord2f, r_shadow_entitylightcolor, vec3_origin, vec3_origin, mesh->map_diffuse, NULL, NULL, mesh->map_normal, mesh->map_specular);
+                       {
+                               rtexture_t *glosstexture = r_texture_black;
+                               float specularscale = 0;
+                               if (mesh->map_specular)
+                               {
+                                       if (r_shadow_gloss.integer >= 1 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
+                                       {
+                                               glosstexture = mesh->map_specular;
+                                               specularscale = r_shadow_rtlight->specularscale * r_shadow_glossintensity.value;
+                                       }
+                               }
+                               else
+                               {
+                                       if (r_shadow_gloss.integer >= 2 && r_shadow_gloss2intensity.value > 0 && r_shadow_glossintensity.value > 0 && r_shadow_rtlight->specularscale > 0)
+                                       {
+                                               glosstexture = r_texture_white;
+                                               specularscale = r_shadow_rtlight->specularscale * r_shadow_gloss2intensity.value;
+                                       }
+                               }
+                               if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorbase) + specularscale * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
+                                       continue;
+                               R_Shadow_RenderLighting(0, mesh->numverts, mesh->numtriangles, mesh->element3i, mesh->vertex3f, mesh->svector3f, mesh->tvector3f, mesh->normal3f, mesh->texcoord2f, r_shadow_entitylightcolor, vec3_origin, vec3_origin, mesh->map_diffuse, r_texture_black, r_texture_black, mesh->map_normal, glosstexture);
+                       }
                }
                else
                        ent->model->DrawLight(ent, r_shadow_entitylightcolor, numsurfaces, surfacelist);
index b63a525..9de0b88 100644 (file)
@@ -38,6 +38,8 @@ void R_Shadow_Init(void);
 void R_Shadow_VolumeFromList(int numverts, int numtris, const float *invertex3f, const int *elements, const int *neighbors, const vec3_t projectorigin, float projectdistance, int nummarktris, const int *marktris);
 void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const vec3_t projectorigin, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs);
 void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles, const int *elements, const float *vertex3f, const float *svector3f, const float *tvector3f, const float *normal3f, const float *texcoord2f, const float *lightcolorbase, const float *lightcolorpants, const float *lightcolorshirt, rtexture_t *basetexture, rtexture_t *pantstexture, rtexture_t *shirttexture, rtexture_t *bumptexture, rtexture_t *glosstexture);
+// light currently being rendered
+extern rtlight_t *r_shadow_rtlight;
 
 void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *vertex3f, const int *element3i);
 qboolean R_Shadow_ScissorForBBox(const float *mins, const float *maxs);