is possible to tile within a texture atlas?
In other words If I have a small brick texture inside a larger texture atlas. Is there a way to only tile the brick part across the mesh.
Good to know because I got really dissapointed when I saw it working on 3Dmax and destroyed once imported into unity.
Answer by michael 4
Feb 07, 2012 at 06:14 PM
I have found that it is indeed possible to tile textures in a texture atlas by modifying the shader.
In your pixel output function where the text2D() sampler function is called change your IN.uv_MainTex (or what ever your main texture uv variable is called) to:
(frac(IN.uv_MainTex) * 0.25f + offset) //this assumes a 4 x 4 texture atlas
so the entire line will look like this
fixed4 tex = tex2D(_MainTex, (frac(IN.uv_MainTex) * 0.25f) + offset);
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
you will have to set offset as a variable that is present in the editor by declaring it in the properties section of your HLSL code
Sure, if you wrap it manually it's possible ;) Haven't thought of wrapping the UVs in the fragment shader.
Would this code work on iOS? And if so, would it cause any performance hit?
I guess it should work. The overhead is marginal. Well like every fragment-shader the load depends on how much of this object is visible on the screen, but the operations aren't really heavy.
What kind of variable is "offset"? A Vector?
Would this approach mean that there would need to be one material for each part of the texture? If so then surely there is no benefit to even using atlases right because each material is batched separately... Where else does the offset get defined?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
11 People are following this question.
Texture Atlas for sprites/particles: Wasting Texture Memory?
Assigning UV Map to model at runtime
Textures in texture atlas are "leaking" when moving camera
Texture atlas - little glow of nearby textures seen from distance
Texture bleeding problem with texture atlas