PointPrimitiveCollectionFS.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "varying vec4 v_color;\n\
  3. varying vec4 v_outlineColor;\n\
  4. varying float v_innerPercent;\n\
  5. varying float v_pixelDistance;\n\
  6. varying vec4 v_pickColor;\n\
  7. \n\
  8. void main()\n\
  9. {\n\
  10. // The distance in UV space from this fragment to the center of the point, at most 0.5.\n\
  11. float distanceToCenter = length(gl_PointCoord - vec2(0.5));\n\
  12. // The max distance stops one pixel shy of the edge to leave space for anti-aliasing.\n\
  13. float maxDistance = max(0.0, 0.5 - v_pixelDistance);\n\
  14. float wholeAlpha = 1.0 - smoothstep(maxDistance, 0.5, distanceToCenter);\n\
  15. float innerAlpha = 1.0 - smoothstep(maxDistance * v_innerPercent, 0.5 * v_innerPercent, distanceToCenter);\n\
  16. \n\
  17. vec4 color = mix(v_outlineColor, v_color, innerAlpha);\n\
  18. color.a *= wholeAlpha;\n\
  19. \n\
  20. // Fully transparent parts of the billboard are not pickable.\n\
  21. #if !defined(OPAQUE) && !defined(TRANSLUCENT)\n\
  22. if (color.a < 0.005) // matches 0/255 and 1/255\n\
  23. {\n\
  24. discard;\n\
  25. }\n\
  26. #else\n\
  27. // The billboard is rendered twice. The opaque pass discards translucent fragments\n\
  28. // and the translucent pass discards opaque fragments.\n\
  29. #ifdef OPAQUE\n\
  30. if (color.a < 0.995) // matches < 254/255\n\
  31. {\n\
  32. discard;\n\
  33. }\n\
  34. #else\n\
  35. if (color.a >= 0.995) // matches 254/255 and 255/255\n\
  36. {\n\
  37. discard;\n\
  38. }\n\
  39. #endif\n\
  40. #endif\n\
  41. \n\
  42. gl_FragColor = czm_gammaCorrect(color);\n\
  43. czm_writeLogDepth();\n\
  44. }\n\
  45. ";