Advertisement
Guest User

Untitled

a guest
Apr 29th, 2025
32
0
321 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. Vertex shader source code:
  2. #version 150
  3. in vec2 xy;
  4. in vec3 stw;
  5. out vec3 atlas;
  6. void main(void) {
  7. gl_Position = vec4(xy, 0, 1);
  8. atlas = stw;
  9. }
  10.  
  11. Geometry shader source code:
  12. #version 150
  13. layout (points) in;
  14. layout (triangle_strip, max_vertices = 4) out;
  15. in vec3 atlas[1];
  16. out vec2 texCoord;
  17. uniform mat4 matrix;
  18. uniform float lineHeight;
  19. void main(void) {
  20. gl_Position = matrix * vec4(gl_in[0].gl_Position.x + atlas[0].z, gl_in[0].gl_Position.y, 0, 1);
  21. texCoord = vec2(atlas[0].x+atlas[0].z, atlas[0].y + lineHeight);
  22. EmitVertex();
  23.  
  24. gl_Position = matrix * vec4(gl_in[0].gl_Position.x + atlas[0].z, gl_in[0].gl_Position.y + lineHeight, 0, 1);
  25. texCoord = vec2(atlas[0].x+atlas[0].z, atlas[0].y);
  26. EmitVertex();
  27.  
  28. gl_Position = matrix * vec4(gl_in[0].gl_Position.x, gl_in[0].gl_Position.y, 0, 1);
  29. texCoord = vec2(atlas[0].x, atlas[0].y + lineHeight);
  30. EmitVertex();
  31.  
  32. gl_Position = matrix * vec4(gl_in[0].gl_Position.x, gl_in[0].gl_Position.y + lineHeight, 0, 1);
  33. texCoord = vec2(atlas[0].x, atlas[0].y);
  34. EmitVertex();
  35.  
  36. EndPrimitive();
  37. }
  38.  
  39. Fragment shader source code:
  40. #version 150
  41. in vec2 texCoord;
  42. uniform sampler2D tex;
  43. uniform float opacity;
  44. out vec4 fragColor;
  45. void main(void) {
  46. float alpha = opacity * texelFetch(tex, ivec2(texCoord), 0).r;
  47. fragColor = vec4(0,0,0,alpha);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement