#version 450 layout(location = 0) flat in uvec2 fragRasterPos; layout(location = 1) flat in uint fragVolumeStart; layout(location = 2) in vec3 origPosition; layout(location = 3) flat in uint facing; layout(location = 0) out vec4 outColor; layout(binding = 2) buffer SceneInfoBuffer{ uint infos[]; } scene_info; uvec4 unpack_color(uint val) { // left most 8 bits first uint val1 = (val >> 24); uint val2 = (val << 8) >> 24; uint val3 = (val << 16) >> 24; uint val4 = (val << 24) >> 24; return uvec4(val1, val2, val3, val4); } uvec4 sample_from_scene_info(uint volume_start, uvec2 raster_pos, uint f) { uint array_descr_start = volume_start + 3; uint color_array_start = array_descr_start + 24; uint top_color_size_u = scene_info.infos[array_descr_start]; uint top_color_size_v = scene_info.infos[array_descr_start + 1]; uint bottom_color_size_u = scene_info.infos[array_descr_start + 2]; uint bottom_color_size_v = scene_info.infos[array_descr_start + 3]; uint left_color_size_u = scene_info.infos[array_descr_start + 4]; uint left_color_size_v = scene_info.infos[array_descr_start + 5]; uint right_color_size_u = scene_info.infos[array_descr_start + 6]; uint right_color_size_v = scene_info.infos[array_descr_start + 7]; uint front_color_size_u = scene_info.infos[array_descr_start + 8]; uint front_color_size_v = scene_info.infos[array_descr_start + 9]; uint back_color_size_u = scene_info.infos[array_descr_start + 10]; uint back_color_size_v = scene_info.infos[array_descr_start + 11]; uint top_neighbor_size_u = scene_info.infos[array_descr_start + 12]; uint top_neighbor_size_v = scene_info.infos[array_descr_start + 13]; /*uint bottom_neighbor_size_u = scene_info.infos[array_descr_start + 14]; uint bottom_neighbor_size_v = scene_info.infos[array_descr_start + 15]; uint left_neighbor_size_u = scene_info.infos[array_descr_start + 16]; uint left_neighbor_size_v = scene_info.infos[array_descr_start + 17]; uint right_neighbor_size_u = scene_info.infos[array_descr_start + 18]; uint right_neighbor_size_v = scene_info.infos[array_descr_start + 19]; uint front_neighbor_size_u = scene_info.infos[array_descr_start + 20]; uint front_neighbor_size_v = scene_info.infos[array_descr_start + 21]; uint back_neighbor_size_u = scene_info.infos[array_descr_start + 22]; uint back_neighbor_size_v = scene_info.infos[array_descr_start + 23];*/ uint top_size = top_color_size_u * top_color_size_v; uint bottom_size = bottom_color_size_u * bottom_color_size_v; uint left_size = left_color_size_u * left_color_size_v; uint right_size = right_color_size_u * right_color_size_v; uint front_size = front_color_size_u * front_color_size_v; uint back_size = back_color_size_u * back_color_size_v; // maybe do an array solution for this as well uint array_start = color_array_start + uint(f > 0) * top_size + uint(f > 1) * bottom_size + uint(f > 2) * left_size + uint(f > 3) * right_size + uint(f > 4) * front_size; uint us[6] = {top_color_size_u, bottom_color_size_u, left_color_size_u, right_color_size_u, front_color_size_u, back_color_size_u}; uint vs[6] = {top_color_size_v, bottom_color_size_v, left_color_size_v, right_color_size_v, front_color_size_v, back_color_size_v}; uint u_size = us[f]; uint v_size = vs[f]; uint value = scene_info.infos[array_start + raster_pos.x * v_size + raster_pos.y]; if (top_color_size_v == 0) { return uvec4(255, 0, 0, 255); } return unpack_color(value); } void main() { uint max_length = scene_info.infos[0]; uint last = scene_info.infos[max_length]; uvec4 color_roughness = sample_from_scene_info(fragVolumeStart, fragRasterPos, facing); outColor = vec4(float(color_roughness.x) / 255.0, float(color_roughness.y) / 255.0, float(color_roughness.z) / 255.0, 1); /*if (scene_info.infos[1] == 16) { outColor = vec4(0, 1, 0, 1); }*/ /*if (fragVolumeStart == 1 && scene_info.infos[fragVolumeStart] == 16) { outColor = vec4(0, 1, 0, 1); }*/ /*if (facing == 0) { outColor = vec4(1, 0, 0, 1); } else if (facing == 1) { outColor = vec4(0, 1, 1, 1); } else if (facing == 2) { outColor = vec4(0, 1, 0, 1); } else if (facing == 3) { outColor = vec4(1, 0, 1, 1); } else if (facing == 4) { outColor = vec4(0, 0, 1, 1); } else if (facing == 5) { outColor = vec4(1, 1, 0, 1); }*/ }