Skip to content

Commit e2c5ccc

Browse files
authored
Merge pull request #4930 from AnalyticalGraphicsInc/ground-primitive-no-frag-depth
Enable GroundPrimitives to render without the fragment depth extension.
2 parents 3cbc21b + e884442 commit e2c5ccc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Change Log
22
==========
33

4+
### 1.31 - 2017-03-01
5+
6+
* Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles.
7+
48
### 1.30 - 2017-02-01
59

610
* Deprecated

Source/Scene/GroundPrimitive.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ define([
8484
* is supported at this time.
8585
* </p>
8686
* <p>
87-
* 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,
88-
* 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
89-
* it. You can use webglreport.com to verify support for your hardware.
87+
* For correct rendering, this feature requires the EXT_frag_depth WebGL extension. For hardware that do not support this extension, there
88+
* will be rendering artifacts for some viewing angles.
9089
* </p>
9190
* <p>
9291
* Valid geometries are {@link CircleGeometry}, {@link CorridorGeometry}, {@link EllipseGeometry}, {@link PolygonGeometry}, and {@link RectangleGeometry}.
@@ -400,7 +399,7 @@ define([
400399
* @returns {Boolean} <code>true</code> if GroundPrimitives are supported; otherwise, returns <code>false</code>
401400
*/
402401
GroundPrimitive.isSupported = function(scene) {
403-
return scene.context.fragmentDepth && scene.context.stencilBuffer;
402+
return scene.context.stencilBuffer;
404403
};
405404

406405
GroundPrimitive._defaultMaxTerrainHeight = 9000.0;
@@ -1032,8 +1031,7 @@ define([
10321031
* @exception {DeveloperError} Not all of the geometry instances have the same color attribute.
10331032
*/
10341033
GroundPrimitive.prototype.update = function(frameState) {
1035-
var context = frameState.context;
1036-
if (!context.fragmentDepth || !this.show || (!defined(this._primitive) && !defined(this.geometryInstances))) {
1034+
if (!this.show || (!defined(this._primitive) && !defined(this.geometryInstances))) {
10371035
return;
10381036
}
10391037

Source/Shaders/ShadowVolumeFS.glsl

+4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
#ifdef GL_EXT_frag_depth
12
#extension GL_EXT_frag_depth : enable
3+
#endif
24

35
// emulated noperspective
46
varying float v_WindowZ;
57
varying vec4 v_color;
68

79
void writeDepthClampedToFarPlane()
810
{
11+
#ifdef GL_EXT_frag_depth
912
gl_FragDepthEXT = min(v_WindowZ * gl_FragCoord.w, 1.0);
13+
#endif
1014
}
1115

1216
void main(void)

0 commit comments

Comments
 (0)