Skip to content

Commit 786c6de

Browse files
authored
Merge pull request #8958 from CesiumGS/remove-log-depth-skin-workaround
Remove log depth skin workaround
2 parents 030a258 + a720407 commit 786c6de

File tree

6 files changed

+8
-108
lines changed

6 files changed

+8
-108
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
##### Fixes :wrench:
1414

1515
- Fixed error with `WallGeoemtry` when there were adjacent positions with very close values [#8952](https://github.com/CesiumGS/cesium/pull/8952)
16+
- Fixed artifact for skinned model when log depth is enabled. [#6447](https://github.com/CesiumGS/cesium/issues/6447)
1617
- Fixed a bug where certain rhumb arc polylines would lead to a crash. [#8787](https://github.com/CesiumGS/cesium/pull/8787)
1718
- Fixed handling of Label's backgroundColor and backgroundPadding option [#8949](https://github.com/CesiumGS/cesium/8949)
1819

CONTRIBUTORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
266266
- [Brandon Nguyen](https://github.com/bn-dignitas)
267267
- [Wang Bao](https://github.com/xiaobaogeit)
268268
- [John Remsberg](https://github.com/easternmotors)
269+
- [Bao Thien Tran](https://github.com/baothientran)

Source/Scene/ClassificationModel.js

-3
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,6 @@ function createProgram(model) {
647647
var drawVS = modifyShader(vs, model._vertexShaderLoaded);
648648
var drawFS = modifyShader(fs, model._classificationShaderLoaded);
649649

650-
drawVS = ModelUtility.modifyVertexShaderForLogDepth(drawVS, toClip);
651-
drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS);
652-
653650
model._shaderProgram = {
654651
vertexShaderSource: drawVS,
655652
fragmentShaderSource: drawFS,

Source/Scene/Model.js

-26
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,6 @@ function createProgram(programToCreate, model, context) {
24232423
var fs = shaders[program.fragmentShader];
24242424

24252425
var quantizedVertexShaders = model._quantizedVertexShaders;
2426-
var toClipCoordinatesGLSL = model._toClipCoordinatesGLSL[programId];
24272426

24282427
if (
24292428
model.extensionsUsed.WEB3D_quantized_attributes ||
@@ -2440,17 +2439,6 @@ function createProgram(programToCreate, model, context) {
24402439
var drawVS = modifyShader(vs, programId, model._vertexShaderLoaded);
24412440
var drawFS = modifyShader(fs, programId, model._fragmentShaderLoaded);
24422441

2443-
// Internet Explorer seems to have problems with discard (for clipping planes) after too many levels of indirection:
2444-
// https://github.com/CesiumGS/cesium/issues/6575.
2445-
// For IE log depth code is defined out anyway due to unsupported WebGL extensions, so the wrappers can be omitted.
2446-
if (!FeatureDetection.isInternetExplorer()) {
2447-
drawVS = ModelUtility.modifyVertexShaderForLogDepth(
2448-
drawVS,
2449-
toClipCoordinatesGLSL
2450-
);
2451-
drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS);
2452-
}
2453-
24542442
if (!defined(model._uniformMapLoaded)) {
24552443
drawFS = "uniform vec4 czm_pickColor;\n" + drawFS;
24562444
}
@@ -2540,7 +2528,6 @@ function recreateProgram(programToCreate, model, context) {
25402528
var shaders = model._rendererResources.sourceShaders;
25412529

25422530
var quantizedVertexShaders = model._quantizedVertexShaders;
2543-
var toClipCoordinatesGLSL = model._toClipCoordinatesGLSL[programId];
25442531

25452532
var clippingPlaneCollection = model.clippingPlanes;
25462533
var addClippingPlaneCode = isClippingEnabled(model);
@@ -2570,14 +2557,6 @@ function recreateProgram(programToCreate, model, context) {
25702557
var drawVS = modifyShader(vs, programId, model._vertexShaderLoaded);
25712558
var drawFS = modifyShader(finalFS, programId, model._fragmentShaderLoaded);
25722559

2573-
if (!FeatureDetection.isInternetExplorer()) {
2574-
drawVS = ModelUtility.modifyVertexShaderForLogDepth(
2575-
drawVS,
2576-
toClipCoordinatesGLSL
2577-
);
2578-
drawFS = ModelUtility.modifyFragmentShaderForLogDepth(drawFS);
2579-
}
2580-
25812560
if (!defined(model._uniformMapLoaded)) {
25822561
drawFS = "uniform vec4 czm_pickColor;\n" + drawFS;
25832562
}
@@ -4084,7 +4063,6 @@ function createResources(model, frameState) {
40844063
var context = frameState.context;
40854064
var scene3DOnly = frameState.scene3DOnly;
40864065
var quantizedVertexShaders = model._quantizedVertexShaders;
4087-
var toClipCoordinates = (model._toClipCoordinatesGLSL = {});
40884066
var techniques = model._sourceTechniques;
40894067
var programs = model._sourcePrograms;
40904068

@@ -4120,10 +4098,6 @@ function createResources(model, frameState) {
41204098
}
41214099

41224100
shader = modifyShader(shader, programId, model._vertexShaderLoaded);
4123-
toClipCoordinates[programId] = ModelUtility.toClipCoordinatesGLSL(
4124-
model.gltf,
4125-
shader
4126-
);
41274101
}
41284102
}
41294103

Source/Scene/ModelUtility.js

-79
Original file line numberDiff line numberDiff line change
@@ -903,85 +903,6 @@ ModelUtility.modifyShaderForQuantizedAttributes = function (
903903
};
904904
};
905905

906-
ModelUtility.toClipCoordinatesGLSL = function (gltf, shader) {
907-
var positionName = ModelUtility.getAttributeOrUniformBySemantic(
908-
gltf,
909-
"POSITION"
910-
);
911-
var decodedPositionName = positionName.replace("a_", "gltf_a_dec_");
912-
if (shader.indexOf(decodedPositionName) !== -1) {
913-
positionName = decodedPositionName;
914-
}
915-
916-
var modelViewProjectionName = ModelUtility.getAttributeOrUniformBySemantic(
917-
gltf,
918-
"MODELVIEWPROJECTION",
919-
undefined,
920-
true
921-
);
922-
if (
923-
!defined(modelViewProjectionName) ||
924-
shader.indexOf(modelViewProjectionName) === -1
925-
) {
926-
var projectionName = ModelUtility.getAttributeOrUniformBySemantic(
927-
gltf,
928-
"PROJECTION",
929-
undefined,
930-
true
931-
);
932-
var modelViewName = ModelUtility.getAttributeOrUniformBySemantic(
933-
gltf,
934-
"MODELVIEW",
935-
undefined,
936-
true
937-
);
938-
if (shader.indexOf("czm_instanced_modelView ") !== -1) {
939-
modelViewName = "czm_instanced_modelView";
940-
} else if (!defined(modelViewName)) {
941-
modelViewName = ModelUtility.getAttributeOrUniformBySemantic(
942-
gltf,
943-
"CESIUM_RTC_MODELVIEW",
944-
undefined,
945-
true
946-
);
947-
}
948-
modelViewProjectionName = projectionName + " * " + modelViewName;
949-
}
950-
951-
return modelViewProjectionName + " * vec4(" + positionName + ".xyz, 1.0)";
952-
};
953-
954-
ModelUtility.modifyFragmentShaderForLogDepth = function (shader) {
955-
shader = ShaderSource.replaceMain(shader, "czm_depth_main");
956-
shader +=
957-
"\n" +
958-
"void main() \n" +
959-
"{ \n" +
960-
" czm_depth_main(); \n" +
961-
" czm_writeLogDepth(); \n" +
962-
"} \n";
963-
964-
return shader;
965-
};
966-
967-
ModelUtility.modifyVertexShaderForLogDepth = function (
968-
shader,
969-
toClipCoordinatesGLSL
970-
) {
971-
shader = ShaderSource.replaceMain(shader, "czm_depth_main");
972-
shader +=
973-
"\n" +
974-
"void main() \n" +
975-
"{ \n" +
976-
" czm_depth_main(); \n" +
977-
" czm_vertexLogDepth(" +
978-
toClipCoordinatesGLSL +
979-
"); \n" +
980-
"} \n";
981-
982-
return shader;
983-
};
984-
985906
function getScalarUniformFunction(value) {
986907
var that = {
987908
value: value,

Specs/Scene/ModelSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,12 @@ describe(
27842784

27852785
it("loads a glTF with KHR_materials_common that has skinning", function () {
27862786
return loadModel(CesiumManUrl).then(function (m) {
2787+
// Face CesiumMan towards the camera. See https://github.com/CesiumGS/cesium/pull/8958#issuecomment-644352798
2788+
m.modelMatrix = Matrix4.multiply(
2789+
m.modelMatrix,
2790+
Axis.Y_UP_TO_X_UP,
2791+
new Matrix4()
2792+
);
27872793
verifyRender(m);
27882794
primitives.remove(m);
27892795
});

0 commit comments

Comments
 (0)