point_vertex.glsl 713 B

1234567891011121314151617181920212223242526272829303132
  1. #include <attributes>
  2. // Model uniforms
  3. uniform mat4 MVP;
  4. uniform mat4 MV;
  5. // Material uniforms
  6. #include <material>
  7. // Outputs for fragment shader
  8. out vec3 Color;
  9. flat out mat2 Rotation;
  10. void main() {
  11. // Rotation matrix for fragment shader
  12. float rotSin = sin(MatPointRotationZ);
  13. float rotCos = cos(MatPointRotationZ);
  14. Rotation = mat2(rotCos, rotSin, - rotSin, rotCos);
  15. // Sets the vertex position
  16. vec4 pos = MVP * vec4(VertexPosition, 1.0);
  17. gl_Position = pos;
  18. // Sets the size of the rasterized point decreasing with distance
  19. vec4 posMV = MV * vec4(VertexPosition, 1.0);
  20. gl_PointSize = MatPointSize / -posMV.z;
  21. // Outputs color
  22. Color = MatEmissiveColor;
  23. }