Working compute
This commit is contained in:
3
shaders/build.sh
Executable file
3
shaders/build.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
glslc compute.comp -o compute.sv
|
||||
37
shaders/compute.comp
Normal file
37
shaders/compute.comp
Normal file
@ -0,0 +1,37 @@
|
||||
#version 450
|
||||
|
||||
layout (binding = 0, rgba32f) uniform writeonly image2D image;
|
||||
|
||||
layout (push_constant) uniform constants
|
||||
{
|
||||
uint width;
|
||||
uint height;
|
||||
} PushConstants;
|
||||
|
||||
layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
vec2 pos = vec2(float(gl_GlobalInvocationID.x) / float(PushConstants.width) - 0.5f, float(gl_GlobalInvocationID.y) / float(PushConstants.height) - 0.5f) * 3.f;
|
||||
|
||||
int iter = 0;
|
||||
float re = 0;
|
||||
float im = 0;
|
||||
while(iter < 200)
|
||||
{
|
||||
float new_im = pos.y + 2. * re * im;
|
||||
float new_re = pos.x + (re * re - im * im);
|
||||
re = new_re;
|
||||
im = new_im;
|
||||
|
||||
if(re * re + im * im > 4.f)
|
||||
{
|
||||
float c = float(iter) / 200;
|
||||
imageStore(image, ivec2(gl_GlobalInvocationID.xy), vec4(c, 0.2, 1.0 - c, 1.0));
|
||||
|
||||
return;
|
||||
}
|
||||
iter += 1;
|
||||
}
|
||||
|
||||
imageStore(image, ivec2(gl_GlobalInvocationID.xy), vec4(0.f));
|
||||
}
|
||||
BIN
shaders/compute.sv
Normal file
BIN
shaders/compute.sv
Normal file
Binary file not shown.
Reference in New Issue
Block a user