Apply scene's lightmap UV transformation during export
Hello, I noticed that when exporting the glb model, it is possible to export the lighting map UV, but the UV is automatically normalized to the 0-1 range. In my model, the UV is not fully occupied, resulting in the UV being stretched. How to keep the exported UV at the mapping size in unity instead of being normalized
Hi,
I don't quite understand, can you elaborate? Visuals like a screenshot of the before/after would be helpful. Feel free to provide a test asset, so I can reproduce the faulty export.
Upon export, glTFast only flips texture coords in the y-direction in order to convert between Unity's space to glTF's. No normalization happens.
I assume you're aware that exporting the lightmaps themselves is not supported (just the UVs are exported).
Thanks
Thanks. That aligns with your textural description, but still does not help me narrow down where the unwanted conversion happens (because I suspect it's not within glTFast).
Both seem to be Blender screenshots, right? Now, how (i.e. in wich format and with which export/import settings) does that cube get from Blender into Unity and back into Blender?
- Blender export format and settings
- Unity importer settings
- glTFast export settings (if non defaults are used in script)
- Blender glTF import settings
Providing the assets would also help.
Thanks
Sorry, my English may not be very good. I converted the lighting texture to PNG format myself. The problem is that exporting GLB can have 2 UV sets, but the mapping relationship between the exported model's UV (UV2) from 0-0.7632 to 0-1 and the UV 0-0.7 in the image is incorrect
Thanks. That aligns with your textural description, but still does not help me narrow down where the unwanted conversion happens (because I suspect it's not within glTFast).
Both seem to be Blender screenshots, right? Now, how (i.e. in wich format and with which export/import settings) does that cube get from Blender into Unity and back into Blender?
- Blender export format and settings
- Unity importer settings
- glTFast export settings (if non defaults are used in script)
- Blender glTF import settings
Providing the assets would also help.
Thanks
Cube and plane are both created in Unity, and Blender is the one I use to view UV distribution. Gltfast seems to export UV2 by multiplying each UV value by 1/0.7632468
OK, I think I get it now.
glTFast exports UVs as-is, but in Unity the second UV set is transformed by the Lightmap tiling/offset (from the MeshRenderer component) in addition. This one is missing in the export.
What you wish would happen is that glTFast transforms those UVs equally, so that you can use the baked lightmap efforlessly and multiple objects can share the same lightmap.
Does any other Unity exporter you're aware of support this? UnityGLTF seems not to.
I think that would deserve a setting to enable/disable it.
The FBX exporter behaves the same.
Can you elaborate more on the actual use-case you/re after? Is it that you want to prepare a scene in Unity, bake its lighting and then export it to glTF to view it somewhere else?
I'll categorize this as a feature request with low priority. Contributions welcome!
FBX导出器的行为也是一样的。
你能详细说说你/想要的实际使用场景吗?你是想在Unity里准备一个场景,烘焙光照,然后导出到glTF以便在别处查看吗?
我会把它归类为一个低优先级的功能请求。欢迎投稿!
I am a WebGL developer. After baking lightmaps in Unity, I use them on the web. I saw on the BABYLON forum that there is a unityExporter plugin that can export UVs correctly, but the models it exports are too large. This plugin seems to use GLTFUtility, or it might have been implemented by the developer themselves.Can I easily achieve this by modifying the source code?
My requirement is to use Unity for fast baking. If I use other software, I would need to manually split the lightmap UVs myself. Unity’s baking automatically sets up the lightmap UVs, allowing a scene with good lighting effects to be rendered on the web in a short amount of time.It not be very common. I’ll try to see if I can modify Unity's own UV. Thank you very much for your help.