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

Remove log depth skin workaround #8958

Merged
merged 7 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 0 additions & 3 deletions Source/Scene/ClassificationModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 0 additions & 26 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -4120,10 +4098,6 @@ function createResources(model, frameState) {
}

shader = modifyShader(shader, programId, model._vertexShaderLoaded);
toClipCoordinates[programId] = ModelUtility.toClipCoordinatesGLSL(
model.gltf,
shader
);
}
}

Expand Down
79 changes: 0 additions & 79 deletions Source/Scene/ModelUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down