- Home /
tiling portion of texture
Can we tile only portion of texture. right now i have 512*128 texture and i want to tile the ground (at the beginning) 2*20 times
BR
Answer by jrocamora · Oct 11, 2016 at 08:37 PM
3D objects read a kind of map embedded into them that tells them what area of the texture file that is assigned to look at, in some cases for different parts of the object. These are called UV's, and I don't think it's possible to edit UV mappings within unity, correct me if I'm wrong. If you want to use part of your texture for an entire object, the easiest solution would be to split the texture into the pieces you want and then use that piece!
You can edit UVs. But they're only defined at the vertices so I'm not sure it'd help much in this case.
Seems to me the way to do this would be with a custom shader. Essentially, you'd be implementing your own tiling system.
The point is i will only want to have one atlas 1024*1024 to have a better performance part of it is sprites some is texture some is tileable
The more I think about it the more convinced I am that a custom shader is the way to do it. If you haven't written a shader before this is actually a good one to start with, would be relatively straightforward, especially if you start with a normal tiling shader.
Answer by Lilius · Oct 12, 2016 at 06:15 AM
Quick and bad solution: Create an empty game object. Add a quad as a child of that game object. Add texture to material and tile it to have the ground part in the quad. Duplicate quad 39 times and position quads in 2 x 20 grid.
You could write your own shader, that is quite much work and reading if you haven't done that before.
Both of these kind of ruin the idea of texture atlasing, if you use atlas to reduce draw calls because you would have to have different materials or shaders with different tiling for different objects (correct me if I'm wrong, I'm quite beginner with shaders).
You can do it with script, setting the UV coordinates to vertices but your model would need to have at least 3*21 vertices (which you could also add via script). You could do the same thing in 3D modelling software, which is much faster and easier (at least when you have something more complicated than simple plane) but you anyway need 3*21 vertices instead of 2*2 to produce that one piece of ground.
Your answer
Follow this Question
Related Questions
Why does applying a material to a object break batching? 2 Answers
Blend between 3 Textures by depth value 0 Answers
How to get realistic textures 1 Answer
resize gui texture, scrollbar 0 Answers