浏览代码

Add a centered ray direction to better support screen space stratification

/Yibing-Project-2
Evgenii Golubev 7 年前
当前提交
0bdfbf03
共有 1 个文件被更改,包括 23 次插入12 次删除
  1. 35
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/Resources/VolumetricLighting.compute

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


struct Ray
{
float3 originWS;
float3 directionWS; // Normalized
float3 directionWS; // Normalized, stratified
float3 centerDirWS; // Not normalized, centered
};
float3 GetPointAtDistance(Ray ray, float t)

float3 GetCenterAtDistance(Ray ray, float t)
{
return ray.originWS + t * ray.centerDirWS;
}
// Computes the light integral (in-scattered radiance) within the voxel.
// Multiplication by the scattering coefficient and the phase function is performed outside.

clusterDepths[1] = GetLightClusterMinLinearDepth(posInput.tileCoord, clusterIndices[1]);
#endif
// Compute the position of the center of the voxel.
// Compute the -exact- position of the center of the voxel.
float3 centerWS = GetPointAtDistance(ray, tc);
float3 centerWS = GetCenterAtDistance(ray, tc);
// Sample the participating medium at 'tc' (or 'centerWS').
// We consider it to be constant along the interval [t0, t1] (within the voxel).

return;
}
float2 centerCoord = voxelCoord + 0.5;
float2 sampleCoord = voxelCoord + 0.5;
// // TODO: use a low-discrepancy point set.
// 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 + halton23[_TaaFrameIndex];
float2 sampleCoord = voxelCoord + _VBufferIntegrationOffset.xy;
float2 sampleCoord = voxelCoord + 0.5;
float2 sampleCoord = centerCoord;
// Compute the ray direction s.t. its ViewSpaceZ = 1.
float3 dir = -mul(float3(sampleCoord, 1), (float3x3)_VBufferCoordToViewDirWS);
float lenSq = dot(dir, dir);
// Compute the (stratified) ray direction s.t. its ViewSpaceZ = 1.
float3 rayDir = mul(-float3(sampleCoord, 1), (float3x3)_VBufferCoordToViewDirWS);
float lenSq = dot(rayDir, rayDir);
#if ENABLE_REPROJECTION
// Compute the ray direction which passes through the center of the voxel s.t. its ViewSpaceZ = 1.
float3 rayCenterDir = mul(-float3(centerCoord, 1), (float3x3)_VBufferCoordToViewDirWS);
#else
float3 rayCenterDir = rayDir;
#endif
ray.directionWS = dir * lenRcp;
ray.directionWS = rayDir * lenRcp;
ray.centerDirWS = rayCenterDir * lenRcp;
// TODO
LightLoopContext context;

正在加载...
取消
保存