t->specularscale = 0;
}
- t->currentpolygonfactor = r_refdef.polygonfactor + t->basepolygonfactor;
- t->currentpolygonoffset = r_refdef.polygonoffset + t->basepolygonoffset;
- // submodels are biased to avoid z-fighting with world surfaces that they
- // may be exactly overlapping (avoids z-fighting artifacts on certain
- // doors and things in Quake maps)
- if (ent->model->brush.submodel)
- {
- t->currentpolygonfactor += r_polygonoffset_submodel_factor.value;
- t->currentpolygonoffset += r_polygonoffset_submodel_offset.value;
- }
-
VectorClear(t->dlightcolor);
t->currentnumlayers = 0;
if (!(t->currentmaterialflags & MATERIALFLAG_NODRAW))
rsurface.frameblend[1] = ent->frameblend[1];
rsurface.frameblend[2] = ent->frameblend[2];
rsurface.frameblend[3] = ent->frameblend[3];
+ rsurface.basepolygonfactor = r_refdef.polygonfactor;
+ rsurface.basepolygonoffset = r_refdef.polygonoffset;
+ if (ent->model->brush.submodel)
+ {
+ rsurface.basepolygonfactor += r_polygonoffset_submodel_factor.value;
+ rsurface.basepolygonoffset += r_polygonoffset_submodel_offset.value;
+ }
if (model->surfmesh.isanimated && (rsurface.frameblend[0].lerp != 1 || rsurface.frameblend[0].frame != 0))
{
if (wanttangents)
RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
}
-static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, msurface_t **texturesurfacelist)
+void RSurf_SetupDepthAndCulling(void)
{
+ // submodels are biased to avoid z-fighting with world surfaces that they
+ // may be exactly overlapping (avoids z-fighting artifacts on certain
+ // doors and things in Quake maps)
GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
- GL_PolygonOffset(rsurface.texture->currentpolygonfactor, rsurface.texture->currentpolygonoffset);
+ GL_PolygonOffset(rsurface.basepolygonfactor + rsurface.texture->biaspolygonfactor, rsurface.basepolygonoffset + rsurface.texture->biaspolygonoffset);
GL_DepthTest(!(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
+}
+
+static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, msurface_t **texturesurfacelist)
+{
+ RSurf_SetupDepthAndCulling();
if (rsurface.mode != RSURFMODE_SHOWSURFACES)
{
rsurface.mode = RSURFMODE_SHOWSURFACES;
// restore entity matrix
R_Mesh_Matrix(&rsurface.matrix);
}
- GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
- GL_PolygonOffset(rsurface.texture->currentpolygonfactor, rsurface.texture->currentpolygonoffset);
- GL_DepthTest(!(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
- GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
+ RSurf_SetupDepthAndCulling();
GL_DepthMask(true);
// LordHavoc: HalfLife maps have freaky skypolys so don't use
// skymasking on them, and Quake3 never did sky masking (unlike
GL_ColorMask(0,0,0,0);
GL_Color(1,1,1,1);
}
- GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
- GL_PolygonOffset(rsurface.texture->currentpolygonfactor, rsurface.texture->currentpolygonoffset);
- GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
+ RSurf_SetupDepthAndCulling();
GL_DepthTest(true);
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(true);
{
if (rsurface.mode != RSURFMODE_MULTIPASS)
rsurface.mode = RSURFMODE_MULTIPASS;
- GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
- GL_PolygonOffset(rsurface.texture->currentpolygonfactor, rsurface.texture->currentpolygonoffset);
+ RSurf_SetupDepthAndCulling();
GL_DepthTest(true);
- GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_DepthMask(writedepth);
GL_Color(1,1,1,1);
// write depth for anything we skipped on the depth-only pass earlier
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
writedepth = true;
- GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
- GL_PolygonOffset(rsurface.texture->currentpolygonfactor, rsurface.texture->currentpolygonoffset);
- GL_DepthTest(!(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
- GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_view.cullface_back);
+ RSurf_SetupDepthAndCulling();
GL_BlendFunc(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
GL_DepthMask(writedepth && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_BLENDED));
GL_AlphaTest((rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);