pointcloud.fs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #if defined paraboloid_point_shape
  2. #extension GL_EXT_frag_depth : enable
  3. #endif
  4. precision highp float;
  5. precision highp int;
  6. uniform mat4 viewMatrix;
  7. uniform mat4 uViewInv;
  8. uniform mat4 uProjInv;
  9. uniform vec3 cameraPosition;
  10. uniform mat4 projectionMatrix;
  11. uniform float uOpacity;
  12. uniform float blendHardness;
  13. uniform float blendDepthSupplement;
  14. uniform float fov;
  15. uniform float uSpacing;
  16. uniform float near;
  17. uniform float far;
  18. uniform float uPCIndex;
  19. uniform float uScreenWidth;
  20. uniform float uScreenHeight;
  21. varying vec3 vColor;
  22. varying float vLogDepth;
  23. varying vec3 vViewPosition;
  24. varying float vRadius;
  25. varying float vPointSize;
  26. varying vec3 vPosition;
  27. float specularStrength = 1.0;
  28. void main() {
  29. // gl_FragColor = vec4(vColor, 1.0);
  30. vec3 color = vColor;
  31. float depth = gl_FragCoord.z;
  32. #if defined(circle_point_shape) || defined(paraboloid_point_shape)
  33. float u = 2.0 * gl_PointCoord.x - 1.0;
  34. float v = 2.0 * gl_PointCoord.y - 1.0;
  35. #endif
  36. #if defined(circle_point_shape)
  37. float cc = u*u + v*v;
  38. if(cc > 1.0){
  39. discard;
  40. }
  41. #endif
  42. #if defined color_type_indices
  43. gl_FragColor = vec4(color, uPCIndex / 255.0);
  44. #else
  45. gl_FragColor = vec4(color, uOpacity);
  46. #endif
  47. #if defined paraboloid_point_shape
  48. float wi = 0.0 - ( u*u + v*v);
  49. vec4 pos = vec4(vViewPosition, 1.0);
  50. pos.z += wi * vRadius;
  51. float linearDepth = -pos.z;
  52. pos = projectionMatrix * pos;
  53. pos = pos / pos.w;
  54. float expDepth = pos.z;
  55. depth = (pos.z + 1.0) / 2.0;
  56. gl_FragDepthEXT = depth;
  57. #if defined(color_type_depth)
  58. color.r = linearDepth;
  59. color.g = expDepth;
  60. #endif
  61. #if defined(use_edl)
  62. gl_FragColor.a = log2(linearDepth);
  63. #endif
  64. #else
  65. #if defined(use_edl)
  66. gl_FragColor.a = vLogDepth;
  67. #endif
  68. #endif
  69. #if defined(weighted_splats)
  70. float distance = 2.0 * length(gl_PointCoord.xy - 0.5);
  71. float weight = max(0.0, 1.0 - distance);
  72. weight = pow(weight, 1.5);
  73. gl_FragColor.a = weight;
  74. gl_FragColor.xyz = gl_FragColor.xyz * weight;
  75. #endif
  76. //gl_FragColor = vec4(0.0, 0.7, 0.0, 1.0);
  77. }