From e11540f7f6a3ca9330dad4fb7d02186b01ce23bb Mon Sep 17 00:00:00 2001
From: Ian Lilley <ianlilleyt@gmail.com>
Date: Fri, 25 Oct 2019 10:42:31 -0400
Subject: [PATCH] added pixel ratio to czm_metersPerPixel function

---
 Source/Shaders/BillboardCollectionVS.glsl            | 4 ++--
 Source/Shaders/Builtin/Functions/metersPerPixel.glsl | 2 +-
 Source/Shaders/PolylineShadowVolumeMorphVS.glsl      | 4 ++--
 Source/Shaders/PolylineShadowVolumeVS.glsl           | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Source/Shaders/BillboardCollectionVS.glsl b/Source/Shaders/BillboardCollectionVS.glsl
index 2693d6990150..8f10dc21d2be 100644
--- a/Source/Shaders/BillboardCollectionVS.glsl
+++ b/Source/Shaders/BillboardCollectionVS.glsl
@@ -56,7 +56,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
 {
     // 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_pixelRatio * 0.5;
+    vec2 halfSize = imageSize * scale * 0.5;
     halfSize *= ((direction * 2.0) - 1.0);
 
     vec2 originTranslate = origin * abs(halfSize);
@@ -102,7 +102,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
     }
 
     positionEC.xy += translate * mpp;
-    positionEC.xy += (pixelOffset * czm_pixelRatio) * mpp;
+    positionEC.xy += pixelOffset * mpp;
     return positionEC;
 }
 
diff --git a/Source/Shaders/Builtin/Functions/metersPerPixel.glsl b/Source/Shaders/Builtin/Functions/metersPerPixel.glsl
index f6066d21e0b5..f0a712d254ee 100644
--- a/Source/Shaders/Builtin/Functions/metersPerPixel.glsl
+++ b/Source/Shaders/Builtin/Functions/metersPerPixel.glsl
@@ -37,5 +37,5 @@ float czm_metersPerPixel(vec4 positionEC)
         pixelWidth = 2.0 * distanceToPixel * tanTheta / width;
     }
 
-    return max(pixelWidth, pixelHeight);
+    return max(pixelWidth, pixelHeight) * czm_pixelRatio;
 }
diff --git a/Source/Shaders/PolylineShadowVolumeMorphVS.glsl b/Source/Shaders/PolylineShadowVolumeMorphVS.glsl
index 53c0a8a45933..a2a618919953 100644
--- a/Source/Shaders/PolylineShadowVolumeMorphVS.glsl
+++ b/Source/Shaders/PolylineShadowVolumeMorphVS.glsl
@@ -103,12 +103,12 @@ void main()
 #endif // PER_INSTANCE_COLOR
 
 #ifdef WIDTH_VARYING
-    float width = czm_batchTable_width(batchId) * czm_pixelRatio;
+    float width = czm_batchTable_width(batchId);
     float halfWidth = width * 0.5;
     v_width = width;
     v_texcoordNormalizationAndHalfWidth.z = halfWidth;
 #else
-    float halfWidth = 0.5 * czm_batchTable_width(batchId) * czm_pixelRatio;
+    float halfWidth = 0.5 * czm_batchTable_width(batchId);
     v_texcoordNormalizationAndHalfWidth.z = halfWidth;
 #endif
 
diff --git a/Source/Shaders/PolylineShadowVolumeVS.glsl b/Source/Shaders/PolylineShadowVolumeVS.glsl
index aa922064b396..9d17be9312d2 100644
--- a/Source/Shaders/PolylineShadowVolumeVS.glsl
+++ b/Source/Shaders/PolylineShadowVolumeVS.glsl
@@ -135,7 +135,7 @@ void main()
     //    { \| }
     //       o---------- polyline segment ---->
     //
-    float width = czm_batchTable_width(batchId) * czm_pixelRatio;
+    float width = czm_batchTable_width(batchId);
 #ifdef WIDTH_VARYING
     v_width = width;
 #endif