Skip to content
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

Occlusion/Roughness/Metalness texture packing rethink #258

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

csubagio
Copy link

@csubagio csubagio commented Jun 3, 2020

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.

csubagio added 2 commits June 2, 2020 12:26
Before this change, the texture assignments for Occlusion, Roughness, and Metalness in the Stingray PBR material path were assumed to be single channel images where the R should be used to build a merged ORM texture. This precluded the use of prebuilt ORM textures.

This commit proposes a few changes:
* if the same texture is detected in all 3 channels, assume it already is ORM and just pass through.
* when combining textures, read R/G/B for O/R/M rather than R/R/R. This allows merging of prebuild ORM textures.
after building the project as directed, (plus isolating Conan using pipenv), was left with these extraneous files that shouldn't be committed
@facebook-github-bot
Copy link

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 [email protected]. Thanks!

@csubagio csubagio changed the title Orm texture packing rethink Occlusion/Roughness/Metalness texture packing rethink Jun 3, 2020
@facebook-github-bot
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants