now in 3D

This commit is contained in:
2025-11-09 11:59:46 +01:00
parent b54bb6a136
commit 6a874a01bb
3 changed files with 41 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
#version 460 core
layout(std430, binding = 3) buffer layoutName {
vec2 o_Points[];
float o_Points[];
};
layout(local_size_x = 64) in;
@@ -16,23 +16,35 @@ highp float rand(vec2 co)
return fract(sin(sn) * c);
}
vec3 unpack(uint index) {
return vec3(o_Points[index * 3], o_Points[index * 3 + 1], o_Points[index * 3 + 2]);
}
void store(vec3 vect, uint index) {
o_Points[index * 3] = vect.x;
o_Points[index * 3 + 1] = vect.y;
o_Points[index * 3 + 2] = vect.z;
}
void main() {
const uint total = gl_NumWorkGroups.x * gl_WorkGroupSize.x;
uint currentPoint = gl_GlobalInvocationID.x;
uint index = uint(rand(o_Points[currentPoint] + currentPoint) * 69);
mat3 transformation;
uint currentIndex = gl_GlobalInvocationID.x;
vec3 currentPoint = unpack(currentIndex);
uint index = uint(rand(currentPoint.xy + currentPoint.z + currentIndex) * 69);
mat4 transformation;
switch (index % 3) {
case 0:
transformation = mat3(0.5, 0, 0, 0, 0.5, 0, 0, 0.36, 1);
transformation = mat4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, 0.36, 0, 1);
break;
case 1:
transformation = mat3(0.5, 0, 0, 0, 0.5, 0, -0.5, -0.5, 1);
transformation = mat4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, -0.5, -0.5, 0, 1);
break;
case 2:
transformation = mat3(0.5, 0, 0, 0, 0.5, 0, 0.5, -0.5, 1);
transformation = mat4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.5, -0.5, 0, 1);
break;
}
o_Points[currentPoint] = (transformation * vec3(o_Points[currentPoint], 1.0)).xy;
vec3 result = (transformation * vec4(currentPoint, 1.0)).xyz;
store(result, currentIndex);
}