Skip to content

Commit

Permalink
Merge pull request #4559 from AnalyticalGraphicsInc/shadows-polygon-o…
Browse files Browse the repository at this point in the history
…ffset

Fix polygon offset check for shadows
  • Loading branch information
mramato authored Nov 1, 2016
2 parents 957d25b + d491fa8 commit a7f1c6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Change Log
* Fix warning when using Webpack. [#4467](https://github.com/AnalyticalGraphicsInc/cesium/pull/4467)
* Fix primitive bounding sphere bug that would cause a crash when loading data sources. [#4431](https://github.com/AnalyticalGraphicsInc/cesium/issues/4431)
* Fix a crash when clustering is enabled, an entity has a label graphics defined, but the label isn't visible. [#4414](https://github.com/AnalyticalGraphicsInc/cesium/issues/4414)
* Fixed a shadow aliasing issue where polygon offset was not being applied. [#4559](https://github.com/AnalyticalGraphicsInc/cesium/pull/4559)

### 1.26 - 2016-10-03

Expand Down
3 changes: 2 additions & 1 deletion Source/Scene/ShadowMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ define([
this._needsUpdate = true;

// In IE11 polygon offset is not functional.
// TODO : Also disabled for Chrome (ANGLE) temporarily. Re-enable once https://github.com/AnalyticalGraphicsInc/cesium/issues/4560 is resolved.
var polygonOffsetSupported = true;
if (FeatureDetection.isInternetExplorer) {
if (FeatureDetection.isInternetExplorer() || (FeatureDetection.isChrome() && FeatureDetection.isWindows())) {
polygonOffsetSupported = false;
}
this._polygonOffsetSupported = polygonOffsetSupported;
Expand Down
5 changes: 4 additions & 1 deletion Source/Scene/ShadowMapShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ define([
var hasPositionVarying = defined(positionVaryingName);

var usesDepthTexture = shadowMap._usesDepthTexture;
var polygonOffsetSupported = shadowMap._polygonOffsetSupported;
var isPointLight = shadowMap._isPointLight;
var isSpotLight = shadowMap._isSpotLight;
var hasCascades = shadowMap._numberOfCascades > 1;
Expand Down Expand Up @@ -230,7 +231,9 @@ define([
if (isTerrain) {
// Scale depth bias based on view distance to reduce z-fighting in distant terrain
fsSource += ' shadowParameters.depthBias *= max(depth * 0.01, 1.0); \n';
} else {
} else if (!polygonOffsetSupported) {
// If polygon offset isn't supported push the depth back based on view, however this
// causes light leaking at further away views
fsSource += ' shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015); \n';
}

Expand Down

0 comments on commit a7f1c6f

Please sign in to comment.