Skip to content

Commit

Permalink
Merge pull request #6315 from AnalyticalGraphicsInc/material-bug-fix
Browse files Browse the repository at this point in the history
Fix generating model shaders for case where material is not used by a primitve
  • Loading branch information
pjcozzi authored Mar 13, 2018
2 parents c0cf087 + 34338c1 commit 6a53d84
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Change Log
##### Fixes :wrench:
* Fixed support of glTF-supplied tangent vectors. [#6302](https://github.com/AnalyticalGraphicsInc/cesium/pull/6302)
* Fixed improper zoom during model load failure. [#6305](https://github.com/AnalyticalGraphicsInc/cesium/pull/6305)
* Fixed model loading failure when containing unused materials. [6315](https://github.com/AnalyticalGraphicsInc/cesium/pull/6315)

### 1.43 - 2018-03-01

Expand Down
24 changes: 16 additions & 8 deletions Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,17 @@ define([
parameterValues.doubleSided = khrMaterialsCommon.doubleSided;
}
var jointCount = defaultValue(khrMaterialsCommon.jointCount, 0);

var hasSkinning = jointCount > 0;
var primitiveInfo = khrMaterialsCommon.extras._pipeline.primitive;
var skinningInfo = primitiveInfo.skinning;
var hasVertexColors = primitiveInfo.hasVertexColors;

var skinningInfo;
var hasSkinning = false;
var hasVertexColors = false;

if (defined(primitiveInfo)) {
skinningInfo = primitiveInfo.skinning;
hasSkinning = skinningInfo.skinned;
hasVertexColors = primitiveInfo.hasVertexColors;
}

var vertexShader = 'precision highp float;\n';
var fragmentShader = 'precision highp float;\n';
Expand Down Expand Up @@ -788,11 +794,13 @@ define([
var jointCount = defaultValue(khrMaterialsCommon.jointCount, 0);
techniqueKey += jointCount.toString() + ';';
var primitiveInfo = khrMaterialsCommon.extras._pipeline.primitive;
var skinningInfo = primitiveInfo.skinning;
if (jointCount > 0) {
techniqueKey += skinningInfo.type + ';';
if (defined(primitiveInfo)) {
var skinningInfo = primitiveInfo.skinning;
if (jointCount > 0) {
techniqueKey += skinningInfo.type + ';';
}
techniqueKey += primitiveInfo.hasVertexColors;
}
techniqueKey += primitiveInfo.hasVertexColors;

return techniqueKey;
}
Expand Down
13 changes: 10 additions & 3 deletions Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,16 @@ define([
var joints = (defined(skin)) ? skin.joints : [];
var jointCount = joints.length;
var primitiveInfo = material.extras._pipeline.primitive;
var skinningInfo = primitiveInfo.skinning;
var hasSkinning = skinningInfo.skinned;
var hasVertexColors = primitiveInfo.hasVertexColors;

var skinningInfo;
var hasSkinning = false;
var hasVertexColors = false;

if (defined(primitiveInfo)) {
skinningInfo = primitiveInfo.skinning;
hasSkinning = skinningInfo.skinned;
hasVertexColors = primitiveInfo.hasVertexColors;
}

var hasNormals = true;
var hasTangents = false;
Expand Down

0 comments on commit 6a53d84

Please sign in to comment.