-
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
Support for emissive-only materials #6501
Conversation
@lilleyse, thanks for the pull request! Maintainers, we have a signed CLA from @lilleyse, so you can review this at any time.
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
I can confirm that this fixes it using the AGI HQ with an emissive-only texture. |
Updated. Confirmed that the models linked in #5838 are now rendering correctly using an unlit shader. |
@lilleyse Just FYI, my suggestion was poorly received by the rest of the glTF WG. They would strongly prefer that engines do calculate the normal vectors, which shouldn't look bad once the rest of the 2.0 lighting issues are fixed. That said though, certainly the glTF spec does not call for "pitch black", so, unlit isn't any more out of compliance than we are currently. I think unlit would be a good stepping stone to have in place so long as normals are still on the roadmap somewhere. It looks like glTF pipeline 1.0 does have automatic calculation of normals in a helper class, and that class was never upgraded to 2.0. |
Yeah I guess generating normals is the right thing to do. It would make sense then to implement KHR_materials_unlit as soon as possible to support photogrammetry. But I agree, that doesn't necessarily need to hold up this PR. We could keep #5838 open after this is merged. |
Diff ignoring white space: https://github.com/AnalyticalGraphicsInc/cesium/pull/6501/files?w=1 |
defined(material.occlusionTexture) || | ||
defined(material.emissiveTexture) || | ||
defined(material.emissiveFactor) || | ||
defined(material.alphaMpde) || |
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.
Typo
Updated. |
@@ -493,6 +513,9 @@ define([ | |||
} else { | |||
if (defined(parameterValues.baseColorFactor)) { | |||
fragmentShader += ' vec4 baseColorWithAlpha = u_baseColorFactor;\n'; | |||
} else if (!hasNormals && (defined(parameterValues.emissiveFactor) || defined(parameterValues.emissiveTexture))) { | |||
// Don't use the default base color of (1,1,1) if the material is emissive only. This handling will be better once we support KHR_materials_unlit. | |||
fragmentShader += ' vec4 baseColorWithAlpha = vec4(vec3(0.0), 1.0);\n'; |
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 breaks glTF spec, and I don't think we have any need to do it in code here. The models can and should simply specify baseColorFactor: [0, 0, 0, 1]
so that all engines know to turn this off.
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.
Yeah that is the better thing to do. Fixed.
], | ||
"materials": [ | ||
{ | ||
"emissiveTexture": { |
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.
Likewise here, we should add baseColorFactor: [0, 0, 0, 1]
.
CHANGES.md
Outdated
@@ -41,6 +41,8 @@ Change Log | |||
* Fixed crash bug in PolylineCollection when a polyline was updated and removed at the same time. [#6455](https://github.com/AnalyticalGraphicsInc/cesium/pull/6455) | |||
* Fixed Imagery Layers Texture Filters Sandcastle example. [#6472](https://github.com/AnalyticalGraphicsInc/cesium/pull/6472). | |||
* Fixed a bug causing Cesium 3D Tilesets to not clip properly when tiles were unloaded and reloaded. [#6484](https://github.com/AnalyticalGraphicsInc/cesium/issues/6484) | |||
* Fixed rendering of glTF models that don't contain normals. [#6501](https://github.com/AnalyticalGraphicsInc/cesium/pull/6501) |
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.
"Fixed" isn't what happened here, we are just applying a temporary workaround for these models.
Travis apparently failed here. Doesn't look like the fault of this branch, but it's hard for me to tell. |
The PR-side passed, so it was definitely just a travis/build hiccup. |
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.
Other than the Travis fail, I think this is good to go. Make sure the gltf-pipeline one is updated too.
OK, thanks @mramato. Merging. |
This PR fixes two related problems:
processPbrMetallicRoughness
only runs ifmaterial.pbrMetallicRoughness
is defined. Effectively the emissive texture gets ignored.The code follows @emackey's suggestion in #5838 (comment):
TODO :