智慧水务管理系统 - 精河县供水工程综合管理平台

PointPrimitiveCollectionFS.glsl 1.5KB

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