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
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);
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
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;
}
}
+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
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);
R_Mesh_Matrix(&identitymatrix);
GL_DepthMask(true);
+ GL_DepthRange(0, 1);
GL_DepthTest(false);
GL_Color(1,1,1,1);
GL_AlphaTest(false);
R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
GL_DepthMask(true);
+ GL_DepthRange(0, 1);
GL_DepthTest(false);
if (v_color_enable.integer)
{
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;
GL_AlphaTest(false);
GL_ScissorTest(false);
GL_DepthMask(false);
+ GL_DepthRange(0, 1);
GL_DepthTest(false);
R_Mesh_Matrix(&identitymatrix);
R_Mesh_ResetTextureState();
GL_AlphaTest(false);
GL_ScissorTest(true);
GL_DepthMask(true);
+ GL_DepthRange(0, 1);
GL_DepthTest(true);
R_Mesh_Matrix(&identitymatrix);
R_Mesh_ResetTextureState();
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);
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);
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];
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;
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
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)
// 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);
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);
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);
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++)
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);
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);
#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
{
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);
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++)
{
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);
}
}
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();
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);
}
R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
+ GL_DepthRange(0, 1);
GL_DepthTest(true);
GL_DepthMask(false);
qglDepthFunc(GL_LEQUAL);CHECKGLERROR
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
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)
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;
}
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)
// 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
{
// 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)
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)
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);
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);
//GL_Clear(GL_DEPTH_BUFFER_BIT);
}
*/
+ GL_DepthRange(0, 1);
GL_DepthTest(true);
GL_DepthMask(true);
}
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);
}
}
}
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;
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"};