Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How to pass chunks of StructedBuffers into a compute shader

Discussion in 'Shaders' started by NighrixUnity, May 10, 2024.

  1. NighrixUnity

    NighrixUnity

    Joined:
    Jun 7, 2023
    Posts:
    3
    I have a sparse voxel octree that is flatten for the gpu now I have the problem that this only allows one octree at a time and not multiple chunks, I thought about combining the octrees but that would mean I have to store the old octree per chunk and the combined octrees (which would double the memory) maybe there is a better solution I am not aware of yet.
    Code (CSharp):
    1. StructuredBuffer<GPUOctreeNode> _SVOBuffer;
    2. StructuredBuffer <float4> _SVOData;
     
  2. NighrixUnity

    NighrixUnity

    Joined:
    Jun 7, 2023
    Posts:
    3
    The GPUOctreeNode looks like this, it points to the _SVOData with the dataIndex
    Code (CSharp):
    1. struct GPUOctreeNode {
    2.     float3 position;
    3.     float halfSize;
    4.     int childIndex;
    5.     int dataIndex;
    6. };
     
  3. NighrixUnity

    NighrixUnity

    Joined:
    Jun 7, 2023
    Posts:
    3
    or I would store the octree chunks in a combined structuredBuffer only and use compute shaders to add and remove chunks during runtime, this way I dont need to keep the old per chunk octree in memory