PolylineOutlineMaterial.js 1.1 KB

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