Advertisement
whillothewhisp

Vert/Frag shaders

Jan 5th, 2022 (edited)
3,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Vertex Shader
  2.  
  3.  #version 450
  4.  
  5. layout(binding = 0) uniform UniformBufferObject {
  6.     mat4 model;
  7.     mat4 view;
  8.     mat4 proj;
  9. } matrices;
  10.  
  11. layout(location = 0) in vec3 inPosition;
  12. layout(location = 1) in uint inID;
  13.  
  14. layout(location = 0) out uint ID;
  15.  
  16. void main() {
  17.     gl_Position = matrices.proj * matrices.view * matrices.model * vec4(inPosition, 1.0);
  18.     ID = inID;
  19. }
  20.  
  21. -------------------------------------------------------------------------------------------------------------------------------------
  22.  //Fragment Shader
  23.  #version 450
  24.  layout(location = 0) flat in uint ID;
  25.  
  26.  
  27. layout(binding = 1) buffer ShaderStorageBufferObject{
  28.     uint Selected_ID;
  29. }ssbo;
  30.  
  31. layout(location = 0) out float outColor;
  32.  
  33. void main() {
  34.     ssbo.Selected_ID = ID;
  35.    
  36.     //only needed for debugging to draw to color attachment
  37.     outColor = ssbo.Selected_ID;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement