fixed r_showsky and cleaned up the related GAL code

This commit is contained in:
myT 2020-04-02 04:50:12 +02:00
parent 24e6cd9277
commit 546296e6ef
6 changed files with 15 additions and 27 deletions

View file

@ -1965,19 +1965,16 @@ static void GAL_EndFrame()
}
}
static void GAL_BeginSkyAndClouds()
static void GAL_BeginSkyAndClouds(double depth)
{
const float clipPlane[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
memcpy(d3d.oldSkyClipPlane, d3d.clipPlane, sizeof(d3d.oldSkyClipPlane));
memcpy(d3d.clipPlane, clipPlane, sizeof(d3d.clipPlane));
ApplyState(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO, CT_TWO_SIDED, qfalse);
d3d.texEnv = TE_DISABLED;
UploadPendingShaderData();
UINT numVP = 1;
d3ds.context->RSGetViewports(&numVP, &d3d.oldSkyViewport);
d3d.oldSkyViewport.MinDepth = 1.0f;
d3d.oldSkyViewport.MaxDepth = 1.0f;
d3d.oldSkyViewport.MinDepth = (FLOAT)depth;
d3d.oldSkyViewport.MaxDepth = (FLOAT)depth;
d3ds.context->RSSetViewports(1, &d3d.oldSkyViewport);
}

View file

@ -1191,18 +1191,9 @@ static void GAL_Begin3D()
}
static void GAL_BeginSkyAndClouds()
static void GAL_BeginSkyAndClouds( double depth )
{
// r_showsky will let all the sky blocks be drawn in
// front of everything to allow developers to see how
// much sky is getting sucked in
if ( r_showsky->integer ) {
glDepthRange( 0.0, 0.0 );
} else {
glDepthRange( 1.0, 1.0 );
}
GL_State( 0 );
glDepthRange( depth, depth );
}

View file

@ -2395,13 +2395,11 @@ static void GAL_Begin3D()
gl.pipelines[PID_GENERIC].uniformsDirty[GU_CLIP_PLANE] = qtrue;
}
static void GAL_BeginSkyAndClouds()
static void GAL_BeginSkyAndClouds(double depth)
{
gl.prevEnableClipPlane = gl.enableClipPlane;
ApplyClipPlane(qfalse);
glDepthRange(1.0, 1.0);
ApplyState(0, CT_TWO_SIDED, qfalse);
gl.alphaTest = AT_ALWAYS;
glDepthRange(depth, depth);
}
static void GAL_EndSkyAndClouds()

View file

@ -435,7 +435,7 @@ static const cvarTableItem_t r_cvars[] =
{ &r_debugSurface, "r_debugSurface", "0", CVAR_CHEAT },
{ &r_nobind, "r_nobind", "0", CVAR_CHEAT },
{ &r_showtris, "r_showtris", "0", CVAR_CHEAT },
{ &r_showsky, "r_showsky", "0", CVAR_CHEAT },
{ &r_showsky, "r_showsky", "0", CVAR_CHEAT, CVART_BOOL, NULL, NULL, "forces sky in front of all surfaces" },
{ &r_shownormals, "r_shownormals", "0", CVAR_CHEAT },
{ &r_clear, "r_clear", "0", CVAR_CHEAT },
{ &r_lockpvs, "r_lockpvs", "0", CVAR_CHEAT },

View file

@ -1522,9 +1522,8 @@ typedef struct {
void (*EndFrame)();
// saves the current clip plane and disables it
// sets depth range to [1; 1]
// disables alpha blending, alpha testing, face culling and polygon offset
void (*BeginSkyAndClouds)();
// sets depth range to [depth; depth]
void (*BeginSkyAndClouds)( double depth );
// sets depth range to [0; 1]
// restores the old clip plane, if any

View file

@ -495,7 +495,7 @@ void R_InitSkyTexCoords( float heightCloud )
static void DrawSkyBox()
{
const image_t*const* skyImages = &tess.shader->sky.outerbox[0];
RB_PushSingleStageShader( 0, CT_TWO_SIDED );
RB_PushSingleStageShader( GLS_DEPTHMASK_TRUE, CT_TWO_SIDED );
shaderStage_t* const stage = tess.shader->stages[0];
stage->rgbGen = CGEN_IDENTITY_LIGHTING;
@ -548,7 +548,10 @@ void RB_DrawSky()
RB_ClipSkyPolygons();
RB_CalcSkyBounds();
gal.BeginSkyAndClouds();
// r_showsky will let all the sky blocks be drawn in
// front of everything to allow developers to see how
// much sky is getting sucked in
gal.BeginSkyAndClouds(r_showsky->integer ? 0.0 : 1.0);
if (tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage)
DrawSkyBox();