TextureMerger icon indicating copy to clipboard operation
TextureMerger copied to clipboard

Merge textures from loaded models

Open antoinemacia opened this issue 2 years ago • 2 comments

Hello!

I would love to use this library to optimise our platform, though testing this on gltf models loaded in THREE, it seems the uv mapping is all over the place (Im using the code from the example, so via replacing uv rather than via the shader)

Screen Shot 2022-05-26 at 6 44 41 pm

Source file: out20211113-51-1jy7lkz-v1.glb.zip

I believe the UV coordinates range for the source object is not normalised (far lower than -1 and far greater than 1), and the UV range Im getting after running the lib is something like

{ startU: 0, endU: 1, startV:1, endV: 0} 

Does this seem right to you? Also, would you have a way to handle arbitrary UV coordinates range?

antoinemacia avatar May 26 '22 10:05 antoinemacia

After further inestigation, the uv on the origin model seem right, but somehow the UV get modified when assigning the texture generated by the canvas

I must say the texture produced by the canvas looks fine, and rather similar to the original texture, yet it seems the UV is incorrect, without even running any code on them..

Original texture

Canvas generated texture

Screen Shot 2022-05-27 at 3 32 10 pm Screen Shot 2022-05-27 at 3 31 30 pm

antoinemacia avatar May 27 '22 05:05 antoinemacia

Hi @antoinemacia It seems to be caused by the different sizes of the textures This merger works well when all textures have same size. so I think, a better approach would be to create all textures the same size and merge them. https://github.com/oguzeroglu/TextureMerger/blob/6566bbeed59e6b19c52f85ebed32f331ebcf52d1/TextureMerger.js#L72 You can set the width and height here. I can't make sure that is the best solution but I've merged all the textures in the model. Please let me know if you have the best solution for this!

intelliverse777 avatar Jun 12 '22 00:06 intelliverse777