generated from Persson-dev/OpenGLComputeShader
30 lines
831 B
GLSL
30 lines
831 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);
|
|
if (index % 3 == 0) {
|
|
o_Points[currentPoint] = o_Points[currentPoint] / 2 + vec2(0, 0.36);
|
|
} else if (index % 3 == 1) {
|
|
o_Points[currentPoint] = o_Points[currentPoint] / 2 + vec2(-0.5, -0.5);
|
|
} else {
|
|
o_Points[currentPoint] = o_Points[currentPoint] / 2 + vec2(0.5, -0.5);
|
|
}
|
|
} |