lightradius2 = lightradius * lightradius;
for (i = 0, surf = ent->model->surfaces + ent->model->firstmodelsurface;i < ent->model->nummodelsurfaces;i++, surf++)
{
- f = PlaneDiff(relativelightorigin, surf->plane);
- if (surf->flags & SURF_PLANEBACK)
- f = -f;
- // draw shadows only for backfaces
- projectdistance = lightradius + f;
- if (projectdistance >= 0.1 && projectdistance < lightradius)
+ if (surf->flags & SURF_SHADOWCAST)
{
- VectorSubtract(relativelightorigin, surf->poly_center, temp);
- if (DotProduct(temp, temp) < (surf->poly_radius2 + lightradius2))
+ f = PlaneDiff(relativelightorigin, surf->plane);
+ if (surf->flags & SURF_PLANEBACK)
+ f = -f;
+ // draw shadows only for backfaces
+ projectdistance = lightradius + f;
+ if (projectdistance >= 0.1 && projectdistance < lightradius)
{
- for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ VectorSubtract(relativelightorigin, surf->poly_center, temp);
+ if (DotProduct(temp, temp) < (surf->poly_radius2 + lightradius2))
{
- R_Mesh_ResizeCheck(mesh->numverts * 2);
- memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- R_Shadow_Volume(mesh->numverts, mesh->numtriangles, varray_vertex, mesh->index, mesh->triangleneighbors, relativelightorigin, lightradius, projectdistance, visiblevolume);
+ for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ {
+ R_Mesh_ResizeCheck(mesh->numverts * 2);
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ R_Shadow_Volume(mesh->numverts, mesh->numtriangles, varray_vertex, mesh->index, mesh->triangleneighbors, relativelightorigin, lightradius, projectdistance, visiblevolume);
+ }
}
}
}
GL_UseColorArray();
for (i = 0, surf = ent->model->surfaces + ent->model->firstmodelsurface;i < ent->model->nummodelsurfaces;i++, surf++)
{
- f = PlaneDiff(relativelightorigin, surf->plane);
- if (surf->flags & SURF_PLANEBACK)
- f = -f;
- if (f >= -0.1 && f < lightradius)
+ if (surf->flags & SURF_SHADOWLIGHT)
{
- f = PlaneDiff(modelorg, surf->plane);
+ f = PlaneDiff(relativelightorigin, surf->plane);
if (surf->flags & SURF_PLANEBACK)
f = -f;
- if (f > 0)
+ if (f >= -0.1 && f < lightradius)
{
- for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ f = PlaneDiff(modelorg, surf->plane);
+ if (surf->flags & SURF_PLANEBACK)
+ f = -f;
+ if (f > 0)
{
- R_Mesh_ResizeCheck(mesh->numverts);
- memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
- R_Shadow_Light(mesh->numverts, mesh->normals, relativelightorigin, lightradius, lightdistbias, lightsubtract, lightcolor);
- R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
+ for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ {
+ R_Mesh_ResizeCheck(mesh->numverts);
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ R_Shadow_Light(mesh->numverts, mesh->normals, relativelightorigin, lightradius, lightdistbias, lightsubtract, lightcolor);
+ R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
+ }
}
}
}
{
tx->flags |= SURF_LIGHTMAP;
if (!tx->fogtexture)
- tx->flags |= SURF_CLIPSOLID;
+ tx->flags |= SURF_SHADOWCAST | SURF_SHADOWLIGHT;
tx->shader = &Cshader_wall_lightmap;
}
qbyte *pvs;
for (lnum = 0, e = loadmodel->lights;lnum < loadmodel->numlights;lnum++, e++)
{
- e->cullradius2 = DotProduct(e->light, e->light) * (1.0f / (8192.0f * 8192.0f)) / (e->falloff * e->falloff) + 4096.0f;
+ e->cullradius2 = DotProduct(e->light, e->light) / (e->falloff * e->falloff * 8192.0f * 8192.0f);// + 4096.0f;
if (e->cullradius2 > 4096.0f * 4096.0f)
e->cullradius2 = 4096.0f * 4096.0f;
e->cullradius = sqrt(e->cullradius2);
svworld = Mod_ShadowBrush_NewWorld(loadmodel->mempool);
for (j = 0, surf = loadmodel->surfaces + loadmodel->firstmodelsurface;j < loadmodel->nummodelsurfaces;j++, surf++)
{
- if (!(surf->flags & SURF_CLIPSOLID))
+ if (!(surf->flags & SURF_SHADOWCAST))
continue;
f = DotProduct(e->origin, surf->plane->normal) - surf->plane->dist;
if (surf->flags & SURF_PLANEBACK)
#if 1
for (j = 0, surf = loadmodel->surfaces + loadmodel->firstmodelsurface;j < loadmodel->nummodelsurfaces;j++, surf++)
{
- if (!(surf->flags & SURF_CLIPSOLID))
+ if (!(surf->flags & SURF_SHADOWCAST))
continue;
/*
if (surf->poly_maxs[0] < e->mins[0]
for (j = 0;j < e->numsurfaces;j++)
{
surf = e->surfaces[j];
- if (!(surf->flags & SURF_CLIPSOLID))
+ if (!(surf->flags & SURF_SHADOWCAST))
continue;
f = DotProduct(e->origin, surf->plane->normal) - surf->plane->dist;
if (surf->flags & SURF_PLANEBACK)
// (only used for shadow volumes)
mod->shadowmesh = Mod_ShadowMesh_Begin(originalloadmodel->mempool);
for (j = 0, surf = &mod->surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surf++)
- if (surf->flags & SURF_CLIPSOLID)
+ if (surf->flags & SURF_SHADOWCAST)
Mod_ShadowMesh_AddPolygon(originalloadmodel->mempool, mod->shadowmesh, surf->poly_numverts, surf->poly_verts);
mod->shadowmesh = Mod_ShadowMesh_Finish(originalloadmodel->mempool, mod->shadowmesh);
Mod_ShadowMesh_CalcBBox(mod->shadowmesh, mod->shadowmesh_mins, mod->shadowmesh_maxs, mod->shadowmesh_center, &mod->shadowmesh_radius);
rtexture_t *r_shadow_attenuationtexture;
cvar_t r_shadow1 = {0, "r_shadow1", "16"};
-cvar_t r_shadow2 = {0, "r_shadow2", "2"};
+cvar_t r_shadow2 = {0, "r_shadow2", "4"};
cvar_t r_shadow3 = {0, "r_shadow3", "65536"};
cvar_t r_shadow4 = {0, "r_shadow4", "1"};
-cvar_t r_shadow5 = {0, "r_shadow5", "0.05"};
+cvar_t r_shadow5 = {0, "r_shadow5", "0"};
cvar_t r_shadow6 = {0, "r_shadow6", "1"};
void r_shadow_start(void)
qglColorMask(0, 0, 0, 0);
qglDisable(GL_BLEND);
qglDepthMask(0);
- qglDepthFunc(GL_LEQUAL);
+ qglDepthFunc(GL_LESS);
qglClearStencil(0);
qglClear(GL_STENCIL_BUFFER_BIT);
qglEnable(GL_STENCIL_TEST);