Skip to content

Commit

Permalink
Fix small angle approximation in VerticalExaggerationStageVS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeshurun Hembd committed Dec 3, 2023
1 parent 8cd5fb5 commit 74bb302
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ void verticalExaggerationStage(
float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC);
float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC);
float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance);
bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;

// Approximate the change in height above the ellipsoid, from camera to vertex position.
float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal);
float smallAngleVersine = 0.5 * sinTheta * sinTheta;
float versine = (sinTheta < 0.05) ? smallAngleVersine : exactVersine;
float versine = isSmallAngle ? smallAngleVersine : exactVersine;
float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine;
float vertexHeight = czm_eyeHeight + dHeight;

Expand Down

0 comments on commit 74bb302

Please sign in to comment.