mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
More SSGI and SSAO bugfixes
This commit is contained in:
parent
dec7944856
commit
05da7306d4
5 changed files with 158 additions and 77 deletions
|
@ -39,6 +39,7 @@
|
|||
#define TEMPORALLY_VARY_TAPS 0
|
||||
#define HIGH_QUALITY 1
|
||||
#define USE_OCT16 0
|
||||
#define USE_MIPMAPS 1
|
||||
|
||||
// Total number of direct samples to take at each pixel
|
||||
#define NUM_SAMPLES 11
|
||||
|
@ -63,7 +64,7 @@ const float METERS_TO_DOOM = ( 1.0 / DOOM_TO_METERS ); // meters to doom
|
|||
|
||||
/** Used for preventing AO computation on the sky (at infinite depth) and defining the CS Z to bilateral depth key scaling.
|
||||
This need not match the real far plane but should not be much more than it.*/
|
||||
const float FAR_PLANE_Z = -4000.0;
|
||||
//const float FAR_PLANE_Z = -4000.0;
|
||||
|
||||
/** World-space AO radius in scene units (r). e.g., 1.0m */
|
||||
const float radius = 1.0 * METERS_TO_DOOM;
|
||||
|
@ -111,10 +112,10 @@ struct PS_OUT
|
|||
|
||||
|
||||
/** Used for packing Z into the GB channels */
|
||||
float CSZToKey( float z )
|
||||
{
|
||||
return clamp( z * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 );
|
||||
}
|
||||
// float CSZToKey( float z )
|
||||
// {
|
||||
// return clamp( z * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 );
|
||||
// }
|
||||
|
||||
/** Used for packing Z into the GB channels */
|
||||
void packKey( float key, out float2 p )
|
||||
|
@ -225,7 +226,7 @@ float3 getOffsetPosition( int2 issC, float2 unitOffset, float ssR, sampler2D csz
|
|||
int2 mipP;
|
||||
computeMipInfo( ssR, ssP, cszBuffer, mipLevel, mipP );
|
||||
|
||||
#if 1
|
||||
#if USE_MIPMAPS
|
||||
// RB: this is the key for fast ambient occlusion - use a hierarchical depth buffer
|
||||
// for more information see McGuire12SAO.pdf - Scalable Ambient Obscurance
|
||||
// http://graphics.cs.williams.edu/papers/SAOHPG12/
|
||||
|
|
|
@ -19,11 +19,13 @@
|
|||
#include "renderprogs/global.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register( s0 ); // view color
|
||||
uniform sampler2D samp0 : register( s0 ); // view normals
|
||||
uniform sampler2D samp1 : register( s1 ); // view depth
|
||||
uniform sampler2D samp2 : register( s2 ); // view AO
|
||||
|
||||
#define source samp0
|
||||
#define normal_buffer samp0
|
||||
#define cszBuffer samp1
|
||||
#define source samp2
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
@ -38,6 +40,7 @@ struct PS_OUT
|
|||
|
||||
#define PEELED_LAYER 0
|
||||
#define USE_OCT16 0
|
||||
#define USE_NORMALS 1
|
||||
|
||||
//#expect PEELED_LAYER "binary"
|
||||
|
||||
|
@ -104,7 +107,12 @@ float3 sampleNormal( sampler2D normalBuffer, int2 ssC, int mipLevel )
|
|||
|
||||
/** Used for preventing AO computation on the sky (at infinite depth) and defining the CS Z to bilateral depth key scaling.
|
||||
This need not match the real far plane but should not be much more than it.*/
|
||||
const float FAR_PLANE_Z = -4000.0;
|
||||
const float FAR_PLANE_Z = -16000.0;
|
||||
|
||||
float CSZToKey( float z )
|
||||
{
|
||||
return clamp( z * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 );
|
||||
}
|
||||
|
||||
float reconstructCSZ( float d )
|
||||
{
|
||||
|
@ -120,7 +128,7 @@ float reconstructCSZ( float d )
|
|||
float3 reconstructCSPosition( float2 S, float z )
|
||||
{
|
||||
float4 P;
|
||||
P.z = z;// * 2.0 - 1.0;
|
||||
P.z = z * 2.0 - 1.0;
|
||||
P.xy = ( S * rpScreenCorrectionFactor.xy ) * 2.0 - 1.0;
|
||||
P.w = 1.0;
|
||||
|
||||
|
@ -143,7 +151,7 @@ float getKey( int2 ssP )
|
|||
float key = texelFetch( cszBuffer, ssP, 0 ).r;
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
key = reconstructCSZ( key );
|
||||
#else
|
||||
float3 P = reconstructCSPosition( float2( ssP ) + float2( 0.5 ), key );
|
||||
|
@ -161,6 +169,18 @@ float3 positionFromKey( float key, int2 ssC )
|
|||
return C;
|
||||
}
|
||||
|
||||
/** Read the camera-space position of the point at screen-space pixel ssP */
|
||||
float3 getPosition( int2 ssP, sampler2D cszBuffer )
|
||||
{
|
||||
float3 P;
|
||||
P.z = texelFetch( cszBuffer, ssP, 0 ).r;
|
||||
|
||||
// Offset to pixel center
|
||||
P = reconstructCSPosition( float2( ssP ) + float2( 0.5 ), P.z );
|
||||
|
||||
return P;
|
||||
}
|
||||
|
||||
float calculateBilateralWeight( float key, float tapKey, int2 tapLoc, float3 n_C, float3 C )
|
||||
{
|
||||
// range domain (the "bilateral" weight). As depth difference increases, decrease weight.
|
||||
|
@ -173,16 +193,17 @@ float calculateBilateralWeight( float key, float tapKey, int2 tapLoc, float3 n_C
|
|||
float normalWeight = 1.0;
|
||||
float planeWeight = 1.0;
|
||||
|
||||
#if 0 //def normal_notNull
|
||||
float3 tapN_C = texelFetch( normal_buffer, tapLoc, 0 ).xyz;
|
||||
tapN_C = normalize( tapN_C * normal_readMultiplyFirst.xyz + normal_readAddSecond.xyz );
|
||||
#if USE_NORMALS
|
||||
float3 tapN_C = sampleNormal( normal_buffer, tapLoc, 0 );
|
||||
depthWeight = 1.0;
|
||||
|
||||
float normalError = 1.0 - dot( tapN_C, n_C ) * k_normal;
|
||||
normalWeight = max( ( 1.0 - EDGE_SHARPNESS * normalError ), 0.00 );
|
||||
|
||||
float lowDistanceThreshold2 = 0.001;
|
||||
|
||||
float3 tapC = positionFromKey( tapKey, tapLoc, projInfo );
|
||||
//float3 tapC = positionFromKey( tapKey, tapLoc, projInfo );
|
||||
float3 tapC = getPosition( tapLoc, cszBuffer );
|
||||
|
||||
// Change in position in camera space
|
||||
float3 dq = C - tapC;
|
||||
|
@ -251,10 +272,6 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float4 temp = texelFetch( source, ssC, 0 );
|
||||
|
||||
float key = getKey( ssC );
|
||||
|
||||
VALUE_TYPE sum = temp.VALUE_COMPONENTS;
|
||||
|
||||
#if 0
|
||||
if( fragment.texcoord0.x < 0.75 )
|
||||
{
|
||||
|
@ -263,6 +280,16 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
float key = getKey( ssC );
|
||||
float3 C = positionFromKey( key, ssC );
|
||||
#else
|
||||
float3 C = getPosition( ssC, cszBuffer );
|
||||
float key = CSZToKey( C.z );
|
||||
#endif
|
||||
|
||||
VALUE_TYPE sum = temp.VALUE_COMPONENTS;
|
||||
|
||||
if( key == 1.0 )
|
||||
{
|
||||
// Sky pixel (if you aren't using depth keying, disable this test)
|
||||
|
@ -280,12 +307,10 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
sum *= totalWeight;
|
||||
|
||||
float3 n_C;
|
||||
#if 0 //def normal_notNull
|
||||
#if USE_NORMALS
|
||||
n_C = sampleNormal( normal_buffer, ssC, 0 );
|
||||
#endif
|
||||
|
||||
float3 C = positionFromKey( key, ssC );
|
||||
|
||||
#if MDB_WEIGHTS == 0
|
||||
for( int r = -R; r <= R; ++r )
|
||||
{
|
||||
|
|
|
@ -19,11 +19,13 @@
|
|||
#include "renderprogs/global.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register( s0 ); // view color
|
||||
uniform sampler2D samp0 : register( s0 ); // view normals
|
||||
uniform sampler2D samp1 : register( s1 ); // view depth
|
||||
uniform sampler2D samp2 : register( s2 ); // view AO
|
||||
|
||||
#define source samp0
|
||||
#define normal_buffer samp0
|
||||
#define cszBuffer samp1
|
||||
#define source samp2
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
@ -38,6 +40,7 @@ struct PS_OUT
|
|||
|
||||
#define PEELED_LAYER 0
|
||||
#define USE_OCT16 0
|
||||
#define USE_NORMALS 1
|
||||
|
||||
//#expect PEELED_LAYER "binary"
|
||||
|
||||
|
@ -100,7 +103,12 @@ float3 sampleNormal( sampler2D normalBuffer, int2 ssC, int mipLevel )
|
|||
|
||||
/** Used for preventing AO computation on the sky (at infinite depth) and defining the CS Z to bilateral depth key scaling.
|
||||
This need not match the real far plane but should not be much more than it.*/
|
||||
const float FAR_PLANE_Z = -4000.0;
|
||||
const float FAR_PLANE_Z = -16000.0;
|
||||
|
||||
float CSZToKey( float z )
|
||||
{
|
||||
return clamp( z * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 );
|
||||
}
|
||||
|
||||
float reconstructCSZ( float d )
|
||||
{
|
||||
|
@ -140,12 +148,12 @@ float getKey( int2 ssP )
|
|||
#endif
|
||||
|
||||
#if 0
|
||||
key = reconstructCSZ( key );
|
||||
key = reconstructCSZ( key );
|
||||
#else
|
||||
float3 P = reconstructCSPosition( float2( ssP ) + float2( 0.5 ), key );
|
||||
key = P.z;
|
||||
#endif
|
||||
|
||||
|
||||
key = clamp( key * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 );
|
||||
return key;
|
||||
}
|
||||
|
@ -157,19 +165,31 @@ float3 positionFromKey( float key, int2 ssC )
|
|||
return C;
|
||||
}
|
||||
|
||||
/** Read the camera-space position of the point at screen-space pixel ssP */
|
||||
float3 getPosition( int2 ssP, sampler2D cszBuffer )
|
||||
{
|
||||
float3 P;
|
||||
P.z = texelFetch( cszBuffer, ssP, 0 ).r;
|
||||
|
||||
// Offset to pixel center
|
||||
P = reconstructCSPosition( float2( ssP ) + float2( 0.5 ), P.z );
|
||||
|
||||
return P;
|
||||
}
|
||||
|
||||
float calculateBilateralWeight( float key, float tapKey, int2 tapLoc, float3 n_C, float3 C )
|
||||
{
|
||||
// range domain (the "bilateral" weight). As depth difference increases, decrease weight.
|
||||
float depthWeight = max( 0.0, 1.0 - ( EDGE_SHARPNESS * 2000.0 ) * abs( tapKey - key ) );
|
||||
|
||||
float k_normal = 40.0;
|
||||
float k_plane = 0.5;
|
||||
float k_normal = 1.0; //40.0;
|
||||
float k_plane = 1.0; //0.5;
|
||||
|
||||
// Prevents blending over creases.
|
||||
float normalWeight = 1000.0;
|
||||
float normalWeight = 1.0; //1000.0;
|
||||
float planeWeight = 1.0;
|
||||
|
||||
#if 0 //def normal_notNull
|
||||
#if USE_NORMALS
|
||||
float3 tapN_C = sampleNormal( normal_buffer, tapLoc, 0 );
|
||||
depthWeight = 1.0;
|
||||
|
||||
|
@ -177,9 +197,10 @@ float calculateBilateralWeight( float key, float tapKey, int2 tapLoc, float3 n_C
|
|||
normalWeight = max( 1.0 - EDGE_SHARPNESS * normalError, 0.00 );
|
||||
|
||||
|
||||
float lowDistanceThreshold2 = 0.01;
|
||||
float lowDistanceThreshold2 = 0.001; //0.01;
|
||||
|
||||
float3 tapC = positionFromKey( tapKey, tapLoc, projInfo );
|
||||
//float3 tapC = positionFromKey( tapKey, tapLoc, projInfo );
|
||||
float3 tapC = getPosition( tapLoc, cszBuffer );
|
||||
|
||||
// Change in position in camera space
|
||||
float3 dq = C - tapC;
|
||||
|
@ -248,10 +269,6 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float4 temp = texelFetch( source, ssC, 0 );
|
||||
|
||||
float key = getKey( ssC );
|
||||
|
||||
VALUE_TYPE sum = temp.VALUE_COMPONENTS;
|
||||
|
||||
#if 0
|
||||
if( fragment.texcoord0.x < 0.75 )
|
||||
{
|
||||
|
@ -260,6 +277,16 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
float key = getKey( ssC );
|
||||
float3 C = positionFromKey( key, ssC );
|
||||
#else
|
||||
float3 C = getPosition( ssC, cszBuffer );
|
||||
float key = CSZToKey( C.z );
|
||||
#endif
|
||||
|
||||
VALUE_TYPE sum = temp.VALUE_COMPONENTS;
|
||||
|
||||
if( key == 1.0 )
|
||||
{
|
||||
// Sky pixel (if you aren't using depth keying, disable this test)
|
||||
|
@ -274,12 +301,10 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
sum *= totalWeight;
|
||||
|
||||
float3 n_C;
|
||||
#if 0 //def normal_notNull
|
||||
#if USE_NORMALS
|
||||
n_C = sampleNormal( normal_buffer, ssC, 0 );
|
||||
#endif
|
||||
|
||||
float3 C = positionFromKey( key, ssC );
|
||||
|
||||
#if MDB_WEIGHTS == 0
|
||||
for( int r = -R; r <= R; ++r )
|
||||
{
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
// #extension GL_EXT_gpu_shader4 : require
|
||||
// #extension GL_ARB_gpu_shader5 : enable
|
||||
|
||||
|
||||
|
||||
#define DIFFERENT_DEPTH_RESOLUTIONS 0
|
||||
#define USE_DEPTH_PEEL 0
|
||||
#define CS_Z_PACKED_TOGETHER 0
|
||||
#define TEMPORALLY_VARY_TAPS 1
|
||||
#define HIGH_QUALITY 1
|
||||
#define TEMPORALLY_VARY_TAPS 0
|
||||
#define USE_OCT16 0
|
||||
#define COMPUTE_PEELED_LAYER 0
|
||||
#define USE_MIPMAPS 0
|
||||
#define USE_MIPMAPS 1
|
||||
#define USE_TAP_NORMAL 0
|
||||
|
||||
#define HIGH_QUALITY 0
|
||||
|
||||
#if HIGH_QUALITY
|
||||
// Total number of direct samples to take at each pixel
|
||||
#define NUM_SAMPLES 39
|
||||
|
||||
|
@ -24,6 +24,13 @@
|
|||
// taps from lining up. This particular choice was tuned for NUM_SAMPLES == 9
|
||||
#define NUM_SPIRAL_TURNS 14
|
||||
|
||||
#else
|
||||
|
||||
#define NUM_SAMPLES 11
|
||||
#define NUM_SPIRAL_TURNS 7
|
||||
|
||||
#endif
|
||||
|
||||
// If using depth mip levels, the log of the maximum pixel offset before we need to switch to a lower
|
||||
// miplevel to maintain reasonable spatial locality in the cache
|
||||
// If this number is too small (< 3), too many taps will land in the same pixel, and we'll get bad variance that manifests as flashing.
|
||||
|
@ -71,7 +78,7 @@ const float projScale = 500.0;
|
|||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register( s0 ); // view normals
|
||||
uniform sampler2D samp1 : register( s1 ); // view depth
|
||||
uniform sampler2D samp2 : register( s2 ); // view depth
|
||||
uniform sampler2D samp2 : register( s2 ); // colors
|
||||
|
||||
#define normal_buffer samp0
|
||||
#define CS_Z_buffer samp1
|
||||
|
@ -219,8 +226,9 @@ void getPositions( int2 ssP, sampler2D cszBuffer, out float3 P0, out float3 P1 )
|
|||
}
|
||||
|
||||
|
||||
void computeMipInfo( float ssR, int2 ssP, sampler2D cszBuffer, out int mipLevel, out int2 mipP )
|
||||
void computeMipInfo( float ssR, int2 ssP, sampler2D cszBuffer, inout int mipLevel, inout int2 mipP )
|
||||
{
|
||||
#if USE_MIPMAPS
|
||||
// Derivation:
|
||||
// mipLevel = floor(log(ssR / MAX_OFFSET));
|
||||
#ifdef GL_EXT_gpu_shader5
|
||||
|
@ -231,7 +239,13 @@ void computeMipInfo( float ssR, int2 ssP, sampler2D cszBuffer, out int mipLevel,
|
|||
|
||||
// We need to divide by 2^mipLevel to read the appropriately scaled coordinate from a MIP-map.
|
||||
// Manually clamp to the texture size because texelFetch bypasses the texture unit
|
||||
mipP = ssP >> mipLevel;//clamp(ssP >> mipLevel, int2(0), textureSize(CS_Z_buffer, mipLevel) - int2(1));
|
||||
//mipP = ssP >> mipLevel;//clamp(ssP >> mipLevel, int2(0), textureSize(CS_Z_buffer, mipLevel) - int2(1));
|
||||
|
||||
mipP = clamp( ssP >> mipLevel, int2( 0 ), textureSize( cszBuffer, mipLevel ) - int2( 1 ) );
|
||||
#else
|
||||
mipLevel = 0;
|
||||
mipP = ssP;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,9 +293,9 @@ void getOffsetPositionNormalAndLambertian
|
|||
sampler2D cszBuffer,
|
||||
sampler2D bounceBuffer,
|
||||
sampler2D normalBuffer,
|
||||
out float3 Q,
|
||||
out float3 lambertian_tap,
|
||||
out float3 n_tap )
|
||||
inout float3 Q,
|
||||
inout float3 lambertian_tap,
|
||||
inout float3 n_tap )
|
||||
{
|
||||
|
||||
#if USE_MIPMAPS
|
||||
|
@ -294,9 +308,18 @@ void getOffsetPositionNormalAndLambertian
|
|||
#endif
|
||||
|
||||
float z = texelFetch( cszBuffer, texel, mipLevel ).r;
|
||||
|
||||
// FIXME mip map bounce/normal buffers FBOs
|
||||
#if 0
|
||||
float3 n = sampleNormal( normalBuffer, texel, mipLevel );
|
||||
n_tap = n;
|
||||
lambertian_tap = texelFetch( bounceBuffer, texel, mipLevel ).rgb;
|
||||
#else
|
||||
float3 n = sampleNormal( normalBuffer, ssP, 0 );
|
||||
lambertian_tap = texelFetch( bounceBuffer, ssP, 0 ).rgb;
|
||||
#endif
|
||||
|
||||
//n_tap = normalize( n );
|
||||
n_tap = n;
|
||||
|
||||
// Offset to pixel center
|
||||
Q = reconstructCSPosition( ( float2( ssP ) + float2( 0.5 ) ), z );
|
||||
|
@ -345,7 +368,7 @@ void getOffsetPositionsNormalsAndLambertians
|
|||
}
|
||||
|
||||
|
||||
void iiValueFromPositionsAndNormalsAndLambertian( int2 ssP, float3 X, float3 n_X, float3 Y, float3 n_Y, float3 radiosity_Y, out float3 E, out float weight_Y, out float visibilityWeight_Y )
|
||||
void iiValueFromPositionsAndNormalsAndLambertian( int2 ssP, float3 X, float3 n_X, float3 Y, float3 n_Y, float3 radiosity_Y, inout float3 E, inout float weight_Y, inout float visibilityWeight_Y )
|
||||
{
|
||||
|
||||
float3 YminusX = Y - X;
|
||||
|
@ -459,7 +482,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
{
|
||||
result.color = float4( 0.0, 0.0, 0.0, 1.0 );
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
if( fragment.texcoord0.x < 0.5 )
|
||||
{
|
||||
discard;
|
||||
|
@ -481,6 +504,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
#endif
|
||||
|
||||
float3 n_C = sampleNormal( normal_buffer, ssC, 0 );
|
||||
//n_C = normalize( n_C );
|
||||
|
||||
|
||||
// Choose the screen-space sample radius
|
||||
|
@ -516,6 +540,8 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
// What is the ambient visibility of this location
|
||||
visibility = 1 - numSamplesUsed / float( NUM_SAMPLES );
|
||||
//visibility = clamp( 1 - numSamplesUsed / float( NUM_SAMPLES ), 0.0, 1.0 );
|
||||
//visibility = pow( max( 0.0, 1.0 - sqrt( sum * ( 3.0 / NUM_SAMPLES ) ) ), intensity );
|
||||
|
||||
//result.color = float4( visibility, visibility, visibility, 1.0 );
|
||||
//result.color = float4( n_C * 0.5 + 0.5, 1.0 );
|
||||
|
|
|
@ -3860,6 +3860,17 @@ static int RB_DrawShaderPasses( const drawSurf_t* const* const drawSurfs, const
|
|||
GL_Cull( CT_FRONT_SIDED );
|
||||
GL_Color( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
// disable stencil shadow test
|
||||
GL_State( GLS_DEFAULT );
|
||||
|
||||
// unbind texture units
|
||||
for( int i = 0; i < 7; i++ )
|
||||
{
|
||||
GL_SelectTexture( i );
|
||||
globalImages->BindNull();
|
||||
}
|
||||
GL_SelectTexture( 0 );
|
||||
|
||||
renderLog.CloseBlock();
|
||||
return i;
|
||||
}
|
||||
|
@ -4728,9 +4739,9 @@ static void RB_SSAO( const viewDef_t* viewDef )
|
|||
}
|
||||
|
||||
SetVertexParms( RENDERPARM_MODELMATRIX_X, cameraToWorldMatrix[0], 4 );
|
||||
//SetVertexParms( RENDERPARM_MODELMATRIX_X, backEnd.viewDef->unprojectionToWorldRenderMatrix[0], 4 );
|
||||
//SetVertexParms( RENDERPARM_MODELMATRIX_X, viewDef->unprojectionToWorldRenderMatrix[0], 4 );
|
||||
#endif
|
||||
SetVertexParms( RENDERPARM_MODELMATRIX_X, backEnd.viewDef->unprojectionToCameraRenderMatrix[0], 4 );
|
||||
SetVertexParms( RENDERPARM_MODELMATRIX_X, viewDef->unprojectionToCameraRenderMatrix[0], 4 );
|
||||
|
||||
|
||||
float jitterTexOffset[4];
|
||||
|
@ -4744,7 +4755,7 @@ static void RB_SSAO( const viewDef_t* viewDef )
|
|||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
}
|
||||
jitterTexOffset[2] = backEnd.viewDef->renderView.time[0] * 0.001f;
|
||||
jitterTexOffset[2] = viewDef->renderView.time[0] * 0.001f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
|
@ -4773,18 +4784,14 @@ static void RB_SSAO( const viewDef_t* viewDef )
|
|||
|
||||
renderProgManager.BindShader_AmbientOcclusionBlur();
|
||||
|
||||
//const idScreenRect& viewport = backEnd.viewDef->viewport;
|
||||
//globalImages->currentAOImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
// set axis parameter
|
||||
|
||||
jitterTexScale[0] = 1;
|
||||
jitterTexScale[1] = 0;
|
||||
jitterTexScale[2] = 0;
|
||||
jitterTexScale[3] = 0;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
GL_SelectTexture( 2 );
|
||||
globalImages->ambientOcclusionImage[0]->Bind();
|
||||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
@ -4805,8 +4812,6 @@ static void RB_SSAO( const viewDef_t* viewDef )
|
|||
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
}
|
||||
|
||||
//globalImages->currentAOImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
renderProgManager.BindShader_AmbientOcclusionBlurAndOutput();
|
||||
|
||||
// set axis parameter
|
||||
|
@ -4816,7 +4821,7 @@ static void RB_SSAO( const viewDef_t* viewDef )
|
|||
jitterTexScale[3] = 0;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
GL_SelectTexture( 2 );
|
||||
globalImages->ambientOcclusionImage[1]->Bind();
|
||||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
@ -4869,7 +4874,6 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
}
|
||||
|
||||
#if 1
|
||||
// build hierarchical depth buffer
|
||||
if( r_useHierarchicalDepthBuffer.GetBool() )
|
||||
{
|
||||
|
@ -4924,17 +4928,14 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// set the window clipping
|
||||
GL_Viewport( 0, 0, screenWidth, screenHeight );
|
||||
GL_Scissor( 0, 0, screenWidth, screenHeight );
|
||||
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
//GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
GL_Cull( CT_TWO_SIDED );
|
||||
|
||||
#if 1
|
||||
if( r_ssgiFiltering.GetBool() )
|
||||
{
|
||||
globalFramebuffers.ambientOcclusionFBO[0]->Bind();
|
||||
|
@ -4946,7 +4947,6 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
renderProgManager.BindShader_DeepGBufferRadiosity();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( r_ssgiDebug.GetInteger() > 0 )
|
||||
{
|
||||
|
@ -4989,9 +4989,9 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
}
|
||||
|
||||
SetVertexParms( RENDERPARM_MODELMATRIX_X, cameraToWorldMatrix[0], 4 );
|
||||
//SetVertexParms( RENDERPARM_MODELMATRIX_X, backEnd.viewDef->unprojectionToWorldRenderMatrix[0], 4 );
|
||||
//SetVertexParms( RENDERPARM_MODELMATRIX_X, viewDef->unprojectionToWorldRenderMatrix[0], 4 );
|
||||
#endif
|
||||
SetVertexParms( RENDERPARM_MODELMATRIX_X, backEnd.viewDef->unprojectionToCameraRenderMatrix[0], 4 );
|
||||
SetVertexParms( RENDERPARM_MODELMATRIX_X, viewDef->unprojectionToCameraRenderMatrix[0], 4 );
|
||||
|
||||
|
||||
float jitterTexOffset[4];
|
||||
|
@ -5005,7 +5005,7 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
}
|
||||
jitterTexOffset[2] = backEnd.viewDef->renderView.time[0] * 0.001f;
|
||||
jitterTexOffset[2] = viewDef->renderView.time[0] * 0.001f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
|
@ -5034,7 +5034,6 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
#if 1
|
||||
if( r_ssgiFiltering.GetBool() )
|
||||
{
|
||||
float jitterTexScale[4];
|
||||
|
@ -5052,7 +5051,7 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
jitterTexScale[3] = 0;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
GL_SelectTexture( 2 );
|
||||
globalImages->ambientOcclusionImage[0]->Bind();
|
||||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
@ -5088,12 +5087,11 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
jitterTexScale[3] = 0;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
GL_SelectTexture( 2 );
|
||||
globalImages->ambientOcclusionImage[1]->Bind();
|
||||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
}
|
||||
#endif
|
||||
|
||||
renderProgManager.Unbind();
|
||||
|
||||
|
@ -5247,6 +5245,7 @@ void RB_DrawViewInternal( const viewDef_t* viewDef, const int stereoEye )
|
|||
// darken the scene using the screen space ambient occlusion result
|
||||
//-------------------------------------------------
|
||||
//RB_SSAO( viewDef );
|
||||
//RB_SSGI( viewDef );
|
||||
|
||||
//-------------------------------------------------
|
||||
// now draw any non-light dependent shading passes
|
||||
|
@ -5631,6 +5630,11 @@ void RB_PostProcess( const void* data )
|
|||
return;
|
||||
}
|
||||
|
||||
if( r_ssgiDebug.GetInteger() > 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_PostProcess() ----------\n" );
|
||||
|
||||
// resolve the scaled rendering to a temporary texture
|
||||
|
|
Loading…
Reference in a new issue