From 0f3e880c9e2d7f490bfb4e8a1c318bd7428a695b Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 22 Feb 2006 10:02:25 +0000 Subject: [PATCH] changed behavior of r_showtris (now only affects geometry in the game view, not sky, not hud, and not bloom) added r_showtris_polygonoffset (doesn't seem to work, for unknown reasons) renamed r_drawcollisionbrushes to r_showcollisionbrushes and got rid of its mode 2 behavior (which was trippy but not all that useful) added r_showdisabledepthtest cvar which disables depth testing on the debugging geometry produced by r_show* cvars renamed r_shadow_visiblelighting/volumes cvars to r_showlighting/shadowvolumes (and they no longer have a mode 2, use r_showdisabledepthtesting to get the same effect instead) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6002 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_backend.c | 168 ++++++++++++++++++++------------------------------- gl_rmain.c | 162 ++++++++++++++++++++++++++++--------------------- gl_rsurf.c | 20 ++---- r_shadow.c | 86 ++++++++++++++------------ r_shadow.h | 2 - render.h | 9 ++- 6 files changed, 221 insertions(+), 226 deletions(-) diff --git a/gl_backend.c b/gl_backend.c index 13efbd30..8e4ec158 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -628,7 +628,7 @@ void GL_DepthTest(int state) { if (gl_state.depthtest != state) { - if (r_showtrispass) + if (r_showtrispass && r_showdisabledepthtest.integer) return; gl_state.depthtest = state; if (gl_state.depthtest) @@ -647,8 +647,6 @@ void GL_ColorMask(int r, int g, int b, int a) int state = r*8 + g*4 + b*2 + a*1; if (gl_state.colormask != state) { - if (r_showtrispass) - return; gl_state.colormask = state; qglColorMask((GLboolean)r, (GLboolean)g, (GLboolean)b, (GLboolean)a);CHECKGLERROR } @@ -674,9 +672,9 @@ void GL_ShowTrisColor(float cr, float cg, float cb, float ca) { if (!r_showtrispass) return; - r_showtrispass = false; + r_showtrispass = 0; GL_Color(cr * r_showtris.value, cg * r_showtris.value, cb * r_showtris.value, ca); - r_showtrispass = true; + r_showtrispass = 1; } @@ -724,8 +722,10 @@ void GL_ScissorTest(int state) void GL_Clear(int mask) { + // in showtris rendering, don't clear the color buffer as that would hide + // the accumulated lines if (r_showtrispass) - return; + mask &= ~GL_COLOR_BUFFER_BIT; qglClear(mask);CHECKGLERROR } @@ -1740,104 +1740,85 @@ int r_stereo_side; void SCR_DrawScreen (void) { - for (r_showtrispass = 0;r_showtrispass <= (r_showtris.value > 0);r_showtrispass++) + R_Mesh_Start(); + + R_TimeReport("setup"); + + if (cls.signon == SIGNONS) { - R_Mesh_Start(); + float size; - R_TimeReport("setup"); + size = scr_viewsize.value * (1.0 / 100.0); + size = min(size, 1); - if (r_showtrispass) + if (r_stereo_sidebyside.integer) { - rmeshstate_t m; - r_showtrispass = 0; - GL_BlendFunc(GL_ONE, GL_ONE); - GL_DepthTest(GL_FALSE); - GL_DepthMask(GL_FALSE); - memset(&m, 0, sizeof(m)); - R_Mesh_State(&m); - //qglEnable(GL_LINE_SMOOTH); - GL_ShowTrisColor(0.2,0.2,0.2,1); - r_showtrispass = 1; + r_refdef.width = vid.width * size / 2.5; + r_refdef.height = vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100); + r_refdef.x = (vid.width - r_refdef.width * 2.5) * 0.5; + r_refdef.y = (vid.height - r_refdef.height)/2; + if (r_stereo_side) + r_refdef.x += r_refdef.width * 1.5; } - - if (cls.signon == SIGNONS) + else { - float size; + r_refdef.width = vid.width * size; + r_refdef.height = vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100); + r_refdef.x = (vid.width - r_refdef.width)/2; + r_refdef.y = (vid.height - r_refdef.height)/2; + } - size = scr_viewsize.value * (1.0 / 100.0); - size = min(size, 1); + // LordHavoc: viewzoom (zoom in for sniper rifles, etc) + // LordHavoc: this is designed to produce widescreen fov values + // when the screen is wider than 4/3 width/height aspect, to do + // this it simply assumes the requested fov is the vertical fov + // for a 4x3 display, if the ratio is not 4x3 this makes the fov + // higher/lower according to the ratio + r_refdef.frustum_y = tan(scr_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0); + r_refdef.frustum_x = r_refdef.frustum_y * (float)r_refdef.width / (float)r_refdef.height / vid_pixelheight.value; - if (r_stereo_sidebyside.integer) - { - r_refdef.width = vid.width * size / 2.5; - r_refdef.height = vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100); - r_refdef.x = (vid.width - r_refdef.width * 2.5) * 0.5; - r_refdef.y = (vid.height - r_refdef.height)/2; - if (r_stereo_side) - r_refdef.x += r_refdef.width * 1.5; - } - else - { - r_refdef.width = vid.width * size; - r_refdef.height = vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100); - r_refdef.x = (vid.width - r_refdef.width)/2; - r_refdef.y = (vid.height - r_refdef.height)/2; - } + r_refdef.frustum_x *= r_refdef.frustumscale_x; + r_refdef.frustum_y *= r_refdef.frustumscale_y; + + if(!CL_VM_UpdateView()) + R_RenderView(); + else + SCR_DrawConsole(); + + if (scr_zoomwindow.integer) + { + float sizex = bound(10, scr_zoomwindow_viewsizex.value, 100) / 100.0; + float sizey = bound(10, scr_zoomwindow_viewsizey.value, 100) / 100.0; + r_refdef.width = vid.width * sizex; + r_refdef.height = vid.height * sizey; + r_refdef.x = (vid.width - r_refdef.width)/2; + r_refdef.y = 0; - // LordHavoc: viewzoom (zoom in for sniper rifles, etc) - // LordHavoc: this is designed to produce widescreen fov values - // when the screen is wider than 4/3 width/height aspect, to do - // this it simply assumes the requested fov is the vertical fov - // for a 4x3 display, if the ratio is not 4x3 this makes the fov - // higher/lower according to the ratio - r_refdef.frustum_y = tan(scr_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0); - r_refdef.frustum_x = r_refdef.frustum_y * (float)r_refdef.width / (float)r_refdef.height / vid_pixelheight.value; + r_refdef.frustum_y = tan(scr_zoomwindow_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0); + r_refdef.frustum_x = r_refdef.frustum_y * vid_pixelheight.value * (float)r_refdef.width / (float)r_refdef.height; r_refdef.frustum_x *= r_refdef.frustumscale_x; r_refdef.frustum_y *= r_refdef.frustumscale_y; if(!CL_VM_UpdateView()) R_RenderView(); - else - SCR_DrawConsole(); - - if (scr_zoomwindow.integer) - { - float sizex = bound(10, scr_zoomwindow_viewsizex.value, 100) / 100.0; - float sizey = bound(10, scr_zoomwindow_viewsizey.value, 100) / 100.0; - r_refdef.width = vid.width * sizex; - r_refdef.height = vid.height * sizey; - r_refdef.x = (vid.width - r_refdef.width)/2; - r_refdef.y = 0; - - r_refdef.frustum_y = tan(scr_zoomwindow_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0); - r_refdef.frustum_x = r_refdef.frustum_y * vid_pixelheight.value * (float)r_refdef.width / (float)r_refdef.height; - - r_refdef.frustum_x *= r_refdef.frustumscale_x; - r_refdef.frustum_y *= r_refdef.frustumscale_y; - - if(!CL_VM_UpdateView()) - R_RenderView(); - } } + } - if (!r_stereo_sidebyside.integer) - { - r_refdef.width = vid.width; - r_refdef.height = vid.height; - r_refdef.x = 0; - r_refdef.y = 0; - } + if (!r_stereo_sidebyside.integer) + { + r_refdef.width = vid.width; + r_refdef.height = vid.height; + r_refdef.x = 0; + r_refdef.y = 0; + } - // draw 2D stuff - R_DrawQueue(); + // draw 2D stuff + R_DrawQueue(); - R_Mesh_Finish(); + R_Mesh_Finish(); - R_TimeReport("meshfinish"); - } - r_showtrispass = 0; - //qglDisable(GL_LINE_SMOOTH); + R_TimeReport("meshfinish"); } void SCR_UpdateLoadingScreen (void) @@ -1912,6 +1893,8 @@ void SCR_UpdateScreen (void) if (gl_combine.integer && !gl_combine_extension) Cvar_SetValueQuick(&gl_combine, 0); + r_showtrispass = 0; + CHECKGLERROR qglViewport(0, 0, vid.width, vid.height); qglDisable(GL_SCISSOR_TEST); @@ -1961,25 +1944,8 @@ void SCR_UpdateScreen (void) r_refdef.viewentitymatrix = originalmatrix; } else - { - r_showtrispass = false; SCR_DrawScreen(); - if (r_showtris.value > 0) - { - rmeshstate_t m; - GL_BlendFunc(GL_ONE, GL_ONE); - GL_DepthTest(GL_FALSE); - GL_DepthMask(GL_FALSE); - memset(&m, 0, sizeof(m)); - R_Mesh_State(&m); - r_showtrispass = true; - GL_ShowTrisColor(0.2,0.2,0.2,1); - SCR_DrawScreen(); - r_showtrispass = false; - } - } - VID_Finish(); R_TimeReport("finish"); } diff --git a/gl_rmain.c b/gl_rmain.c index 1f504139..fa49f791 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -70,7 +70,14 @@ matrix4x4_t r_view_matrix; 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"}; @@ -78,7 +85,6 @@ cvar_t r_fullbright = {0, "r_fullbright","0", "make everything bright cheat (not 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)"}; @@ -448,7 +454,14 @@ void GL_Main_Init(void) // 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); @@ -460,7 +473,6 @@ void GL_Main_Init(void) 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); @@ -1159,8 +1171,6 @@ void R_RenderScene(void) 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; @@ -1183,91 +1193,107 @@ void R_RenderScene(void) 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 (); - // 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"); + } - GL_ShowTrisColor(0, 0.015, 0, 1); + if (R_DrawBrushModelsSky()) + R_TimeReport("bmodelsky"); - R_DrawModels(); - R_TimeReport("models"); + 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 (); + R_DrawLightningBeams(); + R_TimeReport("lightning"); - GL_ShowTrisColor(0, 0, 0.033, 1); - R_ShadowVolumeLighting(false); - R_TimeReport("rtlights"); + R_DrawParticles(); + R_TimeReport("particles"); - // don't let sound skip if going slow - if (r_refdef.extraupdate) - S_ExtraUpdate (); + R_DrawExplosions(); + R_TimeReport("explosions"); + } - GL_ShowTrisColor(0.1, 0, 0, 1); + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); - if (cl.csqc_vidvars.drawworld) - { - R_DrawLightningBeams(); - R_TimeReport("lightning"); + GL_ShowTrisColor(0, 0.015, 0, 1); - R_DrawParticles(); - R_TimeReport("particles"); + R_DrawModels(); + R_TimeReport("models"); - R_DrawExplosions(); - R_TimeReport("explosions"); - } + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); - R_MeshQueue_RenderTransparent(); - R_TimeReport("drawtrans"); + GL_ShowTrisColor(0, 0, 0.033, 1); + R_ShadowVolumeLighting(false); + R_TimeReport("rtlights"); - if (cl.csqc_vidvars.drawworld) - { - R_DrawCoronas(); - R_TimeReport("coronas"); - } - if(cl.csqc_vidvars.drawcrosshair) - { - R_DrawWorldCrosshair(); - R_TimeReport("crosshair"); - } + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); - VM_AddPolygonsToMeshQueue(); + GL_ShowTrisColor(0.1, 0, 0, 1); - R_MeshQueue_Render(); - R_MeshQueue_EndScene(); + R_MeshQueue_RenderTransparent(); + R_TimeReport("drawtrans"); - if ((r_shadow_visiblelighting.integer || r_shadow_visiblevolumes.integer) && !r_showtrispass) - { - R_ShadowVolumeLighting(true); - R_TimeReport("visiblevolume"); + if (cl.csqc_vidvars.drawworld) + { + R_DrawCoronas(); + R_TimeReport("coronas"); + } + if(cl.csqc_vidvars.drawcrosshair) + { + R_DrawWorldCrosshair(); + R_TimeReport("crosshair"); + } + + VM_AddPolygonsToMeshQueue(); + + R_MeshQueue_Render(); + + 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) @@ -2193,7 +2219,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text { 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)); diff --git a/gl_rsurf.c b/gl_rsurf.c index 803c6b42..065e7701 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -30,8 +30,6 @@ cvar_t r_drawportals = {0, "r_drawportals", "0", "shows portals (separating poly cvar_t r_lockpvs = {0, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"}; cvar_t r_lockvisibility = {0, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"}; cvar_t r_useportalculling = {0, "r_useportalculling", "1", "use advanced portal culling visibility method to improve performance over just Potentially Visible Set, provides an even more significant speed improvement in unvised maps"}; -cvar_t r_drawcollisionbrushes_polygonfactor = {0, "r_drawcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"}; -cvar_t r_drawcollisionbrushes_polygonoffset = {0, "r_drawcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"}; cvar_t r_q3bsp_renderskydepth = {0, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"}; // flag arrays used for visibility checking on world model @@ -501,8 +499,7 @@ void R_Q1BSP_DrawSky(entity_render_t *ent) { if (ent->model == NULL) return; - if (r_drawcollisionbrushes.integer < 2) - R_DrawSurfaces(ent, true); + R_DrawSurfaces(ent, true); } void R_Q1BSP_Draw(entity_render_t *ent) @@ -510,9 +507,8 @@ void R_Q1BSP_Draw(entity_render_t *ent) model_t *model = ent->model; if (model == NULL) return; - if (r_drawcollisionbrushes.integer < 2) - R_DrawSurfaces(ent, false); - if (r_drawcollisionbrushes.integer >= 1 && model->brush.num_brushes) + R_DrawSurfaces(ent, false); + if (r_showcollisionbrushes.integer && model->brush.num_brushes && !r_showtrispass) { int i; msurface_t *surface; @@ -520,8 +516,8 @@ void R_Q1BSP_Draw(entity_render_t *ent) R_Mesh_Matrix(&ent->matrix); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); - GL_DepthTest(true); - qglPolygonOffset(r_drawcollisionbrushes_polygonfactor.value, r_drawcollisionbrushes_polygonoffset.value); + GL_DepthTest(!r_showdisabledepthtest.integer); + qglPolygonOffset(r_showcollisionbrushes_polygonfactor.value, r_showcollisionbrushes_polygonoffset.value); for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++) if (brush->colbrushf && brush->colbrushf->numtriangles) R_DrawCollisionBrush(brush->colbrushf); @@ -730,8 +726,6 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, // check the box in modelspace, it was already checked in worldspace if (!BoxesOverlap(ent->model->normalmins, ent->model->normalmaxs, lightmins, lightmaxs)) return; - if (r_drawcollisionbrushes.integer >= 2) - return; R_UpdateAllTextureInfo(ent); if (model->brush.shadowmesh) { @@ -810,8 +804,6 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface vec3_t modelorg; texture_t *tex; qboolean skip; - if (r_drawcollisionbrushes.integer >= 2) - return; R_UpdateAllTextureInfo(ent); Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg); tex = NULL; @@ -943,8 +935,6 @@ void GL_Surf_Init(void) Cvar_RegisterVariable(&r_lockpvs); Cvar_RegisterVariable(&r_lockvisibility); Cvar_RegisterVariable(&r_useportalculling); - Cvar_RegisterVariable(&r_drawcollisionbrushes_polygonfactor); - Cvar_RegisterVariable(&r_drawcollisionbrushes_polygonoffset); Cvar_RegisterVariable(&r_q3bsp_renderskydepth); Cmd_AddCommand ("r_replacemaptexture", R_ReplaceWorldTexture, "override a map texture for testing purposes"); // By [515] diff --git a/r_shadow.c b/r_shadow.c index fdb3f477..f4b0524a 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -217,8 +217,6 @@ cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1", "use scissor optimization cvar_t r_shadow_shadow_polygonfactor = {0, "r_shadow_shadow_polygonfactor", "0", "how much to enlarge shadow volume polygons when rendering (should be 0!)"}; cvar_t r_shadow_shadow_polygonoffset = {0, "r_shadow_shadow_polygonoffset", "1", "how much to push shadow volumes into the distance when rendering, to reduce chances of zfighting artifacts (should not be less than 0)"}; cvar_t r_shadow_texture3d = {0, "r_shadow_texture3d", "1", "use 3D voxel textures for spherical attenuation rather than cylindrical (does not affect r_shadow_glsl lighting)"}; -cvar_t r_shadow_visiblelighting = {0, "r_shadow_visiblelighting", "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_shadow_visiblevolumes = {0, "r_shadow_visiblevolumes", "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_shadow_glsl = {0, "r_shadow_glsl", "1", "enables use of OpenGL 2.0 pixel shaders for lighting"}; cvar_t r_shadow_glsl_offsetmapping = {0, "r_shadow_glsl_offsetmapping", "0", "enables offset mapping effect (also known as parallax mapping or sometimes as virtual displacement mapping, not as good as relief mapping or silohuette mapping but much faster), can cause strange artifacts on many textures, requires bumpmaps for depth information (normalmaps can have depth information as alpha channel, but most do not)"}; cvar_t r_shadow_glsl_offsetmapping_scale = {0, "r_shadow_glsl_offsetmapping_scale", "-0.04", "how deep the offset mapping effect is, and whether it is inward or outward"}; @@ -676,8 +674,8 @@ void R_Shadow_Help_f(void) "r_shadow_shadow_polygonfactor : nudge shadow volumes closer/further\n" "r_shadow_shadow_polygonoffset : nudge shadow volumes closer/further\n" "r_shadow_texture3d : use 3d attenuation texture (if hardware supports)\n" -"r_shadow_visiblelighting : useful for performance testing; bright = slow!\n" -"r_shadow_visiblevolumes : useful for performance testing; bright = slow!\n" +"r_showlighting : useful for performance testing; bright = slow!\n" +"r_showshadowvolumes : useful for performance testing; bright = slow!\n" "Commands:\n" "r_shadow_help : this help\n" ); @@ -709,8 +707,6 @@ void R_Shadow_Init(void) Cvar_RegisterVariable(&r_shadow_shadow_polygonfactor); Cvar_RegisterVariable(&r_shadow_shadow_polygonoffset); Cvar_RegisterVariable(&r_shadow_texture3d); - Cvar_RegisterVariable(&r_shadow_visiblelighting); - Cvar_RegisterVariable(&r_shadow_visiblevolumes); Cvar_RegisterVariable(&r_shadow_glsl); Cvar_RegisterVariable(&r_shadow_glsl_offsetmapping); Cvar_RegisterVariable(&r_shadow_glsl_offsetmapping_scale); @@ -1185,7 +1181,8 @@ void R_Shadow_RenderMode_StencilShadowVolumes(void) GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(false); GL_DepthTest(true); - qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value); + if (!r_showtrispass) + qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value); //if (r_shadow_shadow_polygonoffset.value != 0) //{ // qglPolygonOffset(r_shadow_shadow_polygonfactor.value, r_shadow_shadow_polygonoffset.value); @@ -1226,7 +1223,8 @@ void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent) GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); GL_DepthTest(true); - qglPolygonOffset(0, 0); + if (!r_showtrispass) + qglPolygonOffset(0, 0); //qglDisable(GL_POLYGON_OFFSET_FILL); GL_Color(1, 1, 1, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); @@ -1273,8 +1271,9 @@ void R_Shadow_RenderMode_VisibleShadowVolumes(void) R_Shadow_RenderMode_Reset(); GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); - GL_DepthTest(r_shadow_visiblevolumes.integer < 2); - qglPolygonOffset(0, 0); + GL_DepthTest(!r_showdisabledepthtest.integer); + if (!r_showtrispass) + qglPolygonOffset(0, 0); GL_Color(0.0, 0.0125, 0.1, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); qglDepthFunc(GL_GEQUAL); @@ -1289,8 +1288,9 @@ void R_Shadow_RenderMode_VisibleLighting(qboolean stenciltest, qboolean transpar R_Shadow_RenderMode_Reset(); GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); - GL_DepthTest(r_shadow_visiblelighting.integer < 2); - qglPolygonOffset(0, 0); + GL_DepthTest(!r_showdisabledepthtest.integer); + if (!r_showtrispass) + qglPolygonOffset(0, 0); GL_Color(0.1, 0.0125, 0, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); if (transparent) @@ -1313,7 +1313,8 @@ void R_Shadow_RenderMode_End(void) GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(true); GL_DepthTest(true); - qglPolygonOffset(0, 0); + if (!r_showtrispass) + qglPolygonOffset(0, 0); //qglDisable(GL_POLYGON_OFFSET_FILL); GL_Color(1, 1, 1, 1); GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); @@ -3012,46 +3013,53 @@ void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) if (!numlightentities) return; + // don't let sound skip if going slow + if (r_refdef.extraupdate) + S_ExtraUpdate (); + // make this the active rtlight for rendering purposes R_Shadow_RenderMode_ActiveLight(rtlight); // count this light in the r_speeds renderstats.lights++; - // draw stencil shadow volumes to mask off pixels that are in shadow - // so that they won't receive lighting usestencil = false; - if (numshadowentities && (!visible || r_shadow_visiblelighting.integer == 1) && gl_stencil && rtlight->shadow && (rtlight->isstatic ? r_rtworldshadows : r_rtdlightshadows)) + if (numshadowentities && rtlight->shadow && (rtlight->isstatic ? r_rtworldshadows : r_rtdlightshadows)) { - usestencil = true; - R_Shadow_RenderMode_StencilShadowVolumes(); - for (i = 0;i < numshadowentities;i++) - R_Shadow_DrawEntityShadow(shadowentities[i], numsurfaces, surfacelist); + // draw stencil shadow volumes to mask off pixels that are in shadow + // so that they won't receive lighting + if (gl_stencil) + { + usestencil = true; + R_Shadow_RenderMode_StencilShadowVolumes(); + for (i = 0;i < numshadowentities;i++) + R_Shadow_DrawEntityShadow(shadowentities[i], numsurfaces, surfacelist); + } + + // optionally draw visible shape of the shadow volumes + // for performance analysis by level designers + if (r_showshadowvolumes.integer) + { + R_Shadow_RenderMode_VisibleShadowVolumes(); + for (i = 0;i < numshadowentities;i++) + R_Shadow_DrawEntityShadow(shadowentities[i], numsurfaces, surfacelist); + } } - // draw lighting in the unmasked areas - if (numlightentities && !visible) + if (numlightentities) { + // draw lighting in the unmasked areas R_Shadow_RenderMode_Lighting(usestencil, false); for (i = 0;i < numlightentities;i++) R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist); - } - // optionally draw visible shape of the shadow volumes - // for performance analysis by level designers - if (numshadowentities && visible && r_shadow_visiblevolumes.integer > 0 && rtlight->shadow && (rtlight->isstatic ? r_rtworldshadows : r_rtdlightshadows)) - { - R_Shadow_RenderMode_VisibleShadowVolumes(); - for (i = 0;i < numshadowentities;i++) - R_Shadow_DrawEntityShadow(shadowentities[i], numsurfaces, surfacelist); - } - - // optionally draw the illuminated areas - // for performance analysis by level designers - if (numlightentities && visible && r_shadow_visiblelighting.integer > 0) - { - R_Shadow_RenderMode_VisibleLighting(usestencil, false); - for (i = 0;i < numlightentities;i++) - R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist); + // optionally draw the illuminated areas + // for performance analysis by level designers + if (r_showlighting.integer) + { + R_Shadow_RenderMode_VisibleLighting(usestencil && !r_showdisabledepthtest.integer, false); + for (i = 0;i < numlightentities;i++) + R_Shadow_DrawEntityLight(lightentities[i], numsurfaces, surfacelist); + } } } diff --git a/r_shadow.h b/r_shadow.h index 52fa087a..cce21858 100644 --- a/r_shadow.h +++ b/r_shadow.h @@ -27,8 +27,6 @@ extern cvar_t r_shadow_shadow_polygonfactor; extern cvar_t r_shadow_shadow_polygonoffset; extern cvar_t r_shadow_singlepassvolumegeneration; extern cvar_t r_shadow_texture3d; -extern cvar_t r_shadow_visiblelighting; -extern cvar_t r_shadow_visiblevolumes; extern cvar_t gl_ext_stenciltwoside; extern mempool_t *r_shadow_mempool; diff --git a/render.h b/render.h index c877265a..d9317640 100644 --- a/render.h +++ b/render.h @@ -146,6 +146,14 @@ extern qboolean r_rtdlightshadows; // forces all rendering to draw triangle outlines extern cvar_t r_showtris; +extern cvar_t r_showtris_polygonoffset; +extern cvar_t r_shownormals; +extern cvar_t r_showlighting; +extern cvar_t r_showshadowvolumes; +extern cvar_t r_showcollisionbrushes; +extern cvar_t r_showcollisionbrushes_polygonfactor; +extern cvar_t r_showcollisionbrushes_polygonoffset; +extern cvar_t r_showdisabledepthtest; extern int r_showtrispass; // @@ -174,7 +182,6 @@ extern cvar_t r_speeds; extern cvar_t r_fullbright; extern cvar_t r_wateralpha; extern cvar_t r_dynamic; -extern cvar_t r_drawcollisionbrushes; void R_Init(void); void R_UpdateWorld(void); // needs no r_refdef -- 2.39.2