Skip to content

Commit

Permalink
Merge pull request #4930 from AnalyticalGraphicsInc/ground-primitive-…
Browse files Browse the repository at this point in the history
…no-frag-depth

Enable GroundPrimitives to render without the fragment depth extension.
  • Loading branch information
mramato authored Feb 1, 2017
2 parents 3cbc21b + e884442 commit e2c5ccc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

### 1.31 - 2017-03-01

* Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles.

### 1.30 - 2017-02-01

* Deprecated
Expand Down
10 changes: 4 additions & 6 deletions Source/Scene/GroundPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ define([
* is supported at this time.
* </p>
* <p>
* Because of the cutting edge nature of this feature in WebGL, it requires the EXT_frag_depth extension, which is currently only supported in Chrome,
* Firefox, Edge, and Safari 10. It's not yet supported in iOS 10. Android support varies by hardware and IE11 will most likely never support
* it. You can use webglreport.com to verify support for your hardware.
* For correct rendering, this feature requires the EXT_frag_depth WebGL extension. For hardware that do not support this extension, there
* will be rendering artifacts for some viewing angles.
* </p>
* <p>
* Valid geometries are {@link CircleGeometry}, {@link CorridorGeometry}, {@link EllipseGeometry}, {@link PolygonGeometry}, and {@link RectangleGeometry}.
Expand Down Expand Up @@ -400,7 +399,7 @@ define([
* @returns {Boolean} <code>true</code> if GroundPrimitives are supported; otherwise, returns <code>false</code>
*/
GroundPrimitive.isSupported = function(scene) {
return scene.context.fragmentDepth && scene.context.stencilBuffer;
return scene.context.stencilBuffer;
};

GroundPrimitive._defaultMaxTerrainHeight = 9000.0;
Expand Down Expand Up @@ -1032,8 +1031,7 @@ define([
* @exception {DeveloperError} Not all of the geometry instances have the same color attribute.
*/
GroundPrimitive.prototype.update = function(frameState) {
var context = frameState.context;
if (!context.fragmentDepth || !this.show || (!defined(this._primitive) && !defined(this.geometryInstances))) {
if (!this.show || (!defined(this._primitive) && !defined(this.geometryInstances))) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions Source/Shaders/ShadowVolumeFS.glsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#ifdef GL_EXT_frag_depth
#extension GL_EXT_frag_depth : enable
#endif

// emulated noperspective
varying float v_WindowZ;
varying vec4 v_color;

void writeDepthClampedToFarPlane()
{
#ifdef GL_EXT_frag_depth
gl_FragDepthEXT = min(v_WindowZ * gl_FragCoord.w, 1.0);
#endif
}

void main(void)
Expand Down

0 comments on commit e2c5ccc

Please sign in to comment.