Is it possible to achieve something similar to this video with a shader?
I’m creating an in-game level editor and have generated a grid-based mesh to work with. Currently I’m using an alpha blend shader (found at the Unity forums) to blend between two textures at a vertex point, though I’d like to create something like Warcraft 3’s World Editor which supports multiple textures. Blending/alpha isn’t necessary.
If possible, could somebody point me in the right direction?
An easy and efficient way to do this is to have texture atlas (all of the tile textures are combined into one actual texture, like a sprite sheet) of all the possible tiles, and then handle all of the texture selection with UV coordinates. Normal UV coordinates (Mesh.uv) could be used as the opaque “base” texture, and a second set of UV coordinates (Mesh.uv2) could be used for overlays. Then, all the shader has to do is sample the texture twice and combine the two samples using alpha blending. For tiles that do not have an overlay, it’s a simple matter of setting the UV coordinates to a transparent section of the atlas.
It’s worth noting that Mesh supports up to four UV sets, so theoretically up to four textures could be overlaid on the same tile in this manner.