VectorCopy(ambientcolor, color4f);
if (r_refdef.fogenabled)
{
- float f = VERTEXFOGTABLE(VectorDistance(v, rsurface_modelorg));
+ float f;
+ f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
color4f[3] = 1;
{
float f;
Matrix4x4_Transform(&r_shadow_entitytolight, vertex3f, v);
- f = VERTEXFOGTABLE(VectorDistance(v, rsurface_modelorg));
+ f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
color4f[3] = 1;
}
if (r_refdef.fogenabled)
{
- float f = VERTEXFOGTABLE(VectorDistance(v, rsurface_modelorg));
+ float f;
+ f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
}
color4f[2] = ambientcolor[2] * distintensity;
if (r_refdef.fogenabled)
{
- float f = VERTEXFOGTABLE(VectorDistance(v, rsurface_modelorg));
+ float f;
+ f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
}
}
if (r_refdef.fogenabled)
{
- float f = VERTEXFOGTABLE(VectorDistance(v, rsurface_modelorg));
+ float f;
+ f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
}
color4f[2] = ambientcolor[2] * distintensity;
if (r_refdef.fogenabled)
{
- float f = VERTEXFOGTABLE(VectorDistance(v, rsurface_modelorg));
+ float f;
+ f = FogPoint_Model(vertex3f);
VectorScale(color4f, f, color4f);
}
}
void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
{
- int i, usestencil;
+ int i;
float f;
int numleafs, numsurfaces;
int *leaflist, *surfacelist;
unsigned char *leafpvs, *shadowtrispvs, *lighttrispvs;
int numlightentities;
+ int numlightentities_noselfshadow;
int numshadowentities;
+ int numshadowentities_noselfshadow;
entity_render_t *lightentities[MAX_EDICTS];
+ entity_render_t *lightentities_noselfshadow[MAX_EDICTS];
entity_render_t *shadowentities[MAX_EDICTS];
+ entity_render_t *shadowentities_noselfshadow[MAX_EDICTS];
// skip lights that don't light because of ambientscale+diffusescale+specularscale being 0 (corona only lights)
// skip lights that are basically invisible (color 0 0 0)
// make a list of lit entities and shadow casting entities
numlightentities = 0;
+ numlightentities_noselfshadow = 0;
numshadowentities = 0;
+ numshadowentities_noselfshadow = 0;
// add dynamic entities that are lit by the light
if (r_drawentities.integer)
{
// so now check if it's in a leaf seen by the light
if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingLeafPVS && !r_refdef.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.worldmodel, leafpvs, ent->mins, ent->maxs))
continue;
- lightentities[numlightentities++] = ent;
+ if (ent->flags & RENDER_NOSELFSHADOW)
+ lightentities_noselfshadow[numlightentities_noselfshadow++] = ent;
+ else
+ lightentities[numlightentities++] = ent;
// since it is lit, it probably also casts a shadow...
// about the VectorDistance2 - light emitting entities should not cast their own shadow
Matrix4x4_OriginFromMatrix(&ent->matrix, org);
if ((ent->flags & RENDER_SHADOW) && model->DrawShadowVolume && VectorDistance2(org, rtlight->shadoworigin) > 0.1)
- shadowentities[numshadowentities++] = ent;
+ {
+ // note: exterior models without the RENDER_NOSELFSHADOW
+ // flag still create a RENDER_NOSELFSHADOW shadow but
+ // are lit normally, this means that they are
+ // self-shadowing but do not shadow other
+ // RENDER_NOSELFSHADOW entities such as the gun
+ // (very weird, but keeps the player shadow off the gun)
+ if (ent->flags & (RENDER_NOSELFSHADOW | RENDER_EXTERIORMODEL))
+ shadowentities_noselfshadow[numshadowentities_noselfshadow++] = ent;
+ else
+ shadowentities[numshadowentities++] = ent;
+ }
}
else if (ent->flags & RENDER_SHADOW)
{
// about the VectorDistance2 - light emitting entities should not cast their own shadow
Matrix4x4_OriginFromMatrix(&ent->matrix, org);
if ((ent->flags & RENDER_SHADOW) && model->DrawShadowVolume && VectorDistance2(org, rtlight->shadoworigin) > 0.1)
- shadowentities[numshadowentities++] = ent;
+ {
+ if (ent->flags & (RENDER_NOSELFSHADOW | RENDER_EXTERIORMODEL))
+ shadowentities_noselfshadow[numshadowentities_noselfshadow++] = ent;
+ else
+ shadowentities[numshadowentities++] = ent;
+ }
}
}
}
// count this light in the r_speeds
r_refdef.stats.lights++;
- usestencil = false;
- if (numsurfaces + numshadowentities && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
+ if (r_showshadowvolumes.integer && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
+ {
+ // optionally draw visible shape of the shadow volumes
+ // for performance analysis by level designers
+ R_Shadow_RenderMode_VisibleShadowVolumes();
+ if (numsurfaces)
+ R_Shadow_DrawWorldShadow(numsurfaces, surfacelist, shadowtrispvs);
+ for (i = 0;i < numshadowentities;i++)
+ R_Shadow_DrawEntityShadow(shadowentities[i]);
+ for (i = 0;i < numshadowentities_noselfshadow;i++)
+ R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]);
+ }
+
+ if (gl_stencil && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
{
// draw stencil shadow volumes to mask off pixels that are in shadow
// so that they won't receive lighting
- if (gl_stencil)
+ R_Shadow_RenderMode_StencilShadowVolumes(true);
+ if (numsurfaces)
+ R_Shadow_DrawWorldShadow(numsurfaces, surfacelist, shadowtrispvs);
+ for (i = 0;i < numshadowentities;i++)
+ R_Shadow_DrawEntityShadow(shadowentities[i]);
+ if (numlightentities_noselfshadow)
{
- usestencil = true;
- R_Shadow_RenderMode_StencilShadowVolumes(true);
- if (numsurfaces)
- R_Shadow_DrawWorldShadow(numsurfaces, surfacelist, shadowtrispvs);
- for (i = 0;i < numshadowentities;i++)
- R_Shadow_DrawEntityShadow(shadowentities[i]);
+ // draw lighting in the unmasked areas
+ R_Shadow_RenderMode_Lighting(true, false);
+ for (i = 0;i < numlightentities_noselfshadow;i++)
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i], numsurfaces, surfacelist);
+
+ // optionally draw the illuminated areas
+ // for performance analysis by level designers
+ if (r_showlighting.integer)
+ {
+ R_Shadow_RenderMode_VisibleLighting(!r_showdisabledepthtest.integer, false);
+ for (i = 0;i < numlightentities_noselfshadow;i++)
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i], numsurfaces, surfacelist);
+ }
+
+ R_Shadow_RenderMode_StencilShadowVolumes(false);
}
+ for (i = 0;i < numshadowentities_noselfshadow;i++)
+ R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]);
- // optionally draw visible shape of the shadow volumes
- // for performance analysis by level designers
- if (r_showshadowvolumes.integer)
+ if (numsurfaces + numlightentities)
{
- R_Shadow_RenderMode_VisibleShadowVolumes();
+ // draw lighting in the unmasked areas
+ R_Shadow_RenderMode_Lighting(true, false);
if (numsurfaces)
- R_Shadow_DrawWorldShadow(numsurfaces, surfacelist, shadowtrispvs);
- for (i = 0;i < numshadowentities;i++)
- R_Shadow_DrawEntityShadow(shadowentities[i]);
+ R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
+ for (i = 0;i < numlightentities;i++)
+ R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist);
+
+ // optionally draw the illuminated areas
+ // for performance analysis by level designers
+ if (r_showlighting.integer)
+ {
+ R_Shadow_RenderMode_VisibleLighting(!r_showdisabledepthtest.integer, false);
+ if (numsurfaces)
+ R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
+ for (i = 0;i < numlightentities;i++)
+ R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist);
+ }
}
}
-
- if (numsurfaces + numlightentities)
+ else
{
- // draw lighting in the unmasked areas
- R_Shadow_RenderMode_Lighting(usestencil, false);
- if (numsurfaces)
- R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
- for (i = 0;i < numlightentities;i++)
- R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist);
-
- // optionally draw the illuminated areas
- // for performance analysis by level designers
- if (r_showlighting.integer)
+ if (numsurfaces + numlightentities)
{
- R_Shadow_RenderMode_VisibleLighting(usestencil && !r_showdisabledepthtest.integer, false);
+ // draw lighting in the unmasked areas
+ R_Shadow_RenderMode_Lighting(false, false);
if (numsurfaces)
R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
for (i = 0;i < numlightentities;i++)
R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist);
+ for (i = 0;i < numlightentities_noselfshadow;i++)
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i], numsurfaces, surfacelist);
+
+ // optionally draw the illuminated areas
+ // for performance analysis by level designers
+ if (r_showlighting.integer)
+ {
+ R_Shadow_RenderMode_VisibleLighting(false, false);
+ if (numsurfaces)
+ R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
+ for (i = 0;i < numlightentities;i++)
+ R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist);
+ for (i = 0;i < numlightentities_noselfshadow;i++)
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i], numsurfaces, surfacelist);
+ }
}
}
}
for (lightcount = 0, light = r_shadow_worldlightchain;light;lightcount++, light = light->next)
if (light == r_shadow_selectedlight)
lightnumber = lightcount;
- sprintf(temp, "Cursor %f %f %f Total Lights %i", r_editlights_cursorlocation[0], r_editlights_cursorlocation[1], r_editlights_cursorlocation[2], lightcount);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
+ sprintf(temp, "Cursor %f %f %f Total Lights %i", r_editlights_cursorlocation[0], r_editlights_cursorlocation[1], r_editlights_cursorlocation[2], lightcount);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
if (r_shadow_selectedlight == NULL)
return;
- sprintf(temp, "Light #%i properties", lightnumber);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Origin : %f %f %f\n", r_shadow_selectedlight->origin[0], r_shadow_selectedlight->origin[1], r_shadow_selectedlight->origin[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Angles : %f %f %f\n", r_shadow_selectedlight->angles[0], r_shadow_selectedlight->angles[1], r_shadow_selectedlight->angles[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Color : %f %f %f\n", r_shadow_selectedlight->color[0], r_shadow_selectedlight->color[1], r_shadow_selectedlight->color[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Radius : %f\n", r_shadow_selectedlight->radius);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Corona : %f\n", r_shadow_selectedlight->corona);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Style : %i\n", r_shadow_selectedlight->style);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Shadows : %s\n", r_shadow_selectedlight->shadow ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Cubemap : %s\n", r_shadow_selectedlight->cubemapname);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "CoronaSize : %f\n", r_shadow_selectedlight->coronasizescale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Ambient : %f\n", r_shadow_selectedlight->ambientscale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Diffuse : %f\n", r_shadow_selectedlight->diffusescale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "Specular : %f\n", r_shadow_selectedlight->specularscale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "NormalMode : %s\n", (r_shadow_selectedlight->flags & LIGHTFLAG_NORMALMODE) ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
- sprintf(temp, "RealTimeMode : %s\n", (r_shadow_selectedlight->flags & LIGHTFLAG_REALTIMEMODE) ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0);y += 8;
+ sprintf(temp, "Light #%i properties", lightnumber);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Origin : %f %f %f\n", r_shadow_selectedlight->origin[0], r_shadow_selectedlight->origin[1], r_shadow_selectedlight->origin[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Angles : %f %f %f\n", r_shadow_selectedlight->angles[0], r_shadow_selectedlight->angles[1], r_shadow_selectedlight->angles[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Color : %f %f %f\n", r_shadow_selectedlight->color[0], r_shadow_selectedlight->color[1], r_shadow_selectedlight->color[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Radius : %f\n", r_shadow_selectedlight->radius);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Corona : %f\n", r_shadow_selectedlight->corona);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Style : %i\n", r_shadow_selectedlight->style);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Shadows : %s\n", r_shadow_selectedlight->shadow ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Cubemap : %s\n", r_shadow_selectedlight->cubemapname);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "CoronaSize : %f\n", r_shadow_selectedlight->coronasizescale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Ambient : %f\n", r_shadow_selectedlight->ambientscale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Diffuse : %f\n", r_shadow_selectedlight->diffusescale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "Specular : %f\n", r_shadow_selectedlight->specularscale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "NormalMode : %s\n", (r_shadow_selectedlight->flags & LIGHTFLAG_NORMALMODE) ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
+ sprintf(temp, "RealTimeMode : %s\n", (r_shadow_selectedlight->flags & LIGHTFLAG_REALTIMEMODE) ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true);y += 8;
}
void R_Shadow_EditLights_ToggleShadow_f(void)