How can i stop the stretch effect of a material when i add it to an object and then resize it
When i add a material to an object and then resize the object, the material stretches and goes all fuzzy. How can i stop this?
Is there a way to tile it?
$$anonymous$$oved this to the Help Room (since it's a common Q, been asked and answered a lot. But maybe you don't know the technical terms to search for how $$anonymous$$aterials work, or where to find them.)
I would also like to know how to do it. On terrains material behaves normally but when I put it on the plane for example and then resize it (scaling) then it's stretching but I want it to get "repeated".
Answer by Owen-Reynolds · Oct 09, 2015 at 11:37 PM
Unity borrows the idea of Materials and UVs, tiling ... all of it from standard 3D modeling. Unity borrows a lot of things from a a lot of places, which is a good thing.
The best way to understand why textures stretch, an so on, is to learn about the normal, non-Unity, way that Textures are applied, what tiling means, how UV mapping works ... . Do searches without the word Unity in them. Things that are about 3dsMax or blender (3D modeling programs) might be good, but look for an explanation, not exact settings.
Then all of this will make sense, including why the rule is for textures to stretch. Sure, you can find a line or two that will solve one exact particular problem. But if you plan to do this for real, it's better to do the reading. Then you'll also have a skill that applies to any sort of 3D computer stuff, and be able to solve all sorts of Unity texture problems.
I understand that I should understand it on a lower level to be prepared for unco$$anonymous$$g obstacles but to be honest, I'm beginner, I've just started my journey with Unity and I'm trying to learn as much as possible and there is a lot of stuff to go through. I'm trying to do a lot of research if I don't understand something enough but sometimes I cannot do it with everything and I think that's one of the things right now, but I'm going to back to it probably soon if I need it again. I'm just glad that I sorted this thing up with just 2 lines of code and I can get back to work :) Cheers!
Answer by Statement · Oct 09, 2015 at 11:08 PM
When you scale a model, UV mapping stays the same. In the case of simple models such as quads, planes and boxes, sometimes it could be useful to use procedural UV generation, such as planar texture mapping which uses world coordinates to generate UV coordinates. The answer then would be to use a shader (i.e. find, buy or write it) which supports planar texture mapping.
Triplanar texture mapping can also be used to automatically texture an object on all three axis and is often used with voxel terrain. These shaders can be used on all kinds of geometry while planar mapping will look fine if it's flat but will look stretched if vertices start pointing along the axis it's projecting from.
It can also be called texture projection or uv projection.
Hi, thank you for your effort but I don't understand what you just said to be honest. However I went deeper to check what I wanted and I found solution which works as I wanted which is:
Renderer render = GetComponent<Renderer>();
render.material.mainTextureScale = new Vector2(x, x);
Your answer
Follow this Question
Related Questions
Ever seen blurry textures like this? 0 Answers
Can I use MaterialPropertyBlock to set properties per material instead of per renderer? 0 Answers
Transperancy gives a reverse normal effect? 0 Answers
Change partial material color based on overlap (collision) 0 Answers
Changing color on specific tile in texture at runtime 0 Answers