facebookincubator / FBX2glTF

A command-line tool for the conversion of 3D model assets on the FBX file format to the glTF file format.
Other
2.1k stars 332 forks source link

Occlusion/Roughness/Metalness texture packing rethink #258

Open csubagio opened 4 years ago

csubagio commented 4 years ago

Hey all! First off, thanks for writing this super handy converter. Great stuff!

This PR is a little rethink about how to pack the ORM textures in the Stingray material pipeline. Right now, the code assumes that each texture will be a grayscale single channel input, and attempts to build a packed RGB ORM texture out of each texture's red channel. This unfortunately precludes using an ORM already built elsewhere, if you assign the same ORM texture to all 3 slots, you get the AO red channel from all 3 sources copied into the R, G, and B of the remixed texture!

My suggested pivot in this PR:

  1. continue to support separate ORM inputs, but take R for occlusion, G for roughness, B for metal, when copying. This lets you mix with existing ORMs, or clear a channel you aren't using, and remains backwards compatible with today's assumption of 3 independent grey textures.
  2. add explicit support for the same map being used in all 3 raw slots, signaling that the input is already ORM. In this case, it just passes through the map as is.

Outside of that, I have two questions/comments:

  1. Why does the texture packer premultiply the uniform roughness and metalness values into the texture? Given that the uniforms are passed forward too, this may surprise some downstream users. This should probably at least be documented.

  2. It's relatively rare in my experience, but it's not super unlikely that some artists may want to use separate maps for ORM. Specifically, it's possible you may need a higher resolution occlusion map, and can happily accept much lower resolution metallness & roughness maps. Given that both FBX and gltf can handle this definition, it may be nice to support it in the future.

Thanks! Chris.

facebook-github-bot commented 4 years ago

Hi @csubagio!

Thank you for your pull request and welcome to our community.We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

facebook-github-bot commented 4 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!