Advertisement
Guest User

shader.vert

a guest
Feb 22nd, 2018
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3.  
  4.  //// For image sampler
  5. out gl_PerVertex {
  6.     vec4 gl_Position;
  7. };
  8.  
  9. layout(binding = 0) uniform UniformBufferObject {
  10.     mat4 model;
  11.     mat4 view;
  12.     mat4 proj;
  13. } ubo;
  14.  
  15. layout(location = 0) in vec3 inPosition;
  16. layout(location = 1) in vec2 inCoord;
  17. layout(location = 0) out vec3 outColor;
  18. layout(location = 1) out vec2 outCoord;
  19.  
  20. // Colors for quads for when they don't have an image to sample.
  21. vec3 xColors[4] = vec3[](
  22.     vec3(1.0, 0.0, 0.0),
  23.     vec3(0.0, 1.0, 0.0),
  24.     vec3(0.0, 0.0, 1.0),
  25.     vec3(1.0, 1.0, 1.0)
  26. );
  27.  
  28. void main() {
  29.     outColor    = xColors[gl_VertexIndex % 4];
  30.     outCoord    = inCoord;
  31.     gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0); 
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement