Babylon Editor - export texture scaling

Hey @Drigax, it the playground working and enough for you? :slight_smile:

Hey @julien-moreau, thanks for the playground! I took a look, but I’m not quite seeing what you’re seeing…

My first test is to use one of my testing rigs that exports the scene, disposes the old scene, and imports fom glTF into the new scene:

Here is the starting scene with some modifications to see the texture orientation clearer using a UV checkerboard:
https://playground.babylonjs.com/#DHZKGW#2

when we enable the scene export then import with identical camera settings we get:
https://playground.babylonjs.com/#DHZKGW#3

Ignoring the change in lighting intensity, it looks like we’re properly applying the texture transform to the output texture here…

we can even inspect the output glb:

to see that we are actually preserving the original orientation of the texture, and just exporting with KHR_texture_transform to handle the vscaling

1 Like

Hey @Drigax, I think it has been fixed while you were looking for the bug because I don’t reproduce the bug anymore using my own playground :slight_smile:

I’m testing with the scene of @sguerrero right now to confirm, but I’m pretty sure it is.

Confirmed!

3 Likes

This is awesome news! Thank you @julien-moreau and @Drigax for all your time spent looking into the issue.

2 Likes

Hi, I think the bug still exists with PBRMaterials (Specular/Glossiness). If I export a .glb using GLTF2Export.GLBAsync, the KHR_texture_transform is missing for Specular Glossiness PBRMaterials. Metallic Roughness PBRMaterials are working fine on the other hand. I am on 4.2.0-beta.

1 Like

@Drigax might be able to shade some lights on this one

1 Like

*rimshot*

@thegabman Do you have a repro in a PG we can debug?

Hi,
sorry for being that late with my reply.
I just modified @Drigax playground to reproduce my problem.

https://playground.babylonjs.com/#DHZKGW#7

If ā€œuseMetallicWorkflowā€ is true, than everything is working fine. Otherwise the scaling is not applied.

1 Like

Ah, that appears to happen because when converting the textures from specGloss to metalRough, we’re dropping the extension and transform information when creating the new baseColor texture…

The fix is not too straightforward, as we’ll have to bake texture transform information before combining baseColor + glossiness textures, so any texture transform will be applied to the output texture (I don’t think its too straightforward to preserve texture transform data of two combined textures…)

I’ll create an issue to track this, but I’m not too sure this will be done before 4.2 release. Texture transform is lost when exporting SpecGloss textures Ā· Issue #8968 Ā· BabylonJS/Babylon.js Ā· GitHub

Okay, sound plausible. I got around this issue by implementing a custom postprocess to convert my diffuse/spec/gloss textures to baseColor/metal/rough textures following the math of the GLTFMaterialExporter. I apply this postprocess right before exporting my scene to a gltf/glb. For now that does the job.

For the future it would be great to keep the spec/gloss textures in the export using the KHR_materials_pbrSpecularGlossiness instead of converting them to metal/rough.

1 Like

Maybe a year ago KHR_materials_specularGlossiness might have been the best solution, but at this point is probably most pragmatic to support KHR_materials_specular, since it’s finally proposed for ratification. I’m re-titling this issue to represent this work, As I’d rather not move forward with the texture transform baking approach either, it feels like a half measure as well :slight_smile: