point.vert 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. precision highp float;
  7. precision highp int;
  8. #pragma glslify: import('./chunks/common-vert-params.glsl')
  9. #pragma glslify: import('./chunks/color-vert-params.glsl')
  10. uniform float uPixelRatio;
  11. uniform float uViewportHeight;
  12. #if defined(dSizeType_uniform)
  13. uniform float uSize;
  14. #elif defined(dSizeType_attribute)
  15. attribute float aSize;
  16. #endif
  17. attribute vec3 aPosition;
  18. attribute mat4 aTransform;
  19. attribute float aInstanceId;
  20. attribute float aElementId;
  21. void main(){
  22. #pragma glslify: import('./chunks/assign-color-varying.glsl')
  23. mat4 modelView = uView * uModel * aTransform;
  24. vec4 mvPosition = modelView * vec4(aPosition, 1.0);
  25. #if defined(dSizeType_uniform)
  26. float size = uSize;
  27. #elif defined(dSizeType_attribute)
  28. float size = aSize;
  29. #endif
  30. #ifdef dPointSizeAttenuation
  31. gl_PointSize = size * uPixelRatio * ((uViewportHeight / 2.0) / -mvPosition.z) * 5.0;
  32. #else
  33. gl_PointSize = size * uPixelRatio;
  34. #endif
  35. gl_Position = uProjection * mvPosition;
  36. }