PolylineOutlineMaterial.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. //This file is automatically rebuilt by the Cesium build process.
  2. /*global define*/
  3. define(function() {
  4. "use strict";
  5. return "uniform vec4 color;\n\
  6. uniform vec4 outlineColor;\n\
  7. uniform float outlineWidth;\n\
  8. \n\
  9. varying float v_width;\n\
  10. \n\
  11. czm_material czm_getMaterial(czm_materialInput materialInput)\n\
  12. {\n\
  13. czm_material material = czm_getDefaultMaterial(materialInput);\n\
  14. \n\
  15. vec2 st = materialInput.st;\n\
  16. float halfInteriorWidth = 0.5 * (v_width - outlineWidth) / v_width;\n\
  17. float b = step(0.5 - halfInteriorWidth, st.t);\n\
  18. b *= 1.0 - step(0.5 + halfInteriorWidth, st.t);\n\
  19. \n\
  20. // Find the distance from the closest separator (region between two colors)\n\
  21. float d1 = abs(st.t - (0.5 - halfInteriorWidth));\n\
  22. float d2 = abs(st.t - (0.5 + halfInteriorWidth));\n\
  23. float dist = min(d1, d2);\n\
  24. \n\
  25. vec4 currentColor = mix(outlineColor, color, b);\n\
  26. vec4 outColor = czm_antialias(outlineColor, color, currentColor, dist);\n\
  27. \n\
  28. material.diffuse = outColor.rgb;\n\
  29. material.alpha = outColor.a;\n\
  30. \n\
  31. return material;\n\
  32. }\n\
  33. ";
  34. });