diff --git a/Source/Scene/BillboardCollection.js b/Source/Scene/BillboardCollection.js index 9239bce9fd48..42b114b284db 100644 --- a/Source/Scene/BillboardCollection.js +++ b/Source/Scene/BillboardCollection.js @@ -1276,40 +1276,41 @@ define([ writer(i + 2, translateX, translateY, 0.0, 0.0); writer(i + 3, translateX, translateY, 0.0, 0.0); } - } else { - //write texture coordiante bounds, used by depth testing in fragment shader - var minX = 0; - var minY = 0; - var width = 0; - var height = 0; - var index = billboard._imageIndex; - if (index !== -1) { - var imageRectangle = textureAtlasCoordinates[index]; + return; + } - //>>includeStart('debug', pragmas.debug); - if (!defined(imageRectangle)) { - throw new DeveloperError('Invalid billboard image index: ' + index); - } - //>>includeEnd('debug'); + //write texture coordinate bounds, used by depth testing in fragment shader + var minX = 0; + var minY = 0; + var width = 0; + var height = 0; + var index = billboard._imageIndex; + if (index !== -1) { + var imageRectangle = textureAtlasCoordinates[index]; - minX = imageRectangle.x; - minY = imageRectangle.y; - width = imageRectangle.width; - height = imageRectangle.height; + //>>includeStart('debug', pragmas.debug); + if (!defined(imageRectangle)) { + throw new DeveloperError('Invalid billboard image index: ' + index); } - var maxX = minX + width; - var maxY = minY + height; + //>>includeEnd('debug'); - if (billboardCollection._instanced) { - i = billboard._index; - writer(i, minX, minY, maxX, maxY); - } else { - i = billboard._index * 4; - writer(i + 0, minX, minY, maxX, maxY); - writer(i + 1, minX, minY, maxX, maxY); - writer(i + 2, minX, minY, maxX, maxY); - writer(i + 3, minX, minY, maxX, maxY); - } + minX = imageRectangle.x; + minY = imageRectangle.y; + width = imageRectangle.width; + height = imageRectangle.height; + } + var maxX = minX + width; + var maxY = minY + height; + + if (billboardCollection._instanced) { + i = billboard._index; + writer(i, minX, minY, maxX, maxY); + } else { + i = billboard._index * 4; + writer(i + 0, minX, minY, maxX, maxY); + writer(i + 1, minX, minY, maxX, maxY); + writer(i + 2, minX, minY, maxX, maxY); + writer(i + 3, minX, minY, maxX, maxY); } } diff --git a/Source/Shaders/BillboardCollectionVS.glsl b/Source/Shaders/BillboardCollectionVS.glsl index d1d4c93a5325..01e36c3dfb5a 100644 --- a/Source/Shaders/BillboardCollectionVS.glsl +++ b/Source/Shaders/BillboardCollectionVS.glsl @@ -50,7 +50,6 @@ const float SHIFT_RIGHT1 = 1.0 / 2.0; vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 direction, vec2 origin, vec2 translate, vec2 pixelOffset, vec3 alignedAxis, bool validAlignedAxis, float rotation, bool sizeInMeters, out mat2 rotationMatrix, out float mpp) { - // Note the halfSize cannot be computed in JavaScript because it is sent via // compressed vertex attributes that coerce it to an integer. vec2 halfSize = imageSize * scale * czm_resolutionScale * 0.5; @@ -65,8 +64,8 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir if (validAlignedAxis) { vec4 projectedAlignedAxis = czm_modelViewProjection * vec4(alignedAxis, 0.0); - angle += sign(-projectedAlignedAxis.x) * acos( sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) / - (projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y) ); + angle += sign(-projectedAlignedAxis.x) * acos(sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) / + (projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y)); } float cosTheta = cos(angle); @@ -108,7 +107,7 @@ float getGlobeDepth(vec4 positionEC) { vec4 posWC = czm_eyeToWindowCoordinates(positionEC); - float globeDepth = czm_unpackDepth(texture2D(czm_globeDepthTexture, posWC.xy/czm_viewport.zw)); + float globeDepth = czm_unpackDepth(texture2D(czm_globeDepthTexture, posWC.xy / czm_viewport.zw)); if (globeDepth == 0.0) { @@ -384,11 +383,11 @@ if (lengthSq < disableDepthTestDistance) { imageSize /= mpp; } - #if defined(ROTATION) || defined(ALIGNED_AXIS) +#if defined(ROTATION) || defined(ALIGNED_AXIS) v_rotationMatrix = rotationMatrix; - #else +#else v_rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0); - #endif +#endif v_eyeDepthDistanceAndApplyTranslate.x = eyeDepth; if (lengthSq < disableDepthTestDistance)