]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
r_nearclip cvar
authorsajt <sajt@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 12 Mar 2006 01:04:12 +0000 (01:04 +0000)
committersajt <sajt@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 12 Mar 2006 01:04:12 +0000 (01:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6110 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
render.h
todo

index 4303a2ace0951bc33f50777e232f8da6326e3734..2f262bc0fc0bab6877a5b6a8bb2e81797c03d834 100644 (file)
@@ -67,6 +67,7 @@ matrix4x4_t r_view_matrix;
 //
 refdef_t r_refdef;
 
 //
 refdef_t r_refdef;
 
+cvar_t r_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" };
 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_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"};
@@ -450,6 +451,7 @@ void GL_Main_Init(void)
 {
 // FIXME: move this to client?
        FOG_registercvars();
 {
 // FIXME: move this to client?
        FOG_registercvars();
+       Cvar_RegisterVariable(&r_nearclip);
        Cvar_RegisterVariable(&r_showtris);
        Cvar_RegisterVariable(&r_showtris_polygonoffset);
        Cvar_RegisterVariable(&r_shownormals);
        Cvar_RegisterVariable(&r_showtris);
        Cvar_RegisterVariable(&r_showtris_polygonoffset);
        Cvar_RegisterVariable(&r_shownormals);
@@ -739,7 +741,7 @@ static void R_SetFrustum(void)
 #endif
 
 #if 0
 #endif
 
 #if 0
-       zNear = 1.0;
+       zNear = r_nearclip.value;
        nudge = 1.0 - 1.0 / (1<<23);
        frustum[4].normal[0] = 0 - 0;
        frustum[4].normal[1] = 0 - 0;
        nudge = 1.0 - 1.0 / (1<<23);
        frustum[4].normal[0] = 0 - 0;
        frustum[4].normal[1] = 0 - 0;
@@ -800,7 +802,7 @@ static void R_SetFrustum(void)
        frustum[1].dist = DotProduct (r_vieworigin, frustum[1].normal);
        frustum[2].dist = DotProduct (r_vieworigin, frustum[2].normal);
        frustum[3].dist = DotProduct (r_vieworigin, frustum[3].normal);
        frustum[1].dist = DotProduct (r_vieworigin, frustum[1].normal);
        frustum[2].dist = DotProduct (r_vieworigin, frustum[2].normal);
        frustum[3].dist = DotProduct (r_vieworigin, frustum[3].normal);
-       frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + 1.0f;
+       frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + r_nearclip.value;
        PlaneClassify(&frustum[0]);
        PlaneClassify(&frustum[1]);
        PlaneClassify(&frustum[2]);
        PlaneClassify(&frustum[0]);
        PlaneClassify(&frustum[1]);
        PlaneClassify(&frustum[2]);
@@ -833,7 +835,7 @@ static void R_SetFrustum(void)
 
        // nearclip plane
        //VectorCopy(r_viewforward, frustum[4].normal);
 
        // nearclip plane
        //VectorCopy(r_viewforward, frustum[4].normal);
-       //frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + 1.0f;
+       //frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + r_nearclip.value;
        //PlaneClassify(&frustum[4]);
 }
 
        //PlaneClassify(&frustum[4]);
 }
 
@@ -1164,6 +1166,8 @@ extern void R_DrawLightningBeams (void);
 extern void VM_AddPolygonsToMeshQueue (void);
 void R_RenderScene(void)
 {
 extern void VM_AddPolygonsToMeshQueue (void);
 void R_RenderScene(void)
 {
+       float nearclip;
+
        // 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 ();
@@ -1175,10 +1179,12 @@ void R_RenderScene(void)
        R_SetFrustum();
 
        r_farclip = R_FarClip(r_vieworigin, r_viewforward, 768.0f) + 256.0f;
        R_SetFrustum();
 
        r_farclip = R_FarClip(r_vieworigin, r_viewforward, 768.0f) + 256.0f;
+       nearclip = bound (0.001f, r_nearclip.value, r_farclip - 1.0f);
+
        if (r_rtworldshadows || r_rtdlightshadows)
        if (r_rtworldshadows || r_rtdlightshadows)
-               GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.frustum_x, r_refdef.frustum_y, 1.0f);
+               GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.frustum_x, r_refdef.frustum_y, nearclip);
        else
        else
-               GL_SetupView_Mode_Perspective(r_refdef.frustum_x, r_refdef.frustum_y, 1.0f, r_farclip);
+               GL_SetupView_Mode_Perspective(r_refdef.frustum_x, r_refdef.frustum_y, nearclip, r_farclip);
 
        GL_SetupView_Orientation_FromEntity(&r_view_matrix);
 
 
        GL_SetupView_Orientation_FromEntity(&r_view_matrix);
 
index ee06c0f1212ce870f1893279825e72310928226e..6a9b3f7725bc46b870179faad8b8716ea0f643eb 100644 (file)
--- a/render.h
+++ b/render.h
@@ -143,6 +143,8 @@ extern qboolean r_rtworldshadows;
 extern qboolean r_rtdlight;
 extern qboolean r_rtdlightshadows;
 
 extern qboolean r_rtdlight;
 extern qboolean r_rtdlightshadows;
 
+extern cvar_t r_nearclip;
+
 // forces all rendering to draw triangle outlines
 extern cvar_t r_showtris;
 extern cvar_t r_showtris_polygonoffset;
 // forces all rendering to draw triangle outlines
 extern cvar_t r_showtris;
 extern cvar_t r_showtris_polygonoffset;
diff --git a/todo b/todo
index e4d8a39ff7c97075439f158a216ed7dce30e9e36..8867b74a44526bb20ac8474279ef270442bba22a 100644 (file)
--- a/todo
+++ b/todo
 0 feature darkplaces readme: add documentation about r_lockpvs, r_lockvisibility, r_useportalculling, r_drawportals, r_drawcollisionbrushes, r_showtris, r_speeds, r_shadow_visiblevolumes, and r_shadow_visiblelighting.
 0 feature darkplaces readme: add log_file and log_sync documentation (Edward Holness)
 0 feature darkplaces readme: document the ctrl-escape hotkey for toggleconsole (LordHavoc)
 0 feature darkplaces readme: add documentation about r_lockpvs, r_lockvisibility, r_useportalculling, r_drawportals, r_drawcollisionbrushes, r_showtris, r_speeds, r_shadow_visiblevolumes, and r_shadow_visiblelighting.
 0 feature darkplaces readme: add log_file and log_sync documentation (Edward Holness)
 0 feature darkplaces readme: document the ctrl-escape hotkey for toggleconsole (LordHavoc)
-0 feature darkplaces renderer: add a nearclip cvar (Tomaz)
 0 feature darkplaces renderer: add a rtlight flag to disable vis culling, for ambient area lights and such (Kaz)
 0 feature darkplaces renderer: add cubemap support to low quality rtlighting path for cards that support >= 2 TMUs and cubemap
 0 feature darkplaces renderer: add per-entity PolygonOffset to renderer, to allow zfighting bmodel/world glitches to be fixed, this has to affect all rendering involving the entity, including light/shadow (Tomaz)
 0 feature darkplaces renderer: add a rtlight flag to disable vis culling, for ambient area lights and such (Kaz)
 0 feature darkplaces renderer: add cubemap support to low quality rtlighting path for cards that support >= 2 TMUs and cubemap
 0 feature darkplaces renderer: add per-entity PolygonOffset to renderer, to allow zfighting bmodel/world glitches to be fixed, this has to affect all rendering involving the entity, including light/shadow (Tomaz)
@@ -1096,6 +1095,7 @@ d feature darkplaces physics: add a sv_ cvar to disable demonland.wav when monst
 d feature darkplaces playerphysics: add sv_maxairspeed cvar and use it in sv_user.c, default 30 to match quake player physics (Vermeulen)
 d feature darkplaces protocol: add PRYDON_CLIENTCURSOR extension - clientside mouse with highlighting of selected entities with the EF_SELECTABLE flag, and qc fields on the client entity on the server would indicate which entity the cursor is highlighting as well as where it is (Urre, Harb, FrikaC)
 d feature darkplaces protocol: allow sending of additional precaches during game, this needs to send a reliable message to all connected clients stating the new filename to load, and also to be sent to new connections (VorteX, Vermeulen)
 d feature darkplaces playerphysics: add sv_maxairspeed cvar and use it in sv_user.c, default 30 to match quake player physics (Vermeulen)
 d feature darkplaces protocol: add PRYDON_CLIENTCURSOR extension - clientside mouse with highlighting of selected entities with the EF_SELECTABLE flag, and qc fields on the client entity on the server would indicate which entity the cursor is highlighting as well as where it is (Urre, Harb, FrikaC)
 d feature darkplaces protocol: allow sending of additional precaches during game, this needs to send a reliable message to all connected clients stating the new filename to load, and also to be sent to new connections (VorteX, Vermeulen)
+d feature darkplaces renderer: add a nearclip cvar (Tomaz)
 d feature darkplaces renderer: add q3bsp water rendering, both scrolling and watershader (Zombie)
 d feature darkplaces renderer: add r_shadow_visiblelighting cvar which draws redish orange polygons similar to visiblevolumes for measuring number of light passes per pixel (Harbish)
 d feature darkplaces server: add DP_QC_WRITEUNTERMINATEDSTRING extension (shadowalker)
 d feature darkplaces renderer: add q3bsp water rendering, both scrolling and watershader (Zombie)
 d feature darkplaces renderer: add r_shadow_visiblelighting cvar which draws redish orange polygons similar to visiblevolumes for measuring number of light passes per pixel (Harbish)
 d feature darkplaces server: add DP_QC_WRITEUNTERMINATEDSTRING extension (shadowalker)