- Home /
How can I use a tile set to texture a large mesh?
I am new to Unity and game design (however I'm very experienced with programming). I am creating a large 3D mesh in Blender for my terrain, as I am trying to make a very low-poly terrain and I don't think Unity's terrain tools allow me to do that. So I have a UV-mapped mesh for the terrain, and I have a tile set of seamless 32x32 pixel PNG images that I would like to use to create the texture for my terrain mesh.
I know how to just create a material from one tile (a grass tile, for example) and apply it to the mesh and have it repeat. But that looks very monotonous and I would like to know how I could add other tiles like dirt patches and what not on top of that.
For reference, I am talking about doing something similar to this (Daggerfall): https://www.youtube.com/watch?v=tAf1QfO4Xug
In the video, there is clearly a grass base tile that is repeated, but then there are also patches of dirt and rock throughout the terrain. It's also pretty obvious that they're using a tile set for it because the edges of the dirt patches all look the same, rather than seamlessly blending into the grass as if it was painted on.
What's the best way for me to go about doing something like this?
Answer by toddisarockstar · Apr 04, 2018 at 05:41 AM
tracking down the actual UV mapping of a particular face from an imported mesh would be extremely difficult. this is what modeling software is for. if you created the mesh through code and had organized code references/arrays to what triangles lined up to which points of your mesh and how they are constructed then you could possibly change a texture of a uv face like this: https://docs.unity3d.com/ScriptReference/Mesh-uv.html
in other words it's not practicle.
but what you are seeing in your video is not done through uv mapping ... horray.
it's done through a custom shader. the shader you are seeing would allow for three textures. one to represent texture1, one texure represents texture2 and the third texture is used as a texture map telling the shader where to use texture1 and texture2.
the shader picks up on the float value of a color channel in the third texture to decide what percentage to display texture1 over texture 2. unfortunely, as far as i know, this type of shader is not included in unitys default shaders but it shouldnt be too difficult to either write one or find a custome shader code like this on the web
if you are not finding similar options in unity's terrain building/editing options
Great, thanks! I don't know anything about creating or using custom shaders so I'm gonna have to find out some more info about it. That being said, I was hoping there'd be some sort of way to directly paint various textures onto the terrain mesh, while having it sorta "snap" to each individual unit, for the rough edges. Generally, something simpler than writing a shader and then having to make sure my texture map looks how I want it to. I guess yeah, if I want to do that I should be doing it in modeling software, rather than Unity. Anyways, thanks a bunch!