diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2016-04-24 23:33:05 +0200 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2016-04-24 23:33:05 +0200 |
commit | a00fb682a7e3552ab4f5ee0a161d0e21d17d6a26 (patch) | |
tree | 4c25244223bde246c97cce0335da0dad4e353959 /samples/OpenGL/compute_shader/positiongen.glsl | |
parent | 1e387fc8eee4925616967edd26de0ee416dbce3f (diff) | |
download | codesamples-a00fb682a7e3552ab4f5ee0a161d0e21d17d6a26.tar.gz codesamples-a00fb682a7e3552ab4f5ee0a161d0e21d17d6a26.tar.bz2 |
computeshader
Diffstat (limited to 'samples/OpenGL/compute_shader/positiongen.glsl')
-rw-r--r-- | samples/OpenGL/compute_shader/positiongen.glsl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/samples/OpenGL/compute_shader/positiongen.glsl b/samples/OpenGL/compute_shader/positiongen.glsl new file mode 100644 index 0000000..99018b6 --- /dev/null +++ b/samples/OpenGL/compute_shader/positiongen.glsl @@ -0,0 +1,24 @@ +#version 430 + +layout( local_size_x = 16, local_size_y = 16 ) in; +layout(std430) buffer; +layout(binding = 0) buffer w_output { + vec4 data[]; +}; + +uniform float u_time; + +void main() +{ + uvec3 GlobalSize = gl_WorkGroupSize * gl_NumWorkGroups; + uint GlobalInvocationIndex = + GlobalSize.x * GlobalSize.y * gl_GlobalInvocationID.z + + GlobalSize.x * gl_GlobalInvocationID.y + + gl_GlobalInvocationID.x; + + vec2 p = 2*vec2(gl_GlobalInvocationID.xy)/GlobalSize.xy - 1; + + float z = sin(10.*p.x + u_time) + sin(30.*p.y + 0.1*u_time); + + data[GlobalInvocationIndex] = vec4(p, z*0.25, 1); +} |