Files
RealTimeFractal/Shaders/Compute.glsl
2025-11-09 11:19:22 +01:00

38 lines
921 B
GLSL

#version 460 core
layout(std430, binding = 3) buffer layoutName {
vec2 o_Points[];
};
layout(local_size_x = 64) in;
highp float rand(vec2 co)
{
highp float a = 12.9898;
highp float b = 78.233;
highp float c = 43758.5453;
highp float dt= dot(co.xy ,vec2(a,b));
highp float sn= mod(dt,3.14);
return fract(sin(sn) * c);
}
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;
switch (index % 3) {
case 0:
transformation = mat3(0.5, 0, 0, 0, 0.5, 0, 0, 0.36, 1);
break;
case 1:
transformation = mat3(0.5, 0, 0, 0, 0.5, 0, -0.5, -0.5, 1);
break;
case 2:
transformation = mat3(0.5, 0, 0, 0, 0.5, 0, 0.5, -0.5, 1);
break;
}
o_Points[currentPoint] = (transformation * vec3(o_Points[currentPoint], 1.0)).xy;
}