From 0351120f0763b88677d20326cdcb31e2cc05e1fc Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 3 Mar 2021 21:09:07 -0500 Subject: [PATCH] Premultiplied alpha to fix colors for globe translucency --- Source/Scene/Vector3DTileClampedPolylines.js | 2 +- Source/Shaders/Vector3DTileClampedPolylinesFS.glsl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Vector3DTileClampedPolylines.js b/Source/Scene/Vector3DTileClampedPolylines.js index cad5b034e96a..a8074171d86a 100644 --- a/Source/Scene/Vector3DTileClampedPolylines.js +++ b/Source/Scene/Vector3DTileClampedPolylines.js @@ -478,7 +478,7 @@ function getRenderState(mask3DTiles) { cull: { enabled: true, // prevent double-draw. Geometry is "inverted" (reversed winding order) so we're drawing backfaces. }, - blending: BlendingState.ALPHA_BLEND, + blending: BlendingState.PRE_MULTIPLIED_ALPHA_BLEND, depthMask: false, stencilTest: { enabled: mask3DTiles, diff --git a/Source/Shaders/Vector3DTileClampedPolylinesFS.glsl b/Source/Shaders/Vector3DTileClampedPolylinesFS.glsl index 444edf3e0c5c..2bb70a206ffb 100644 --- a/Source/Shaders/Vector3DTileClampedPolylinesFS.glsl +++ b/Source/Shaders/Vector3DTileClampedPolylinesFS.glsl @@ -48,5 +48,8 @@ void main() } gl_FragColor = u_highlightColor; + // Premultiply alpha. Required for classification primitives on translucent globe. + gl_FragColor.rgb *= gl_FragColor.a; + czm_writeDepthClamp(); } \ No newline at end of file