Horizon Occlusion Point Assistance

I am attempting to create a quantized mesh terrain tile, but am having difficulty correctly computing the horizon occlusion point. I have read through https://cesiumjs.org/2013/05/09/Computing-the-horizon-occlusion-point/, http://cesiumjs.org/2013/04/25/Horizon-culling/, and http://blogs.agi.com/insight3d/index.php/2009/03/25/horizon-culling-2/ and believe I understand the basic idea, but cannot seem to comprehend the implementations offered.

For the example:

function computeMagnitude(ellipsoid, position, scaledSpaceDirectionToPoint) {
    var scaledSpacePosition = ellipsoid.transformPositionToScaledSpace(position);
    var magnitudeSquared = scaledSpacePosition.magnitudeSquared();
    var magnitude = Math.sqrt(magnitudeSquared);
    var direction = scaledSpacePosition.divideByScalar(magnitude);

    // For the purpose of this computation, points below the ellipsoid
  // are considered to be on it instead.
    magnitudeSquared = Math.max(1.0, magnitudeSquared);
    magnitude = Math.max(1.0, magnitude);

    var cosAlpha = direction.dot(scaledSpaceDirectionToPoint);
    var sinAlpha = direction.cross(scaledSpaceDirectionToPoint).magnitude();
    var cosBeta = 1.0 / magnitude;
    var sinBeta = Math.sqrt(magnitudeSquared - 1.0) * cosBeta;

    return 1.0 / (cosAlpha * cosBeta - sinAlpha * sinBeta);
}

what is scaledSpaceDirectionToPoint? if it is a unit vector pointing to position, then isn't it the same as direction?

Hi,

scaledSpaceDirectionToPoint is not the direction to the position, it is the direction to the horizon occlusion point. Remember that we pick (rather than compute) the direction to the horizon occlusion point. Usually a vector through the center of the tile is a good choice. So, to compute scaledSpaceDirectionToPoint:

  1. Find a point near the center of the tile. Averaging the coordinates of the corners is one way to do it.

  2. Transform that center point to the ellipsoid scaled space.

  3. Normalize it to get a direction vector.

Kevin