-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
KHR_materials_common and KHR_binary_glTF compatibility #3294
KHR_materials_common and KHR_binary_glTF compatibility #3294
Conversation
I believe the models and Cesium code are right and that the extension spec is wrong (well, not up to date). This was discussed starting with this comment: KhronosGroup/glTF#424 (comment). Do you want to open a pull request to update the extension in the glTF repo? |
@tfili what do you think? |
I think it is useful to have the 4-byte alignment (we did require it in Cesium at one point, but the code could have changed). The extension spec says that the way to get 4-byte alignment is to add trailing spaces to the JSON:
Does this work for you? @tfili do you have any other comments? |
@tfili I think we should leave the extension spec alone and update the converter and Cesium (with backwards compatibility in Cesium). |
Although glTF uses "by semantic", not "by name", I agree that there is no place to put the semantic so I think it is fine to have well-known attribute ids just like KHR_binary_glTF has a well-known buffer id. I think that is what this part of the extension spec is trying to say:
Can you open a pull request into the glTF repo to make it more explicit? |
This could be a nice glTF extension and perhaps even the same extension used for collision volumes. @MattMcMullan is also interested in this. Submit an issue to the glTF repo for discussion when you are ready. |
Oh, how did I miss that? Yeah, this obviously matches with what I had in mind. So we would be able to fix this on the server side (i.e., in my converter). |
Let me track the sub-issues / TODOs that are part of this PR:
|
Cool, sounds good! |
I see - sorry I didn't follow that discussion so closely at that point... otherwise, I would have probably supported the argumentation of @tparisi that the definition of the types should be known in advance ;-) In fact, I got the impression that we actually have to explicitly allow only a very few different cases: Two alternative suggestions:
After all, both of these alternatives do the same thing, which is to allow only a pre-defined set of valid types and values. However, I would prefer the first way, it seems more flexible to me (you can blend textures with a factor), but still easier/cleaner to implement. @tfili What do you think? |
5.: PR to KHR_materials_common spec issued: |
I adapted this in Cesium as part of this PR: mlimper@948b1ed Okay like this? |
Done: KhronosGroup/glTF#507 |
.idea/encodings.xml | ||
.idea/inspectionProfiles/Project_Default.xml | ||
.idea/jsLinters/jshint.xml | ||
.idea/misc.xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to ignore any of these files (and they are also already committed in master, so ignoring them would product odd behavior). What is your reasoning for adding them here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hint!
My Webstorm seemed to have changed some of them automatically, and I didn't want to commit those changes (but then I don't need to add the changes to .gitignore, of course). I wanted to revert this inside the pull request, but didn't do it so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I'm not WebStorm expert so I wanted to make sure we didn't do something non-standard on our side. Most of us our running WebStorm 11, so if you're on an earlier version, that could be the source of it changing files locally. Out of curiosity, what did it change? Maybe we can prevent that from happening with a different config tweak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using an older WebStorm version - that's probably the problem.
Here's a diff:
diff --git a/.idea/cesium.iml b/.idea/cesium.iml
index 9d1caef..1f7737b 100644
--- a/.idea/cesium.iml
+++ b/.idea/cesium.iml
@@ -3,6 +3,7 @@
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Specs" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/Apps/SampleData/models/BloodhoundSSC" />
<excludeFolder url="file://$MODULE_DIR$/Build" />
<excludeFolder url="file://$MODULE_DIR$/Instrumented" />
</content>
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 97626ba..f758959 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="Encoding">
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index eff7139..76d98c8 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager">
- <profile version="1.0">
+ <profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
+ <option name="myLocal" value="true" />
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
diff --git a/.idea/jsLinters/jshint.xml b/.idea/jsLinters/jshint.xml
index aed467c..bf9607e 100644
--- a/.idea/jsLinters/jshint.xml
+++ b/.idea/jsLinters/jshint.xml
@@ -5,31 +5,25 @@
<option bitwise="true" />
<option boss="false" />
<option browser="true" />
- <option browserify="false" />
<option camelcase="false" />
<option couch="false" />
<option curly="true" />
<option debug="false" />
<option devel="false" />
<option dojo="false" />
- <option elision="false" />
- <option enforceall="false" />
<option eqeqeq="true" />
<option eqnull="false" />
<option es3="false" />
- <option es5="false" />
<option esnext="false" />
<option evil="false" />
<option expr="false" />
<option forin="true" />
<option freeze="false" />
<option funcscope="false" />
- <option futurehostile="false" />
<option gcl="false" />
<option globalstrict="false" />
<option immed="false" />
<option iterator="false" />
- <option jasmine="false" />
<option jquery="false" />
<option lastsemic="false" />
<option latedef="false" />
@@ -37,13 +31,11 @@
<option laxcomma="false" />
<option loopfunc="false" />
<option maxerr="50" />
- <option mocha="false" />
<option mootools="false" />
<option moz="false" />
<option multistr="false" />
<option newcap="false" />
<option noarg="true" />
- <option nocomma="false" />
<option node="false" />
<option noempty="true" />
<option nomen="false" />
@@ -58,24 +50,19 @@
<option plusplus="false" />
<option proto="false" />
<option prototypejs="false" />
- <option qunit="false" />
<option quotmark="false" />
<option rhino="false" />
<option scripturl="false" />
<option shadow="false" />
- <option shelljs="false" />
- <option singleGroups="false" />
<option smarttabs="false" />
<option strict="true" />
<option sub="false" />
<option supernew="false" />
<option trailing="false" />
- <option typed="false" />
<option undef="true" />
<option unused="false" />
<option validthis="false" />
<option white="false" />
- <option withstmt="false" />
<option worker="false" />
<option wsh="false" />
<option yui="false" />
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 72abef0..19f74da 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -10,4 +10,5 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
+ <component name="ProjectRootManager" version="2" />
</project>
\ No newline at end of file
Sub-issue 7: Implementing this would probably look somehow like this: mlimper@c566172 I think assuming a range [0, 128] or [0, 256] is pretty common, so one could clarify this in the spec and say: if the value is smaller than 1, map it to [0, 128] or so, otherwise use the value as-is. The current phrasing seems a bit complicated (at least I don't know the blinn-torrance-sparrow model). An alternative could be to remove this part from the spec again and say that the value will be interpreted as-is, and hence exporters should now that 1 corresponds to a low shininess, and not to a high one. |
No. The line we want to change is: if (id === 'CESIUM_binary_glTF' || id === 'KHR_binary_glTF') { It should be (include the comment): // The 'KHR_binary_glTF' check is for backwards compatibility with Cesium 1.15.
if (id === 'CESIUM_binary_glTF' || id === 'binary_glTF' || id === 'KHR_binary_glTF') { |
I don't know this spec/code well, but your solution sounds like it would work well and would simplify the logic in the client. If @tfili agrees, perhaps open a pull request in the glTF repo. |
I agree. I think mapping values 0-1 to [0,128] is a good solution. |
@mlimper As far as the type situation, I think I'd prefer having an explicit type but I wouldn't be against the diffuse/diffuseTexture solution. |
Gotcha, changed that (503f087) |
@mlimper for this PR, also add yourself to CONTRIBUTORS.md. |
Issued a PR to get this clarified within the spec: |
@tfili If we wouldn't have an explicit type, do you think it would be possible to check if the parameter is a string, using the |
…om/mlimper/cesium into KHR_common_materials-compatibility
Okay, I cleaned up the code a bit. It can now deal with the old/current glb files, where the parameters are objects with type/value, as well as with new ones that directly list parameter values, as suggested by the spec. Now, there are also checks to determine whether the This PR should now be ready for code review / merge. |
|
||
// for compatibility with old glb files, encoding materials using | ||
// KHR_materials_common with explicit "type" / "value" members | ||
if (value.value != undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably use the defined
function that is used throughout Cesium.
@Qantas94Heavy @tfili Thanks for your helpful suggestions, I adapted the code. |
Looks good to me. |
Did you see my questions:
|
Missed that one. One thing I noticed is that this change uses double quotes and the rest of Cesium uses single quotes. As for the questions: For Converter For Doc For Test |
(currently not intended for direct merge, just for discussion)
Hi Cesium folks! :-)
After writing a binary glTF exporter, also using the KHR_materials_common extension, this PR summarizes my changes to Cesium, in order to get it working with the glb files I was exporting.
It also lists some open points regarding the spec.
Here's what I noticed (items numbered to ease discussion):
Well, I guess that's a lot of input for discussion, and some of the points are clearly more related to glTF than to Cesium... still, I believed it could be useful to collect everything that came up during this test in one place.
Thanks a lot in advance for your input :-)