PolylineOutlineMaterial.glsl 904 B

12345678910111213141516171819202122232425262728
  1. uniform vec4 color;
  2. uniform vec4 outlineColor;
  3. uniform float outlineWidth;
  4. varying float v_width;
  5. czm_material czm_getMaterial(czm_materialInput materialInput)
  6. {
  7. czm_material material = czm_getDefaultMaterial(materialInput);
  8. vec2 st = materialInput.st;
  9. float halfInteriorWidth = 0.5 * (v_width - outlineWidth) / v_width;
  10. float b = step(0.5 - halfInteriorWidth, st.t);
  11. b *= 1.0 - step(0.5 + halfInteriorWidth, st.t);
  12. // Find the distance from the closest separator (region between two colors)
  13. float d1 = abs(st.t - (0.5 - halfInteriorWidth));
  14. float d2 = abs(st.t - (0.5 + halfInteriorWidth));
  15. float dist = min(d1, d2);
  16. vec4 currentColor = mix(outlineColor, color, b);
  17. vec4 outColor = czm_antialias(outlineColor, color, currentColor, dist);
  18. material.diffuse = outColor.rgb;
  19. material.alpha = outColor.a;
  20. return material;
  21. }