Voxel cache rewrite

This commit is contained in:
2026-10-30 17:32:12 +01:00
parent 92d61b75a8
commit 570ec62bdf
31 changed files with 1537 additions and 533 deletions
+7 -4
View File
@@ -87,8 +87,9 @@ public struct VoxelCache
public RWStructuredBuffer<uint32_t> attributes_pool[2];
public RWStructuredBuffer<RequestBufferElement> request_buffer;
public RWStructuredBuffer<uint32_t> usage_buffer;
public RWStructuredBuffer<StructurePointer> structure_table_pointer;
public RWStructuredBuffer<Atomic<uint32_t>> structure_table_request_buffer;
public RWStructuredBuffer<StructurePointer> structure_table_pointer;
public RWStructuredBuffer<Atomic<uint32_t>> structure_table_request_buffer;
}
ByteColor fetch_color(VoxelCache cache, uint32_t index, uint32_t child_index)
@@ -165,6 +166,8 @@ HitInformation chunk_ray_march(
hit.hit = false;
return hit;
}
// _hit.color = float4(0., 1., 0., 1.);
// return _hit;
// Ray mirroring
ray_origin += float3(1.);
@@ -232,7 +235,6 @@ HitInformation chunk_ray_march(
uint64_t occupancy = get_child_mask(cache.structure_pool[current_node_index].occupancy_low, cache.structure_pool[current_node_index].occupancy_high);
let occupied = ((occupancy >> child_index) & 1) != 0;
// if (occupied)
if (fetch_color(cache, current_node_index, child_index).byte_a != 0)
{
var hit : HitInformation;
@@ -342,7 +344,8 @@ public HitInformation ray_cast(
{
let off = t - abs(1. / context.ray_direction);
let t_adv = max(max(off.x, max(off.y, off.z)), 0.);
let chunk_index = current_voxel.y + current_voxel.z * context.bounds.y + current_voxel.x * context.bounds.y * context.bounds.z;
// let chunk_index = current_voxel.y + current_voxel.z * context.bounds.y + current_voxel.x * context.bounds.y * context.bounds.z;
let chunk_index = current_voxel.x + current_voxel.z * context.bounds.x + current_voxel.y * context.bounds.x * context.bounds.z;
let position = context.ray_origin + context.ray_direction * t_adv;
var hit = chunk_ray_march(
cache,