mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 10:38:53 +00:00
Add required render matrices to SsaoConstants and init them for render pass
This commit is contained in:
parent
6d83ad0f8d
commit
c7ad3f2801
5 changed files with 25 additions and 38 deletions
|
@ -36,11 +36,10 @@ struct SsaoConstants
|
|||
{
|
||||
idVec2 viewportOrigin;
|
||||
idVec2 viewportSize;
|
||||
|
||||
idVec4 modelMatrixX;
|
||||
idVec4 modelMatrixY;
|
||||
idVec4 modelMatrixZ;
|
||||
idVec4 modelMatrixW;
|
||||
|
||||
idRenderMatrix matClipToView;
|
||||
idRenderMatrix matWorldToView;
|
||||
idRenderMatrix matViewToWorld;
|
||||
|
||||
idVec2 clipToView;
|
||||
idVec2 invQuantizedGbufferSize;
|
||||
|
@ -251,7 +250,13 @@ void SsaoPass::Render(
|
|||
SsaoConstants ssaoConstants = {};
|
||||
ssaoConstants.viewportOrigin = idVec2( viewDef->viewport.x1, viewDef->viewport.y1 );
|
||||
ssaoConstants.viewportSize = idVec2( viewDef->viewport.GetWidth(), viewDef->viewport.GetHeight() );
|
||||
idRenderMatrix::CopyMatrix( *( idRenderMatrix* )viewDef->worldSpace.modelMatrix, ssaoConstants.modelMatrixX, ssaoConstants.modelMatrixY, ssaoConstants.modelMatrixZ, ssaoConstants.modelMatrixW );
|
||||
|
||||
// SRS - FIXME: These transformations need to be verified
|
||||
ssaoConstants.matClipToView = viewDef->unprojectionToCameraRenderMatrix;
|
||||
ssaoConstants.matViewToWorld = viewDef->unprojectionToWorldRenderMatrix;
|
||||
idRenderMatrix::Inverse( ssaoConstants.matViewToWorld, ssaoConstants.matWorldToView );
|
||||
// SRS end
|
||||
|
||||
ssaoConstants.clipToView = idVec2(
|
||||
viewDef->projectionMatrix[2 * 4 + 3] / viewDef->projectionMatrix[0 * 4 + 0],
|
||||
viewDef->projectionMatrix[2 * 4 + 3] / viewDef->projectionMatrix[1 * 4 + 1] );
|
||||
|
|
|
@ -6241,7 +6241,8 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion2( const viewDef_t* _viewDe
|
|||
if( !_viewDef->viewEntitys || _viewDef->is2Dgui )
|
||||
{
|
||||
// 3D views only
|
||||
return;
|
||||
// FIXME: Disable for now until flickering problem is solved
|
||||
//return;
|
||||
}
|
||||
|
||||
if( !r_useSSAO.GetBool() )
|
||||
|
|
|
@ -29,10 +29,9 @@ struct SsaoConstants
|
|||
float2 viewportOrigin;
|
||||
float2 viewportSize;
|
||||
|
||||
float4 modelMatrixX;
|
||||
float4 modelMatrixY;
|
||||
float4 modelMatrixZ;
|
||||
float4 modelMatrixW;
|
||||
float4x4 matClipToView;
|
||||
float4x4 matWorldToView;
|
||||
float4x4 matViewToWorld;
|
||||
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
|
|
|
@ -29,10 +29,9 @@ struct SsaoConstants
|
|||
float2 viewportOrigin;
|
||||
float2 viewportSize;
|
||||
|
||||
float4 modelMatrixX;
|
||||
float4 modelMatrixY;
|
||||
float4 modelMatrixZ;
|
||||
float4 modelMatrixW;
|
||||
float4x4 matClipToView;
|
||||
float4x4 matWorldToView;
|
||||
float4x4 matViewToWorld;
|
||||
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
|
@ -207,13 +206,7 @@ void main( uint3 globalId : SV_DispatchThreadID )
|
|||
float3 pixelNormal = t_Normals[pixelPos].xyz;
|
||||
#endif
|
||||
|
||||
// View to clip space.
|
||||
float3 pN;
|
||||
pN.x = dot4( float4( pixelNormal, 0 ), g_Ssao.modelMatrixX );
|
||||
pN.y = dot4( float4( pixelNormal, 0 ), g_Ssao.modelMatrixY );
|
||||
pN.z = dot4( float4( pixelNormal, 0 ), g_Ssao.modelMatrixZ );
|
||||
|
||||
pixelNormal = normalize( pN );
|
||||
pixelNormal = normalize(mul(float4(pixelNormal, 0), g_Ssao.matWorldToView).xyz);
|
||||
|
||||
float2 pixelClipPos = WindowToClip( pixelPos );
|
||||
float3 pixelViewPos = ViewDepthToViewPos( pixelClipPos.xy, pixelViewDepth );
|
||||
|
@ -276,12 +269,7 @@ void main( uint3 globalId : SV_DispatchThreadID )
|
|||
float directionalLength = length( result.xyz );
|
||||
if( directionalLength > 0 )
|
||||
{
|
||||
float3 worldSpaceResult;
|
||||
worldSpaceResult.x = dot4( float4( normalize( result.xyz ), 0 ), g_Ssao.modelMatrixX );
|
||||
worldSpaceResult.y = dot4( float4( normalize( result.xyz ), 0 ), g_Ssao.modelMatrixY );
|
||||
worldSpaceResult.z = dot4( float4( normalize( result.xyz ), 0 ), g_Ssao.modelMatrixZ );
|
||||
|
||||
result.xyz = worldSpaceResult.xyz * directionalLength;
|
||||
result.xyz = mul(float4(normalize(result.xyz), 0), g_Ssao.matViewToWorld).xyz * directionalLength;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,10 +29,9 @@ struct SsaoConstants
|
|||
float2 viewportOrigin;
|
||||
float2 viewportSize;
|
||||
|
||||
float4 modelMatrixX;
|
||||
float4 modelMatrixY;
|
||||
float4 modelMatrixZ;
|
||||
float4 modelMatrixW;
|
||||
float4x4 matClipToView;
|
||||
float4x4 matWorldToView;
|
||||
float4x4 matViewToWorld;
|
||||
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
|
@ -76,12 +75,7 @@ void main( uint3 globalId : SV_DispatchThreadID )
|
|||
float linearDepth = depth;
|
||||
#else
|
||||
float4 clipPos = float4( 0, 0, depth, 1 );
|
||||
float4 viewPos;
|
||||
viewPos.x = dot4( clipPos, g_Ssao.modelMatrixX );
|
||||
viewPos.y = dot4( clipPos, g_Ssao.modelMatrixY );
|
||||
viewPos.z = dot4( clipPos, g_Ssao.modelMatrixZ );
|
||||
viewPos.w = dot4( clipPos, g_Ssao.modelMatrixW );
|
||||
|
||||
float4 viewPos = mul(clipPos, g_Ssao.matClipToView);
|
||||
float linearDepth = viewPos.z / viewPos.w;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue