Hi all,
I’m new to Unity, so I’m just trying to learn some new stuff.
I’ve cobbled together a procedural road generator, which creates roads out of individual tiles, like this:
What I’d like to do is add some slight variations to each one, such as a bit of random dirt on them.
I’m not sure if this is best done through a custom shader, or a secondary UV mapping, or if it’s possible to assign a material and have it shifted around each time one is instantiated.
Also, is there a better way to group/spawn these tiles? There is going to be a lot of them, and I know prefab variants was recently added?
Thanks
There are many ways to skin a cat (or road in this case) in unity. None are right or wrong. It’s hard for anyone to tell you which is best as we don’t know what your requirements are, what your restrictions are and we don’t know what your skills are either.
I’d randomise things in script but that’s because I’m a programmer and that’s how i think.
How would you go about doing it in script, just so I can have an idea of an approach?
That depends how you author your assets.
if you want to swap models, then do that. If you want to swap textures or materials then do that, or both.
have a list of possible options for whatever it is you want randomised and chose one at random on Awake().
Well this is what I was trying to avoid. I’d rather not have tonnes of different models/prefabs, I would just like to use the one single road prefab, but apply a randomised dirt layer to each one instantiated.
This is why I was looking at potentially using the shader graph to randomise each one, but I wasn’t sure if that was the best approach.
Or my other idea was to apply a second material to the prefab, but each time it’s instantiated apply the material with a slightly different alignment.
As I said, I’m new to Unity, so I don’t really know what I want, I’m hoping someone can just give me some ideas on how to approach a problem like this 
Yeah, if that’s what you want to do then do it.
it’s easy to set UVs from script to. Look into material property blocks
OK, I’ll take a look, thanks