Add gl_shownormals cvar as enabling ssao and setting a specific debug level was a bit too obscure for this feature

This commit is contained in:
Magnus Norddahl 2024-03-18 03:26:29 +01:00
commit 7e2d1da4a6
4 changed files with 7 additions and 5 deletions

View file

@ -43,6 +43,7 @@ EXTERN_CVAR(Int, gl_ssao)
EXTERN_CVAR(Int, gl_ssao_portals)
EXTERN_CVAR(Float, gl_ssao_strength)
EXTERN_CVAR(Int, gl_ssao_debug)
EXTERN_CVAR(Bool, gl_shownormals)
EXTERN_CVAR(Float, gl_ssao_bias)
EXTERN_CVAR(Float, gl_ssao_radius)
EXTERN_CVAR(Float, gl_ssao_blur_amount)

View file

@ -722,7 +722,7 @@ void PPAmbientOcclusion::UpdateTextures(int width, int height)
void PPAmbientOcclusion::Render(PPRenderState *renderstate, float m5, int sceneWidth, int sceneHeight)
{
if (gl_ssao == 0 || sceneWidth == 0 || sceneHeight == 0)
if ((gl_ssao == 0 && !gl_shownormals) || sceneWidth == 0 || sceneHeight == 0)
{
return;
}
@ -813,7 +813,7 @@ void PPAmbientOcclusion::Render(PPRenderState *renderstate, float m5, int sceneW
renderstate->Draw();
// Blur SSAO texture
if (gl_ssao_debug < 2)
if (gl_ssao_debug < 2 && !gl_shownormals)
{
renderstate->Clear();
renderstate->Shader = &BlurHorizontal;
@ -840,12 +840,12 @@ void PPAmbientOcclusion::Render(PPRenderState *renderstate, float m5, int sceneW
renderstate->Uniforms.Set(combineUniforms);
renderstate->Viewport = screen->mSceneViewport;
renderstate->SetInputTexture(0, &Ambient0, PPFilterMode::Linear);
if (gl_ssao_debug < 4)
if (gl_ssao_debug < 4 && !gl_shownormals)
renderstate->SetInputSceneFog(1);
else
renderstate->SetInputSceneNormal(1, PPFilterMode::Linear);
renderstate->SetOutputSceneColor();
if (gl_ssao_debug != 0)
if (gl_ssao_debug != 0 || gl_shownormals)
renderstate->SetNoBlend();
else
renderstate->SetAlphaBlend();

View file

@ -72,6 +72,7 @@ CUSTOM_CVAR(Int, gl_ssao_portals, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, gl_ssao_strength, 0.7f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, gl_ssao_debug, 0, 0)
CVAR(Bool, gl_shownormals, false, 0)
CVAR(Float, gl_ssao_bias, 0.2f, 0)
CVAR(Float, gl_ssao_radius, 80.0f, 0)
CUSTOM_CVAR(Float, gl_ssao_blur, 16.0f, 0)

View file

@ -145,7 +145,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
{
bool useSSAO = (gl_ssao != 0);
bool useSSAO = (gl_ssao != 0 || gl_shownormals);
screen->SetSceneRenderTarget(useSSAO);
RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
RenderState.EnableDrawBuffers(RenderState.GetPassDrawBufferCount(), true);