浏览代码

Add some jittering

/Yibing-Project-2
Evgenii Golubev 7 年前
当前提交
8df9f3db
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 6
      ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl
  2. 11
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/Resources/VolumetricLighting.compute

6
ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl


return LOAD_TEXTURE3D(VBufferLighting, float3(positionSS, slice));
}
#include "Random.hlsl"
// Returns linearly interpolated {volumetric radiance, opacity}. The sampler clamps to edge.
float4 SampleInScatteredRadianceAndTransmittance(float2 positionNDC, float linearDepth,
TEXTURE3D_ARGS(VBufferLighting, linearClampSampler),

float z = linearDepth;
float d = EncodeLogarithmicDepth(z, VBufferDepthEncodingParams);
// TODO: Add some kind of jitter to the look-up.
// TODO: Also add some kind of animated 3D noise to the sampled result.
// d -= GenerateHashedRandomFloat(asuint(positionNDC)) / (2 * k);
// Account for the visible area of the V-Buffer.
float2 uv = positionNDC * VBufferScale;

11
ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/Resources/VolumetricLighting.compute


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);

正在加载...
取消
保存