Hello!
Is there a way for textures on export to keep their transform values, specifically changing scaling V to -1?
Thanks
Hello!
Is there a way for textures on export to keep their transform values, specifically changing scaling V to -1?
Thanks
Pinging @julien-moreau
Hey @sguerrero,
It should. If not, I suggest to use the Editor v4. Are you using the Editor v4 ? It is availble here in beta.3: BabylonJS Editor v4.0.0 beta Ā· BabylonJS/Editor Wiki Ā· GitHub and will be released in few weeks.
Documentation is available here (still WIP): Editor/doc.md at release/4.0.0 Ā· BabylonJS/Editor Ā· GitHub
The Editor v3 projects are not compatible with v4. If you are not in an advanced project using the v3, I highly suggest that you use the v4 as it provides more stability and is more wysiwyg than the v3.
@julien-moreau Thank you for the speedy response!
I am using v4 of the Editor, but it was beta.2. I just downloaded beta.3 to see if that helped, but I still got the same issue on export. I uploaded two images to show how my scene looks in the Editor prior to export, and what is being exported. In the Editor I do scale V on the textures to -1, but it is either not saving that or flipping them back on export.
Ouch! Iām fixing ASAP!!!
Thanks for that feedback, Iām testing right now
With my first tries, I donāt reproduce
When I dragānādropped a mesh with its textures in the assets, I got the textures added to the ātextures assetsā directly. When I dropped the mesh from the assets in my preview I got textures created twice.
What you can try: clear the unused textures using the button āClear Unusedā in the textures assets panel:
Then, select the texture you want to modify.
If it shows UV equal to -1 that means I have a big bug. If they look untouched that means you havenāt modified to right texture.
In any cases, I should not create textures twice, the Editor should reuse them. Iām fixing that ASAP as well
I havenāt encountered an issue with duplicate textures. What I think is happening is exporting out of the Editor is not saving the texture scaling changes.
When I open an exported glb in either Editor or sandbox the textures V scaling resets back to 1, instead of the -1 I set it to.
Ah !! You are using GLTF
Iām trying with a GLB right now
@sguerrero I still donāt reproduce
Is that possible that you share your scene with me ? Via PM or a public link? That would help me a lot to reproduce and fix that bug. Thanks
As seen with @sguerrero, the problem appears when the GLTF/GLB serializer is used.
Context: All textures in the Editor have UV scales equal to (1, -1).
Using Babylon.JS Scene Serializer: When the scene is exported using the .babylon serializer, that works well: the UV scales are preserved in the .babylon file and the scene looks well after the serialization in the sandbox.
Using the GLTF/GLB Scene Serializer: When the scene is exported using the GLTF/GLB serializer, all UV scales are reset to (1, 1). @bghgary is that an issue you know ? The only thing that the Editor does is using the .GLBAsync or .GLTFAsync functions: Editor/tools.ts at release/4.0.0 Ā· BabylonJS/Editor Ā· GitHub
@julien-moreau depending on the current texture transform, we bake the texture transform into the output texture. we mainly do this because of restrictions of the texture transforms that can be expressed in glTF
Thanks for that informations @Drigax!
That means if the texture matrix is modified then it is applied on the output texture when exporting to gltf or glb?
It depends. Check our logic when deciding whether to preserve the texture and preserve the texture transform, or bake the texture and reset its matrix:
Where if the rotation center is not centered, we have any uAng or vAng texture rotations, we canāt express this so we have to bake the texture information and export the baked map.
The expection is that one should consider the exported texture as separate from the imported texture that was used in the scene. Meaning, one isnāt guaranteed to be able to roundtrip an exported texture into the same scene using the same texture transformations, as it may have been baked
I appreciate all the assistance so far on the issue. What I am using the Editor for at the moment is to assemble a scene to then export into a repository.
If we connect all the textures to the materials in Maya or Blender before we export, the textures then export from the Editor correctly. If we update textures in the Editor however, they export inverted. It would be nice to be able to edit textures in the Editor without having to re-export a new glb from either Maya or Blender.
Thanks!
Hi @Drigax thanks a lot for all these informations
I understood the limitations and thatās not good news for us! Ahah
Do you think there can be a workaround for @sguerrero? I mean what can we do instead of using UV Scales to invert the texture on V ?
Thanks for your answer
Iām back
We shouldnāt be baking the texture unless itās necessary as @Drigax pointed out. It should only be necessary when the texture is rotated. Is the texture rotated in this case?
@bghgary hello !
Looks like it is not rotated.
The problem is if you modify the UV scaling of a texture in your scene, for example (uScale, vScale)=(1,-1) and then serialize your scene using the GLTF serializer, the final gltf file doesnāt take car of these values. That means when you load your previously serialized GLTF, then all textures have their UV scaling equal to (1, 1) and they donāt appear flipped on V visually.
The question of @sguerrero is Ā« are these UV scaling values set on textures supported by the gltf format ? Ā»
If not, what can be the workaround for @sguerrero, as he just want to flip the scale on V for some textures.
glTF has an extension that supports texture transforms: glTF/extensions/2.0/Khronos/KHR_texture_transform at master Ā· KhronosGroup/glTF Ā· GitHub
The serializer is aware of this extension and should be exporting it when the values are not the default. Would it be possible to debug the serializer and make sure itās working properly?
Not sure, Iād have to take a look at a scene that reproduces this issue. Can you or @sgurrero create a Playground that loads some asset that reproduces this issue when exported? At this point I need to debug this.
Hi @Drigax,
You can find the repro here: Babylon.js Playground
The V scale is set to -1 so the palm tree texture appears on the top of the sphere.
Once you downloaded the file and dragānādropped in the sandbox, the palm tree appears on the bottom of the sphere. That means the scale is set to 1 on V.
From camera on top of sphere in playground:
From camera on top of sphere in sandbox: