From 2ad1780cc996258012b43c7ea6ac64210c188929 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Oct 2016 14:52:16 -0400 Subject: [PATCH 1/6] Correctly check for polygon offset --- Source/Scene/ShadowMap.js | 2 +- Source/Scene/ShadowMapShader.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Scene/ShadowMap.js b/Source/Scene/ShadowMap.js index 0ef5677758ee..43688260d1fe 100644 --- a/Source/Scene/ShadowMap.js +++ b/Source/Scene/ShadowMap.js @@ -186,7 +186,7 @@ define([ // In IE11 polygon offset is not functional. var polygonOffsetSupported = true; - if (FeatureDetection.isInternetExplorer) { + if (FeatureDetection.isInternetExplorer()) { polygonOffsetSupported = false; } this._polygonOffsetSupported = polygonOffsetSupported; diff --git a/Source/Scene/ShadowMapShader.js b/Source/Scene/ShadowMapShader.js index 61d4c851313e..7884e2cadf4f 100644 --- a/Source/Scene/ShadowMapShader.js +++ b/Source/Scene/ShadowMapShader.js @@ -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; @@ -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 + // causing light leaking at further away views fsSource += ' shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015); \n'; } From 8b812ebfe990987399d8d4d77247fa30bf8edd84 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Oct 2016 15:06:47 -0400 Subject: [PATCH 2/6] Typo --- Source/Scene/ShadowMapShader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/ShadowMapShader.js b/Source/Scene/ShadowMapShader.js index 7884e2cadf4f..dcb70bd245b3 100644 --- a/Source/Scene/ShadowMapShader.js +++ b/Source/Scene/ShadowMapShader.js @@ -233,7 +233,7 @@ define([ fsSource += ' shadowParameters.depthBias *= max(depth * 0.01, 1.0); \n'; } else if (!polygonOffsetSupported) { // If polygon offset isn't supported push the depth back based on view, however this - // causing light leaking at further away views + // causes light leaking at further away views fsSource += ' shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015); \n'; } From d0619b0c026596e950272f089216aa553d86618b Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Oct 2016 15:16:23 -0400 Subject: [PATCH 3/6] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c2d7354f028f..fd0e595f714a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 From 300191df3c99cc976264a70da55750e4fa977884 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Oct 2016 15:30:12 -0400 Subject: [PATCH 4/6] Turn off polygon offset from Chrome temporarily --- Source/Scene/ShadowMap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Scene/ShadowMap.js b/Source/Scene/ShadowMap.js index 43688260d1fe..dadcf4c83bfb 100644 --- a/Source/Scene/ShadowMap.js +++ b/Source/Scene/ShadowMap.js @@ -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. var polygonOffsetSupported = true; - if (FeatureDetection.isInternetExplorer()) { + if (FeatureDetection.isInternetExplorer() || FeatureDetection.isChrome()) { polygonOffsetSupported = false; } this._polygonOffsetSupported = polygonOffsetSupported; From 9964fc9ae9301903e36b9a393b26b7e912a44f1e Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Oct 2016 15:43:27 -0400 Subject: [PATCH 5/6] Change url --- Source/Scene/ShadowMap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/ShadowMap.js b/Source/Scene/ShadowMap.js index dadcf4c83bfb..a1a8bc089c21 100644 --- a/Source/Scene/ShadowMap.js +++ b/Source/Scene/ShadowMap.js @@ -185,7 +185,7 @@ 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. + // TODO : Also disabled for Chrome temporarily. Re-enable once https://github.com/AnalyticalGraphicsInc/cesium/issues/4560 is resolved. var polygonOffsetSupported = true; if (FeatureDetection.isInternetExplorer() || FeatureDetection.isChrome()) { polygonOffsetSupported = false; From d491fa8f2e52e4168e8be01be4f502082672c61f Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 31 Oct 2016 20:19:33 -0400 Subject: [PATCH 6/6] More specific test --- Source/Scene/ShadowMap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Scene/ShadowMap.js b/Source/Scene/ShadowMap.js index a1a8bc089c21..bf51dcd9d6af 100644 --- a/Source/Scene/ShadowMap.js +++ b/Source/Scene/ShadowMap.js @@ -185,9 +185,9 @@ define([ this._needsUpdate = true; // In IE11 polygon offset is not functional. - // TODO : Also disabled for Chrome temporarily. Re-enable once https://github.com/AnalyticalGraphicsInc/cesium/issues/4560 is resolved. + // 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() || FeatureDetection.isChrome()) { + if (FeatureDetection.isInternetExplorer() || (FeatureDetection.isChrome() && FeatureDetection.isWindows())) { polygonOffsetSupported = false; } this._polygonOffsetSupported = polygonOffsetSupported;