- Home /
The correct way of making Texture Atlas
Hello.
I think i got the idea of the texture atlas, but now i think of 2 ways making this and i wanted to be sure, which one is correct, so i'll need your help :).
Let's say i have 4 different objects with 4 different textures. Below are the 2 ways that i think they can be setUp'd. Each texture is 512x512.
1: The first way i think of is: I keep each model's UV's at 0 to 1 UV space. I combine all the 4 textures into one file (1024 x 1024). Then in Unity i create one scrip and apply it to all these 4 models. The script is something like this:
#pragma strict
public var xTile : float;
public var yTile : float;
public var xOffset : float;
public var yOffset : float;
function Start()
{
renderer.material.mainTextureScale = Vector2(xTile, yTile);
renderer.material.mainTextureOffset = Vector2(xOffset, yOffset);
}
After that i just specify the Tile and Offset for each object, so it matches with the position of it's texture, in the big texture map. The dissadvantage of this method is, that every object (That have Atlas texture) will have to execute that small piece of code at start...
2: The second way is: I make one big texture (1024 x 1024) but this time, instead of keeping each model's UV's, to 0 to 1, i select them and scale them down, so all 4 objects, have their UV's combined into one 0 to 1 UV space. (1 - up left, 2 - up right, 3 - low left, 4 - low right). Then i simply apply the same material to each object in Unity and avoid using the script for adjusting the Tiling and the Offset...
thanks :)
"The dissadvantage of this method is, that every object (That have Atlas texture) will have to execute that small piece of code at start..."
It is at Start so shouldn't that be considered an advantage ins$$anonymous$$d?
In some way yes, but the second way, doesn't execute any code at all :)
I actually do not understand the second principle, for this reason, I'm out.
Second Way - Here you can see, that every cube's UV's are in the same UV space (0 to 1). This way i don't need to touch the Tiling or Offset of the material in Unity. I just apply the same material and the UV's of each model will fit to it's texture...
The Uv's shoud be actually over the image, but i have moved them to the side so you can see them.
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
SkinnedMeshRenderer offset UVs to match texture atlas? 1 Answer
Assigning UV coords, from texture atlas. Losing texture uv accuracy at distance. 0 Answers
Having Trouble with Texture Tiling and offset values. Very specific case. 2 Answers
How to match texture Scaling/offset to UV coordinates 1 Answer