gol_render.glsl 616 B

1234567891011121314151617181920212223242526272829
  1. #version 430
  2. // Game of Life rendering shader
  3. // Just renders the content of the ssbo at binding 1 to screen
  4. #define GOL_WIDTH 768
  5. // Input vertex attributes (from vertex shader)
  6. in vec2 fragTexCoord;
  7. // Output fragment color
  8. out vec4 finalColor;
  9. // Input game of life grid.
  10. layout(std430, binding = 1) readonly buffer golLayout
  11. {
  12. uint golBuffer[];
  13. };
  14. // Output resolution
  15. uniform vec2 resolution;
  16. void main()
  17. {
  18. ivec2 coords = ivec2(fragTexCoord*resolution);
  19. if ((golBuffer[coords.x + coords.y*uvec2(resolution).x]) == 1) finalColor = vec4(1.0);
  20. else finalColor = vec4(0.0, 0.0, 0.0, 1.0);
  21. }