30 lines
738 B
GLSL
30 lines
738 B
GLSL
|
|
#[compute]
|
|
#version 450
|
|
|
|
// Workgroup size
|
|
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
|
|
|
// Storage buffer
|
|
layout(set = 0, binding = 0, std430) buffer DataBuffer {
|
|
float sample_points[];
|
|
} voxels;
|
|
|
|
layout(set = 0, binding = 1) uniform Params {
|
|
int world_size;
|
|
float threshold;
|
|
} params;
|
|
|
|
void main() {
|
|
uvec3 id = gl_GlobalInvocationID;
|
|
if (id.x >= uint(params.world_size) ||
|
|
id.y >= uint(params.world_size) ||
|
|
id.z >= uint(params.world_size))
|
|
return;
|
|
|
|
uint index = id.x + id.y * uint(params.world_size) + id.z * uint(params.world_size) * uint(params.world_size);
|
|
vec3 p = vec3(id);
|
|
float d = length(p) - params.threshold;
|
|
voxels.sample_points[index] = d;
|
|
}
|