]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added GL_DepthRange function and MATERIALFLAG_SHORTDEPTHRANGE (now used by viewmodels...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 7 Apr 2007 08:07:08 +0000 (08:07 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 7 Apr 2007 08:07:08 +0000 (08:07 +0000)
changed EF_NODEPTHTEST code to set MATERIALFLAG_SHORTDEPTHRANGE instead of MATERIALFLAG_NODEPTHTEST, this causes proper rendering of opaque models (such as the held item in prydon gate)
this also reenabled stencil shadows on view models but they render as if they are very very small (due to MATERIALFLAG_SHORTDEPTHRANGE)
changed default value of cl_viewmodel_scale from 0.3 to 1, this makes stereo rendering look better (small gun model looks silly when you can actually see that it is small) and makes rtlight cubemaps affect the gun more realistically

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7068 d7cf8633-e32d-0410-b094-e92efae38249

17 files changed:
cl_particles.c
cl_screen.c
darkplaces.txt
gl_backend.c
gl_backend.h
gl_draw.c
gl_rmain.c
gl_rsurf.c
model_brush.h
r_explosion.c
r_light.c
r_lightning.c
r_shadow.c
r_sky.c
r_sprites.c
render.h
view.c

index fb1c128284e49a56ccf3788955171b7f452eee07..557872c5dd3c19c3a9c83d93eae135d4d1493cf8 100644 (file)
@@ -2129,6 +2129,7 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtligh
        R_Mesh_TexCoordPointer(0, 2, particle_texcoord2f, 0, 0);
        R_Mesh_ColorPointer(particle_color4f, 0, 0);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        GL_CullFace(GL_FRONT); // quake is backwards, this culls back faces
 
index 610dd4fa3d8853da9ce16bcd14f3ed00e9326992..f7360f22767ce31da432fe1947caadcf742d834e 100644 (file)
@@ -1649,6 +1649,7 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        y = (vid_conheight.integer - pic->height)/2;
        GL_Color(1,1,1,1);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       GL_DepthRange(0, 1);
        GL_DepthTest(false);
        R_Mesh_VertexPointer(vertex3f, 0, 0);
        R_Mesh_ColorPointer(NULL, 0, 0);
index 07864dd38ee8a885000ca24886b83bea4e18f0ca..2f59b5c7103783bc1266e4180112a6c6f962a372 100644 (file)
@@ -478,7 +478,7 @@ cl_stainmaps                                      1                   stains lig
 cl_stainmaps_clearonload                          1                   clear stainmaps on map restart\r
 cl_stairsmoothspeed                               160                 how fast your view moves upward/downward when running up/down stairs\r
 cl_upspeed                                        400                 vertical movement speed (while swimming or flying)\r
-cl_viewmodel_scale                                0.3                 changes size of gun model, lower values prevent poking into walls but cause strange artifacts on lighting and especially r_stereo/vid_stereobuffer options where the size of the gun becomes visible\r
+cl_viewmodel_scale                                1                   changes size of gun model, lower values prevent poking into walls but cause strange artifacts on lighting and especially r_stereo/vid_stereobuffer options where the size of the gun becomes visible\r
 cl_yawspeed                                       140                 keyboard yaw turning speed\r
 cmdline                                           0                   contains commandline the engine was launched with\r
 collision_endnudge                                0                   how much to bias collision trace end\r
index 5a6b86214ba875c3c1a68d946637475ad4791b5a..93d23b774ddbbc94b58ac72b958b875381f2f845 100644 (file)
@@ -357,6 +357,7 @@ static struct gl_state_s
        GLboolean depthmask;
        int colormask; // stored as bottom 4 bits: r g b a (3 2 1 0 order)
        int depthtest;
+       float depthrange[2];
        int alphatest;
        int scissortest;
        unsigned int unit;
@@ -631,6 +632,16 @@ void GL_DepthTest(int state)
        }
 }
 
+void GL_DepthRange(float nearfrac, float farfrac)
+{
+       if (gl_state.depthrange[0] != nearfrac || gl_state.depthrange[1] != farfrac)
+       {
+               gl_state.depthrange[0] = nearfrac;
+               gl_state.depthrange[1] = farfrac;
+               qglDepthRange(nearfrac, farfrac);
+       }
+}
+
 void GL_CullFace(int state)
 {
        CHECKGLERROR
index f3d8ab7c0015c683489bbe26d987d0368beed00a..a51c6da76755b24af146bbdf1efceb19dd19f601 100644 (file)
@@ -18,6 +18,7 @@ void GL_SetupView_Mode_Ortho(double x1, double y1, double x2, double y2, double
 void GL_BlendFunc(int blendfunc1, int blendfunc2);
 void GL_DepthMask(int state);
 void GL_DepthTest(int state);
+void GL_DepthRange(float nearfrac, float farfrac);
 void GL_CullFace(int state);
 void GL_AlphaTest(int state);
 void GL_ColorMask(int r, int g, int b, int a);
index 17883ca217202990b505f020c816b613ea54f4a0..62649f5d0cba813928870c7477aa9bc0bcb060c8 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -549,6 +549,7 @@ static void _DrawQ_Setup(void)
        R_Mesh_Matrix(&identitymatrix);
 
        GL_DepthMask(true);
+       GL_DepthRange(0, 1);
        GL_DepthTest(false);
        GL_Color(1,1,1,1);
        GL_AlphaTest(false);
@@ -896,6 +897,7 @@ void R_DrawGamma(void)
                R_Mesh_ColorPointer(NULL, 0, 0);
                R_Mesh_ResetTextureState();
                GL_DepthMask(true);
+               GL_DepthRange(0, 1);
                GL_DepthTest(false);
                if (v_color_enable.integer)
                {
index 67ee63e5eb6f8d58f18037849548b2ff0dc80195..2373443873e0691395bd480d39e02bed358909cd 100644 (file)
@@ -1361,14 +1361,14 @@ static void R_View_UpdateEntityVisible (void)
                for (i = 0;i < r_refdef.numentities;i++)
                {
                        ent = r_refdef.entities[i];
-                       r_viewcache.entityvisible[i] = !(ent->flags & renderimask) && !R_CullBox(ent->mins, ent->maxs) && ((ent->effects & EF_NODEPTHTEST) || r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.worldmodel, r_viewcache.world_leafvisible, ent->mins, ent->maxs));
+                       r_viewcache.entityvisible[i] = !(ent->flags & renderimask) && !R_CullBox(ent->mins, ent->maxs) && ((ent->effects & EF_NODEPTHTEST) || (ent->flags & RENDER_VIEWMODEL) || r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.worldmodel, r_viewcache.world_leafvisible, ent->mins, ent->maxs));
                }
                if(r_cullentities_trace.integer)
                {
                        for (i = 0;i < r_refdef.numentities;i++)
                        {
                                ent = r_refdef.entities[i];
-                               if(r_viewcache.entityvisible[i] && !(ent->effects & EF_NODEPTHTEST) && !(ent->model && (ent->model->name[0] == '*')))
+                               if(r_viewcache.entityvisible[i] && !(ent->effects & EF_NODEPTHTEST) && !(ent->flags & RENDER_VIEWMODEL) && !(ent->model && (ent->model->name[0] == '*')))
                                {
                                        if(Mod_CanSeeBox_Trace(r_cullentities_trace_samples.integer, r_cullentities_trace_enlarge.value, r_refdef.worldmodel, r_view.origin, ent->mins, ent->maxs))
                                                ent->last_trace_visibility = realtime;
@@ -1604,6 +1604,7 @@ void R_ResetViewRendering2D(void)
        GL_AlphaTest(false);
        GL_ScissorTest(false);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(false);
        R_Mesh_Matrix(&identitymatrix);
        R_Mesh_ResetTextureState();
@@ -1636,6 +1637,7 @@ void R_ResetViewRendering3D(void)
        GL_AlphaTest(false);
        GL_ScissorTest(true);
        GL_DepthMask(true);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        R_Mesh_Matrix(&identitymatrix);
        R_Mesh_ResetTextureState();
@@ -2320,6 +2322,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        float *v, *c, f1, f2, diff[3], vertex3f[8*3], color4f[8*4];
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        R_Mesh_Matrix(&identitymatrix);
 
@@ -2406,6 +2409,7 @@ void R_DrawNoModel_TransparentCallback(const entity_render_t *ent, const rtlight
                GL_BlendFunc(GL_ONE, GL_ZERO);
                GL_DepthMask(true);
        }
+       GL_DepthRange(0, (ent->flags & RENDER_VIEWMODEL) ? 0.0625 : 1);
        GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
        GL_CullFace((ent->effects & EF_DOUBLESIDED) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces
        R_Mesh_VertexPointer(nomodelvertex3f, 0, 0);
@@ -2480,7 +2484,7 @@ void R_CalcBeam_Vertex3f (float *vert, const vec3_t org1, const vec3_t org2, flo
 
 float spritetexcoord2f[4*2] = {0, 1, 0, 0, 1, 0, 1, 1};
 
-void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, int depthdisable, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca)
+void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, qboolean depthdisable, qboolean depthshort, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca)
 {
        float fog = 0.0f, ifog;
        float vertex3f[12];
@@ -2492,6 +2496,7 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
        R_Mesh_Matrix(&identitymatrix);
        GL_BlendFunc(blendfunc1, blendfunc2);
        GL_DepthMask(false);
+       GL_DepthRange(0, depthshort ? 0.0625 : 1);
        GL_DepthTest(!depthdisable);
 
        vertex3f[ 0] = origin[0] + left[0] * scalex2 + up[0] * scaley1;
@@ -2713,9 +2718,9 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
        if (ent->effects & EF_DOUBLESIDED)
                t->currentmaterialflags |= MATERIALFLAG_NOSHADOW | MATERIALFLAG_NOCULLFACE;
        if (ent->effects & EF_NODEPTHTEST)
-               t->currentmaterialflags |= MATERIALFLAG_NODEPTHTEST | MATERIALFLAG_NOSHADOW;
+               t->currentmaterialflags |= MATERIALFLAG_SHORTDEPTHRANGE;
        if (ent->flags & RENDER_VIEWMODEL)
-               t->currentmaterialflags |= MATERIALFLAG_VIEWMODEL;
+               t->currentmaterialflags |= MATERIALFLAG_SHORTDEPTHRANGE;
        if (t->currentmaterialflags & MATERIALFLAG_WATER && r_waterscroll.value != 0)
                t->currenttexmatrix = r_waterscrollmatrix;
        else
@@ -3569,6 +3574,7 @@ static void RSurf_DrawBatch_GL11_VertexShade(int texturenumsurfaces, msurface_t
 
 static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, msurface_t **texturesurfacelist)
 {
+       GL_DepthRange(0, (rsurface_texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
        GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
        GL_CullFace((rsurface_texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces
        if (rsurface_mode != RSURFMODE_SHOWSURFACES)
@@ -3603,6 +3609,7 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, msurface_t **te
                // restore entity matrix
                R_Mesh_Matrix(&rsurface_entity->matrix);
        }
+       GL_DepthRange(0, (rsurface_texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
        GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
        GL_CullFace((rsurface_texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces
        GL_DepthMask(true);
@@ -3956,6 +3963,7 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                R_DrawTextureSurfaceList_Sky(texturenumsurfaces, texturesurfacelist);
        else if (rsurface_texture->currentnumlayers)
        {
+               GL_DepthRange(0, (rsurface_texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
                GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
                GL_CullFace((rsurface_texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces
                GL_BlendFunc(rsurface_texture->currentlayers[0].blendfunc1, rsurface_texture->currentlayers[0].blendfunc2);
@@ -4092,6 +4100,7 @@ void R_DrawLoc_Callback(const entity_render_t *ent, const rtlight_t *rtlight, in
        CHECKGLERROR
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        GL_CullFace(GL_NONE);
        R_Mesh_Matrix(&identitymatrix);
@@ -4150,6 +4159,7 @@ void R_DrawCollisionBrushes(entity_render_t *ent)
        R_Mesh_ResetTextureState();
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(!r_showdisabledepthtest.integer);
        qglPolygonOffset(r_refdef.polygonfactor + r_showcollisionbrushes_polygonfactor.value, r_refdef.polygonoffset + r_showcollisionbrushes_polygonoffset.value);CHECKGLERROR
        for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++)
@@ -4169,6 +4179,7 @@ void R_DrawTrianglesAndNormals(entity_render_t *ent, qboolean drawtris, qboolean
        model_t *model = ent->model;
        vec3_t v;
        CHECKGLERROR
+       GL_DepthRange(0, 1);
        GL_DepthTest(!r_showdisabledepthtest.integer);
        GL_DepthMask(true);
        GL_BlendFunc(GL_ONE, GL_ZERO);
index ae64ff487f5216fa0842bd78cd2f6902d990478f..a5d1e3f3f71a4b2144948069aaa95712adfa1c42 100644 (file)
@@ -337,6 +337,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r
        CHECKGLERROR
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        GL_CullFace(GL_NONE);
        R_Mesh_Matrix(&identitymatrix);
index 511c56f0c75f5eecf554f3942de80e266dc9d382..9d29e4d8a8d5db12e8172cd2966f2084fde3ec1a 100644 (file)
@@ -97,10 +97,10 @@ mplane_t;
 #define MATERIALFLAG_VERTEXTEXTUREBLEND 32768
 // disables GL_CULL_FACE on this texture (making it double sided)
 #define MATERIALFLAG_NOCULLFACE 65536
-// render after the normal scene
-#define MATERIALFLAG_VIEWMODEL 131072
+// render with a very short depth range (like 10% of normal), this causes entities to appear infront of most of the scene
+#define MATERIALFLAG_SHORTDEPTHRANGE 131072
 // combined mask of all attributes that require depth sorted rendering
-#define MATERIALFLAGMASK_DEPTHSORTED (MATERIALFLAG_BLENDED | MATERIALFLAG_NODEPTHTEST | MATERIALFLAG_VIEWMODEL)
+#define MATERIALFLAGMASK_DEPTHSORTED (MATERIALFLAG_BLENDED | MATERIALFLAG_NODEPTHTEST)
 
 typedef struct medge_s
 {
index 3d8efefbf5c4452d0ebe6e5e47c0e986bcd6599e..f73e5cc9f2664cab90d382ab5391c56a5070f46d 100644 (file)
@@ -187,6 +187,7 @@ static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, cons
        rmeshstate_t m;
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        GL_CullFace(GL_FRONT); // quake is backwards, this culls back faces
        R_Mesh_Matrix(&identitymatrix);
index 327c7e3b72fa9b1fd23fe21ac4001ab17f0b144b..3510db724886b3ac8da1af71b6b4accadd26ac79 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -98,7 +98,7 @@ void R_DrawCoronas(void)
                        continue;
                if (CL_Move(rtlight->shadoworigin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
                        continue;
-               R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
+               R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, false, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
        }
        for (i = 0;i < r_refdef.numlights;i++)
        {
@@ -123,7 +123,7 @@ void R_DrawCoronas(void)
                        continue;
                if (CL_Move(rtlight->shadoworigin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
                        continue;
-               R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
+               R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, false, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
        }
 }
 
index 0d287946dd794dee0e62e691cdda64afc92f6f3b..44fa53e8ba2330466bdb5f05de582f0cb9befc81 100644 (file)
@@ -239,6 +239,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, const r
        R_Mesh_Matrix(&identitymatrix);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        if (r_lightningbeam_qmbtexture.integer && r_lightningbeamqmbtexture == NULL)
                r_lightningbeams_setupqmbtexture();
index cc4e6a13a39a1a5021280dfb3721ef067c708991..0959b37be8d3bcbda5ef0d8d6a1111bc01f7a758 100644 (file)
@@ -1006,6 +1006,7 @@ void R_Shadow_RenderMode_Begin(void)
        R_Mesh_ColorPointer(NULL, 0, 0);
        R_Mesh_ResetTextureState();
        GL_BlendFunc(GL_ONE, GL_ZERO);
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        GL_DepthMask(false);
        GL_Color(0, 0, 0, 1);
@@ -1046,6 +1047,7 @@ void R_Shadow_RenderMode_Reset(void)
        }
        R_Mesh_ColorPointer(NULL, 0, 0);
        R_Mesh_ResetTextureState();
+       GL_DepthRange(0, 1);
        GL_DepthTest(true);
        GL_DepthMask(false);
        qglDepthFunc(GL_LEQUAL);CHECKGLERROR
@@ -1132,6 +1134,7 @@ void R_Shadow_RenderMode_VisibleShadowVolumes(void)
        CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        GL_BlendFunc(GL_ONE, GL_ONE);
+       GL_DepthRange(0, 1);
        GL_DepthTest(r_showshadowvolumes.integer < 2);
        GL_Color(0.0, 0.0125 * r_view.colorscale, 0.1 * r_view.colorscale, 1);
        qglPolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);CHECKGLERROR
@@ -1144,6 +1147,7 @@ void R_Shadow_RenderMode_VisibleLighting(qboolean stenciltest, qboolean transpar
        CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        GL_BlendFunc(GL_ONE, GL_ONE);
+       GL_DepthRange(0, 1);
        GL_DepthTest(r_showlighting.integer < 2);
        GL_Color(0.1 * r_view.colorscale, 0.0125 * r_view.colorscale, 0, 1);
        if (!transparent)
@@ -2237,7 +2241,6 @@ static void R_Shadow_RenderLighting_Light_Vertex(int firstvertex, int numvertice
 void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset)
 {
        float ambientscale, diffusescale, specularscale;
-       // FIXME: support MATERIALFLAG_NODEPTHTEST
        vec3_t lightcolorbase, lightcolorpants, lightcolorshirt;
        // calculate colors to render this texture with
        lightcolorbase[0] = r_shadow_rtlight->currentcolor[0] * rsurface_entity->colormod[0] * rsurface_texture->currentalpha;
@@ -2254,6 +2257,7 @@ void R_Shadow_RenderLighting(int firstvertex, int numvertices, int numtriangles,
        }
        if ((ambientscale + diffusescale) * VectorLength2(lightcolorbase) + specularscale * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
                return;
+       GL_DepthRange(0, (rsurface_texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
        GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
        GL_CullFace((rsurface_texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces
        if (rsurface_texture->colormapping)
@@ -3053,6 +3057,7 @@ void R_DrawModelShadows(void)
 
        // set up a 50% darkening blend on shadowed areas
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       GL_DepthRange(0, 1);
        GL_DepthTest(false);
        GL_DepthMask(false);
        qglPolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);CHECKGLERROR
@@ -3272,7 +3277,7 @@ void R_Shadow_DrawCursor_TransparentCallback(const entity_render_t *ent, const r
 {
        // this is never batched (there can be only one)
        float scale = r_editlights_cursorgrid.value * 0.5f;
-       R_DrawSprite(GL_SRC_ALPHA, GL_ONE, r_crosshairs[1]->tex, NULL, false, r_editlights_cursorlocation, r_view.right, r_view.up, scale, -scale, -scale, scale, 1, 1, 1, 0.5f);
+       R_DrawSprite(GL_SRC_ALPHA, GL_ONE, r_crosshairs[1]->tex, NULL, false, false, r_editlights_cursorlocation, r_view.right, r_view.up, scale, -scale, -scale, scale, 1, 1, 1, 0.5f);
 }
 
 void R_Shadow_DrawLightSprite_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
@@ -3286,7 +3291,7 @@ void R_Shadow_DrawLightSprite_TransparentCallback(const entity_render_t *ent, co
                intensity = 0.75 + 0.25 * sin(realtime * M_PI * 4.0);
        if (!light->shadow)
                intensity *= 0.5f;
-       R_DrawSprite(GL_SRC_ALPHA, GL_ONE, r_crosshairs[surfacelist[0]]->tex, NULL, false, light->origin, r_view.right, r_view.up, 8, -8, -8, 8, intensity, intensity, intensity, 0.5);
+       R_DrawSprite(GL_SRC_ALPHA, GL_ONE, r_crosshairs[surfacelist[0]]->tex, NULL, false, false, light->origin, r_view.right, r_view.up, 8, -8, -8, 8, intensity, intensity, intensity, 0.5f);
 }
 
 void R_Shadow_DrawLightSprites(void)
diff --git a/r_sky.c b/r_sky.c
index 837dde9f540d30fc2896510f6753fe660cf0d868..e7e5b30bb046a9dcca63d74279bfeda91bcd278d 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -272,6 +272,7 @@ static void R_SkyBox(void)
        GL_Color(1 * r_view.colorscale, 1 * r_view.colorscale, 1 * r_view.colorscale, 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(false);
+       GL_DepthRange(0, 1);
        GL_DepthTest(false); // don't modify or read zbuffer
        R_Mesh_VertexPointer(skyboxvertex3f, 0, 0);
        R_Mesh_ColorPointer(NULL, 0, 0);
@@ -370,6 +371,7 @@ static void R_SkySphere(void)
        GL_Color(1 * r_view.colorscale, 1 * r_view.colorscale, 1 * r_view.colorscale, 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);
+       GL_DepthRange(0, 1);
        GL_DepthTest(false); // don't modify or read zbuffer
        R_Mesh_VertexPointer(skysphere_vertex3f, 0, 0);
        R_Mesh_ColorPointer(NULL, 0, 0);
@@ -429,6 +431,7 @@ void R_Sky(void)
                        //GL_Clear(GL_DEPTH_BUFFER_BIT);
                }
                */
+               GL_DepthRange(0, 1);
                GL_DepthTest(true);
                GL_DepthMask(true);
        }
index df61d746e9e657918f46b5530e4fc5aecd051e1a..f352e017164625e8d2a2a52cd3222778169824a7 100644 (file)
@@ -75,7 +75,7 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
                        texture_t *texture = &frame->texture;
                        R_UpdateTextureInfo(ent, texture);
                        // FIXME: negate left and right in loader
-                       R_DrawSprite(texture->currentlayers[0].blendfunc1, texture->currentlayers[0].blendfunc2, frame->texture.currentskinframe->base, frame->texture.currentskinframe->fog, (ent->effects & EF_NODEPTHTEST), org, left, up, frame->left, frame->right, frame->down, frame->up, texture->currentlayers[0].color[0], texture->currentlayers[0].color[1], texture->currentlayers[0].color[2], ent->alpha * ent->frameblend[i].lerp);
+                       R_DrawSprite(texture->currentlayers[0].blendfunc1, texture->currentlayers[0].blendfunc2, frame->texture.currentskinframe->base, frame->texture.currentskinframe->fog, (texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST), (texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE), org, left, up, frame->left, frame->right, frame->down, frame->up, texture->currentlayers[0].color[0], texture->currentlayers[0].color[1], texture->currentlayers[0].color[2], ent->alpha * ent->frameblend[i].lerp);
                }
        }
 }
index 3b89d211b09c571f2d513c7d1b409f671cdfd4ba..b575ae9fa49769b27b7c83913343704e617553b7 100644 (file)
--- a/render.h
+++ b/render.h
@@ -180,7 +180,7 @@ void R_TimeReport(char *name);
 void R_Stain(const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2);
 
 void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width);
-void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, int depthdisable, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca);
+void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, qboolean depthdisable, qboolean depthshort, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca);
 
 extern mempool_t *r_main_mempool;
 
diff --git a/view.c b/view.c
index 64d1b7cecba416a8cf8b8ae2a0d14af3f8817d32..9be30a703051aaad6e4380a78bb0095f6f2d4eba 100644 (file)
--- a/view.c
+++ b/view.c
@@ -43,7 +43,7 @@ cvar_t cl_bobmodel_side = {CVAR_SAVE, "cl_bobmodel_side", "0.15", "gun bobbing s
 cvar_t cl_bobmodel_up = {CVAR_SAVE, "cl_bobmodel_up", "0.06", "gun bobbing upward movement amount"};
 cvar_t cl_bobmodel_speed = {CVAR_SAVE, "cl_bobmodel_speed", "7", "gun bobbing speed"};
 
-cvar_t cl_viewmodel_scale = {0, "cl_viewmodel_scale", "0.3", "changes size of gun model, lower values prevent poking into walls but cause strange artifacts on lighting and especially r_stereo/vid_stereobuffer options where the size of the gun becomes visible"};
+cvar_t cl_viewmodel_scale = {0, "cl_viewmodel_scale", "1", "changes size of gun model, lower values prevent poking into walls but cause strange artifacts on lighting and especially r_stereo/vid_stereobuffer options where the size of the gun becomes visible"};
 
 cvar_t v_kicktime = {0, "v_kicktime", "0.5", "how long a view kick from damage lasts"};
 cvar_t v_kickroll = {0, "v_kickroll", "0.6", "how much a view kick from damage rolls your view"};