Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GroundPrimitives to render without the fragment depth extension. #4930

Merged
merged 4 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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