Sign in to follow this  
giugio

texture atlas

Recommended Posts

hello.
I'm trying to create a texture atlas for group meshes and create some massive batch.
for do this I must convert generic images to power of two images(because atlas program needs poweroftwo images).
i have creates the a function that return the smallest poweroftwo int from the width or height of the generic image.
Now i have a doubt:
these image are extracted from a sketchup model and have some texture coord,for mantain the correct texture mapping ,i must resize the image or i can add some empty space at the power of two image for preserve the correct texture coord?
the texture atlas generator return an offset width and an offset height for each texture in the atlas;
these offsets are from 0(begin of images )and 1 (end of image ), is sufficent to add the offset to the texcoord for mantain the texture mapping?
and if i have some values in the texcoord that are from 0 to 47.1323?
is possible to translate all to range 0-1 ?
how ?


thanks.

Share this post


Link to post
Share on other sites
Your models have a UV range 0-1 for each vertice. These are the texture coordinates on the mesh. You would need to change the UV on your model in order to match the new coordinates on the atlas (ie 0-0.25).

However, if your model has UV tiled (ie UV is 0-47) then you cannot use a texture atlas. Texture atlases do not work out of the box with models that have tiled textures. You can only do it by using a shader which multiplies the UV within a certain range, but I'm not really sure if this is what you are asking.

Share this post


Link to post
Share on other sites
[quote name='braincell' timestamp='1306002056' post='4813923']
Your models have a UV range 0-1 for each vertice. These are the texture coordinates on the mesh. You would need to change the UV on your model in order to match the new coordinates on the atlas (ie 0-0.25).

However, if your model has UV tiled (ie UV is 0-47) then you cannot use a texture atlas. Texture atlases do not work out of the box with models that have tiled textures. You can only do it by using a shader which multiplies the UV within a certain range, but I'm not really sure if this is what you are asking.
[/quote]

thanks,
I have also the width and the height of the texture in the texture atlas, can i do a division for translate the range from0- 47 to a 0-?.
thnaks.

Share this post


Link to post
Share on other sites
[quote name='giugio' timestamp='1306006721' post='4813939']
I have also the width and the height of the texture in the texture atlas, can i do a division for translate the range from0- 47 to a 0-?.
thnaks.
[/quote]

Just divide the xy-point from the texture atlas with the texture atlas width and height. That gives you the uv coordinates in 0-1.

Share this post


Link to post
Share on other sites
[quote]
i must resize the image or i can add some empty space at the power of two image for preserve the correct texture coord?
[/quote]

i think that must resize the image at all, but I ask for security.
by.

Share this post


Link to post
Share on other sites
[quote name='giugio' timestamp='1306006721' post='4813939']
[quote name='braincell' timestamp='1306002056' post='4813923']
Your models have a UV range 0-1 for each vertice. These are the texture coordinates on the mesh. You would need to change the UV on your model in order to match the new coordinates on the atlas (ie 0-0.25).

However, if your model has UV tiled (ie UV is 0-47) then you cannot use a texture atlas. Texture atlases do not work out of the box with models that have tiled textures. You can only do it by using a shader which multiplies the UV within a certain range, but I'm not really sure if this is what you are asking.
[/quote]

thanks,
I have also the width and the height of the texture in the texture atlas, can i do a division for translate the range from0- 47 to a 0-?.
thnaks.
[/quote]


If you mean, convert the UV on the model from 0-47 to 0-? then yes of course, but the texture will no longer be tiled on the model.

In order to have a tiled texture on a model which is from an atlas you must use a shader that divides the UV for a given pixel, like I said. I hope you understand.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this