cvar_t r_equalize_entities_to = {CVAR_SAVE, "r_equalize_entities_to", "0.8", "light equalizing: target light level (DEPRECATED)"};
cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
+cvar_t r_skylast = {CVAR_SAVE, "r_skylast", "0", "renders sky after normal rendering ends to eliminate overdraw, values: 0 = nodepth sky first, 1 = sky after depth pass(if enabled), 2 = sky after world, 3 = sky after entities"};
cvar_t r_useinfinitefarclip = {CVAR_SAVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};
cvar_t r_farclip_base = {0, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"};
cvar_t r_farclip_world = {0, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"};
Cvar_RegisterVariable(&r_equalize_entities_by);
Cvar_RegisterVariable(&r_equalize_entities_to);
Cvar_RegisterVariable(&r_depthfirst);
+ Cvar_RegisterVariable(&r_skylast);
Cvar_RegisterVariable(&r_useinfinitefarclip);
Cvar_RegisterVariable(&r_farclip_base);
Cvar_RegisterVariable(&r_farclip_world);
extern cvar_t cl_decals_newsystem;
extern qboolean r_shadow_usingdeferredprepass;
extern int r_shadow_shadowmapatlas_modelshadows_size;
+static void R_RenderSky(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture) {
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky)
+ {
+ r_refdef.scene.worldmodel->DrawSky(r_refdef.scene.worldentity);
+ if (r_timereport_active)
+ R_TimeReport("worldsky");
+ }
+
+ if (R_DrawBrushModelsSky() && r_timereport_active)
+ R_TimeReport("bmodelsky");
+
+ if (skyrendermasked && skyrenderlater)
+ {
+ // we have to force off the water clipping plane while rendering sky
+ R_SetupView(false, fbo, depthtexture, colortexture);
+ R_Sky();
+ R_SetupView(true, fbo, depthtexture, colortexture);
+ if (r_timereport_active)
+ R_TimeReport("sky");
+ }
+}
void R_RenderScene(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture)
{
qboolean shadowmapping = false;
// don't let sound skip if going slow
if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
+ if(r_skylast.integer <= 0)
+ R_RenderSky(fbo, depthtexture, colortexture);
}
R_Shadow_PrepareModelShadows();
if (r_timereport_active)
R_TimeReport("modeldepth");
}
+ if (cl.csqc_vidvars.drawworld && r_skylast.integer == 1)
+ R_RenderSky(fbo, depthtexture, colortexture);
if (cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->Draw)
{
// don't let sound skip if going slow
if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
+ if (cl.csqc_vidvars.drawworld && r_skylast.integer == 2)
+ R_RenderSky(fbo, depthtexture, colortexture);
R_DrawModels();
if (r_timereport_active)
if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
- if (cl.csqc_vidvars.drawworld)
- {
- // don't let sound skip if going slow
- if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky)
- {
- r_refdef.scene.worldmodel->DrawSky(r_refdef.scene.worldentity);
- if (r_timereport_active)
- R_TimeReport("worldsky");
- }
-
- if (R_DrawBrushModelsSky() && r_timereport_active)
- R_TimeReport("bmodelsky");
-
- if (skyrendermasked && skyrenderlater)
- {
- // we have to force off the water clipping plane while rendering sky
- R_SetupView(false, fbo, depthtexture, colortexture);
- R_Sky();
- R_SetupView(true, fbo, depthtexture, colortexture);
- if (r_timereport_active)
- R_TimeReport("sky");
- }
- }
+ if (cl.csqc_vidvars.drawworld && r_skylast.integer >= 3)
+ R_RenderSky(fbo, depthtexture, colortexture);
if ((r_shadows.integer == 1 || (r_shadows.integer > 0 && !shadowmapping)) && !r_shadows_drawafterrtlighting.integer && r_refdef.scene.lightmapintensity > 0)
{
cvar_t r_skyscroll1 = {CVAR_SAVE, "r_skyscroll1", "1", "speed at which upper clouds layer scrolls in quake sky"};
cvar_t r_skyscroll2 = {CVAR_SAVE, "r_skyscroll2", "2", "speed at which lower clouds layer scrolls in quake sky"};
cvar_t r_sky_scissor = {0, "r_sky_scissor", "1", "limit rendering of sky to approximately the area of the sky surfaces"};
+extern cvar_t r_skylast;
int skyrenderlater;
int skyrendermasked;
int skyscissor[4];
{
int i;
RSurf_ActiveCustomEntity(&skymatrix, &skyinversematrix, 0, 0, 1, 1, 1, 1, 6*4, skyboxvertex3f, skyboxtexcoord2f, NULL, NULL, NULL, NULL, 6*2, skyboxelement3i, skyboxelement3s, false, false);
+ int flags = MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE;
+ flags |= r_skylast.integer > 0 ? 0 : MATERIALFLAG_NODEPTHTEST;
for (i = 0;i < 6;i++)
if(skyboxskinframe[i])
- R_DrawCustomSurface(skyboxskinframe[i], &identitymatrix, MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE, i*4, 4, i*2, 2, false, false);
+ R_DrawCustomSurface(skyboxskinframe[i], &identitymatrix, flags, i*4, 4, i*2, 2, false, false);
}
#define skygridx 32
speedscale -= floor(speedscale);
Matrix4x4_CreateTranslate(&scroll2matrix, speedscale, speedscale, 0);
+ int flags = MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE;
+ flags |= r_skylast.integer > 0 ? 0 : MATERIALFLAG_NODEPTHTEST;
+
RSurf_ActiveCustomEntity(&skymatrix, &skyinversematrix, 0, 0, 1, 1, 1, 1, skysphere_numverts, skysphere_vertex3f, skysphere_texcoord2f, NULL, NULL, NULL, NULL, skysphere_numtriangles, skysphere_element3i, skysphere_element3s, false, false);
- R_DrawCustomSurface(r_refdef.scene.worldmodel->brush.solidskyskinframe, &scroll1matrix, MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE | MATERIALFLAG_NODEPTHTEST , 0, skysphere_numverts, 0, skysphere_numtriangles, false, false);
- R_DrawCustomSurface(r_refdef.scene.worldmodel->brush.alphaskyskinframe, &scroll2matrix, MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE | MATERIALFLAG_NODEPTHTEST | MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED, 0, skysphere_numverts, 0, skysphere_numtriangles, false, false);
+ R_DrawCustomSurface(r_refdef.scene.worldmodel->brush.solidskyskinframe, &scroll1matrix, flags, 0, skysphere_numverts, 0, skysphere_numtriangles, false, false);
+ R_DrawCustomSurface(r_refdef.scene.worldmodel->brush.alphaskyskinframe, &scroll2matrix, flags | MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED, 0, skysphere_numverts, 0, skysphere_numtriangles, false, false);
}
void R_Sky(void)