|
|
|
|
|
|
float extinction = _GlobalFog_Extinction; |
|
|
|
|
|
|
|
// TODO: use a low-discrepancy point set. |
|
|
|
float rndVal = 0.5; |
|
|
|
float rndVal = VanDerCorputBase2(_TaaFrameIndex + 1); |
|
|
|
|
|
|
|
float3 voxelRadiance = EvaluateVoxelLighting(context, featureFlags, posInput, |
|
|
|
ray, t0, t1, dt, rndVal, extinction |
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
// Reproject the history at 'centerWS'. |
|
|
|
// TODO! WARNING! THE REPROJECTED VALUE IS AN INTEGRAL OVER A SEGMENT, THE LENGTH OF THE CURRENT SEGMENT IS DIFFERENT, ACCOUNT FOR THAT! |
|
|
|
float2 reprojPosNDC = ComputeNormalizedDeviceCoordinates(centerWS, _PrevViewProjMatrix); |
|
|
|
float reprojZ = mul(_PrevViewProjMatrix, float4(centerWS, 1)).w; |
|
|
|
float4 reprojValue = LoadFromVBuffer(reprojPosNDC, reprojZ, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Perform temporal blending. |
|
|
|
float3 blendedRadiance = lerp(voxelRadiance, reprojValue.rgb, reprojValue.a == 0 ? 0 : 0.1); |
|
|
|
float3 blendedRadiance = lerp(voxelRadiance, reprojValue.rgb, reprojValue.a == 0 ? 0 : 0.9); |
|
|
|
|
|
|
|
// Store the feedback. |
|
|
|
_VBufferLightingFeedback[uint3(posInput.positionSS, slice)] = float4(blendedRadiance, 1); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// TODO: use a low-discrepancy point set. |
|
|
|
float2 sampleCoord = voxelCoord + 0.5; |
|
|
|
|
|
|
|
float2 halton23[8] = {float2(1.0/2.0, 1.0/3.0), float2(1.0/4.0, 2.0/3.0), float2(3.0/4.0, 1.0/9.0), float2(1.0/8.0, 4.0/9.0), float2(5.0/8.0, 7.0/9.0), float2(3.0/8.0, 2.0/9.0), float2(7.0/8.0, 5.0/9.0), float2(1.0/16.0, 8.0/9.0)}; |
|
|
|
|
|
|
|
// float2 sampleCoord = voxelCoord + 0.5; |
|
|
|
float2 sampleCoord = voxelCoord + halton23[_TaaFrameIndex]; |
|
|
|
|
|
|
|
// Compute the ray direction s.t. its ViewSpaceZ = 1. |
|
|
|
float3 dir = -mul(float3(sampleCoord, 1), (float3x3)_VBufferCoordToViewDirWS); |
|
|
|