Skip to content

Commit

Permalink
Merge pull request #5735 from AnalyticalGraphicsInc/depth-math
Browse files Browse the repository at this point in the history
Fix some math used by disableDepthDistance
  • Loading branch information
bagnell authored Aug 10, 2017
2 parents be83a12 + 99b50ec commit 3958c02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Change Log
* Fixed `replaceState` bug that was causing the `CesiumViewer` demo application to crash in Safari and iOS
* Fixed issue where `Model` and `BillboardCollection` would throw an error if the globe is undefined [#5638](https://github.com/AnalyticalGraphicsInc/cesium/issues/5638)
* Fixed issue where the `Model` glTF cache loses reference to the model's buffer data. [#5720](https://github.com/AnalyticalGraphicsInc/cesium/issues/5720)
* Fixed some issues with `disableDepthTestDistance` [#5501](https://github.com/AnalyticalGraphicsInc/cesium/issues/5501) [#5331](https://github.com/AnalyticalGraphicsInc/cesium/issues/5331) [#5621](https://github.com/AnalyticalGraphicsInc/cesium/issues/5621)

### 1.36 - 2017-08-01

Expand Down
7 changes: 4 additions & 3 deletions Source/Shaders/BillboardCollectionVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,12 @@ void main()

if (disableDepthTestDistance != 0.0)
{
gl_Position.z = min(gl_Position.z, gl_Position.w);

bool clipped = gl_Position.z < -gl_Position.w || gl_Position.z > gl_Position.w;
// Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
float zclip = gl_Position.z / gl_Position.w;
bool clipped = (zclip < -1.0 || zclip > 1.0);
if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))
{
// Position z on the near plane.
gl_Position.z = -gl_Position.w;
}
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Shaders/PointPrimitiveCollectionVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@ void main()

if (disableDepthTestDistance != 0.0)
{
gl_Position.z = min(gl_Position.z, gl_Position.w);

bool clipped = gl_Position.z < -gl_Position.w || gl_Position.z > gl_Position.w;
// Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
float zclip = gl_Position.z / gl_Position.w;
bool clipped = (zclip < -1.0 || zclip > 1.0);
if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))
{
// Position z on the near plane.
gl_Position.z = -gl_Position.w;
}
}
Expand Down

0 comments on commit 3958c02

Please sign in to comment.