mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Merge branch '649-donut-ssao'
This commit is contained in:
commit
c4748f584f
12 changed files with 49 additions and 207 deletions
|
@ -535,7 +535,7 @@ void R_SetupProjectionMatrix( viewDef_t* viewDef, bool doJitter )
|
|||
projectionMatrix[2 * 4 + 2] = -0.999f; // adjust value to prevent imprecision issues
|
||||
|
||||
// RB: was -2.0f * zNear
|
||||
// the transformation into window space has changed from [-1 .. -1] to [0 .. -1]
|
||||
// the transformation into window space has changed from [-1 .. 1] to [0 .. 1]
|
||||
projectionMatrix[3 * 4 + 2] = -1.0f * zNear;
|
||||
|
||||
projectionMatrix[0 * 4 + 3] = 0.0f;
|
||||
|
@ -545,7 +545,8 @@ void R_SetupProjectionMatrix( viewDef_t* viewDef, bool doJitter )
|
|||
|
||||
#else
|
||||
|
||||
// alternative Z for better precision in the distance
|
||||
// alternative far plane at infinity Z for better precision in the distance but still no reversed depth buffer
|
||||
// see Foundations of Game Engine Development 2, chapter 6.3
|
||||
|
||||
float aspect = viewDef->renderView.fov_x / viewDef->renderView.fov_y;
|
||||
|
||||
|
@ -570,7 +571,11 @@ void R_SetupProjectionMatrix( viewDef_t* viewDef, bool doJitter )
|
|||
|
||||
projectionMatrix[0 * 4 + 2] = 0.0f;
|
||||
projectionMatrix[1 * 4 + 2] = 0.0f;
|
||||
|
||||
// adjust value to prevent imprecision issues
|
||||
projectionMatrix[2 * 4 + 2] = -k;
|
||||
|
||||
// the clip space Z range has changed from [-1 .. 1] to [0 .. 1] for DX12 & Vulkan
|
||||
projectionMatrix[3 * 4 + 2] = -k * zNear;
|
||||
|
||||
projectionMatrix[0 * 4 + 3] = 0.0f;
|
||||
|
@ -665,10 +670,12 @@ create a matrix with similar functionality like gluUnproject, project from windo
|
|||
*/
|
||||
void R_SetupUnprojection( viewDef_t* viewDef )
|
||||
{
|
||||
// RB: I don't like that this doesn't work
|
||||
//idRenderMatrix::Inverse( *( idRenderMatrix* ) viewDef->projectionMatrix, viewDef->unprojectionToCameraRenderMatrix );
|
||||
|
||||
R_MatrixFullInverse( viewDef->projectionMatrix, viewDef->unprojectionToCameraMatrix );
|
||||
idRenderMatrix::Transpose( *( idRenderMatrix* )viewDef->unprojectionToCameraMatrix, viewDef->unprojectionToCameraRenderMatrix );
|
||||
|
||||
|
||||
R_MatrixMultiply( viewDef->worldSpace.modelViewMatrix, viewDef->projectionMatrix, viewDef->unprojectionToWorldMatrix );
|
||||
R_MatrixFullInverse( viewDef->unprojectionToWorldMatrix, viewDef->unprojectionToWorldMatrix );
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (C) 2022 Stephen Pridham (id Tech 4x integration)
|
||||
* Copyright (C) 2023 Stephen Saunders (id Tech 4x integration)
|
||||
* Copyright (C) 2023 Robert Beckebans (id Tech 4x integration)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -27,12 +30,12 @@
|
|||
#include "SsaoPass.h"
|
||||
|
||||
|
||||
static idCVar r_ssaoBackgroundViewDepth( "r_ssaoBackgroundViewDepth", "100", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
static idCVar r_ssaoRadiusWorld( "r_ssaoRadiusWorld", "0.5", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
static idCVar r_ssaoSurfaceBias( "r_ssaoSurfaceBias", "0.1", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
static idCVar r_ssaoBackgroundViewDepth( "r_ssaoBackgroundViewDepth", "100", CVAR_RENDERER | CVAR_FLOAT, "specified in meters" );
|
||||
static idCVar r_ssaoRadiusWorld( "r_ssaoRadiusWorld", "1.0", CVAR_RENDERER | CVAR_FLOAT, "specified in meters" );
|
||||
static idCVar r_ssaoSurfaceBias( "r_ssaoSurfaceBias", "0.05", CVAR_RENDERER | CVAR_FLOAT, "specified in meters" );
|
||||
static idCVar r_ssaoPowerExponent( "r_ssaoPowerExponent", "2", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
static idCVar r_ssaoBlurSharpness( "r_ssaoBlurSharpness", "16", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
static idCVar r_ssaoAmount( "r_ssaoAmount", "2", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
static idCVar r_ssaoAmount( "r_ssaoAmount", "4", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
|
||||
struct SsaoConstants
|
||||
{
|
||||
|
@ -40,8 +43,8 @@ struct SsaoConstants
|
|||
idVec2 viewportSize;
|
||||
|
||||
idRenderMatrix matClipToView;
|
||||
idRenderMatrix matWorldToView;
|
||||
idRenderMatrix matViewToWorld;
|
||||
idRenderMatrix matWorldToView; // unused
|
||||
idRenderMatrix matViewToWorld; // unused
|
||||
|
||||
idVec2 clipToView;
|
||||
idVec2 invQuantizedGbufferSize;
|
||||
|
@ -240,42 +243,44 @@ void SsaoPass::Render(
|
|||
assert( m_Blur.BindingSets[bindingSetIndex] );
|
||||
|
||||
{
|
||||
nvrhi::Rect viewExtent( viewDef->viewport.x1, viewDef->viewport.x2, viewDef->viewport.y1, viewDef->viewport.y2 );
|
||||
// RB HACK: add one 1 extra pixel to width and height
|
||||
nvrhi::Rect viewExtent( viewDef->viewport.x1, viewDef->viewport.x2 + 1, viewDef->viewport.y1, viewDef->viewport.y2 + 1 );
|
||||
nvrhi::Rect quarterResExtent = viewExtent;
|
||||
quarterResExtent.minX /= 4;
|
||||
quarterResExtent.minY /= 4;
|
||||
quarterResExtent.maxX = ( quarterResExtent.maxX + 3 ) / 4;
|
||||
quarterResExtent.maxY = ( quarterResExtent.maxY + 3 ) / 4;
|
||||
|
||||
// TODO required and remove this by fixing the shaders
|
||||
renderProgManager.BindShader_TextureVertexColor();
|
||||
renderProgManager.CommitConstantBuffer( commandList, true );
|
||||
|
||||
SsaoConstants ssaoConstants = {};
|
||||
ssaoConstants.viewportOrigin = idVec2( viewDef->viewport.x1, viewDef->viewport.y1 );
|
||||
ssaoConstants.viewportSize = idVec2( viewDef->viewport.GetWidth(), viewDef->viewport.GetHeight() );
|
||||
|
||||
ssaoConstants.matClipToView = viewDef->unprojectionToCameraRenderMatrix;
|
||||
// RB: this actually should work but it only works with the old SSAO method ...
|
||||
//ssaoConstants.matClipToView = viewDef->unprojectionToCameraRenderMatrix;
|
||||
|
||||
// SRS - FIXME: These transformations need to be verified
|
||||
idRenderMatrix::Inverse( *( idRenderMatrix* ) viewDef->projectionMatrix, ssaoConstants.matClipToView );
|
||||
|
||||
// RB: TODO: only need for DIRECTIONAL_OCCLUSION
|
||||
// we don't store the view matrix separatly yet
|
||||
//ssaoConstants.matViewToWorld = viewDef->worldSpace;
|
||||
//idRenderMatrix::Inverse( ssaoConstants.matViewToWorld, ssaoConstants.matWorldToView );
|
||||
// SRS end
|
||||
|
||||
float projectionMatrix[16];
|
||||
|
||||
//R_MatrixTranspose( viewDef->projectionMatrix, projectionMatrix );
|
||||
memcpy( projectionMatrix, viewDef->projectionMatrix, 16 * 4 );
|
||||
|
||||
ssaoConstants.clipToView = idVec2(
|
||||
projectionMatrix[2 * 4 + 3] / projectionMatrix[0 * 4 + 0],
|
||||
projectionMatrix[2 * 4 + 3] / projectionMatrix[1 * 4 + 1] );
|
||||
ssaoConstants.invQuantizedGbufferSize = 1.f / m_QuantizedGbufferTextureSize;
|
||||
viewDef->projectionMatrix[2 * 4 + 3] / viewDef->projectionMatrix[0 * 4 + 0],
|
||||
viewDef->projectionMatrix[2 * 4 + 3] / viewDef->projectionMatrix[1 * 4 + 1] );
|
||||
|
||||
ssaoConstants.invQuantizedGbufferSize = idVec2( 1.0f, 1.0f ) / m_QuantizedGbufferTextureSize;
|
||||
ssaoConstants.quantizedViewportOrigin = idVec2i( quarterResExtent.minX, quarterResExtent.minY ) * 4;
|
||||
ssaoConstants.amount = r_ssaoAmount.GetFloat();
|
||||
ssaoConstants.invBackgroundViewDepth = ( r_ssaoBackgroundViewDepth.GetFloat() > 0.f ) ? 1.f / r_ssaoBackgroundViewDepth.GetFloat() : 0.f;
|
||||
ssaoConstants.radiusWorld = r_ssaoRadiusWorld.GetFloat();
|
||||
ssaoConstants.surfaceBias = r_ssaoSurfaceBias.GetFloat();
|
||||
ssaoConstants.powerExponent = r_ssaoPowerExponent.GetFloat();
|
||||
ssaoConstants.radiusToScreen = 0.5f * viewDef->viewport.GetHeight() * abs( projectionMatrix[1 * 4 + 1] );
|
||||
ssaoConstants.radiusToScreen = 0.5f * viewDef->viewport.GetHeight() * abs( viewDef->projectionMatrix[1 * 4 + 1] );
|
||||
commandList->writeBuffer( m_ConstantBuffer, &ssaoConstants, sizeof( ssaoConstants ) );
|
||||
|
||||
uint32_t dispatchWidth = ( quarterResExtent.width() + 7 ) / 8;
|
||||
|
|
|
@ -44,7 +44,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include <sys/DeviceManager.h>
|
||||
#include <nvrhi/utils.h>
|
||||
|
||||
idCVar r_useNewSsaoPass( "r_useNewSSAOPass", "0", CVAR_RENDERER | CVAR_BOOL, "use the new ssao pass from donut" );
|
||||
idCVar r_useNewSsaoPass( "r_useNewSSAOPass", "1", CVAR_RENDERER | CVAR_BOOL, "use the new SSAO pass from Donut" );
|
||||
extern DeviceManager* deviceManager;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -560,8 +560,6 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
|
|||
{ BUILTIN_AMBIENT_OCCLUSION_AND_OUTPUT, "builtin/SSAO/AmbientOcclusion_AO", "_write", { { "BRIGHTPASS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_AO },
|
||||
{ BUILTIN_AMBIENT_OCCLUSION_BLUR, "builtin/SSAO/AmbientOcclusion_blur", "", { { "BRIGHTPASS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_AO },
|
||||
{ BUILTIN_AMBIENT_OCCLUSION_BLUR_AND_OUTPUT, "builtin/SSAO/AmbientOcclusion_blur", "_write", { { "BRIGHTPASS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_AO },
|
||||
{ BUILTIN_AMBIENT_OCCLUSION_MINIFY, "builtin/SSAO/AmbientOcclusion_minify", "", { { "BRIGHTPASS", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_AO1 },
|
||||
{ BUILTIN_AMBIENT_OCCLUSION_RECONSTRUCT_CSZ, "builtin/SSAO/AmbientOcclusion_minify", "_mip0", { { "BRIGHTPASS", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_AO1 },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI, "builtin/SSGI/DeepGBufferRadiosity_radiosity", "", { }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR, "builtin/SSGI/DeepGBufferRadiosity_blur", "", { }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR_AND_OUTPUT, "builtin/SSGI/DeepGBufferRadiosity_blur", "_write", { }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
|
|
|
@ -392,8 +392,6 @@ enum
|
|||
BUILTIN_AMBIENT_OCCLUSION_AND_OUTPUT,
|
||||
BUILTIN_AMBIENT_OCCLUSION_BLUR,
|
||||
BUILTIN_AMBIENT_OCCLUSION_BLUR_AND_OUTPUT,
|
||||
BUILTIN_AMBIENT_OCCLUSION_MINIFY,
|
||||
BUILTIN_AMBIENT_OCCLUSION_RECONSTRUCT_CSZ,
|
||||
|
||||
BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI,
|
||||
BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR,
|
||||
|
@ -915,16 +913,6 @@ public:
|
|||
BindShader_Builtin( BUILTIN_AMBIENT_OCCLUSION_BLUR_AND_OUTPUT );
|
||||
}
|
||||
|
||||
void BindShader_AmbientOcclusionMinify()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_AMBIENT_OCCLUSION_MINIFY );
|
||||
}
|
||||
|
||||
void BindShader_AmbientOcclusionReconstructCSZ()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_AMBIENT_OCCLUSION_RECONSTRUCT_CSZ );
|
||||
}
|
||||
|
||||
void BindShader_DeepGBufferRadiosity()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI );
|
||||
|
@ -940,13 +928,6 @@ public:
|
|||
BindShader_Builtin( BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR_AND_OUTPUT );
|
||||
}
|
||||
|
||||
#if 0
|
||||
void BindShader_ZCullReconstruct()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_ZCULL_RECONSTRUCT );
|
||||
}
|
||||
#endif
|
||||
|
||||
void BindShader_Bink()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_BINK );
|
||||
|
|
|
@ -163,8 +163,8 @@ float3 reconstructNonUnitCSFaceNormal( float3 C )
|
|||
float3 reconstructCSPosition( float2 S, float z )
|
||||
{
|
||||
float4 P;
|
||||
P.z = z * 2.0 - 1.0;
|
||||
P.xy = ( S * rpWindowCoord.xy ) * 2.0 - 1.0;
|
||||
P.z = z;// * 2.0 - 1.0;
|
||||
P.xy = ( S * rpWindowCoord.xy );// * 2.0 - 1.0;
|
||||
P.w = 1.0;
|
||||
|
||||
float4 csP;
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/**
|
||||
\file AmbientOcclusion_minify.pix
|
||||
\author Morgan McGuire and Michael Mara, NVIDIA Research
|
||||
|
||||
Open Source under the "BSD" license: http://www.opensource.org/licenses/bsd-license.php
|
||||
|
||||
Copyright (c) 2011-2012, NVIDIA
|
||||
Copyright (c) 2016 Robert Beckebans ( id Tech 4.x integration )
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_ViewDepth : register( t0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 2 ) );
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
{
|
||||
float4 color : SV_Target0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
//#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
//#expect USE_PEELED_DEPTH_BUFFER "binary"
|
||||
|
||||
#if 0 //( USE_PEELED_DEPTH_BUFFER != 0 )
|
||||
#define mask rg
|
||||
#else
|
||||
#define mask r
|
||||
#endif
|
||||
|
||||
float reconstructCSZ( float d )
|
||||
{
|
||||
//return clipInfo[0] / (clipInfo[1] * d + clipInfo[2]);
|
||||
|
||||
// infinite far perspective matrix
|
||||
return -3.0 / ( -1.0 * d + 1.0 );
|
||||
|
||||
//d = d * 2.0 - 1.0;
|
||||
//return -rpProjectionMatrixZ.w / ( -rpProjectionMatrixZ.z - d );
|
||||
}
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
#if defined(BRIGHTPASS)
|
||||
float2 ssC = fragment.texcoord0;
|
||||
float depth = t_ViewDepth.Sample( LinearSampler, ssC ).r;
|
||||
//depth = reconstructCSZ( depth );
|
||||
result.color.mask = depth;
|
||||
#else
|
||||
//int2 ssP = int2( gl_FragCoord.xy );
|
||||
int2 ssP = int2( fragment.texcoord0 * rpScreenCorrectionFactor.zw );
|
||||
|
||||
int previousMIPNumber = int( rpJitterTexScale.x );
|
||||
|
||||
// Rotated grid subsampling to avoid XY directional bias or Z precision bias while downsampling.
|
||||
// On DX9, the bit-and can be implemented with floating-point modulo
|
||||
//result.color.mask = texture( samp0, clamp( ssP * 2 + int2( ssP.y & 1, ssP.x & 1 ), int2( 0 ), textureSize( samp0, previousMIPNumber ) - int2( 1 ) ) * rpScreenCorrectionFactor.xy, previousMIPNumber ).mask;
|
||||
int2 ssc = clamp( ssP * 2 + int2( ssP.y & 1, ssP.x & 1 ), int2( 0 ), textureSize( t_ViewDepth, previousMIPNumber ) - int2( 1 ) );
|
||||
result.color.mask = texelFetch( t_ViewDepth, ssc, previousMIPNumber ).mask;
|
||||
//result.color.mask = texelFetch2D( samp0, int3( ssP * 2 + int2( ( ssP.y & 1 ) ^ 1, ( ssP.x & 1 ) ^ 1 ), 0 ) );
|
||||
|
||||
// result.color.mask = texelFetch( samp0, ssP, 0 ).r;
|
||||
|
||||
//float2 ssC = float2( ssP * 2 + int2( ( ssP.y & 1 ) ^ 1, ( ssP.x & 1 ) ^ 1 ) ) * rpScreenCorrectionFactor.xy;
|
||||
//float2 ssC = float2( ssP ) * rpScreenCorrectionFactor.xy;
|
||||
//float2 ssC = fragment.texcoord0;
|
||||
//float depth = tex2D( samp0, ssC ).r;
|
||||
result.color.mask = 0.5;
|
||||
#endif
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct VS_IN
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
float4 color2 : COLOR1;
|
||||
};
|
||||
|
||||
struct VS_OUT
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
result.position = vertex.position;
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
}
|
|
@ -176,13 +176,14 @@ float ComputeAO( float3 V, float3 N, float InvR2 )
|
|||
|
||||
float2 WindowToClip( float2 windowPos )
|
||||
{
|
||||
float2 clipToWindowScale = float2( 0.5f * g_Ssao.viewportSize.x, -0.5f * g_Ssao.viewportSize.y );
|
||||
float2 clipToWindowBias = g_Ssao.viewportOrigin.xy + g_Ssao.viewportSize.xy * 0.5f;
|
||||
float2 clipToWindowScale = float2( 0.5 * g_Ssao.viewportSize.x, -0.5 * g_Ssao.viewportSize.y );
|
||||
float2 clipToWindowBias = g_Ssao.viewportOrigin.xy + g_Ssao.viewportSize.xy * 0.5;
|
||||
|
||||
float2 windowToClipScale = 1.f / clipToWindowScale;
|
||||
float2 windowToClipScale = 1.0 / clipToWindowScale;
|
||||
float2 windowToClipBias = -clipToWindowBias * windowToClipScale;
|
||||
|
||||
// TODO add pixelOffset for TAA
|
||||
//windowPos = windowPos * 2.0 - 1.0;
|
||||
return windowPos.xy * windowToClipScale + windowToClipBias;
|
||||
}
|
||||
|
||||
|
@ -207,7 +208,9 @@ void main( uint3 globalId : SV_DispatchThreadID )
|
|||
float3 pixelNormal = t_Normals[pixelPos].xyz;
|
||||
#endif
|
||||
|
||||
// RB: pixelNormal is already in view space
|
||||
// RB: pixelNormal is already in view space but it has to be negated to look correct which is weird
|
||||
pixelNormal = -normalize( pixelNormal );
|
||||
//pixelNormal = normalize( float3( pixelNormal.x, 1.0 - pixelNormal.y, -pixelNormal.z ) );
|
||||
//pixelNormal = normalize( mul( float4( pixelNormal, 0 ), g_Ssao.matWorldToView ).xyz );
|
||||
|
||||
float2 pixelClipPos = WindowToClip( pixelPos );
|
||||
|
|
|
@ -74,22 +74,12 @@ void main( uint3 globalId : SV_DispatchThreadID )
|
|||
#if LINEAR_DEPTH
|
||||
float linearDepth = depth;
|
||||
#else
|
||||
//float4 clipPos = float4( 0, 0, depth, 1 );
|
||||
//float4 clipPos = float4( 0, 0, depth * 2.0 - 1.0, 1 );
|
||||
|
||||
// adjust depth
|
||||
depth = ( depth * 2.0 - 1.0 );
|
||||
float4 clipPos = float4( 0, 0, depth, 1 );
|
||||
|
||||
float4 viewPos = mul( clipPos, g_Ssao.matClipToView );
|
||||
float linearDepth = viewPos.z / viewPos.w;
|
||||
|
||||
// HACK: adjust linear depth to fit into [0 .. 16000] range
|
||||
//linearDepth += 0.35;
|
||||
//linearDepth = saturate( linearDepth );
|
||||
//linearDepth = 1.0 - linearDepth; // reverse depth
|
||||
//linearDepth *= 4000; // zFar
|
||||
//linearDepth *= DOOM_TO_METERS;
|
||||
linearDepth *= -1.0f; // now we have something similar to Doom units = inches
|
||||
linearDepth *= DOOM_TO_METERS;
|
||||
#endif
|
||||
|
||||
depths[y * 4 + x] = linearDepth;
|
||||
|
|
|
@ -66,7 +66,9 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
localNormal.z = sqrt( 1.0f - dot3( localNormal, localNormal ) );
|
||||
|
||||
float3 globalNormal;
|
||||
#if 0
|
||||
|
||||
#if 1
|
||||
// rotate normal into view space
|
||||
globalNormal.x = dot3( localNormal, fragment.texcoord2 );
|
||||
globalNormal.y = dot3( localNormal, fragment.texcoord3 );
|
||||
globalNormal.z = dot3( localNormal, fragment.texcoord4 );
|
||||
|
@ -81,6 +83,5 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
// RB: rpColor is white and only used to generate the _fa_ uniform array
|
||||
result.color.rgb = ( globalNormal.xyz * 0.5 + 0.5 ) * fragment.color.rgb;// * rpColor;
|
||||
//result.color.rgb = ( globalNormal.xyz );// * fragment.color.rgb;// * rpColor;
|
||||
result.color.a = 1.0;
|
||||
}
|
||||
|
|
|
@ -80,8 +80,6 @@ builtin/SSAO/AmbientOcclusion_AO.vs.hlsl -T vs_5_0 -D BRIGHTPASS={0,1}
|
|||
builtin/SSAO/AmbientOcclusion_AO.ps.hlsl -T ps_5_0 -D BRIGHTPASS={0,1}
|
||||
builtin/SSAO/AmbientOcclusion_blur.vs.hlsl -T vs_5_0 -D BRIGHTPASS={0,1}
|
||||
builtin/SSAO/AmbientOcclusion_blur.ps.hlsl -T ps_5_0 -D BRIGHTPASS={0,1}
|
||||
builtin/SSAO/AmbientOcclusion_minify.vs.hlsl -T vs_5_0 -D BRIGHTPASS={0,1}
|
||||
builtin/SSAO/AmbientOcclusion_minify.ps.hlsl -T ps_5_0 -D BRIGHTPASS={0,1}
|
||||
|
||||
builtin/SSGI/DeepGBufferRadiosity_blur.vs.hlsl -T vs_5_0
|
||||
builtin/SSGI/DeepGBufferRadiosity_blur.ps.hlsl -T ps_5_0
|
||||
|
|
Loading…
Reference in a new issue