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

Update gltf Pipeline and support KHR_techniques_webgl and KHR_blend #6805

Merged
merged 61 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
be6fffa
Update gltf pipeline files and support KHR_techniques_webgl and KHR_b…
ggetz Jul 16, 2018
9d907df
Cleanup
ggetz Jul 16, 2018
e82b4b6
Doc edits
lilleyse Jul 19, 2018
395eb34
Minor cleanup
lilleyse Jul 23, 2018
173f4b5
Cleanup model with new gltf-pipeline
ggetz Jul 25, 2018
923874b
Simplify render states
ggetz Aug 2, 2018
7abc5c7
Fix ClassificationModel, factor out duplicate code
ggetz Aug 2, 2018
1e5d67f
Various gltf cleanup
ggetz Aug 3, 2018
58f99b4
Merge branch 'master' into gltf-update-pipeline
ggetz Aug 3, 2018
6de38fe
alphaCutoff uniform, attribute location fix
ggetz Aug 3, 2018
5651d79
Update gltf-pipeline
ggetz Aug 3, 2018
c098115
Update pipeline, resolve material errors
ggetz Aug 20, 2018
be83cc2
Remove pipeline extras where possible
ggetz Aug 20, 2018
681aa24
Fix model caching, cleanup forward axis, cleanup specs
ggetz Aug 27, 2018
c0db13d
Fix docs, use gltfPipeline removePipelineExtras
ggetz Aug 27, 2018
c69505b
Cleanup eslint error
ggetz Aug 27, 2018
a7a4ced
Fix render states
ggetz Aug 27, 2018
514c2b7
Discard instead of blend for alphaMode MASK
ggetz Aug 27, 2018
71ff4c4
Cleanup eslint error
ggetz Aug 27, 2018
ccad16c
Add KHR_materials_unlit to list of supported extensions
Aug 30, 2018
b136052
Turn off lighting when detects unlit extension
Aug 30, 2018
7a9faa7
Updated changes.md
Aug 30, 2018
c56a339
Ignore unlit and occlusion when unlit
Aug 30, 2018
21caa93
Remove log and fix formatting
Aug 31, 2018
7c28d2a
Added test for unlit
Aug 31, 2018
ba4d840
Moved BoxUnlit to its own folder
Aug 31, 2018
db96ceb
Added KHR_materials_pbrSpecularGlossiness to supported extensions
Sep 4, 2018
ca4dc6c
Add support for spec gloss
Sep 4, 2018
f3afd01
Moved changes.md text into October release
Sep 5, 2018
0d8a577
Merge branch 'master' into gltf-update-pipeline
ggetz Sep 5, 2018
6401433
Added BoomBox SpecGloss model
Sep 5, 2018
3dad95a
Updated old boom box model
Sep 5, 2018
6d8e5dc
Added entry to CHANGES.md
Sep 5, 2018
974af0d
Merge branch 'gltf-update-pipeline' into gltf-unlit
lilleyse Sep 5, 2018
604400d
Merge pull request #6977 from OmarShehata/gltf-unlit
lilleyse Sep 5, 2018
602db48
Merge branch 'gltf-update-pipeline' into specgloss-ext
OmarShehata Sep 7, 2018
73db740
Fixed linting
Sep 7, 2018
5fb072e
Emackey's feedback
Sep 7, 2018
d97b899
Rename to processPbrMaterials.js
Sep 7, 2018
fcd4433
Added spec gloss tests
Sep 7, 2018
e59593a
Add one more test
Sep 7, 2018
67ef702
Update gltf-pipeline
ggetz Sep 13, 2018
22cc546
Update axis based on version before update
ggetz Sep 13, 2018
4ec829c
Fix model specs
ggetz Sep 13, 2018
3cc7c98
Add additional tests
ggetz Sep 13, 2018
5b94577
All glTF materials are PBR by default
Sep 13, 2018
05ef68d
Fix merge conflict
Sep 13, 2018
0e63533
Fix failing tests
Sep 13, 2018
3cad9ea
Merge branch 'master' into gltf-update-pipeline
ggetz Sep 13, 2018
b137ab4
Update CHANGES.md
ggetz Sep 13, 2018
2de8d69
Simplify check for PBR materials
Sep 17, 2018
4d5d53f
No need to account for glTF 1.0
Sep 17, 2018
e88ac9d
Merge pull request #7006 from OmarShehata/specgloss-ext
lilleyse Sep 17, 2018
88ebec6
Fix glTF 1.0 asset version and no mesh edge cases
ggetz Sep 18, 2018
4c168a9
Fix modelInstanceCollection spec
ggetz Sep 18, 2018
015e700
Update model specs
ggetz Sep 18, 2018
e5e495c
Clean up after test
Sep 19, 2018
f78b4f5
Added expectations to spec gloss tests
Sep 19, 2018
125c36f
Use defaultValue
Sep 19, 2018
fb69626
2 -> 2.0
Sep 19, 2018
c0eaf28
Merge pull request #7050 from OmarShehata/gltf-update-pipeline
ggetz Sep 19, 2018
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define([
'../../Core/WebGLConstants'
'./WebGLConstants'
], function(
WebGLConstants) {
'use strict';
Expand Down
54 changes: 27 additions & 27 deletions Source/Scene/ClassificationModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define([
'../ThirdParty/GltfPipeline/ForEach',
'../ThirdParty/GltfPipeline/getAccessorByteStride',
'../ThirdParty/GltfPipeline/numberOfComponentsForType',
'../ThirdParty/GltfPipeline/parseBinaryGltf',
'../ThirdParty/GltfPipeline/parseGlb',
'../ThirdParty/when',
'./Axis',
'./ClassificationType',
Expand Down Expand Up @@ -59,7 +59,7 @@ define([
ForEach,
getAccessorByteStride,
numberOfComponentsForType,
parseBinaryGltf,
parseGlb,
when,
Axis,
ClassificationType,
Expand Down Expand Up @@ -124,25 +124,25 @@ define([

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth doing a pass over the documentation to fix some of the existing problems like:

  • References the old KHR_binary_glTF extension
  • Some errors that are old
    • @exception {DeveloperError} bgltf is not a valid Binary glTF file.
    • @exception {DeveloperError} Only glTF Binary version 1 is supported.
  • @param {Object|ArrayBuffer|Uint8Array} options.gltf The object for the glTF JSON or an arraybuffer of Binary glTF defined by the KHR_binary_glTF extension. - only binary glTF is supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also for Model and Model.fromGltf.

if (gltf instanceof Uint8Array) {
// Binary glTF
gltf = parseBinaryGltf(gltf);
gltf = parseGlb(gltf);
} else {
throw new RuntimeError('Only binary glTF is supported as a classifier.');
}

var gltfNodes = gltf.nodes;
var gltfMeshes = gltf.meshes;

var gltfNode = gltfNodes[0];
var meshId = gltfNode.mesh;
if (gltfNodes.length !== 1 || !defined(meshId)) {
var gltfNode = gltfNodes.rootNode;
if (!defined(gltfNode) || !defined(gltfNode.meshes)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classification model is still based on glTF 1.0, and the indices seem to be wrong. Any ideas?

It looks like parseBinaryGltf used to also update the version but parseGlb does not. Make sure to call updateVersion and addDefaults after parseGlb.

After fixing that I suspect a lot of the other code changes below may not be needed.

throw new RuntimeError('Only one node is supported for classification and it must have a mesh.');
}

if (gltfMeshes.length !== 1) {
throw new RuntimeError('Only one mesh is supported when using b3dm for classification.');
var nodeMesh = gltfNode.meshes[0];
if (!defined(nodeMesh)) {
throw new RuntimeError('Only one node is supported for classification and it must have a mesh.');
}

var gltfPrimitives = gltfMeshes[0].primitives;
var gltfPrimitives = gltfMeshes[nodeMesh].primitives;
if (gltfPrimitives.length !== 1) {
throw new RuntimeError('Only one primitive per mesh is supported when using b3dm for classification.');
}
Expand Down Expand Up @@ -499,8 +499,8 @@ define([
var min = new Cartesian3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
var max = new Cartesian3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);

var n = gltfNodes[0];
var meshId = n.mesh;
var n = gltfNodes.rootNode;
var meshId = n.meshes[0];

var transformToRoot = ModelUtility.getTransform(n);
var mesh = gltfMeshes[meshId];
Expand Down Expand Up @@ -646,7 +646,9 @@ define([
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above in parseBuffers, and throughout - keep an eye out for ways to clean up the code using gltf-pipeline helper functions. For example, parseBuffers can use ForEach.buffer. Also it may not need the extras._pipeline lines.

buffer.extras = defaultValue(buffer.extras, {});
buffer.extras._pipeline = defaultValue(buffer.extras._pipeline, {});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly ForEach.meshPrimitiveAttribute in createVertexArray.


function modifyShaderForQuantizedAttributes(shader, model) {
var primitive = model.gltf.meshes[0].primitives[0];
var gltfMeshes = model.gltf.meshes;
var gltfRootNode = model.gltf.nodes.rootNode;
var primitive = gltfMeshes[gltfRootNode.meshes[0]].primitives[0];
var result = ModelUtility.modifyShaderForQuantizedAttributes(model.gltf, primitive, shader);
model._quantizedUniforms = result.uniforms;
return result.shader;
Expand Down Expand Up @@ -748,7 +750,8 @@ define([
var gltf = model.gltf;
var accessors = gltf.accessors;
var meshes = gltf.meshes;
var primitives = meshes[0].primitives;
var rootNode = gltf.nodes.rootNode;
var primitives = meshes[rootNode.meshes[0]].primitives;

var primitive = primitives[0];
var attributeLocations = getAttributeLocations();
Expand Down Expand Up @@ -804,23 +807,19 @@ define([
return;
}

var techniques = model.gltf.techniques;
var technique = techniques[0];
var parameters = technique.parameters;
var uniforms = technique.uniforms;

var uniformMap = {};
for (var name in uniforms) {
if (uniforms.hasOwnProperty(name) && name !== 'extras') {
var parameterName = uniforms[name];
ForEach.technique(model.gltf, function(technique) {
var parameters = technique.parameters;
ForEach.techniqueUniform(technique, function(parameterName, uniformName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like another area that is depending on the glTF being 1.0. Normally a 2.0 model with the techniques extension would not have parameters.

var parameter = parameters[parameterName];

if (!defined(parameter.semantic) || !defined(gltfSemanticUniforms[parameter.semantic])) {
continue;
return;
}
uniformMap[name] = gltfSemanticUniforms[parameter.semantic](context.uniformState, model);
}
}

uniformMap[uniformName] = gltfSemanticUniforms[parameter.semantic](context.uniformState, model);
});
});

model._uniformMap = uniformMap;
}
Expand Down Expand Up @@ -850,7 +849,8 @@ define([
var gltf = model.gltf;
var accessors = gltf.accessors;
var gltfMeshes = gltf.meshes;
var primitive = gltfMeshes[0].primitives[0];
var gltfRootNode = gltf.nodes.rootNode;
var primitive = gltfMeshes[gltfRootNode.meshes[0]].primitives[0];
var ix = accessors[primitive.indices];

var positionAccessor = primitive.attributes.POSITION;
Expand Down Expand Up @@ -999,7 +999,7 @@ define([

var gltf = model.gltf;
var nodes = gltf.nodes;
var gltfNode = nodes[0];
var gltfNode = nodes.rootNode;
model._nodeMatrix = ModelUtility.getTransform(gltfNode, model._nodeMatrix);

createPrimitive(model);
Expand Down
Loading