refdef_t r_refdef;
cvar_t r_showtris = {0, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"};
+cvar_t r_showtris_polygonoffset = {0, "r_showtris_polygonoffset", "-10", "nudges triangle outlines in hardware depth units, used to make outlines appear infront of walls"};
cvar_t r_shownormals = {0, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"};
+cvar_t r_showlighting = {0, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"};
+cvar_t r_showshadowvolumes = {0, "r_showshadowvolumes", "0", "shows areas shadowed by lights, useful for finding out why some areas of a map render slowly (bright blue = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"};
+cvar_t r_showcollisionbrushes = {0, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"};
+cvar_t r_showcollisionbrushes_polygonfactor = {0, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"};
+cvar_t r_showcollisionbrushes_polygonoffset = {0, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"};
+cvar_t r_showdisabledepthtest = {0, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing\n"};
cvar_t r_drawentities = {0, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"};
cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1", "draw your weapon model"};
cvar_t r_speeds = {0, "r_speeds","0", "displays rendering statistics and per-subsystem timings"};
cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1", "opacity of water polygons"};
cvar_t r_dynamic = {CVAR_SAVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"};
cvar_t r_fullbrights = {CVAR_SAVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"};
-cvar_t r_drawcollisionbrushes = {0, "r_drawcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"};
cvar_t gl_fogenable = {0, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"};
cvar_t gl_fogdensity = {0, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"};
// FIXME: move this to client?
FOG_registercvars();
Cvar_RegisterVariable(&r_showtris);
+ Cvar_RegisterVariable(&r_showtris_polygonoffset);
Cvar_RegisterVariable(&r_shownormals);
+ Cvar_RegisterVariable(&r_showlighting);
+ Cvar_RegisterVariable(&r_showshadowvolumes);
+ Cvar_RegisterVariable(&r_showcollisionbrushes);
+ Cvar_RegisterVariable(&r_showcollisionbrushes_polygonfactor);
+ Cvar_RegisterVariable(&r_showcollisionbrushes_polygonoffset);
+ Cvar_RegisterVariable(&r_showdisabledepthtest);
Cvar_RegisterVariable(&r_drawentities);
Cvar_RegisterVariable(&r_drawviewmodel);
Cvar_RegisterVariable(&r_speeds);
Cvar_RegisterVariable(&r_lerpsprites);
Cvar_RegisterVariable(&r_lerpmodels);
Cvar_RegisterVariable(&r_waterscroll);
- Cvar_RegisterVariable(&r_drawcollisionbrushes);
Cvar_RegisterVariable(&r_bloom);
Cvar_RegisterVariable(&r_bloom_intensity);
Cvar_RegisterVariable(&r_bloom_blur);
R_MeshQueue_BeginScene();
- GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
-
R_SetFrustum();
r_farclip = R_FarClip(r_vieworigin, r_viewforward, 768.0f) + 256.0f;
R_Shadow_UpdateWorldLightSelection();
- // don't let sound skip if going slow
- if (r_refdef.extraupdate)
- S_ExtraUpdate ();
-
- if (cl.csqc_vidvars.drawworld)
+ for (r_showtrispass = 0;r_showtrispass <= (r_showtris.value > 0);r_showtrispass++)
{
- GL_ShowTrisColor(0.025, 0.025, 0, 1);
- if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky)
+ if (r_showtrispass)
{
- r_refdef.worldmodel->DrawSky(r_refdef.worldentity);
- R_TimeReport("worldsky");
+ rmeshstate_t m;
+ r_showtrispass = 0;
+ GL_BlendFunc(GL_ONE, GL_ONE);
+ GL_DepthTest(!r_showdisabledepthtest.integer);
+ GL_DepthMask(GL_FALSE);
+ memset(&m, 0, sizeof(m));
+ R_Mesh_State(&m);
+ //qglEnable(GL_LINE_SMOOTH);
+ qglEnable(GL_POLYGON_OFFSET_LINE);
+ qglPolygonOffset(0, r_showtris_polygonoffset.value);
+ r_showtrispass = 1;
}
- if (R_DrawBrushModelsSky())
- R_TimeReport("bmodelsky");
-
- GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
- if (r_refdef.worldmodel && r_refdef.worldmodel->Draw)
+ if (cl.csqc_vidvars.drawworld)
{
- r_refdef.worldmodel->Draw(r_refdef.worldentity);
- R_TimeReport("world");
+ // don't let sound skip if going slow
+ if (r_refdef.extraupdate)
+ S_ExtraUpdate ();
+
+ GL_ShowTrisColor(0.025, 0.025, 0, 1);
+ if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky)
+ {
+ r_refdef.worldmodel->DrawSky(r_refdef.worldentity);
+ R_TimeReport("worldsky");
+ }
+
+ if (R_DrawBrushModelsSky())
+ R_TimeReport("bmodelsky");
+
+ GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
+ if (r_refdef.worldmodel && r_refdef.worldmodel->Draw)
+ {
+ r_refdef.worldmodel->Draw(r_refdef.worldentity);
+ R_TimeReport("world");
+ }
}
- }
- // don't let sound skip if going slow
- if (r_refdef.extraupdate)
- S_ExtraUpdate ();
+ // don't let sound skip if going slow
+ if (r_refdef.extraupdate)
+ S_ExtraUpdate ();
- GL_ShowTrisColor(0, 0.015, 0, 1);
+ GL_ShowTrisColor(0, 0.015, 0, 1);
- R_DrawModels();
- R_TimeReport("models");
+ R_DrawModels();
+ R_TimeReport("models");
- // don't let sound skip if going slow
- if (r_refdef.extraupdate)
- S_ExtraUpdate ();
+ // don't let sound skip if going slow
+ if (r_refdef.extraupdate)
+ S_ExtraUpdate ();
- GL_ShowTrisColor(0, 0, 0.033, 1);
- R_ShadowVolumeLighting(false);
- R_TimeReport("rtlights");
+ GL_ShowTrisColor(0, 0, 0.033, 1);
+ R_ShadowVolumeLighting(false);
+ R_TimeReport("rtlights");
- // don't let sound skip if going slow
- if (r_refdef.extraupdate)
- S_ExtraUpdate ();
+ // don't let sound skip if going slow
+ if (r_refdef.extraupdate)
+ S_ExtraUpdate ();
- GL_ShowTrisColor(0.1, 0, 0, 1);
+ GL_ShowTrisColor(0.1, 0, 0, 1);
- if (cl.csqc_vidvars.drawworld)
- {
- R_DrawLightningBeams();
- R_TimeReport("lightning");
+ if (cl.csqc_vidvars.drawworld)
+ {
+ R_DrawLightningBeams();
+ R_TimeReport("lightning");
- R_DrawParticles();
- R_TimeReport("particles");
+ R_DrawParticles();
+ R_TimeReport("particles");
- R_DrawExplosions();
- R_TimeReport("explosions");
- }
+ R_DrawExplosions();
+ R_TimeReport("explosions");
+ }
- R_MeshQueue_RenderTransparent();
- R_TimeReport("drawtrans");
+ R_MeshQueue_RenderTransparent();
+ R_TimeReport("drawtrans");
- if (cl.csqc_vidvars.drawworld)
- {
- R_DrawCoronas();
- R_TimeReport("coronas");
- }
- if(cl.csqc_vidvars.drawcrosshair)
- {
- R_DrawWorldCrosshair();
- R_TimeReport("crosshair");
- }
+ if (cl.csqc_vidvars.drawworld)
+ {
+ R_DrawCoronas();
+ R_TimeReport("coronas");
+ }
+ if(cl.csqc_vidvars.drawcrosshair)
+ {
+ R_DrawWorldCrosshair();
+ R_TimeReport("crosshair");
+ }
- VM_AddPolygonsToMeshQueue();
+ VM_AddPolygonsToMeshQueue();
- R_MeshQueue_Render();
- R_MeshQueue_EndScene();
+ R_MeshQueue_Render();
- if ((r_shadow_visiblelighting.integer || r_shadow_visiblevolumes.integer) && !r_showtrispass)
- {
- R_ShadowVolumeLighting(true);
- R_TimeReport("visiblevolume");
+ if (r_showtrispass)
+ {
+ //qglDisable(GL_LINE_SMOOTH);
+ qglDisable(GL_POLYGON_OFFSET_LINE);
+ }
}
- GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
+ r_showtrispass = 0;
+
+ R_MeshQueue_EndScene();
// don't let sound skip if going slow
if (r_refdef.extraupdate)
{
if (planenum2 == planenum)
continue;
- PolygonF_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, 1.0/32.0, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints);
+ PolygonF_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, 1.0/32.0, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints, NULL);
w = !w;
}
if (tempnumpoints < 3)
int layerflags = 0;
if (fogenabled && (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
layerflags |= TEXTURELAYERFLAG_FOGDARKEN;
- currentbasetexture = (ent->colormap < 0 && t->skin.merged) ? t->skin.merged : t->skin.base;
+ currentbasetexture = (VectorLength2(ent->colormap_pantscolor) + VectorLength2(ent->colormap_shirtcolor) < (1.0f / 1048576.0f) && t->skin.merged) ? t->skin.merged : t->skin.base;
if (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)
{
// fullbright is not affected by r_lightmapintensity
R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0], ent->colormod[1], ent->colormod[2], t->currentalpha);
- if (ent->colormap >= 0 && t->skin.pants)
- R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0], ent->colormap_pantscolor[1], ent->colormap_pantscolor[2], t->currentalpha);
- if (ent->colormap >= 0 && t->skin.shirt)
- R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0], ent->colormap_shirtcolor[1], ent->colormap_shirtcolor[2], t->currentalpha);
+ if (VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f) && t->skin.pants)
+ R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0], ent->colormap_pantscolor[1] * ent->colormod[1], ent->colormap_pantscolor[2] * ent->colormod[2], t->currentalpha);
+ if (VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f) && t->skin.shirt)
+ R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0], ent->colormap_shirtcolor[1] * ent->colormod[1], ent->colormap_shirtcolor[2] * ent->colormod[2], t->currentalpha);
}
else
{
R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * colorscale, ent->colormod[1] * colorscale, ent->colormod[2] * colorscale, t->currentalpha);
if (r_ambient.value >= (1.0f/64.0f))
R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha);
- if (ent->colormap >= 0 && t->skin.pants)
+ if (VectorLength2(ent->colormap_pantscolor) >= (1.0f / 1048576.0f) && t->skin.pants)
{
- R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * colorscale, ent->colormap_pantscolor[1] * colorscale, ent->colormap_pantscolor[2] * colorscale, t->currentalpha);
+ R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0] * colorscale, ent->colormap_pantscolor[1] * ent->colormod[1] * colorscale, ent->colormap_pantscolor[2] * ent->colormod[2] * colorscale, t->currentalpha);
if (r_ambient.value >= (1.0f/64.0f))
- R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha);
+ R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[1] * ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[2] * ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha);
}
- if (ent->colormap >= 0 && t->skin.shirt)
+ if (VectorLength2(ent->colormap_shirtcolor) >= (1.0f / 1048576.0f) && t->skin.shirt)
{
- R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * colorscale, ent->colormap_shirtcolor[1] * colorscale, ent->colormap_shirtcolor[2] * colorscale, t->currentalpha);
+ R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0] * colorscale, ent->colormap_shirtcolor[1] * ent->colormod[1] * colorscale, ent->colormap_shirtcolor[2] * ent->colormod[2] * colorscale, t->currentalpha);
if (r_ambient.value >= (1.0f/64.0f))
- R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha);
+ R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[1] * ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[2] * ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), t->currentalpha);
}
}
if (t->skin.glow != NULL)
{
int j, k;
float v[3];
- GL_DepthTest(true);
+ GL_DepthTest(!r_showdisabledepthtest.integer);
GL_DepthMask(texture->currentlayers->depthmask);
GL_BlendFunc(texture->currentlayers->blendfunc1, texture->currentlayers->blendfunc2);
memset(&m, 0, sizeof(m));