@@ -172,7 +172,7 @@ TraceOpaqueResult TraceOpaque( GeometryProps geometryProps0, MaterialProps mater
172172 sharcParams.resolvedBuffer = gInOut_SharcResolved;
173173
174174 #if ( USE_SHARC_DEBUG == 2 )
175- result.diffRadiance = HashGridDebugColoredHash ( sharcHitData.positionWorld, hashGridParams );
175+ result.diffRadiance = HashGridDebugColoredHash ( sharcHitData.positionWorld, sharcHitData.normalWorld, hashGridParams );
176176 #else
177177 bool isValid = SharcGetCachedRadiance ( sharcParams, sharcHitData, result.diffRadiance, true );
178178
@@ -349,10 +349,9 @@ TraceOpaqueResult TraceOpaque( GeometryProps geometryProps0, MaterialProps mater
349349 rndScaled *= USE_SHARC_DITHERING;
350350
351351 float3x3 mBasis = Geometry::GetBasis ( geometryProps.N );
352- Xglobal + = mBasis[ 0 ] * rndScaled.x + mBasis[ 1 ] * rndScaled.y;
352+ float3 jitter = mBasis[ 0 ] * rndScaled.x + mBasis[ 1 ] * rndScaled.y;
353353
354354 SharcHitData sharcHitData;
355- sharcHitData.positionWorld = Xglobal;
356355 sharcHitData.materialDemodulation = GetMaterialDemodulation ( geometryProps, materialProps );
357356 sharcHitData.normalWorld = geometryProps.N;
358357 sharcHitData.emissive = materialProps.Lemi;
@@ -374,9 +373,24 @@ TraceOpaqueResult TraceOpaque( GeometryProps geometryProps0, MaterialProps mater
374373 isSharcAllowed &= Rng::Hash::GetFloat ( ) < ( bounce == gBounceNum ? 1.0 : footprintNorm ); // is voxel size acceptable?
375374 isSharcAllowed &= gSHARC && NRD_MODE < OCCLUSION; // trivial
376375
377- float3 sharcRadiance;
378- if ( isSharcAllowed && SharcGetCachedRadiance ( sharcParams, sharcHitData, sharcRadiance, false ) )
379- Lcached = float4 ( sharcRadiance, 1.0 );
376+ if ( isSharcAllowed )
377+ {
378+ // Try jittered position
379+ float3 sharcRadiance;
380+
381+ sharcHitData.positionWorld = Xglobal + jitter;
382+ bool isFound = SharcGetCachedRadiance ( sharcParams, sharcHitData, sharcRadiance, false );
383+
384+ if ( !isFound )
385+ {
386+ // Slipped out of the surface or mismatched normals, try non-jittered position
387+ sharcHitData.positionWorld = Xglobal;
388+ isFound = SharcGetCachedRadiance ( sharcParams, sharcHitData, sharcRadiance, false );
389+ }
390+
391+ if ( isFound )
392+ Lcached = float4 ( sharcRadiance, 1.0 );
393+ }
380394
381395 // Cache miss - compute lighting, if not found in caches
382396 if ( Rng::Hash::GetFloat ( ) > Lcached.w )
0 commit comments