feat: Good bvh traversal
This commit is contained in:
+50
-53
@@ -147,63 +147,60 @@ void ray_march_compute(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_
|
||||
Bvh bvh;
|
||||
bvh.parameters = table_parameters;
|
||||
bvh.thread_index = stack_index;
|
||||
BvhCursor c = bvh.begin(r);
|
||||
Cell cell;
|
||||
// BvhCursor c = bvh.begin(r);
|
||||
Cell cell;
|
||||
|
||||
// for (uint32_t i = 0; i < 100; i++)
|
||||
// Setup for simple bvh traversal check
|
||||
// if (bvh.next(c, cell))
|
||||
// {
|
||||
if (bvh.next(c, cell))
|
||||
// gbuffer_albedo.Store(location.xy, float4(0., 1., 0., 1.));
|
||||
// return;
|
||||
// }
|
||||
// gbuffer_albedo.Store(location.xy, float4(0.));
|
||||
|
||||
// ToroidalStructureTableTracer table_tracer;
|
||||
// table_tracer.structure_table = table_parameters;
|
||||
// table_tracer.extent =
|
||||
// uint32_t3(constants.chunk_width, constants.chunk_alt, constants.chunk_height);
|
||||
// table_tracer.base_slot = uint32_t3(
|
||||
// constants.table_base_slot_x,
|
||||
// constants.table_base_slot_y,
|
||||
// constants.table_base_slot_z);
|
||||
|
||||
PixelFootprintLod lod = PixelFootprintLod.create((100.f * 3.14f) / 180.f, 1080.f, 2.f);
|
||||
|
||||
Tracer<Bvh, VoxelCacheTracer<2, ColorHit<2>>, PixelFootprintLod> tracer;
|
||||
tracer.structure = bvh;
|
||||
tracer.cache = cache_tracer;
|
||||
tracer.lod = lod;
|
||||
|
||||
Hit h;
|
||||
// Closest hit at or past tMin. Re-trace past a hit with:
|
||||
// t_min = h.t + 1e-4;
|
||||
// hit = tracer.trace(stack_index, t_min, h, r);
|
||||
bool hit = tracer.trace(stack_index, 0., h, r);
|
||||
|
||||
// ToroidalStructureTableTracer.Cursor cursor = table_tracer.begin(r);
|
||||
// Cell cell;
|
||||
|
||||
if (hit)
|
||||
{
|
||||
gbuffer_albedo.Store(location.xy, float4(0., 1., 0., 1.));
|
||||
return;
|
||||
// Gather
|
||||
let hit_pos = h.hit_location;
|
||||
|
||||
let hit_normal = fetch_normal(h.node_index, h.child_index);
|
||||
var hit_albedo = float4(0.);
|
||||
hit_albedo = fetch_color(h.node_index, h.child_index).float_color;
|
||||
// let hit_albedo = hit.color;
|
||||
|
||||
gbuffer_position.Store(location.xy, float4(hit_pos, 1.));
|
||||
gbuffer_normal.Store(location.xy, float4(hit_normal, 1.));
|
||||
gbuffer_albedo.Store(location.xy, hit_albedo);
|
||||
}
|
||||
else
|
||||
{
|
||||
gbuffer_albedo.Store(location.xy, float4(0.));
|
||||
}
|
||||
//}
|
||||
gbuffer_albedo.Store(location.xy, float4(0.));
|
||||
|
||||
/*
|
||||
ToroidalStructureTableTracer table_tracer;
|
||||
table_tracer.structure_table = table_parameters;
|
||||
table_tracer.extent =
|
||||
uint32_t3(constants.chunk_width, constants.chunk_alt, constants.chunk_height);
|
||||
table_tracer.base_slot = uint32_t3(
|
||||
constants.table_base_slot_x,
|
||||
constants.table_base_slot_y,
|
||||
constants.table_base_slot_z);
|
||||
|
||||
|
||||
|
||||
PixelFootprintLod lod = PixelFootprintLod.create((100.f * 3.14f) / 180.f, 1080.f, 2.f);
|
||||
|
||||
Tracer<ToroidalStructureTableTracer, VoxelCacheTracer<2, ColorHit<2>>, PixelFootprintLod> tracer;
|
||||
tracer.structure = table_tracer;
|
||||
tracer.cache = cache_tracer;
|
||||
tracer.lod = lod;
|
||||
|
||||
Hit h;
|
||||
bool hit = tracer.trace(stack_index, h, r);
|
||||
|
||||
ToroidalStructureTableTracer.Cursor cursor = table_tracer.begin(r);
|
||||
Cell cell;
|
||||
|
||||
if (hit)
|
||||
{
|
||||
// Gather
|
||||
let hit_pos = h.hit_location;
|
||||
|
||||
let hit_normal = fetch_normal(h.node_index, h.child_index);
|
||||
var hit_albedo = float4(0.);
|
||||
hit_albedo = fetch_color(h.node_index, h.child_index).float_color;
|
||||
// let hit_albedo = hit.color;
|
||||
|
||||
gbuffer_position.Store(location.xy, float4(hit_pos, 1.));
|
||||
gbuffer_normal.Store(location.xy, float4(hit_normal, 1.));
|
||||
gbuffer_albedo.Store(location.xy, hit_albedo);
|
||||
}
|
||||
else
|
||||
{
|
||||
gbuffer_albedo.Store(location.xy, float4(0.));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
float2 box_intersect(float3 origin, float3 ray_direction, float3 box_min, float3 box_max)
|
||||
|
||||
Reference in New Issue
Block a user