cvar_t r_shadow_realtime_world_lightmaps = {CVAR_SAVE, "r_shadow_realtime_world_lightmaps", "0"};
cvar_t r_shadow_realtime_world_shadows = {CVAR_SAVE, "r_shadow_realtime_world_shadows", "1"};
cvar_t r_shadow_realtime_world_compile = {0, "r_shadow_realtime_world_compile", "1"};
-cvar_t r_shadow_realtime_world_compilelight = {0, "r_shadow_realtime_world_compilelight", "1"};
cvar_t r_shadow_realtime_world_compileshadow = {0, "r_shadow_realtime_world_compileshadow", "1"};
cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1"};
cvar_t r_shadow_shadow_polygonfactor = {0, "r_shadow_shadow_polygonfactor", "0"};
"r_shadow_realtime_world_lightmaps : use lightmaps in addition to lights\n"
"r_shadow_realtime_world_shadows : cast shadows from world lights\n"
"r_shadow_realtime_world_compile : compile surface/visibility information\n"
-"r_shadow_realtime_world_compilelight : compile lighting geometry\n"
"r_shadow_realtime_world_compileshadow : compile shadow geometry\n"
"r_shadow_glsl : use OpenGL Shading Language for lighting\n"
"r_shadow_glsl_offsetmapping : enables Offset Mapping bumpmap enhancement\n"
Cvar_RegisterVariable(&r_shadow_realtime_world_lightmaps);
Cvar_RegisterVariable(&r_shadow_realtime_world_shadows);
Cvar_RegisterVariable(&r_shadow_realtime_world_compile);
- Cvar_RegisterVariable(&r_shadow_realtime_world_compilelight);
Cvar_RegisterVariable(&r_shadow_realtime_world_compileshadow);
Cvar_RegisterVariable(&r_shadow_scissor);
Cvar_RegisterVariable(&r_shadow_shadow_polygonfactor);
}
// 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;
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) <= 0.001)
- return;
if (r_shadowstage == R_SHADOWSTAGE_VISIBLELIGHTING)
{
int passes = 0;
// 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;
{
// 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);
// 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);
{
// 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);
{
// 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);
// (undone by R_FreeCompiledRTLight, which R_UpdateLight calls)
void R_RTLight_Compile(rtlight_t *rtlight)
{
- int shadowmeshes, shadowtris, lightmeshes, lighttris, numleafs, numleafpvsbytes, numsurfaces;
+ int shadowmeshes, shadowtris, numleafs, numleafpvsbytes, numsurfaces;
entity_render_t *ent = r_refdef.worldentity;
model_t *model = r_refdef.worldmodel;
qbyte *data;
model->DrawShadowVolume(ent, rtlight->shadoworigin, rtlight->radius, numsurfaces, r_shadow_buffer_surfacelist, rtlight->cullmins, rtlight->cullmaxs);
rtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_shadow_mempool, rtlight->static_meshchain_shadow, false, false);
}
- if (model->DrawLight)
- {
- rtlight->static_meshchain_light = Mod_ShadowMesh_Begin(r_shadow_mempool, 32768, 32768, NULL, NULL, NULL, true, false, true);
- model->DrawLight(ent, vec3_origin, numsurfaces, r_shadow_buffer_surfacelist);
- rtlight->static_meshchain_light = Mod_ShadowMesh_Finish(r_shadow_mempool, rtlight->static_meshchain_light, true, false);
- }
// switch back to rendering when DrawShadowVolume or DrawLight is called
r_shadow_compilingrtlight = NULL;
}
}
}
- lightmeshes = 0;
- lighttris = 0;
- if (rtlight->static_meshchain_light)
- {
- shadowmesh_t *mesh;
- for (mesh = rtlight->static_meshchain_light;mesh;mesh = mesh->next)
- {
- lightmeshes++;
- lighttris += mesh->numtriangles;
- }
- }
-
- Con_DPrintf("static light built: %f %f %f : %f %f %f box, %i shadow volume triangles (in %i meshes), %i light triangles (in %i meshes)\n", rtlight->cullmins[0], rtlight->cullmins[1], rtlight->cullmins[2], rtlight->cullmaxs[0], rtlight->cullmaxs[1], rtlight->cullmaxs[2], shadowtris, shadowmeshes, lighttris, lightmeshes);
+ Con_DPrintf("static light built: %f %f %f : %f %f %f box, %i shadow volume triangles (in %i meshes)\n", rtlight->cullmins[0], rtlight->cullmins[1], rtlight->cullmins[2], rtlight->cullmaxs[0], rtlight->cullmaxs[1], rtlight->cullmaxs[2], shadowtris, shadowmeshes);
}
void R_RTLight_Uncompile(rtlight_t *rtlight)
if (rtlight->static_meshchain_shadow)
Mod_ShadowMesh_Free(rtlight->static_meshchain_shadow);
rtlight->static_meshchain_shadow = NULL;
- if (rtlight->static_meshchain_light)
- Mod_ShadowMesh_Free(rtlight->static_meshchain_light);
- rtlight->static_meshchain_light = NULL;
// these allocations are grouped
if (rtlight->static_leaflist)
Mem_Free(rtlight->static_leaflist);
}
}
-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);
}
}
if (ent == r_refdef.worldentity)
- {
- 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);
- }
- else
- ent->model->DrawLight(ent, r_shadow_entitylightcolor, numsurfaces, surfacelist);
- }
+ ent->model->DrawLight(ent, r_shadow_entitylightcolor, numsurfaces, surfacelist);
else
ent->model->DrawLight(ent, r_shadow_entitylightcolor, ent->model->nummodelsurfaces, ent->model->surfacelist);
}
entity_render_t *shadowentities[MAX_EDICTS];
// skip lights that don't light (corona only lights)
- if (rtlight->ambientscale + rtlight->diffusescale + rtlight->specularscale < 0.01)
+ if (rtlight->ambientscale + rtlight->diffusescale + rtlight->specularscale < (1.0f / 32768.0f))
return;
f = (rtlight->style >= 0 ? d_lightstylevalue[rtlight->style] : 128) * (1.0f / 256.0f) * r_shadow_lightintensityscale.value;
VectorScale(rtlight->color, f, lightcolor);
- if (VectorLength2(lightcolor) < 0.01)
+ if (VectorLength2(lightcolor) < (1.0f / 32768.0f))
return;
/*
if (rtlight->selected)
{
originhack[0] = 0;
originhack[1] = 0;
- originhack[2] = 48;
+ originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
{
originhack[0] = 0;
originhack[1] = 0;
- originhack[2] = 40;
+ originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
{
originhack[0] = 0;
originhack[1] = 0;
- originhack[2] = 40;
+ originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
{
originhack[0] = 0;
originhack[1] = 0;
- originhack[2] = 40;
+ originhack[2] = 0;
overridecolor[0] = 1;
overridecolor[1] = 0.5;
overridecolor[2] = 0.1;
}
else if (!strcmp("style", key))
style = atoi(value);
+ else if (!strcmp("skin", key))
+ skin = (int)atof(value);
+ else if (!strcmp("pflags", key))
+ pflags = (int)atof(value);
+ else if (!strcmp("effects", key))
+ effects = (int)atof(value);
else if (r_refdef.worldmodel->type == mod_brushq3)
{
if (!strcmp("scale", key))
if (!strcmp("fade", key))
fadescale = atof(value);
}
- else if (!strcmp("skin", key))
- skin = (int)atof(value);
- else if (!strcmp("pflags", key))
- pflags = (int)atof(value);
- else if (!strcmp("effects", key))
- effects = (int)atof(value);
}
if (!islight)
continue;
VectorMA(trace.endpos, push, r_viewforward, endpos);
VectorMA(endpos, r_editlights_cursorpushoff.value, trace.plane.normal, endpos);
}
+ else
+ {
+ VectorClear( endpos );
+ }
r_editlights_cursorlocation[0] = floor(endpos[0] / r_editlights_cursorgrid.value + 0.5f) * r_editlights_cursorgrid.value;
r_editlights_cursorlocation[1] = floor(endpos[1] / r_editlights_cursorgrid.value + 0.5f) * r_editlights_cursorgrid.value;
r_editlights_cursorlocation[2] = floor(endpos[2] / r_editlights_cursorgrid.value + 0.5f) * r_editlights_cursorgrid.value;