Cesium billboard 自定义shader实现描边效果
uniform sampler2D u_atlas;uniform vec2 dimensions;in vec2 v_textureCoordinates;in vec4 v_pickColor;in vec4 v_color;in float v_splitDirection;void main(){if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;float outlineWidth = 2.0;vec2 uv = v_textureCoordinates;vec2 uv_up = vec2(uv.x, uv.y + 1./dimensions.y * outlineWidth);vec2 uv_down = vec2(uv.x, uv.y - 1./dimensions.y * outlineWidth);vec2 uv_left = vec2(uv.x + 1./dimensions.x * outlineWidth, uv.y);vec2 uv_right = vec2(uv.x - 1./dimensions.x * outlineWidth, uv.y);vec4 color_up = texture(u_atlas, uv_up);vec4 color_down = texture(u_atlas, uv_down);vec4 color_left = texture(u_atlas, uv_left);vec4 color_right = texture(u_atlas, uv_right);vec4 outlineColor = color_left + color_right + color_up + color_down;outlineColor.rgb = vec3(1., 0., 0.);vec4 rayColor = texture(u_atlas, uv);vec4 color = mix(outlineColor,rayColor, rayColor.a);color = czm_gammaCorrect(color);#if !defined(OPAQUE) && !defined(TRANSLUCENT)if (color.a < 0.005) {discard;}#else#ifdef OPAQUEif (color.a < 0.995) {discard;}#elseif (color.a >= 0.995) {discard;}#endif#endif#ifdef VECTOR_TILEcolor *= u_highlightColor;#endifout_FragColor = color;#ifdef LOG_DEPTHczm_writeLogDepth();#endif