From 5204bb8cced9548d5c44f6d6a5ab2e5e4a841030 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 7 Apr 2007 08:07:08 +0000 Subject: [PATCH] added GL_DepthRange function and MATERIALFLAG_SHORTDEPTHRANGE (now used by viewmodels), this prevents viewmodels from poking into walls 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 --- cl_particles.c | 1 + cl_screen.c | 1 + darkplaces.txt | 2 +- gl_backend.c | 11 +++++++++++ gl_backend.h | 1 + gl_draw.c | 2 ++ gl_rmain.c | 21 ++++++++++++++++----- gl_rsurf.c | 1 + model_brush.h | 6 +++--- r_explosion.c | 1 + r_light.c | 4 ++-- r_lightning.c | 1 + r_shadow.c | 11 ++++++++--- r_sky.c | 3 +++ r_sprites.c | 2 +- render.h | 2 +- view.c | 2 +- 17 files changed, 55 insertions(+), 17 deletions(-) diff --git a/cl_particles.c b/cl_particles.c index fb1c1282..557872c5 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -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 diff --git a/cl_screen.c b/cl_screen.c index 610dd4fa..f7360f22 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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); diff --git a/darkplaces.txt b/darkplaces.txt index 07864dd3..2f59b5c7 100644 --- a/darkplaces.txt +++ b/darkplaces.txt @@ -478,7 +478,7 @@ cl_stainmaps 1 stains lig cl_stainmaps_clearonload 1 clear stainmaps on map restart cl_stairsmoothspeed 160 how fast your view moves upward/downward when running up/down stairs cl_upspeed 400 vertical movement speed (while swimming or flying) -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 +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 cl_yawspeed 140 keyboard yaw turning speed cmdline 0 contains commandline the engine was launched with collision_endnudge 0 how much to bias collision trace end diff --git a/gl_backend.c b/gl_backend.c index 5a6b8621..93d23b77 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -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 diff --git a/gl_backend.h b/gl_backend.h index f3d8ab7c..a51c6da7 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -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); diff --git a/gl_draw.c b/gl_draw.c index 17883ca2..62649f5d 100644 --- 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) { diff --git a/gl_rmain.c b/gl_rmain.c index 67ee63e5..23734438 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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); diff --git a/gl_rsurf.c b/gl_rsurf.c index ae64ff48..a5d1e3f3 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -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); diff --git a/model_brush.h b/model_brush.h index 511c56f0..9d29e4d8 100644 --- a/model_brush.h +++ b/model_brush.h @@ -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 { diff --git a/r_explosion.c b/r_explosion.c index 3d8efefb..f73e5cc9 100644 --- a/r_explosion.c +++ b/r_explosion.c @@ -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); diff --git a/r_light.c b/r_light.c index 327c7e3b..3510db72 100644 --- 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); } } diff --git a/r_lightning.c b/r_lightning.c index 0d287946..44fa53e8 100644 --- a/r_lightning.c +++ b/r_lightning.c @@ -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(); diff --git a/r_shadow.c b/r_shadow.c index cc4e6a13..0959b37b 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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 837dde9f..e7e5b30b 100644 --- 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); } diff --git a/r_sprites.c b/r_sprites.c index df61d746..f352e017 100644 --- a/r_sprites.c +++ b/r_sprites.c @@ -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); } } } diff --git a/render.h b/render.h index 3b89d211..b575ae9f 100644 --- 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 64d1b7ce..9be30a70 100644 --- 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"}; -- 2.39.2