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

Fix polygon offset check for shadows #4559

Merged
merged 6 commits into from Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
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
Expand Up @@ -185,8 +185,9 @@ define([
this._needsUpdate = true;

// In IE11 polygon offset is not functional.
// TODO : Also disabled for Chrome temporarily. Re-enable once https://groups.google.com/forum/#!topic/webgl-dev-list/E1dAG65QBhg is resolved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write up a Cesium bug instead of linking to a forum post. (the Cesium bug can include the above link, of course).

If we ever need to do this check in more than one place, we should move the code to FeatureDetection but it's fine here for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the new issue is here: #4560

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is specifically an ANGLE problem, why are we disabling on Chrome in all cases? We have lots of non-ANGLE Chrome users (Mac/Linux/Android/iOS)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, the check is now Chrome + Windows

var polygonOffsetSupported = true;
if (FeatureDetection.isInternetExplorer) {
if (FeatureDetection.isInternetExplorer() || FeatureDetection.isChrome()) {
polygonOffsetSupported = false;
}
this._polygonOffsetSupported = polygonOffsetSupported;
Expand Down
5 changes: 4 additions & 1 deletion Source/Scene/ShadowMapShader.js
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