Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #shader vertex
  2. #version 330 core
  3.  
  4. layout(location = 0) in vec2 InPosition;
  5. layout(location = 1) in vec4 InColor;
  6. layout(location = 2) in vec2 InTexCoords;
  7.  
  8. out vec4 VPos;
  9. out vec4 VCol;
  10. out vec2 VTex;
  11.  
  12. void main()
  13. {
  14.     VPos = vec4(InPosition, 0, 1);
  15.     VCol = InColor;
  16.     VTex = InTexCoords;
  17. }
  18.  
  19.  
  20.  
  21. #shader geometry
  22. #version 330 core
  23.  
  24. layout(triangles) in;
  25. layout(triangle_strip, max_vertices = 3) out;
  26. in vec4 VPos[3];
  27. in vec4 VCol[3];
  28. in vec2 VTex[3];
  29.  
  30. out vec4 Color;
  31. out vec2 TexPos;
  32.  
  33. void main()
  34. {
  35.     Color = VCol[0];
  36.     TexPos = VTex[0];
  37.     gl_Position = VPos[0];
  38.     EmitVertex();
  39.     Color = VCol[1];
  40.     TexPos = VTex[1];
  41.     gl_Position = VPos[1];
  42.     EmitVertex();
  43.     Color = VCol[2];
  44.     TexPos = VTex[2];
  45.     gl_Position = VPos[2];
  46.     EmitVertex();
  47.     EndPrimitive();
  48. }
  49.  
  50.  
  51.  
  52. #shader fragment
  53. #version 330 core
  54.  
  55. uniform sampler2D Texture;
  56.  
  57. in vec4 Color;
  58. in vec2 TexPos;
  59.  
  60. out vec4 ResultColor;
  61.  
  62. void main()
  63. {
  64.     ResultColor = texture(Texture, TexPos) * Color;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement