Voxel cache rewrite
This commit is contained in:
+8
-6
@@ -85,9 +85,10 @@ RWStructuredBuffer<uint32_t> attributes_pool[2];
|
||||
RWStructuredBuffer<RequestBufferElement> request_buffer;
|
||||
[[vk::binding(3, 0)]]
|
||||
RWStructuredBuffer<uint32_t> usage_buffer;
|
||||
[[vk::binding(4, 0)]]
|
||||
|
||||
[[vk::binding(0, 1)]]
|
||||
RWStructuredBuffer<StructurePointer> structure_table_pointer;
|
||||
[[vk::binding(5, 0)]]
|
||||
[[vk::binding(1, 1)]]
|
||||
RWStructuredBuffer<Atomic<uint32_t>> structure_table_request_buffer;
|
||||
|
||||
ByteColor fetch_color(uint32_t index, uint32_t child_index)
|
||||
@@ -109,19 +110,19 @@ bool3 min_mask(float3 val)
|
||||
return val == min_val;
|
||||
}
|
||||
|
||||
[[vk::binding(0, 1)]]
|
||||
[[vk::binding(0, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
WTexture2D<float4> target_texture;
|
||||
|
||||
[[vk::binding(1, 1)]]
|
||||
[[vk::binding(1, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
RWTexture2D<float4> gbuffer_position;
|
||||
|
||||
[[vk::binding(2, 1)]]
|
||||
[[vk::binding(2, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
RWTexture2D<float4> gbuffer_albedo;
|
||||
|
||||
[[vk::binding(3, 1)]]
|
||||
[[vk::binding(3, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
RWTexture2D<float4> gbuffer_normal;
|
||||
|
||||
@@ -154,6 +155,7 @@ void gi(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_location: SV_Gr
|
||||
let albedo = gbuffer_albedo.Load(location.xy);
|
||||
target_texture.Store(location.xy, albedo);
|
||||
return;
|
||||
|
||||
let illumination = dot(float3(0., 1., 0.), normal.xyz);
|
||||
|
||||
let view_dir = pos.xyz - constants.cam_pos;
|
||||
|
||||
Binary file not shown.
@@ -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,
|
||||
|
||||
+9
-6
@@ -85,9 +85,10 @@ RWStructuredBuffer<uint32_t> attributes_pool[2];
|
||||
RWStructuredBuffer<RequestBufferElement> request_buffer;
|
||||
[[vk::binding(3, 0)]]
|
||||
RWStructuredBuffer<uint32_t> usage_buffer;
|
||||
[[vk::binding(4, 0)]]
|
||||
|
||||
[[vk::binding(0, 1)]]
|
||||
RWStructuredBuffer<StructurePointer> structure_table_pointer;
|
||||
[[vk::binding(5, 0)]]
|
||||
[[vk::binding(1, 1)]]
|
||||
RWStructuredBuffer<Atomic<uint32_t>> structure_table_request_buffer;
|
||||
|
||||
ByteColor fetch_color(uint32_t index, uint32_t child_index)
|
||||
@@ -109,15 +110,15 @@ bool3 min_mask(float3 val)
|
||||
return val == min_val;
|
||||
}
|
||||
|
||||
[[vk::binding(0, 1)]]
|
||||
[[vk::binding(0, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
WTexture2D<float4> gbuffer_position;
|
||||
|
||||
[[vk::binding(1, 1)]]
|
||||
[[vk::binding(1, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
WTexture2D<float4> gbuffer_albedo;
|
||||
|
||||
[[vk::binding(2, 1)]]
|
||||
[[vk::binding(2, 2)]]
|
||||
[[format("rgba32f")]]
|
||||
WTexture2D<float4> gbuffer_normal;
|
||||
|
||||
@@ -174,8 +175,10 @@ void ray_march_compute(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_
|
||||
{
|
||||
// Gather
|
||||
let hit_pos = hit.hit_pos;
|
||||
|
||||
let hit_normal = fetch_normal(hit.node_index, hit.child_index);
|
||||
let hit_albedo = fetch_color(hit.node_index, hit.child_index).float_color;
|
||||
var hit_albedo = float4(0.);
|
||||
hit_albedo = fetch_color(hit.node_index, hit.child_index).float_color;
|
||||
// let hit_albedo = hit.color;
|
||||
|
||||
gbuffer_position.Store(location.xy, float4(hit_pos, 1.));
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user