diff --git a/CHANGES.md b/CHANGES.md index bb5f6123717d..734db9d9ffe7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ ##### Fixes :wrench: - Fixed error with `WallGeoemtry` when there were adjacent positions with very close values [#8952](https://github.com/CesiumGS/cesium/pull/8952) +- Fixed artifact for skinned model when log depth is enabled. [#6447](https://github.com/CesiumGS/cesium/issues/6447) - Fixed a bug where certain rhumb arc polylines would lead to a crash. [#8787](https://github.com/CesiumGS/cesium/pull/8787) ### 1.70.1 - 2020-06-10 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ded4552a8d07..62aacf0f3f66 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -264,3 +264,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [Brandon Nguyen](https://github.com/bn-dignitas) - [Wang Bao](https://github.com/xiaobaogeit) - [John Remsberg](https://github.com/easternmotors) +- [Bao Thien Tran](https://github.com/baothientran) diff --git a/Source/Scene/ClassificationModel.js b/Source/Scene/ClassificationModel.js index 679fa24cd0b0..cf3a8369f2e6 100644 --- a/Source/Scene/ClassificationModel.js +++ b/Source/Scene/ClassificationModel.js @@ -647,9 +647,6 @@ function createProgram(model) { var drawVS = modifyShader(vs, model._vertexShaderLoaded); var drawFS = modifyShader(fs, model._classificationShaderLoaded); - drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClip); - drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); - model._shaderProgram = { vertexShaderSource: drawVS, fragmentShaderSource: drawFS, diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index f337048d58c4..b3a2f3772ff5 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -2423,7 +2423,6 @@ function createProgram(programToCreate, model, context) { var fs = shaders[program.fragmentShader]; var quantizedVertexShaders = model._quantizedVertexShaders; - var toClipCoordinatesGLSL = model._toClipCoordinatesGLSL[programId]; if ( model.extensionsUsed.WEB3D_quantized_attributes || @@ -2440,17 +2439,6 @@ function createProgram(programToCreate, model, context) { var drawVS = modifyShader(vs, programId, model._vertexShaderLoaded); var drawFS = modifyShader(fs, programId, model._fragmentShaderLoaded); - // Internet Explorer seems to have problems with discard (for clipping planes) after too many levels of indirection: - // https://github.com/CesiumGS/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); - } - if (!defined(model._uniformMapLoaded)) { drawFS = "uniform vec4 czm_pickColor;\n" + drawFS; } @@ -2540,7 +2528,6 @@ function recreateProgram(programToCreate, model, context) { var shaders = model._rendererResources.sourceShaders; var quantizedVertexShaders = model._quantizedVertexShaders; - var toClipCoordinatesGLSL = model._toClipCoordinatesGLSL[programId]; var clippingPlaneCollection = model.clippingPlanes; var addClippingPlaneCode = isClippingEnabled(model); @@ -2570,14 +2557,6 @@ function recreateProgram(programToCreate, model, context) { var drawVS = modifyShader(vs, programId, model._vertexShaderLoaded); var drawFS = modifyShader(finalFS, programId, model._fragmentShaderLoaded); - if (!FeatureDetection.isInternetExplorer()) { - drawVS = ModelUtility.modifyVertexShaderForLogDepth( - drawVS, - toClipCoordinatesGLSL - ); - drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS); - } - if (!defined(model._uniformMapLoaded)) { drawFS = "uniform vec4 czm_pickColor;\n" + drawFS; } @@ -4084,7 +4063,6 @@ function createResources(model, frameState) { var context = frameState.context; var scene3DOnly = frameState.scene3DOnly; var quantizedVertexShaders = model._quantizedVertexShaders; - var toClipCoordinates = (model._toClipCoordinatesGLSL = {}); var techniques = model._sourceTechniques; var programs = model._sourcePrograms; @@ -4120,10 +4098,6 @@ function createResources(model, frameState) { } shader = modifyShader(shader, programId, model._vertexShaderLoaded); - toClipCoordinates[programId] = ModelUtility.toClipCoordinatesGLSL( - model.gltf, - shader - ); } } diff --git a/Source/Scene/ModelUtility.js b/Source/Scene/ModelUtility.js index 36a50738d7ea..7ede09e07575 100644 --- a/Source/Scene/ModelUtility.js +++ b/Source/Scene/ModelUtility.js @@ -903,85 +903,6 @@ ModelUtility.modifyShaderForQuantizedAttributes = function ( }; }; -ModelUtility.toClipCoordinatesGLSL = function (gltf, shader) { - var positionName = ModelUtility.getAttributeOrUniformBySemantic( - gltf, - "POSITION" - ); - var decodedPositionName = positionName.replace("a_", "gltf_a_dec_"); - if (shader.indexOf(decodedPositionName) !== -1) { - positionName = decodedPositionName; - } - - var modelViewProjectionName = ModelUtility.getAttributeOrUniformBySemantic( - gltf, - "MODELVIEWPROJECTION", - undefined, - true - ); - if ( - !defined(modelViewProjectionName) || - shader.indexOf(modelViewProjectionName) === -1 - ) { - var projectionName = ModelUtility.getAttributeOrUniformBySemantic( - gltf, - "PROJECTION", - undefined, - true - ); - var modelViewName = ModelUtility.getAttributeOrUniformBySemantic( - gltf, - "MODELVIEW", - undefined, - true - ); - if (shader.indexOf("czm_instanced_modelView ") !== -1) { - modelViewName = "czm_instanced_modelView"; - } else if (!defined(modelViewName)) { - modelViewName = ModelUtility.getAttributeOrUniformBySemantic( - gltf, - "CESIUM_RTC_MODELVIEW", - undefined, - true - ); - } - modelViewProjectionName = projectionName + " * " + modelViewName; - } - - return modelViewProjectionName + " * vec4(" + positionName + ".xyz, 1.0)"; -}; - -ModelUtility.modifyFragmentShaderForLogDepth = function (shader) { - shader = ShaderSource.replaceMain(shader, "czm_depth_main"); - shader += - "\n" + - "void main() \n" + - "{ \n" + - " czm_depth_main(); \n" + - " czm_writeLogDepth(); \n" + - "} \n"; - - return shader; -}; - -ModelUtility.modifyVertexShaderForLogDepth = function ( - shader, - toClipCoordinatesGLSL -) { - shader = ShaderSource.replaceMain(shader, "czm_depth_main"); - shader += - "\n" + - "void main() \n" + - "{ \n" + - " czm_depth_main(); \n" + - " czm_vertexLogDepth(" + - toClipCoordinatesGLSL + - "); \n" + - "} \n"; - - return shader; -}; - function getScalarUniformFunction(value) { var that = { value: value, diff --git a/Specs/Scene/ModelSpec.js b/Specs/Scene/ModelSpec.js index 5fb5e6bd56af..b2db67d54604 100644 --- a/Specs/Scene/ModelSpec.js +++ b/Specs/Scene/ModelSpec.js @@ -2784,6 +2784,12 @@ describe( it("loads a glTF with KHR_materials_common that has skinning", function () { return loadModel(CesiumManUrl).then(function (m) { + // Face CesiumMan towards the camera. See https://github.com/CesiumGS/cesium/pull/8958#issuecomment-644352798 + m.modelMatrix = Matrix4.multiply( + m.modelMatrix, + Axis.Y_UP_TO_X_UP, + new Matrix4() + ); verifyRender(m); primitives.remove(m); });