I’m basically trying to map a bunch of 1x1 texture squares onto individual 1x1 plots of the terrain at runtime. The terrain heightmap is also set at runtime, so this texture assignment of small texture squares also needs to be at runtime.
Does anyone know the best way to go about this in Unity? I’d really like to take advantage of the Terrain object instead of having to generate gameobjects for each square. I’ve been down that route, and it kills performance (even with quads).
Thanks in advance!
I should also point out that I’m willing to use/buy any Unity Asset to accomplish this. I’m not looking to reinvent the wheel, but I have not been able to find a way that this is currently done anywhere.
So you essentially want a large “quilt” of different texture patches?
Some questions:
- Are the patches a unified resolution (e.g., 64x64)?
- When a texture is assigned, is it from a finite library of preloaded, pre-existing textures, or are the textures created on demand during runtime?
- How many different tiles must co-exist at once?
Sounds like to me you need a shader-based option. I would use one large texture, commensurate in resolution to how many tiles you want, whereupon each pixel represents a different tile. To change the tiles, you make changes to the large texture.
Thanks for helping! Yes! A quilt terrain.
- Yes, the patches can be a unified resolution.
- It can be preloaded, pre-existing textures
- Right now I’m using a 128x128 terrain, so 128x128 tiles would be ideal, though I’m currently working on a 64x64 solution.
I understand the idea of having a pixel to encode the texture number for each quilt patch, but I don’t understand how that could be used in Unity. What keywords describe that approach?
Take a look at this link: Improved Terrain Tiling – Daggerfall Workshop
It’s from a Unity project (recreating an old DOS game called Daggerfall), and it looks like they might have addressed the same issue.
The basic idea is to create a shader that accepts two texture inputs, one that expresses the coarse tile information (i.e., the “quilt”), and one with the textures (i.e., the “atlas”). The “quilt” texture should be some uncompressed monochromatic format, such as R16, and without filtering.
Perhaps download the project/source for Daggerfall Unity. You might be able to take a look at the shader directly.
Good luck!