KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.49k stars 317 forks source link

Generate orm texture if separate textures are present #1058

Closed makidoll closed 4 years ago

makidoll commented 4 years ago

When creating models in Blender, most people use separate occlusion, roughness and metallic textures. This makes it easy to edit each one separately especially when using tools like substance painter or even procedurally generating textures to be baked.

However, when you export to gltf, those 3 textures are ignored and it's a pain to manually convert everything to orm just for gltf. I even made a tool to make this easier: https://makitsune.github.io/orm Once I've converted all my textures to orm, then I suddenly cant export to any other formats anymore because gltf is the only one that utilizes this format for now.

My proposal is simply, make an orm texture at export! Perhaps find the maximum texture size between each 3 and generate a new texture just for exporting.

I've been dying for this, together with my friends since the release candidate of 2.8 in ~July 2019. It's also been complicated working with freelancers who don't create their own orm textures.

donmccurdy commented 4 years ago

From the docs:

If images are connected to the Blender node in a manner that does not follow this convention, the add-on may attempt to adapt the image to the correct form during exporting (with an increased export time).

We've spent significant time on this and the addon does attempt to combine images, but it's only able to do so much. In particular, I think that your images will need to be the same size. It should also be possible to use a separate occlusion texture, and to keep it separate, but roughness/metallic must be packed in the final glTF file.

Could you confirm if any part of that behavior is not working as expected for you?

Note that exports merging ORM textures will be significantly slower.

scurest commented 4 years ago

So can this be closed?

makidoll commented 4 years ago

Oh I never knew a pr was merged for this. I'll take a look today and reply back asap. This is a really awesome addition, thank you so much. It'll make things much less complicated for so many people and artists

makidoll commented 4 years ago

I was able to test this and I came across a different problem...

When I don't apply a metallic texture, the metallic value doesn't get converted to a gray scale image.

Here's an example principled shader setup with base color, roughness and normal:

This exports the textures like this:

image

When decomposing the ORM texture in GIMP, the metallic is 100% white:

image

I tried changing the metallic value to different values, but I always get 100% white.

donmccurdy commented 4 years ago

@makitsune if the value is constant (e.g. 0.5), you will get a white metallic texture and the metallicFactor value will be 0.5. The two get multiplied together when rendering, so that's 0.5 x 1 = 0.5.

makidoll commented 4 years ago

I tested the original issue combining a 2048x2048 jpg roughness with 16x16 png metallic and it worked perfectly! Thank you so much for fixing this. :heart:

@donmccurdy Ah I see, thank you. I missed that.

Awesome! I'll close the issue. Thanks again!