Is it possible to tile within an atlas and still have one draw call?

Hi there,

I’m trying to save draw calls and I was thinking it would be nice if you were able to tile within one big texture atlas that contained all of your tiles.
I imagine this would be possible through a shader but I’m wondering if there would be any point to it as I can’t think of a way to do it without multiple materials (meaning multiple draw calls).
Just wondering if anyone has any cool ideas on how you could achieve this.

Any ideas?
Thanks
Pete

Do you mean just use a part of that texture on 4 separate models? You can do that by modifying the UVs within your 3d models. If you mean how can you tile that entire texture instead of using unity’s tiling feature, you can modify the UV of the UV of the 3d model so it extends outside the 1x1 UV space or you can shrink the size of that texture in photoshop and tile it yourself.

Hey Pete, you could do it in a pixel shader. You would have to modify the uv coordinate using a modulus Modulo - Wikipedia.

To be honest though, no hardware is that sensitive to 3 extra draw calls, I wouldn’t bother

Thanks Guys,

I reckon I’d be going for the shader approach because I was going to end up with way more than four textures on the atlas.
I still can’t think of a way to get it to work as the materials will have to have different offsets within them thus making them unique and negating the draw call benefit.

Thanks for the modulo tip though, sounds handy!
Pete.

Petey,

I don’t understand why do you need to use a shader, when you can just simply modify UV of your mesh.

Here is a cubes with different textures from the atlas and i have just 2 drawcal because all of them use shared material and one atlas


more details here atlasToCube

nicloay, this is useful when you want to tile a texture multiple times over one quad. if you wanted four of each (but same) fish on every side of the box, that wouldn’t work with just an atlas and uvmapping.

this is possible, and as DanTreble mentioned, requires using modulus. the problem with this approach is that mipmaps don’t play nice with fmod(). You get block artifacts at the “seams” because the screenspace block derivatives get messed up, and tex2D decides to pick a lower miplevel when you do this. The result is something like this;

using this image
I guess you could get around this by using tex2Dlod directly or perhaps even some frac()s or fwidth()s.