start of combine shader
This commit is contained in:
parent
8902c2a0e3
commit
37d816fc98
8 changed files with 106 additions and 3 deletions
|
@ -12,4 +12,5 @@ C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_quad.frag -o shaders/compiled/fr
|
|||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_compute_rasterize.comp -o shaders/compiled/rt_compute_rasterize.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_compute_grow_one.comp -o shaders/compiled/rt_compute_grow_one.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_compute_grow_two.comp -o shaders/compiled/rt_compute_grow_two.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_compute_grow_three.comp -o shaders/compiled/rt_compute_grow_three.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_compute_grow_three.comp -o shaders/compiled/rt_compute_grow_three.spv
|
||||
C:/VulkanSDK/1.3.280.0/Bin/glslc.exe shaders/rt_compute_combine.comp -o shaders/compiled/rt_compute_combine.spv
|
|
@ -13,4 +13,5 @@ glslc shaders/rt_quad.frag -o shaders/compiled/frag_rt_quad.spv
|
|||
glslc shaders/rt_compute_rasterize.comp -o shaders/compiled/rt_compute_rasterize.spv
|
||||
glslc shaders/rt_compute_grow_one.comp -o shaders/compiled/rt_compute_grow_one.spv
|
||||
glslc shaders/rt_compute_grow_two.comp -o shaders/compiled/rt_compute_grow_two.spv
|
||||
glslc shaders/rt_compute_grow_three.comp -o shaders/compiled/rt_compute_grow_three.spv
|
||||
glslc shaders/rt_compute_grow_three.comp -o shaders/compiled/rt_compute_grow_three.spv
|
||||
glslc shaders/rt_compute_combine.comp -o shaders/compiled/rt_compute_combine.spv
|
BIN
shaders/compiled/rt_compute_combine.spv
Normal file
BIN
shaders/compiled/rt_compute_combine.spv
Normal file
Binary file not shown.
51
shaders/rt_compute_combine.comp
Normal file
51
shaders/rt_compute_combine.comp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#version 450
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject {
|
||||
mat4 model;
|
||||
mat4 geom_rot;
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
vec3 camera_pos;
|
||||
bool[16] use_geom_shader;
|
||||
} ubo;
|
||||
|
||||
layout(binding = 3) readonly buffer CompoundBuffer {
|
||||
uint compounds[];
|
||||
};
|
||||
|
||||
layout(binding = 4) readonly buffer ColorBuffer {
|
||||
uint grid_in[];
|
||||
};
|
||||
|
||||
layout(binding = 9) readonly buffer TransparentBuffer {
|
||||
bool transparent_grid[];
|
||||
};
|
||||
|
||||
layout(binding = 8) buffer SizeBuffer3D {
|
||||
uint grid_size_in[];
|
||||
};
|
||||
|
||||
layout (local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
uint output_offset = 0;
|
||||
uint compound_start = 0;
|
||||
// iterate over the compounds and find the work index inside of it
|
||||
while (index > compounds[compound_start] * compounds[compound_start]) {
|
||||
output_offset += compounds[compound_start] * compounds[compound_start] * compounds[compound_start] * 2;
|
||||
index -= compounds[compound_start] * compounds[compound_start];
|
||||
compound_start = compounds[compound_start + 2];
|
||||
}
|
||||
// grid pos in the task
|
||||
uint compound_grid_size = compounds[compound_start];
|
||||
float compound_scale = uintBitsToFloat(compounds[compound_start + 1]);
|
||||
vec3 mid_offset = vec3(compound_scale * 0.5, compound_scale * 0.5, compound_scale * 0.5);
|
||||
uint x = index % compound_grid_size;
|
||||
uint y = ((index) % (compound_grid_size * compound_grid_size) - x) / (compound_grid_size);
|
||||
uint z = (index - x - y * compound_grid_size) / (compound_grid_size * compound_grid_size);
|
||||
|
||||
uint size_x = grid_size_in[output_offset + (x * compound_grid_size * compound_grid_size + y * compound_grid_size + z) * 3];
|
||||
uint size_y = grid_size_in[output_offset + (x * compound_grid_size * compound_grid_size + y * compound_grid_size + z) * 3 + 1];
|
||||
uint size_z = grid_size_in[output_offset + (x * compound_grid_size * compound_grid_size + y * compound_grid_size + z) * 3 + 2];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue