Open BigRoy opened 5 years ago
I'm not sure if I fully understand your request. So you would like an option to merge occlusion, metallic and roughness into a single texture?
That would be easy to do, since I already have code to merge to metallic and roughness (as required by GLTF)
I am not sure why the viewer you mention is not displaying textures correctly. Is the GLTF file exported by maya2gltf invalid? If not, the viewer should show it?
Regarding the blend mode, currently you have to specify in the PBR Maya glsl material that the material is transparent. I could scan all the pixels of the diffuse texture for transparency, but currently it is up to the user to indicate if a material needs to be considered transparent or not.
Can you give some example code for scan all the pixels of the diffuse texture for transparency?
Sure, it should be easy to add.
I already do some image processing when combining the metal and roughness textures:
https://github.com/WonderMediaProductions/Maya2glTF/blob/master/src/ExportableMaterial.cpp#L257
It would be just a matter of testing for semi-transparent pixels (alpha != 255
), in a loop like this one:
https://github.com/WonderMediaProductions/Maya2glTF/blob/master/src/ExportableMaterial.cpp#L288
I'm not sure if I fully understand your request.
I think the core of what I'm trying to ask is how to influence how the exporter works with regards to the textures. Like, what customization options are possible to potentially just load the completely prepped glTF
textures from substance and having those applied to the model in Maya so we can export with animations, etc.
Using those textures it would mean the maya exporter would basically not need to "merge" textures whatsoever. It just needs to be aware of which textures need to apply to which material slot in glTF
.
Maybe what I need is already feasible with Maya2glTF
I just wasn't aware of a way on how one could have thorough control of how the materials are exported into the .gltf
format.
So you would like an option to merge occlusion, metallic and roughness into a single texture?
To match the substance output that would be what is needed yes. However, with Substance exporting it is possible to have that completely prepared for glTF
so it is already merged in a single image.
I am not sure why the viewer you mention is not displaying textures correctly. Is the GLTF file exported by maya2gltf invalid? If not, the viewer should show it?
I'll see if I can get our artists to create a reproducable example of what goes wrong and where it differs from the expected output (where the expected output is what we're seeing from Substance correctly). Will see if the artist can prepare that today.
Regarding the blend mode, currently you have to specify in the PBR Maya glsl material that the material is transparent. I could scan all the pixels of the diffuse texture for transparency, but currently it is up to the user to indicate if a material needs to be considered transparent or not.
Thanks, for now that's already helpful and I missed that was a possibility. Will look into it.
Oh but then no actions are required, at Wondermedia we already using the textures generated by Substance Painter as-is. So it should work out-of-the-box.
I even think the default helper in Maya2glTF to assign a material will recognize the Substance painter extensions, and place the textures in the correct Maya shader slots.
Oh but then no actions are required, at Wondermedia we already using the textures generated by Substance Painter as-is. So it should work out-of-the-box.
Could you share which export settings you're using in Substance to generate the textures to load up in Maya?
In our case we compared with the "glTF" export from Substance. Anyway, as stated I'll have our artists do some more checking as to what is going on exactly.
Ah indeed, we are not exporting with Substance's GLTF export feature, we use a custom exporter preset in Substance Painter.
I can't attach this preset here (it's binary, and might not be allowed), but here's a screenshot:
Actually. It seems the Maya2glTF
export works flawlessly too with the textures. It's not a texture material problem, however it seems to be an issue with UVs flipping/stretching when exporting from Maya.
We actually get output that loads correctly however there's an issue with the texture being stretched near the UV border where Substance export does not do it. Or we've another one where it appears the full texture is "flipped" on the surface (upside-down) whereas Substance exports it fine. Funnily enough, the actual textures on disk are exactly the same. It must be something going wrong with the geometry/UVs being generated from Maya.
Unfortunately I can't share the production assets publicly, but here's a preview of the "upside/down" effect:
Both are the exported gltf files viewed in the glTF viewer. I think this screenshots might have been from this viewer though.
Ah indeed, we are not exporting with Substance's GLTF export feature, we use a custom exporter preset in Substance Painter.
Thanks for that screenshot, that definitely helps. :)
Mmm, then I guess it's more of a problem how you imported the models into Maya?
It's best to inspect the UVs in Maya with the UV editor, and also look for warnings in the output log of Maya2glTF, some tangents might be wrong or zero (although in your case, it really seems that UVs are wrong in Maya).
Does the model render correctly in the Maya viewport itself, with the Maya2glTF PBR shader?
Ha! It appears that the test case the artists were providing me actually weren't accurate test cases as they had different model versions loaded into Maya than the one that was loaded into Substance. As such, the differences actually were human error in this scenario. I'll close this issue as it seems we are able to work with this as expected now.
However thanks for the screenshot as that helped us define a good basis for exporting from Substance to textures that worked flawlessly. And of course, thanks for the pointers on the transparency on the shader.
Nice! Opening this again so others can see the screenshot, until I put this in the readme
Issue
It seems that when exporting with the plug-ins the output is limited to a specific format where the default glTF 2.0 viewer doesn't display all textures as expected. Whereas if you compare the output of Substance Painter to glTF that one shows perfectly in that viewer.
It seems that when using the
glTF
export settings in Substance it combines specific maps in a specific way. E.g.1001_occlusionRoughnessMetallic.png
.What would be required to support this different layout of textures to align with the default export setup of Substance?
For completeness sake, here's an example of the output materials in a substance export to glTF:
This specific export also had transparency, that's why the "alphaMode" is set to "BLEND". If fully opaque that value would be: "OPAQUE".
Note how the Substance export actually points to the same index for
metallicRoughnessTexture
andocclusionTexture
.As a comparison this is another export (different object) exported with
Maya2glTF
:Note: this issue is not saying
Maya2glTF
exports things completely wrong, however it's more a question about how to customize the output from the exporter to fit the exact needs of production.