mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
SSGI radiosity blur
This commit is contained in:
parent
9e4b6188cc
commit
3c9bc63f61
9 changed files with 459 additions and 32 deletions
351
base/renderprogs/DeepGBufferRadiosity_blur.pixel
Normal file
351
base/renderprogs/DeepGBufferRadiosity_blur.pixel
Normal file
|
@ -0,0 +1,351 @@
|
|||
/**
|
||||
\file AmbientOcclusion_blur.pix
|
||||
\author Morgan McGuire and Michael Mara, NVIDIA Research
|
||||
|
||||
\brief 7-tap 1D cross-bilateral blur using a packed depth key
|
||||
|
||||
Open Source under the "BSD" license: http://www.opensource.org/licenses/bsd-license.php
|
||||
|
||||
Copyright (c) 2011-2014, 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 "renderprogs/global.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register( s0 ); // view color
|
||||
uniform sampler2D samp1 : register( s1 ); // view depth
|
||||
|
||||
#define source samp0
|
||||
#define cszBuffer samp1
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
{
|
||||
float4 color : COLOR;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
#define PEELED_LAYER 0
|
||||
#define USE_OCT16 0
|
||||
|
||||
//#expect PEELED_LAYER "binary"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Tunable Parameters:
|
||||
|
||||
//#define NUM_KEY_COMPONENTS 1
|
||||
|
||||
// The other parameters in this section must be passed in as macro values
|
||||
|
||||
/** Increase to make depth edges crisper. Decrease to reduce flicker. */
|
||||
#define EDGE_SHARPNESS (1.0)
|
||||
|
||||
/** Step in 2-pixel intervals since we already blurred against neighbors in the
|
||||
first AO pass. This constant can be increased while R decreases to improve
|
||||
performance at the expense of some dithering artifacts.
|
||||
|
||||
Morgan found that a scale of 3 left a 1-pixel checkerboard grid that was
|
||||
unobjectionable after shading was applied but eliminated most temporal incoherence
|
||||
from using small numbers of sample taps.
|
||||
*/
|
||||
#define SCALE (2)
|
||||
|
||||
/** Filter radius in pixels. This will be multiplied by SCALE. */
|
||||
#define R (4)
|
||||
|
||||
#define MDB_WEIGHTS 0
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Type of data to read from source. This macro allows
|
||||
the same blur shader to be used on different kinds of input data. */
|
||||
#define VALUE_TYPE float4
|
||||
|
||||
/** Swizzle to use to extract the channels of source. This macro allows
|
||||
the same blur shader to be used on different kinds of input data. */
|
||||
#define VALUE_COMPONENTS rgba
|
||||
|
||||
#define VALUE_IS_KEY 0
|
||||
|
||||
|
||||
//uniform sampler2D cszBuffer;
|
||||
|
||||
/** (1, 0) or (0, 1)*/
|
||||
//uniform int2 axis;
|
||||
|
||||
//#include <compatibility.glsl>
|
||||
|
||||
#if USE_OCT16
|
||||
#include <oct.glsl>
|
||||
#endif
|
||||
|
||||
float3 sampleNormal( sampler2D normalBuffer, int2 ssC, int mipLevel )
|
||||
{
|
||||
#if USE_OCT16
|
||||
return decode16( texelFetch( normalBuffer, ssC, mipLevel ).xy * 2.0 - 1.0 );
|
||||
#else
|
||||
return normalize( texelFetch( normalBuffer, ssC, mipLevel ).xyz * 2.0 - 1.0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
#define blurResult result.color.VALUE_COMPONENTS
|
||||
|
||||
/** 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. Should match the value in AmbientOcclusion_AO.pix */
|
||||
const float FAR_PLANE_Z = -16000.0;
|
||||
|
||||
float3 reconstructCSPosition( float2 S, float z )
|
||||
{
|
||||
float4 P;
|
||||
P.z = z;
|
||||
P.xy = S * rpScreenCorrectionFactor.xy;
|
||||
P.w = 1.0;
|
||||
|
||||
float4 csP;
|
||||
csP.x = dot4( P, rpProjectionMatrixX );
|
||||
csP.y = dot4( P, rpProjectionMatrixY );
|
||||
csP.z = dot4( P, rpProjectionMatrixZ );
|
||||
csP.w = dot4( P, rpProjectionMatrixW );
|
||||
|
||||
csP.xyz /= csP.w;
|
||||
|
||||
return csP.xyz;
|
||||
}
|
||||
|
||||
float3 positionFromKey( float key, int2 ssC )
|
||||
{
|
||||
float z = key * FAR_PLANE_Z;
|
||||
float3 C = reconstructCSPosition( vec2( ssC ) + vec2( 0.5 ), z );
|
||||
return C;
|
||||
}
|
||||
|
||||
#if 0 //def normal_notNull
|
||||
/** Same size as result buffer, do not offset by guard band when reading from it */
|
||||
uniform sampler2D normal_buffer;
|
||||
uniform float4 normal_readMultiplyFirst; // 2.0
|
||||
uniform float4 normal_readAddSecond; // 1.0
|
||||
#endif
|
||||
|
||||
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;
|
||||
|
||||
// Prevents blending over creases.
|
||||
float normalWeight = 1000.0;
|
||||
float planeWeight = 1.0;
|
||||
|
||||
#if 0 //def normal_notNull
|
||||
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.01;
|
||||
|
||||
float3 tapC = positionFromKey( tapKey, tapLoc, projInfo );
|
||||
|
||||
// Change in position in camera space
|
||||
float3 dq = C - tapC;
|
||||
|
||||
// How far away is this point from the original sample
|
||||
// in camera space? (Max value is unbounded)
|
||||
float distance2 = dot( dq, dq );
|
||||
|
||||
// How far off the expected plane (on the perpendicular) is this point? Max value is unbounded.
|
||||
float planeError = max( abs( dot( dq, tapN_C ) ), abs( dot( dq, n_C ) ) );
|
||||
|
||||
planeWeight = ( distance2 < lowDistanceThreshold2 ) ? 1.0 :
|
||||
pow( max( 0.0, 1.0 - EDGE_SHARPNESS * 2.0 * k_plane * planeError / sqrt( distance2 ) ), 2.0 );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
return depthWeight * normalWeight * planeWeight;
|
||||
}
|
||||
|
||||
float getKey( int2 ssP )
|
||||
{
|
||||
#if PEELED_LAYER
|
||||
float key = texelFetch( cszBuffer, ssP, 0 ).g;
|
||||
#else
|
||||
float key = texelFetch( cszBuffer, ssP, 0 ).r;
|
||||
#endif
|
||||
key = clamp( key * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 );
|
||||
return key;
|
||||
}
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
|
||||
//# if __VERSION__ < 330
|
||||
float kernel[R + 1];
|
||||
// if R == 0, we never call this shader
|
||||
#if R == 1
|
||||
kernel[0] = 0.5;
|
||||
kernel[1] = 0.25;
|
||||
#elif R == 2
|
||||
kernel[0] = 0.153170;
|
||||
kernel[1] = 0.144893;
|
||||
kernel[2] = 0.122649;
|
||||
#elif R == 3
|
||||
kernel[0] = 0.153170;
|
||||
kernel[1] = 0.144893;
|
||||
kernel[2] = 0.122649;
|
||||
kernel[3] = 0.092902;
|
||||
#elif R == 4
|
||||
kernel[0] = 0.153170;
|
||||
kernel[1] = 0.144893;
|
||||
kernel[2] = 0.122649;
|
||||
kernel[3] = 0.092902;
|
||||
kernel[4] = 0.062970;
|
||||
#elif R == 5
|
||||
kernel[0] = 0.111220;
|
||||
kernel[1] = 0.107798;
|
||||
kernel[2] = 0.098151;
|
||||
kernel[3] = 0.083953;
|
||||
kernel[4] = 0.067458;
|
||||
kernel[5] = 0.050920;
|
||||
#elif R == 6
|
||||
kernel[0] = 0.111220;
|
||||
kernel[1] = 0.107798;
|
||||
kernel[2] = 0.098151;
|
||||
kernel[3] = 0.083953;
|
||||
kernel[4] = 0.067458;
|
||||
kernel[5] = 0.050920;
|
||||
kernel[6] = 0.036108;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
int2 ssC = int2( gl_FragCoord.xy );
|
||||
|
||||
float4 temp = texelFetch( source, ssC, 0 );
|
||||
|
||||
float key = getKey( ssC );
|
||||
|
||||
VALUE_TYPE sum = temp.VALUE_COMPONENTS;
|
||||
|
||||
#if 0
|
||||
if( fragment.texcoord0.x < 0.75 )
|
||||
{
|
||||
result.color = temp;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( key == 1.0 )
|
||||
{
|
||||
// Sky pixel (if you aren't using depth keying, disable this test)
|
||||
blurResult = sum;
|
||||
#if 0 //defined(BRIGHTPASS)
|
||||
result.color = float4( blurResult, blurResult, blurResult, 1.0 );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Base weight for falloff. Increase this for more blurriness,
|
||||
// decrease it for better edge discrimination
|
||||
float BASE = kernel[0];
|
||||
float totalWeight = BASE;
|
||||
sum *= totalWeight;
|
||||
|
||||
float3 n_C;
|
||||
#if 0 //def normal_notNull
|
||||
n_C = sampleNormal( normal_buffer, ssC, 0 );
|
||||
#endif
|
||||
|
||||
float3 C = positionFromKey( key, ssC );
|
||||
|
||||
#if MDB_WEIGHTS == 0
|
||||
for( int r = -R; r <= R; ++r )
|
||||
{
|
||||
// We already handled the zero case above. This loop should be unrolled and the static branch optimized out,
|
||||
// so the IF statement has no runtime cost
|
||||
if( r != 0 )
|
||||
{
|
||||
int2 tapLoc = ssC + int2( rpJitterTexScale.xy ) * ( r * SCALE );
|
||||
temp = texelFetch( source, tapLoc, 0 );
|
||||
|
||||
|
||||
float tapKey = getKey( tapLoc );
|
||||
VALUE_TYPE value = temp.VALUE_COMPONENTS;
|
||||
|
||||
// spatial domain: offset kernel tap
|
||||
float weight = 0.3 + kernel[abs( r )];
|
||||
|
||||
float bilateralWeight = calculateBilateralWeight( key, tapKey, tapLoc, n_C, C );
|
||||
|
||||
weight *= bilateralWeight;
|
||||
sum += value * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
float lastBilateralWeight = 9999.0;
|
||||
for( int r = -1; r >= -R; --r )
|
||||
{
|
||||
int2 tapLoc = ssC + int2( rpJitterTexScale.xy ) * ( r * SCALE );
|
||||
temp = texelFetch( source, tapLoc, 0 );
|
||||
float tapKey = getKey( tapLoc );
|
||||
|
||||
VALUE_TYPE value = temp.VALUE_COMPONENTS;
|
||||
|
||||
// spatial domain: offset kernel tap
|
||||
float weight = 0.3 + kernel[abs( r )];
|
||||
|
||||
// range domain (the "bilateral" weight). As depth difference increases, decrease weight.
|
||||
float bilateralWeight = calculateBilateralWeight( key, tapKey, tapLoc, n_C, C );
|
||||
bilateralWeight = min( lastBilateralWeight, bilateralWeight );
|
||||
lastBilateralWeight = bilateralWeight;
|
||||
weight *= bilateralWeight;
|
||||
sum += value * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
lastBilateralWeight = 9999.0;
|
||||
for( int r = 1; r <= R; ++r )
|
||||
{
|
||||
int2 tapLoc = ssC + int2( rpJitterTexScale.xy ) * ( r * SCALE );
|
||||
temp = texelFetch( source, tapLoc, 0 );
|
||||
float tapKey = getKey( tapLoc );
|
||||
VALUE_TYPE value = temp.VALUE_COMPONENTS;
|
||||
|
||||
// spatial domain: offset kernel tap
|
||||
float weight = 0.3 + kernel[abs( r )];
|
||||
|
||||
// range domain (the "bilateral" weight). As depth difference increases, decrease weight.
|
||||
float bilateralWeight = calculateBilateralWeight( key, tapKey, tapLoc, n_C, C );
|
||||
bilateralWeight = min( lastBilateralWeight, bilateralWeight );
|
||||
lastBilateralWeight = bilateralWeight;
|
||||
weight *= bilateralWeight;
|
||||
sum += value * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
#endif
|
||||
|
||||
const float epsilon = 0.0001;
|
||||
|
||||
blurResult = sum / ( totalWeight + epsilon );
|
||||
|
||||
#if 0 //defined(BRIGHTPASS)
|
||||
result.color = float4( blurResult, blurResult, blurResult, 1.0 );
|
||||
#endif
|
||||
}
|
|
@ -35,6 +35,8 @@
|
|||
// This must be less than or equal to the MAX_MIP_LEVEL defined in SAmbientOcclusion.cpp
|
||||
#define MAX_MIP_LEVEL (5)
|
||||
|
||||
#define MIN_MIP_LEVEL 0
|
||||
|
||||
const float DOOM_TO_METERS = 0.0254; // doom to meters
|
||||
const float METERS_TO_DOOM = ( 1.0 / DOOM_TO_METERS ); // meters to doom
|
||||
|
||||
|
@ -223,9 +225,9 @@ void computeMipInfo( float ssR, int2 ssP, sampler2D cszBuffer, out int mipLevel,
|
|||
// Derivation:
|
||||
// mipLevel = floor(log(ssR / MAX_OFFSET));
|
||||
#ifdef GL_EXT_gpu_shader5
|
||||
mipLevel = clamp( findMSB( int( ssR ) ) - LOG_MAX_OFFSET, MIN_MIP_LEVEL, MAX_MIP_LEVEL );
|
||||
mipLevel = clamp( findMSB( int( ssR ) ) - LOG_MAX_OFFSET, MIN_MIP_LEVEL, MAX_MIP_LEVEL );
|
||||
#else
|
||||
mipLevel = clamp( int( floor( log2( ssR ) ) ) - LOG_MAX_OFFSET, MIN_MIP_LEVEL, MAX_MIP_LEVEL );
|
||||
mipLevel = clamp( int( floor( log2( ssR ) ) ) - LOG_MAX_OFFSET, MIN_MIP_LEVEL, MAX_MIP_LEVEL );
|
||||
#endif
|
||||
|
||||
// We need to divide by 2^mipLevel to read the appropriately scaled coordinate from a MIP-map.
|
||||
|
@ -390,9 +392,9 @@ void sampleIndirectLight
|
|||
in sampler2D cszBuffer,
|
||||
in sampler2D nBuffer,
|
||||
in sampler2D bounceBuffer,
|
||||
inout float3 irradianceSum,
|
||||
inout float3 irradianceSum,
|
||||
inout float numSamplesUsed,
|
||||
inout float3 iiPeeled,
|
||||
inout float3 iiPeeled,
|
||||
inout float weightSumPeeled )
|
||||
{
|
||||
|
||||
|
@ -457,7 +459,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;
|
47
base/renderprogs/DeepGBufferRadiosity_radiosity.vertex
Normal file
47
base/renderprogs/DeepGBufferRadiosity_radiosity.vertex
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
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 "renderprogs/global.inc"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUT
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
result.position = vertex.position;
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
}
|
|
@ -154,7 +154,9 @@ void idRenderProgManager::Init()
|
|||
{ BUILTIN_AMBIENT_OCCLUSION_BLUR_AND_OUTPUT, "AmbientOcclusion_blur", "_write", BIT( BRIGHTPASS ), false },
|
||||
{ BUILTIN_AMBIENT_OCCLUSION_MINIFY, "AmbientOcclusion_minify", "", 0, false },
|
||||
{ BUILTIN_AMBIENT_OCCLUSION_RECONSTRUCT_CSZ, "AmbientOcclusion_minify", "_mip0", BIT( BRIGHTPASS ), false },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI, "DeepGBufferRadiosity_DeepGBufferRadiosity", "", 0, false },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI, "DeepGBufferRadiosity_radiosity", "", 0, false },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR, "DeepGBufferRadiosity_blur", "", 0, false },
|
||||
{ BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR_AND_OUTPUT, "DeepGBufferRadiosity_blur", "_write", BIT( BRIGHTPASS ), false },
|
||||
// RB end
|
||||
{ BUILTIN_STEREO_DEGHOST, "stereoDeGhost.vfp", 0, false },
|
||||
{ BUILTIN_STEREO_WARP, "stereoWarp.vfp", 0, false },
|
||||
|
|
|
@ -488,6 +488,16 @@ public:
|
|||
BindShader_Builtin( BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI );
|
||||
}
|
||||
|
||||
void BindShader_DeepGBufferRadiosityBlur()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR );
|
||||
}
|
||||
|
||||
void BindShader_DeepGBufferRadiosityBlurAndOutput()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR_AND_OUTPUT );
|
||||
}
|
||||
|
||||
#if 0
|
||||
void BindShader_ZCullReconstruct()
|
||||
{
|
||||
|
@ -619,6 +629,8 @@ protected:
|
|||
BUILTIN_AMBIENT_OCCLUSION_RECONSTRUCT_CSZ,
|
||||
|
||||
BUILTIN_DEEP_GBUFFER_RADIOSITY_SSGI,
|
||||
BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR,
|
||||
BUILTIN_DEEP_GBUFFER_RADIOSITY_BLUR_AND_OUTPUT,
|
||||
// RB end
|
||||
BUILTIN_STEREO_DEGHOST,
|
||||
BUILTIN_STEREO_WARP,
|
||||
|
|
|
@ -262,6 +262,8 @@ idCVar r_forceAmbient( "r_forceAmbient", "0.2", CVAR_RENDERER | CVAR_FLOAT, "ren
|
|||
|
||||
idCVar r_useSSGI( "r_useSSGI", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space global illumination and reflections" );
|
||||
idCVar r_ssgiDebug( "r_ssgiDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
|
||||
idCVar r_ssgiFiltering( "r_ssgiFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
|
||||
|
||||
idCVar r_ssaoFiltering( "r_ssaoFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
|
||||
idCVar r_useHierarchicalDepthBuffer( "r_useHierarchicalDepthBuffer", "1", CVAR_RENDERER | CVAR_BOOL, "" );
|
||||
// RB end
|
||||
|
|
|
@ -2123,9 +2123,9 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
|
|||
const idScreenRect& viewport = backEnd.viewDef->viewport;
|
||||
globalImages->currentNormalsImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
if( r_ssgiDebug.GetInteger() != 1 )
|
||||
//if( r_ssgiDebug.GetInteger() != 1 )
|
||||
{
|
||||
GL_Clear( true, false, false, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f, false );
|
||||
GL_Clear( true, false, false, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 1.0f, false );
|
||||
}
|
||||
|
||||
//if( hdrIsActive )
|
||||
|
@ -4859,7 +4859,19 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
int screenWidth = renderSystem->GetWidth();
|
||||
int screenHeight = renderSystem->GetHeight();
|
||||
|
||||
#if 0
|
||||
// set the window clipping
|
||||
GL_Viewport( 0, 0, screenWidth, screenHeight );
|
||||
GL_Scissor( 0, 0, screenWidth, screenHeight );
|
||||
|
||||
#if 1
|
||||
if( !hdrIsActive )
|
||||
{
|
||||
const idScreenRect& viewport = viewDef->viewport;
|
||||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// build hierarchical depth buffer
|
||||
if( r_useHierarchicalDepthBuffer.GetBool() )
|
||||
{
|
||||
|
@ -4921,31 +4933,31 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
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( !hdrIsActive )
|
||||
{
|
||||
const idScreenRect& viewport = viewDef->viewport;
|
||||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
}
|
||||
|
||||
#if 0
|
||||
if( r_ssaoFiltering.GetBool() )
|
||||
#if 1
|
||||
if( r_ssgiFiltering.GetBool() )
|
||||
{
|
||||
globalFramebuffers.ambientOcclusionFBO[0]->Bind();
|
||||
|
||||
// FIXME remove and mix with color from previous frame
|
||||
glClearColor( 0, 0, 0, 0 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
renderProgManager.BindShader_AmbientOcclusion();
|
||||
renderProgManager.BindShader_DeepGBufferRadiosity();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
//if( r_ssgiDebug.GetInteger() <= 0 )
|
||||
//{
|
||||
// GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
//}
|
||||
if( r_ssgiDebug.GetInteger() <= 0 )
|
||||
{
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
}
|
||||
|
||||
if( hdrIsActive )
|
||||
{
|
||||
|
@ -5015,8 +5027,8 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
#if 0
|
||||
if( r_ssaoFiltering.GetBool() )
|
||||
#if 1
|
||||
if( r_ssgiFiltering.GetBool() )
|
||||
{
|
||||
float jitterTexScale[4];
|
||||
|
||||
|
@ -5024,13 +5036,9 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
#if 1
|
||||
globalFramebuffers.ambientOcclusionFBO[1]->Bind();
|
||||
|
||||
renderProgManager.BindShader_AmbientOcclusionBlur();
|
||||
|
||||
//const idScreenRect& viewport = backEnd.viewDef->viewport;
|
||||
//globalImages->currentAOImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
renderProgManager.BindShader_DeepGBufferRadiosityBlur();
|
||||
|
||||
// set axis parameter
|
||||
|
||||
jitterTexScale[0] = 1;
|
||||
jitterTexScale[1] = 0;
|
||||
jitterTexScale[2] = 0;
|
||||
|
@ -5054,13 +5062,15 @@ static void RB_SSGI( const viewDef_t* viewDef )
|
|||
}
|
||||
|
||||
if( r_ssgiDebug.GetInteger() <= 0 )
|
||||
{
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
renderProgManager.BindShader_DeepGBufferRadiosityBlurAndOutput();
|
||||
|
||||
// set axis parameter
|
||||
jitterTexScale[0] = 0;
|
||||
|
|
|
@ -1104,6 +1104,7 @@ extern idCVar r_forceAmbient;
|
|||
|
||||
extern idCVar r_useSSGI;
|
||||
extern idCVar r_ssgiDebug;
|
||||
extern idCVar r_ssgiFiltering;
|
||||
extern idCVar r_ssaoFiltering;
|
||||
extern idCVar r_useHierarchicalDepthBuffer;
|
||||
// RB end
|
||||
|
|
Loading…
Reference in a new issue