2121#define USE_SHARC_DITHERING 1
2222#define USE_TRANSLUCENCY 1 // translucent foliage
2323#define USE_MOVING_EMISSION_FIX 1 // fixes a dark tail, left by an animated emissive object
24+ #define USE_IS_FOR_ALL_BOUNCES 1 // slower, but better lighting for 2nd+ bounces
2425
2526// Default = 0
2627#define USE_SANITIZATION 0 // NRD sample is NAN/INF free
3637#define USE_SHARC_DEBUG 0 // 1 - show cache, 2 - show grid (NRD sample recompile required)
3738#define USE_TAA_DEBUG 0 // 1 - show weight
3839#define USE_BIAS_FIX 0 // fixes negligible hair and specular bias
40+ #define USE_AO_FOR_LAST_BOUNCE 0 // apply a simple AO estimation to SHARC data for the last bounce
41+ #define USE_WHITE_FURNACE 0 // energy conservation test
3942#define USE_CAMERA_ATTACHED_REFLECTION_TEST 0 // test special treatment for reflections of objects attached to the camera
4043#define USE_RUSSIAN_ROULETTE 0 // bad practice for real-time denoising
4144
125128#define SHARC_MATERIAL_DEMODULATION 1
126129#define SHARC_USE_FP16 0
127130#define SHARC_RADIANCE_SCALE 100.0 // matches max emission intensity range ( must be > SUN_INTENSITY )
131+ #define SHARC_RESAMPLING_DEPTH_MIN 1
128132
129133// Blue noise
130134#define BLUE_NOISE_SPATIAL_DIM 128 // see StaticTexture::ScramblingRanking
131135#define BLUE_NOISE_TEMPORAL_DIM 4 // good values: 4-8 for shadows, 8-16 for occlusion, 8-32 for lighting
132136
133137// Other
134138#define FP16_MAX 65504.0
135- #define INF 1e5
139+ #define INF 1e5 // IMPORTANT: INF * FP16_VIEWZ_SCALE < FP16_MAX!
136140#define LINEAR_BLOCK_SIZE 256
137141#define FP16_VIEWZ_SCALE 0.125 // TODO: tuned for meters, needs to be scaled down for cm and mm
138142#define MAX_MIP_LEVEL 11.0
@@ -238,10 +242,11 @@ NRI_RESOURCE( cbuffer, GlobalConstants, b, 0, SET_ROOT )
238242 float4x4 gViewToWorld;
239243 float4x4 gViewToClip;
240244 float4x4 gWorldToView;
241- float4x4 gWorldToViewPrev;
242245 float4x4 gWorldToClip;
246+ float4x4 gWorldToViewPrev;
243247 float4x4 gWorldToClipPrev;
244- float4 gHitDistParams;
248+ float4x4 gViewToWorldPrev;
249+ float4 gHitDistSettings;
245250 float4 gCameraFrustum;
246251 float4 gSunBasisX;
247252 float4 gSunBasisY;
@@ -260,7 +265,9 @@ NRI_RESOURCE( cbuffer, GlobalConstants, b, 0, SET_ROOT )
260265 float2 gRectSizePrev;
261266 float2 gInvSharcRenderSize;
262267 float2 gJitter;
263- float gEmissionIntensity;
268+ float2 gJitterPrev;
269+ float gEmissionIntensityLights;
270+ float gEmissionIntensityCubes;
264271 float gNearZ;
265272 float gSeparator;
266273 float gRoughnessOverride;
@@ -332,9 +339,8 @@ NRI_RESOURCE( cbuffer, MorphMeshUpdatePrimitivesConstants, b, 0, SET_ROOT )
332339NRI_RESOURCE ( SamplerState , gLinearMipmapLinearSampler, s, 0 , SET_ROOT );
333340NRI_RESOURCE ( SamplerState , gLinearMipmapNearestSampler, s, 1 , SET_ROOT );
334341NRI_RESOURCE ( SamplerState , gNearestMipmapNearestSampler, s, 2 , SET_ROOT );
335-
336- #define gLinearSampler gLinearMipmapLinearSampler
337- #define gNearestSampler gNearestMipmapNearestSampler
342+ NRI_RESOURCE ( SamplerState , gLinearClamp, s, 3 , SET_ROOT );
343+ NRI_RESOURCE ( SamplerState , gNearestClamp, s, 4 , SET_ROOT );
338344
339345//=============================================================================================
340346// MISC
@@ -498,7 +504,11 @@ float3 GetSunIntensity( float3 v )
498504
499505 sunColor *= Math::SmoothStep ( -0.01 , 0.05 , gSunDirection.z );
500506
507+ #if USE_WHITE_FURNACE
508+ return 0.0 ;
509+ #else
501510 return Color::FromGamma ( sunColor ) * SUN_INTENSITY;
511+ #endif
502512}
503513
504514float3 GetSkyIntensity ( float3 v )
@@ -515,7 +525,11 @@ float3 GetSkyIntensity( float3 v )
515525 float ground = 0.5 + 0.5 * Math::SmoothStep ( -1.0 , 0.0 , v.z );
516526 skyColor *= ground;
517527
528+ #if USE_WHITE_FURNACE
529+ return 1.0 ;
530+ #else
518531 return Color::FromGamma ( skyColor ) * SKY_INTENSITY + GetSunIntensity ( v );
532+ #endif
519533}
520534
521535#endif
0 commit comments