Correctly index shading table in shader

This commit is contained in:
Jarrod Doyle 2023-05-04 10:50:00 +01:00
parent 0e1921d32d
commit 5f0ea3fa03
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 4 additions and 2 deletions

View File

@ -66,9 +66,11 @@ fn to_1d_index(p: vec3<i32>, dims: vec3<i32>) -> u32 {
fn get_shading_offset(p: vec3<i32>) -> u32 { fn get_shading_offset(p: vec3<i32>) -> u32 {
// What brickmap are we in? // What brickmap are we in?
let brickmap_index = to_1d_index(p / 8, vec3<i32>(world_state.brickmap_cache_dims)); let brickgrid_index = to_1d_index(p / 8, vec3<i32>(world_state.brickmap_cache_dims));
let brick_ptr = brickgrid[brickgrid_index];
let brickmap = &brickmap_cache[brick_ptr >> 8u];
let local_index = to_1d_index(p % 8, vec3<i32>(8)); let local_index = to_1d_index(p % 8, vec3<i32>(8));
let brickmap = &brickmap_cache[brickmap_index];
let bitmask_index = local_index / 32u; let bitmask_index = local_index / 32u;
var map_voxel_idx = 0u; var map_voxel_idx = 0u;
for (var i: i32 = 0; i < i32(bitmask_index); i++) { for (var i: i32 = 0; i < i32(bitmask_index); i++) {