Skip to content

Commit

Permalink
Fixed ground primitives in orthographic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
IanLilleyT committed May 15, 2020
1 parent d07271e commit 2da52de
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fixed a bug where a removed billboard could prevent changing of the `TerrainProvider`. [#8766](https://github.com/CesiumGS/cesium/pull/8766)
- Fixed an issue with 3D Tiles point cloud styling where `${feature.propertyName}` and `${feature["propertyName"]}` syntax would cause a crash. Also fixed an issue where property names with non-alphanumeric characters would crash. [#8785](https://github.com/CesiumGS/cesium/pull/8785)
- Fixed a bug where `DebugCameraPrimitive` was ignoring the near and far planes of the `Camera`. [#8848](https://github.com/CesiumGS/cesium/issues/8848)
- Fixed ground primitives in orthographic mode. [#5110](https://github.com/CesiumGS/cesium/issues/5110)

### 1.69.0 - 2020-05-01

Expand Down
10 changes: 7 additions & 3 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,14 @@ UniformState.prototype.update = function (frameState) {
var fov = camera.frustum.fov;
var viewport = this._viewport;
var pixelSizePerMeter;
if (viewport.height > viewport.width) {
pixelSizePerMeter = (Math.tan(0.5 * fov) * 2.0) / viewport.height;
if (defined(fov)) {
if (viewport.height > viewport.width) {
pixelSizePerMeter = (Math.tan(0.5 * fov) * 2.0) / viewport.height;
} else {
pixelSizePerMeter = (Math.tan(0.5 * fov) * 2.0) / viewport.width;
}
} else {
pixelSizePerMeter = (Math.tan(0.5 * fov) * 2.0) / viewport.width;
pixelSizePerMeter = 1.0 / Math.max(viewport.width, viewport.height);
}

this._geometricToleranceOverMeter =
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ function depthClampVS(vertexShaderSource) {
" czm_non_depth_clamp_main();\n" +
" vec4 position = gl_Position;\n" +
" v_WindowZ = (0.5 * (position.z / position.w) + 0.5) * position.w;\n" +
" position.z = min(position.z, position.w);\n" +
" position.z = clamp(position.z, -position.w, +position.w);\n" +
" gl_Position = position;\n" +
"}\n";
return modifiedVS;
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/Builtin/Functions/depthClampFarPlane.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vec4 czm_depthClampFarPlane(vec4 coords)
{
#ifndef LOG_DEPTH
v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;
coords.z = min(coords.z, coords.w);
coords.z = clamp(coords.z, -coords.w, +coords.w);
#endif
return coords;
}

0 comments on commit 2da52de

Please sign in to comment.