• 3dTiles 最后一块拼图:几何误差与屏幕空间误差


    // Cesium3DTile.js Cesium3DTile.prototype.getScreenSpaceError()
    Cesium3DTile.prototype.getScreenSpaceError = function (
      frameState,
      useParentGeometricError,
      progressiveResolutionHeightFraction
    ) {
      var tileset = this._tileset;
      var heightFraction = defaultValue(progressiveResolutionHeightFraction, 1.0);
      var parentGeometricError = defined(this.parent)
        ? this.parent.geometricError
        : tileset._geometricError;
      var geometricError = useParentGeometricError
        ? parentGeometricError
        : this.geometricError;
      if (geometricError === 0.0) {
        // Leaf tiles do not have any error so save the computation
        return 0.0;
      }
      var camera = frameState.camera;
      var frustum = camera.frustum;
      var context = frameState.context;
      var width = context.drawingBufferWidth;
      var height = context.drawingBufferHeight * heightFraction;
      var error;
      if (
        frameState.mode === SceneMode.SCENE2D ||
        frustum instanceof OrthographicFrustum
      ) {
        if (defined(frustum._offCenterFrustum)) {
          frustum = frustum._offCenterFrustum;
        }
        var pixelSize =
          Math.max(frustum.top - frustum.bottom, frustum.right - frustum.left) /
          Math.max(width, height);
        error = geometricError / pixelSize;
      } else {
        // Avoid divide by zero when viewer is inside the tile
        var distance = Math.max(this._distanceToCamera, CesiumMath.EPSILON7);
        var sseDenominator = camera.frustum.sseDenominator;
        error = (geometricError * height) / (distance * sseDenominator);
        if (tileset.dynamicScreenSpaceError) {
          var density = tileset._dynamicScreenSpaceErrorComputedDensity;
          var factor = tileset.dynamicScreenSpaceErrorFactor;
          var dynamicError = CesiumMath.fog(distance, density) * factor;
          error -= dynamicError;
        }
      }
    
      error /= frameState.pixelRatio;
    
      return error;
    };
    

    上述源码是获取当前 Tile 的屏幕空间误差的,在这里,可以很直观看出 几何误差 与 屏幕空间误差 的关系。
    屏幕空间误差是指当前摄像机状态下(如果是2D,那么就是当前高度的视角下),实时计算出来的一个值
    而几何误差,则用于计算当前状态下的屏幕空间误差,见这两行:

    error = geometricError / pixelSize;
    
    error = (geometricError * height) / (distance * sseDenominator);
    

    而具体的这个屏幕空间误差的含义,待后续研究。

  • 相关阅读:
    CF809E Surprise me!
    2019-4-12-WPF-绑定的默认模式
    2019-4-12-WPF-绑定的默认模式
    2019-2-28-C#-16-进制字符串转-int-
    2019-2-28-C#-16-进制字符串转-int-
    2019-10-23-WPF-使用-SharpDx-异步渲染
    2019-10-23-WPF-使用-SharpDx-异步渲染
    2019-8-31-ASP.NET-Core-开启后台任务
    2019-8-31-ASP.NET-Core-开启后台任务
    2019-8-24-win10-uwp-读取文本GBK错误
  • 原文地址:https://www.cnblogs.com/onsummer/p/13357226.html
Copyright © 2020-2023  润新知