PolylineDashMaterial.js 1014 B

1234567891011121314151617181920212223242526272829303132
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform vec4 color;\n\
  3. uniform vec4 gapColor;\n\
  4. uniform float dashLength;\n\
  5. uniform float dashPattern;\n\
  6. varying float v_polylineAngle;\n\
  7. const float maskLength = 16.0;\n\
  8. mat2 rotate(float rad) {\n\
  9. float c = cos(rad);\n\
  10. float s = sin(rad);\n\
  11. return mat2(\n\
  12. c, s,\n\
  13. -s, c\n\
  14. );\n\
  15. }\n\
  16. czm_material czm_getMaterial(czm_materialInput materialInput)\n\
  17. {\n\
  18. czm_material material = czm_getDefaultMaterial(materialInput);\n\
  19. vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;\n\
  20. float dashPosition = fract(pos.x / (dashLength * czm_pixelRatio));\n\
  21. float maskIndex = floor(dashPosition * maskLength);\n\
  22. float maskTest = floor(dashPattern / pow(2.0, maskIndex));\n\
  23. vec4 fragColor = (mod(maskTest, 2.0) < 1.0) ? gapColor : color;\n\
  24. if (fragColor.a < 0.005) {\n\
  25. discard;\n\
  26. }\n\
  27. fragColor = czm_gammaCorrect(fragColor);\n\
  28. material.emission = fragColor.rgb;\n\
  29. material.alpha = fragColor.a;\n\
  30. return material;\n\
  31. }\n\
  32. ";