Skip to content

Commit

Permalink
Improve (???) Screen Space Ambient Occulsion (at least the shadow arc…
Browse files Browse the repository at this point in the history
…hes are removed now) (ref #61 #84 #135)
  • Loading branch information
MadDeCoDeR committed Dec 10, 2023
1 parent 2b66287 commit 0c79c33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
19 changes: 10 additions & 9 deletions base/renderprogs/AmbientOcclusion_AO.ps.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ float3 reconstructNonUnitCSFaceNormal( float3 C )
float3 reconstructCSPosition( float2 S, float z )
{
float4 P;
P.z = z * 2.0 - 1.0;
P.xy = ( S * rpScreenCorrectionFactor.xy ) * 2.0 - 1.0;
P.w = 1.0;
//P.z = z * 2.0 - 1.0;
//P.xy = S * 2.0 - 1.0;
//P.w = 1.0;
P = float4(S * rpScreenCorrectionFactor.xy, z, 1.0) * 4.0 - 1.0;

float4 csP;
csP.x = dot4( P, rpModelMatrixX );
Expand All @@ -158,7 +159,7 @@ float3 reconstructCSPosition( float2 S, float z )

csP.xyz /= csP.w;

return csP.xyz;
return (csP.xyz * 0.5) + 0.5;
}

float3 sampleNormal( sampler2D normalBuffer, int2 ssC, int mipLevel )
Expand Down Expand Up @@ -312,7 +313,7 @@ float sampleAO( int2 issC, in float3 C, in float3 n_C, in float ssDiskRadius, in
return max( aoValueFromPositionsAndNormal( C, n_C, Q0 ), aoValueFromPositionsAndNormal( C, n_C, Q1 ) );
#else
// The occluding point in camera space
vec3 Q = getOffsetPosition( issC, unitOffset, ssR, cszBuffer, invCszBufferScale );
float3 Q = getOffsetPosition( issC, unitOffset, ssR, cszBuffer, invCszBufferScale );

return aoValueFromPositionsAndNormal( C, n_C, Q );
#endif
Expand All @@ -335,13 +336,13 @@ void main( PS_IN fragment, out PS_OUT result )
#endif

// Pixel being shaded
//float2 ssC = fragment.texcoord0;
//int2 issC = int2( ssC.x * rpScreenCorrectionFactor.z, ssC.y * rpScreenCorrectionFactor.w );
//float2 ssC = fragment.texcoord0 * rpScreenCorrectionFactor.xy;
//int2 ssP = int2( ssC.x * rpScreenCorrectionFactor.z, ssC.y * rpScreenCorrectionFactor.w );

int2 ssP = int2( gl_FragCoord.xy );
int2 ssP = int2(gl_FragCoord.xy);

// World space point being shaded
vec3 C = getPosition( ssP, CS_Z_buffer );
float3 C = getPosition( ssP, CS_Z_buffer );

//float z = length( C - rpGlobalEyePos.xyz );
//bilateralKey = CSZToKey( C.z );
Expand Down
2 changes: 1 addition & 1 deletion neo/renderer/RenderBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4749,7 +4749,7 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion( const viewDef_t* _viewDef
glClearColor( 0, 0, 0, 1 );

GL_SelectTexture( 0 );
globalImages->currentDepthImage->Bind();
//globalImages->currentDepthImage->Bind();

for( int i = 0; i < MAX_HIERARCHICAL_ZBUFFERS; i++ )
{
Expand Down
4 changes: 2 additions & 2 deletions neo/renderer/RenderSystem_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ idCVar r_ssgiFiltering( "r_ssgiFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useSSAO( "r_useSSAO", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space ambient occlusion to darken corners" );
idCVar r_ssaoDebug( "r_ssaoDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
idCVar r_ssaoFiltering( "r_ssaoFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useHierarchicalDepthBuffer( "r_useHierarchicalDepthBuffer", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useHierarchicalDepthBuffer( "r_useHierarchicalDepthBuffer", "0", CVAR_RENDERER | CVAR_BOOL, "" );

idCVar r_exposure( "r_exposure", "0.5", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "HDR exposure or LDR brightness [0.0 .. 1.0]", 0.0f, 1.0f );
// RB end
Expand Down Expand Up @@ -1948,7 +1948,7 @@ void R_VidRestart_f( const idCmdArgs& args )
}

// set the mode without re-initializing the context
R_SetNewMode( false );
R_SetNewMode(false);
// GK: Borderless Mode resolution fixup.
// While we are in exclusive fullscreen we can control the monitor resolution alongside with the game's resolution.
// But in borderless we are limited to the System's resolution and without any DPI awareness System.
Expand Down

0 comments on commit 0c79c33

Please sign in to comment.