cvar_t r_floatbuildlightmap = {0, "r_floatbuildlightmap", "0"};
cvar_t r_detailtextures = {CVAR_SAVE, "r_detailtextures", "1"};
cvar_t r_surfaceworldnode = {0, "r_surfaceworldnode", "1"};
-cvar_t r_drawcollisionbrushes_polygonoffset = {0, "r_drawcollisionbrushes_polygonoffset", "-4"};
+cvar_t r_drawcollisionbrushes_polygonfactor = {0, "r_drawcollisionbrushes_polygonfactor", "-1"};
+cvar_t r_drawcollisionbrushes_polygonoffset = {0, "r_drawcollisionbrushes_polygonoffset", "0"};
static int dlightdivtable[32768];
{
rmeshstate_t m;
memset(&m, 0, sizeof(m));
- GL_BlendFunc(GL_ONE, GL_SRC_COLOR);
+ GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
GL_DepthMask(true);
GL_DepthTest(true);
m.tex[0] = R_GetTexture(face->lightmaptexture);
{
int i;
q3mleaf_t *leaf;
- while (node->isnode)
+ for (;;)
{
if (R_CullBox(node->mins, node->maxs))
return;
+ if (!node->plane)
+ break;
c_nodes++;
R_Q3BSP_RecursiveWorldNode(ent, node->children[0], modelorg, pvs, markframe);
node = node->children[1];
}
- if (R_CullBox(node->mins, node->maxs))
- return;
- c_leafs++;
leaf = (q3mleaf_t *)node;
if (pvs[leaf->clusterindex >> 3] & (1 << (leaf->clusterindex & 7)))
+ {
+ c_leafs++;
for (i = 0;i < leaf->numleaffaces;i++)
leaf->firstleafface[i]->markframe = markframe;
+ }
+}
+
+// FIXME: num_leafs needs to be recalculated at load time to include only
+// node-referenced leafs, as some maps are incorrectly compiled with leafs for
+// the submodels (which would render the submodels occasionally, as part of
+// the world - not good)
+void R_Q3BSP_MarkLeafPVS(entity_render_t *ent, qbyte *pvs, int markframe)
+{
+ int i, j;
+ q3mleaf_t *leaf;
+ for (j = 0, leaf = ent->model->brushq3.data_leafs;j < ent->model->brushq3.num_leafs;j++, leaf++)
+ {
+ if (pvs[leaf->clusterindex >> 3] & (1 << (leaf->clusterindex & 7)))
+ {
+ c_leafs++;
+ for (i = 0;i < leaf->numleaffaces;i++)
+ leaf->firstleafface[i]->markframe = markframe;
+ }
+ }
}
static int r_q3bsp_framecount = -1;
{
r_q3bsp_framecount = r_framecount;
R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, r_framecount);
+ //R_Q3BSP_MarkLeafPVS(ent, pvs, r_framecount);
}
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
if (face->markframe == r_framecount && (face->texture->surfaceflags & Q3SURFACEFLAG_SKY) && !R_CullBox(face->mins, face->maxs))
{
r_q3bsp_framecount = r_framecount;
R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, r_framecount);
+ //R_Q3BSP_MarkLeafPVS(ent, pvs, r_framecount);
}
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
if (face->markframe == r_framecount && !R_CullBox(face->mins, face->maxs))
GL_DepthMask(false);
GL_DepthTest(true);
R_Mesh_State_Texture(&m);
+ qglPolygonOffset(r_drawcollisionbrushes_polygonfactor.value, r_drawcollisionbrushes_polygonoffset.value);
for (i = 0;i < model->brushq3.data_thismodel->numbrushes;i++)
if (model->brushq3.data_thismodel->firstbrush[i].colbrushf && model->brushq3.data_thismodel->firstbrush[i].colbrushf->numtriangles)
R_DrawCollisionBrush(model->brushq3.data_thismodel->firstbrush[i].colbrushf);
+ qglPolygonOffset(0, 0);
}
}
Cvar_RegisterVariable(&r_floatbuildlightmap);
Cvar_RegisterVariable(&r_detailtextures);
Cvar_RegisterVariable(&r_surfaceworldnode);
+ Cvar_RegisterVariable(&r_drawcollisionbrushes_polygonfactor);
Cvar_RegisterVariable(&r_drawcollisionbrushes_polygonoffset);
R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown, gl_surf_newmap);
cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1"};
cvar_t r_shadow_bumpscale_bumpmap = {0, "r_shadow_bumpscale_bumpmap", "4"};
cvar_t r_shadow_bumpscale_basetexture = {0, "r_shadow_bumpscale_basetexture", "0"};
-cvar_t r_shadow_polygonoffset = {0, "r_shadow_polygonoffset", "0"};
+cvar_t r_shadow_polygonfactor = {0, "r_shadow_polygonfactor", "0"};
+cvar_t r_shadow_polygonoffset = {0, "r_shadow_polygonoffset", "1"};
cvar_t r_shadow_portallight = {0, "r_shadow_portallight", "1"};
cvar_t r_shadow_projectdistance = {0, "r_shadow_projectdistance", "10000"};
cvar_t r_shadow_texture3d = {0, "r_shadow_texture3d", "1"};
"r_shadow_scissor : use scissor optimization\n"
"r_shadow_bumpscale_bumpmap : depth scale for bumpmap conversion\n"
"r_shadow_bumpscale_basetexture : base texture as bumpmap with this scale\n"
+"r_shadow_polygonfactor : nudge shadow volumes closer/further\n"
"r_shadow_polygonoffset : nudge shadow volumes closer/further\n"
"r_shadow_portallight : use portal visibility for static light precomputation\n"
"r_shadow_projectdistance : shadow volume projection distance\n"
Cvar_RegisterVariable(&r_shadow_scissor);
Cvar_RegisterVariable(&r_shadow_bumpscale_bumpmap);
Cvar_RegisterVariable(&r_shadow_bumpscale_basetexture);
+ Cvar_RegisterVariable(&r_shadow_polygonfactor);
Cvar_RegisterVariable(&r_shadow_polygonoffset);
Cvar_RegisterVariable(&r_shadow_portallight);
Cvar_RegisterVariable(&r_shadow_projectdistance);
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(false);
GL_DepthTest(true);
- if (r_shadow_polygonoffset.value != 0)
- {
- qglPolygonOffset(1.0f, r_shadow_polygonoffset.value);
- qglEnable(GL_POLYGON_OFFSET_FILL);
- }
- else
- qglDisable(GL_POLYGON_OFFSET_FILL);
+ qglPolygonOffset(r_shadow_polygonfactor.value, r_shadow_polygonoffset.value);
+ //if (r_shadow_polygonoffset.value != 0)
+ //{
+ // qglPolygonOffset(r_shadow_polygonfactor.value, r_shadow_polygonoffset.value);
+ // qglEnable(GL_POLYGON_OFFSET_FILL);
+ //}
+ //else
+ // qglDisable(GL_POLYGON_OFFSET_FILL);
qglDepthFunc(GL_LESS);
qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
qglEnable(GL_STENCIL_TEST);
GL_BlendFunc(GL_ONE, GL_ONE);
GL_DepthMask(false);
GL_DepthTest(true);
- qglDisable(GL_POLYGON_OFFSET_FILL);
+ qglPolygonOffset(0, 0);
+ //qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
qglColorMask(1, 1, 1, 1);
qglDepthFunc(GL_EQUAL);
GL_BlendFunc(GL_ONE, GL_ONE);
GL_DepthMask(false);
GL_DepthTest(true);
- qglDisable(GL_POLYGON_OFFSET_FILL);
+ qglPolygonOffset(0, 0);
+ //qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
qglColorMask(1, 1, 1, 1);
qglDepthFunc(GL_EQUAL);
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(true);
GL_DepthTest(true);
- qglDisable(GL_POLYGON_OFFSET_FILL);
+ qglPolygonOffset(0, 0);
+ //qglDisable(GL_POLYGON_OFFSET_FILL);
GL_Color(1, 1, 1, 1);
qglColorMask(1, 1, 1, 1);
qglDisable(GL_SCISSOR_TEST);