moves compiled shaders, first version with scene info on gpu
This commit is contained in:
parent
57e862832a
commit
694d93c0f3
20 changed files with 623 additions and 113 deletions
|
@ -1,10 +1,10 @@
|
|||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cube.vert -o shaders/vert_cube.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cube.frag -o shaders/frag_cube.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cube.geom -o shaders/geo_cube.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cube.vert -o shaders/compiled/vert_cube.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cube.frag -o shaders/compiled/frag_cube.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cube.geom -o shaders/compiled/geo_cube.spv
|
||||
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cuboid.vert -o shaders/vert_cuboid.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cuboid.frag -o shaders/frag_cuboid.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cuboid.geom -o shaders/geo_cuboid.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cuboid.vert -o shaders/compiled/vert_cuboid.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cuboid.frag -o shaders/compiled/frag_cuboid.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/cuboid.geom -o shaders/compiled/geo_cuboid.spv
|
||||
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_quad.vert -o shaders/vert_rt_quad.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_quad.frag -o shaders/frag_rt_quad.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_quad.vert -o shaders/compiled/vert_rt_quad.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_quad.frag -o shaders/compiled/frag_rt_quad.spv
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/sh
|
||||
glslc shaders/cube.vert -o shaders/vert_cube.spv
|
||||
glslc shaders/cube.frag -o shaders/frag_cube.spv
|
||||
glslc shaders/cube.geom -o shaders/geo_cube.spv
|
||||
glslc shaders/cube.vert -o shaders/compiled/vert_cube.spv
|
||||
glslc shaders/cube.frag -o shaders/compiled/frag_cube.spv
|
||||
glslc shaders/cube.geom -o shaders/compiled/geo_cube.spv
|
||||
|
||||
glslc shaders/cuboid.vert -o shaders/vert_cuboid.spv
|
||||
glslc shaders/cuboid.frag -o shaders/frag_cuboid.spv
|
||||
glslc shaders/cuboid.geom -o shaders/geo_cuboid.spv
|
||||
glslc shaders/cuboid.vert -o shaders/compiled/vert_cuboid.spv
|
||||
glslc shaders/cuboid.frag -o shaders/compiled/frag_cuboid.spv
|
||||
glslc shaders/cuboid.geom -o shaders/compiled/geo_cuboid.spv
|
||||
|
||||
glslc shaders/rt_quad.vert -o shaders/vert_rt_quad.spv
|
||||
glslc shaders/rt_quad.frag -o shaders/frag_rt_quad.spv
|
||||
glslc shaders/rt_quad.vert -o shaders/compiled/vert_rt_quad.spv
|
||||
glslc shaders/rt_quad.frag -o shaders/compiled/frag_rt_quad.spv
|
BIN
shaders/compiled/frag_rt_quad.spv
Normal file
BIN
shaders/compiled/frag_rt_quad.spv
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,9 +2,114 @@
|
|||
|
||||
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() {
|
||||
outColor = vec4(1, 0, 0, 1);
|
||||
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);
|
||||
}*/
|
||||
|
||||
}
|
|
@ -12,9 +12,12 @@ layout(binding = 0) uniform UniformBufferObject {
|
|||
layout(location = 0) in vec3 inPosition;
|
||||
layout(location = 1) in uvec2 inRasterPos;
|
||||
layout(location = 2) in uint inVolumeStart;
|
||||
layout(location = 3) in uint inFacing;
|
||||
|
||||
layout(location = 0) out uvec2 rasterPos;
|
||||
layout(location = 1) out uint volumeStart;
|
||||
layout(location = 0) flat out uvec2 rasterPos;
|
||||
layout(location = 1) flat out uint volumeStart;
|
||||
layout(location = 2) out vec3 origPosition;
|
||||
layout(location = 3) flat out uint facing;
|
||||
|
||||
void main() {
|
||||
if (ubo.use_geom_shader[0]) {
|
||||
|
@ -24,4 +27,6 @@ void main() {
|
|||
}
|
||||
rasterPos = inRasterPos;
|
||||
volumeStart = inVolumeStart;
|
||||
origPosition = inPosition;
|
||||
facing = inFacing;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue