Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds an option to specify the names of base color texture and factor uniforms when updating glTF with KHR_techniques_webgl extension to PBR.
By default,
gltf-pipeline
will try to convert materials that use theKHR_techniques_webgl
extension into PBR materials. This is not possible generically, but it is possible to make some "educated guesses". Specifically, it is possible to guess which texture is supposed to be the PBRbaseColorTexture
by looking at the name of the uniform in the techniques definition: When the uniform is calledu_diffuse
(and refers to a texture), then it is very likely that this texture is supposed to become thebaseColorTexture
.The set of names that suggest that a texture may become a base color texture is ... somewhat arbitrary. One can never know which names one might encounter in the wild.
This PR adds an option to specify the base color texture names at the command line and pass them to the update function in the
options
object. For example, when a GLB contains techniques where the uniform names areu_my_diffuse_tex
andu_another_diffuse_tex
, then the linewill cause these names to be treated as indicators for the textures to become
baseColorTexture
.(All this applies to the base color factors as well, with
baseColorFactors
as the command line option)Things to consider:
The README marks these arguments as 'optional', but explicitly says that the set of "default names" for this is not specified. I'd hesitate to explicitly list things like
"u_tex", "u_diffuse", "u_emission", "u_diffuse_tex"
there...The current approach is somewhat "fail silent" in nature. When someone has a GLB where such a name is
u_diff_tex
, then this texture will just be removed, and it may not be obvious for the user why this happened. Loading the model in a viewer might give the impression that the viewer can not display the texture for some reason (with that 'reason' being the too obvious one: It's not there...).I considered to bring a few more high-level guesses into that conversion, and/or add some sort of warning or hint when something looks odd. For example:
I think that could help to avoid some confusion for users, some support requests, and save some debugging time...