-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add packer option to retain texture sizes (avoid scaling) in atlas #18
Comments
Input UVs should be in texture space - scale the them by their corresponding texture dimensions and set To copy texture data to the atlas you will have to rasterize chart triangles using the new UVs as position (destination) and use barycentric coordinates to interpolate the old UVs (source). Rasterization must be conservative and you'll need to handle bilinear filtering. |
Thanks a lot. I knew I was doing something wrong but couldn't pinpoint it. I'll try and let you know. |
If I use example.exe without making any changes to it, I get this (UVs are scaled up for cube.obj): You gave me some tips.
I took the code from your example project and made a couple of changes that you advised me to do, and I'm still not getting the expected result (cube.obj model). The model I used was cube.obj. The UVs are within range from 0-1. There are only three textures.
Here's the code that I modified in example project of xatlas to avoid scaling of UV charts:code for normalizing UVs to texture space(click me)Loop through all .obj shapes (meshes) and within the loop, convert the UVs
code for Adding mesh using xatlas::AddUvMesh(click me)
And finally:
Full code: https://pastebin.com/c2iJpeB9 |
…xture data into a new atlas texture. #18
Thank you so much for your help. This looks amazing. I tried using uvatlastool, but it failed miserably in packing. I think xatlas is the only library which can create an atlas for a model without needing any human interaction whatsoever because adding seams in the proper location is the hardest part.
I see, I'll fix that.
Yes, that's a small price to pay but worth it. Once again, thanks for the help. |
@jpcy Do I need to modify the output UVs when writing them to .obj? I am normalizing the output UVs (diving x and y by atlas width and height). I added support for generating .mtl and .obj files to example_repack. This is what I'm getting:
Maybe that's why? |
Correct.
Perfect, thanks. :) |
@jpcy The current version of |
I'm working on a project which allows you to generate texture atlases for 3D models (.obj files) in order to reduce the number of images used by the model by copying the pixels from textures to atlas. xatlas is nice, but it will scale the UVs in order to fit multiple charts within one atlas.
How about adding an option to not resize the UVs at all and if the charts don't fit within the resolution of the atlas, then create multiple atlases for the remaining charts if they don't fit in one?
I've tested xatlas with two .obj models (textures included):
models.zip
Cube - A basic cube with 3 textures.
In this case, UVs are scaled up.
Dwarf - model from DirectX samples. I converted it to .obj.
For this model, UVs are scaled down.
If this gets resolved, xatlas will be perfect 💯
The text was updated successfully, but these errors were encountered: