Start working on Cluster;

This commit is contained in:
2025-03-01 16:58:26 +09:00
parent 2f79df128e
commit 5f24e4c27d
6 changed files with 90 additions and 98 deletions

View File

@@ -1,14 +1,19 @@
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
RWTexture2D<float4> Result;
#include "Packages/com.misaki.ao-volume/Runtime/Shader/Includes/GeometryData.cs.hlsl"
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
StructuredBuffer<OrientedBoundingBox> _VolumeBounds;
ByteAddressBuffer _VisibleVolumeCount;
ByteAddressBuffer _VisibleVolumeIndices;
// For the volume list buffer, we allocate a buffer with the size of "cluster count" * "max volume count on screen" / 4.
// The first slot of each cluster group is always reserved for the count of volumes in the cluster.
// The rest of the slots are used for the indices of the volumes in the cluster, each slot are packed with 2 16 bits indices.
// To total number of indices in each cluster is "max volume count on screen" / 4 - 1.
RWByteAddressBuffer _VolumeListCluster : register(u0);
[numthreads(64,1,1)]
void CSMain(uint3 dispatchThreadId : SV_DispatchThreadID)
{
// TODO: insert actual code here!
Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0);
}
}