From 59621ac8e2dd3d38b02194081ba0cae433707fef Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Fri, 11 May 2018 13:33:05 -0400 Subject: [PATCH 1/2] workaround for IE model + clipping planes shader bug --- CHANGES.md | 1 + Source/Scene/Model.js | 36 ++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a40ecbeeb53a..8a1b8a61a900 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ Change Log * Fixed incorrect 3D Tiles statistics when a tile fails during processing. [#6558](https://github.com/AnalyticalGraphicsInc/cesium/pull/6558) * Fixed race condition causing intermittent crash when changing geometry show value [#3061](https://github.com/AnalyticalGraphicsInc/cesium/issues/3061) * `ProviderViewModel`s with no category are displayed in an untitled group in `BaseLayerPicker` instead of being labeled as `'Other'` [#6574](https://github.com/AnalyticalGraphicsInc/cesium/pull/6574) +* Added a workaround for clipping planes causing a picking shader compilation failure for gltf models and 3D Tilesets in Internet Explorer [#6575](https://github.com/AnalyticalGraphicsInc/cesium/issues/6575) ### 1.45 - 2018-05-01 diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index c53098437a4d..c102dc86dcbf 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -1995,10 +1995,13 @@ define([ var drawVS = modifyShader(vs, id, model._vertexShaderLoaded); var drawFS = modifyShader(fs, id, model._fragmentShaderLoaded); - drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClipCoordinatesGLSL); - drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); + if (!FeatureDetection.isInternetExplorer()) { + drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClipCoordinatesGLSL); + drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); + } - var pickFS, pickVS; + var pickFS; + var pickVS; if (model.allowPicking) { // PERFORMANCE_IDEA: Can optimize this shader with a glTF hint. https://github.com/KhronosGroup/glTF/issues/181 pickVS = modifyShader(vs, id, model._pickVertexShaderLoaded); @@ -2008,8 +2011,13 @@ define([ pickFS = ShaderSource.createPickFragmentShaderSource(fs, 'uniform'); } - pickVS = ModelUtility.modifyVertexShaderForLogDepth(pickVS, toClipCoordinatesGLSL); - pickFS = ModelUtility.modifyFragmentShaderForLogDepth(pickFS); + // Internet Explorer seems to have problems with discard after too many levels of indirection: + // https://github.com/AnalyticalGraphicsInc/cesium/issues/6575. + // In this case, log depth modifications are empty wrappers and can be omitted. + if (!FeatureDetection.isInternetExplorer()) { + pickVS = ModelUtility.modifyVertexShaderForLogDepth(pickVS, toClipCoordinatesGLSL); + pickFS = ModelUtility.modifyFragmentShaderForLogDepth(pickFS); + } } createAttributesAndProgram(id, drawFS, drawVS, pickFS, pickVS, model, context); } @@ -2041,10 +2049,13 @@ define([ var drawVS = modifyShader(vs, id, model._vertexShaderLoaded); var drawFS = modifyShader(finalFS, id, model._fragmentShaderLoaded); - drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClipCoordinatesGLSL); - drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); + if (!FeatureDetection.isInternetExplorer()) { + drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClipCoordinatesGLSL); + drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); + } - var pickFS, pickVS; + var pickFS; + var pickVS; if (model.allowPicking) { // PERFORMANCE_IDEA: Can optimize this shader with a glTF hint. https://github.com/KhronosGroup/glTF/issues/181 pickVS = modifyShader(vs, id, model._pickVertexShaderLoaded); @@ -2058,8 +2069,13 @@ define([ pickFS = modifyShaderForClippingPlanes(pickFS, clippingPlaneCollection); } - pickVS = ModelUtility.modifyVertexShaderForLogDepth(pickVS, toClipCoordinatesGLSL); - pickFS = ModelUtility.modifyFragmentShaderForLogDepth(pickFS); + // Internet Explorer seems to have problems with discard after too many levels of indirection: + // https://github.com/AnalyticalGraphicsInc/cesium/issues/6575. + // In this case, log depth modifications are empty wrappers and can be omitted. + if (!FeatureDetection.isInternetExplorer()) { + pickVS = ModelUtility.modifyVertexShaderForLogDepth(pickVS, toClipCoordinatesGLSL); + pickFS = ModelUtility.modifyFragmentShaderForLogDepth(pickFS); + } } createAttributesAndProgram(id, drawFS, drawVS, pickFS, pickVS, model, context); } From 2edcb9d85ae6c58666d63812081bf32bd65c775b Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Fri, 11 May 2018 13:48:05 -0400 Subject: [PATCH 2/2] move and update comment for Ie clipping planes bugfix --- Source/Scene/Model.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index c102dc86dcbf..64132b2e194e 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -1995,6 +1995,9 @@ define([ var drawVS = modifyShader(vs, id, model._vertexShaderLoaded); var drawFS = modifyShader(fs, id, model._fragmentShaderLoaded); + // Internet Explorer seems to have problems with discard (for clipping planes) after too many levels of indirection: + // https://github.com/AnalyticalGraphicsInc/cesium/issues/6575. + // For IE log depth code is defined out anyway due to unsupported WebGL extensions, so the wrappers can be omitted. if (!FeatureDetection.isInternetExplorer()) { drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClipCoordinatesGLSL); drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); @@ -2011,9 +2014,6 @@ define([ pickFS = ShaderSource.createPickFragmentShaderSource(fs, 'uniform'); } - // Internet Explorer seems to have problems with discard after too many levels of indirection: - // https://github.com/AnalyticalGraphicsInc/cesium/issues/6575. - // In this case, log depth modifications are empty wrappers and can be omitted. if (!FeatureDetection.isInternetExplorer()) { pickVS = ModelUtility.modifyVertexShaderForLogDepth(pickVS, toClipCoordinatesGLSL); pickFS = ModelUtility.modifyFragmentShaderForLogDepth(pickFS); @@ -2069,9 +2069,6 @@ define([ pickFS = modifyShaderForClippingPlanes(pickFS, clippingPlaneCollection); } - // Internet Explorer seems to have problems with discard after too many levels of indirection: - // https://github.com/AnalyticalGraphicsInc/cesium/issues/6575. - // In this case, log depth modifications are empty wrappers and can be omitted. if (!FeatureDetection.isInternetExplorer()) { pickVS = ModelUtility.modifyVertexShaderForLogDepth(pickVS, toClipCoordinatesGLSL); pickFS = ModelUtility.modifyFragmentShaderForLogDepth(pickFS);