texture atlas

Started by
4 comments, last by braincell 12 years, 11 months ago
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.
Advertisement
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.

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.


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.

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.


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.

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.

[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.


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.

This topic is closed to new replies.

Advertisement