Added AoVolumePassContext;
Added AoVolumePassBuffer; Changed center of each OBB in FrustumCullingJob from world position to camera-relative world position; Changed outputVolumeData and outputVolumeBounds from NativeList to NativeArray;
This commit is contained in:
@@ -17,7 +17,7 @@ uint _DepthPyramidMaxMip;
|
||||
StructuredBuffer<OrientedBoundingBox> _VolumeBounds;
|
||||
StructuredBuffer<int2> _DepthPyramidMipLevelOffsets;
|
||||
|
||||
RWByteAddressBuffer _VisibleVolumeCount : register(u0);
|
||||
RWByteAddressBuffer _VisibleVolumeCounter : register(u0);
|
||||
RWByteAddressBuffer _VisibleVolumeIndices : register(u1);
|
||||
|
||||
float SampleDepthLod(int2 uv, int lod)
|
||||
@@ -42,20 +42,20 @@ void CSMain(uint3 dispatchThreadId : SV_DispatchThreadID)
|
||||
// Compute the 8 corners of the OBB.
|
||||
// The box is defined by its center, two axes (right & up) and its extents.
|
||||
// We compute the forward vector as the cross product (assuming right and up are orthogonal).
|
||||
float3 rightExtent = box.right * box.extent.x;
|
||||
float3 upExtent = box.up * box.extent.y;
|
||||
float3 forward = normalize(cross(box.right, box.up));
|
||||
float3 forwardExtent = forward * box.extent.z;
|
||||
float3 rightExtent = box.right.xyz * box.extentX;
|
||||
float3 upExtent = box.up.xyz * box.extentY;
|
||||
float3 forward = normalize(cross(box.right.xyz, box.up.xyz));
|
||||
float3 forwardExtent = forward * box.extentZ;
|
||||
|
||||
float3 corners[_CORNERS_COUNT];
|
||||
corners[0] = box.center + rightExtent + upExtent + forwardExtent;
|
||||
corners[1] = box.center + rightExtent + upExtent - forwardExtent;
|
||||
corners[2] = box.center + rightExtent - upExtent + forwardExtent;
|
||||
corners[3] = box.center + rightExtent - upExtent - forwardExtent;
|
||||
corners[4] = box.center - rightExtent + upExtent + forwardExtent;
|
||||
corners[5] = box.center - rightExtent + upExtent - forwardExtent;
|
||||
corners[6] = box.center - rightExtent - upExtent + forwardExtent;
|
||||
corners[7] = box.center - rightExtent - upExtent - forwardExtent;
|
||||
corners[0] = box.center.xyz + rightExtent + upExtent + forwardExtent;
|
||||
corners[1] = box.center.xyz + rightExtent + upExtent - forwardExtent;
|
||||
corners[2] = box.center.xyz + rightExtent - upExtent + forwardExtent;
|
||||
corners[3] = box.center.xyz + rightExtent - upExtent - forwardExtent;
|
||||
corners[4] = box.center.xyz - rightExtent + upExtent + forwardExtent;
|
||||
corners[5] = box.center.xyz - rightExtent + upExtent - forwardExtent;
|
||||
corners[6] = box.center.xyz - rightExtent - upExtent + forwardExtent;
|
||||
corners[7] = box.center.xyz - rightExtent - upExtent - forwardExtent;
|
||||
|
||||
// Compute screen-space bounding rectangle and find the maximum depth (closest point)
|
||||
float2 screenMin = float2(_FLT_MAX, _FLT_MAX);
|
||||
@@ -67,8 +67,7 @@ void CSMain(uint3 dispatchThreadId : SV_DispatchThreadID)
|
||||
[unroll]
|
||||
for (int i = 0; i < _CORNERS_COUNT; i++)
|
||||
{
|
||||
float3 cornerRWS = GetCameraRelativePositionWS(corners[i]);
|
||||
float4 positionCS = TransformWorldToHClip(cornerRWS);
|
||||
float4 positionCS = TransformWorldToHClip(corners[i]);
|
||||
positionCS /= positionCS.w;
|
||||
|
||||
float2 positionNDC = ComputePositionNDC(positionCS, _ProjectionParams.x).xy;
|
||||
@@ -100,7 +99,7 @@ void CSMain(uint3 dispatchThreadId : SV_DispatchThreadID)
|
||||
if (occluderDepth <= boxMaxDepth)
|
||||
{
|
||||
uint index;
|
||||
_VisibleVolumeCount.InterlockedAdd(0, 1, index);
|
||||
_VisibleVolumeCounter.InterlockedAdd(0, 1, index);
|
||||
_VisibleVolumeIndices.Store(index << 2, dispatchThreadId.x);
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user