Texture tiling based on Object size/scale

I want to create a ground plane that can be scaled to any size and maintain the same texture size on the surface without having to change the material tiling every time.

To give an example. Make a plane 1000x1000x1000. Add a grid 100x100 pixel texture and change the tiling to 1000 on both x and y. Now when you scale the plane the texture changes size relative to everything else.

How do I mitigate this effect?

Update:

I wrote an article, Texture Tiling based on object Size/Scale in Unity, that goes over two methods to get this feature.

There's something in the Asset Store that handles this.

–

any success with that? im trying to get the same thing done....

–

@pcace Just finished up an article, Texture Tiling based on object Size/Scale in Unity, that goes through both methods DaveA suggested in his answer.

–

I think the solution posted by @MLM is very promising. I've been looking around for an answer to this question for some time today, and the script he publishes in his article works great for tiling planes. The only issue I ran into was something about materials leaking out onto the scene, which I found a small bit of workaround code to resolve. I want to do the same type of tiling technique for cubes and other 3d objects -- this seems like it gets very close. Any guidance to modify his script in order to perform tiling on cubes would be great.

–

3 Answers

3

Basically you look for changes in scale and adjust the tiling accordingly. If you want this in the editor, make the script ‘execute in editor’. Note that affecting the tiling is per-material so if that same material is used elsewhere, it will mess with them. The other option is to play with UV’s but I wouldn’t.

It would be nice if it could be used on many different planes. A script that listens to scale and adjusts tiling would not be suitable as you said. This seems like a necessary feature in order to keep textures from stretching and blurring. Is there somewhere where I can define the texture size and just tile that size across whatever?

–

Is there a way to get method 1 in your article to work in all 3 directions and not just on the top surface?
I want to make a rescalable wall.

You could use this: Unity Asset Store - The Best Assets for Game Making

And change the plane’s size instead of scale. Except you don’t want to do it at run time very often, because it regenerates the mesh. It’s an out-of-the-box implementation of the second method you describe. It has an advantage of not taxing your material count.