shaderLineDashed.go 774 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package shader
  2. const shaderLineDashedVertex = `
  3. #version {{.Version}}
  4. {{?attributes}}
  5. // Model uniforms
  6. uniform mat4 MVP;
  7. // Material uniforms
  8. uniform float Scale;
  9. // Outputs for fragment shader
  10. out vec3 Color;
  11. out float vLineDistance;
  12. void main() {
  13. vLineDistance = Scale * VertexDistance;
  14. Color = VertexColor;
  15. gl_Position = MVP * vec4(VertexPosition, 1.0);
  16. }
  17. `
  18. //
  19. // Fragment Shader template
  20. //
  21. const shaderLineDashedFrag = `
  22. #version {{.Version}}
  23. // Inputs from vertex shader
  24. in vec3 Color;
  25. in float vLineDistance;
  26. // Material uniforms
  27. uniform float DashSize;
  28. uniform float TotalSize;
  29. // Output
  30. out vec4 FragColor;
  31. void main() {
  32. if (mod(vLineDistance, TotalSize) > DashSize) {
  33. discard;
  34. }
  35. FragColor = vec4(Color, 1.0);
  36. }
  37. `