- Home /
Best Technique for Generating Textures in Realtime
In my game, the world is being procedurally generated, with individual terrain chunks (not using unity terrain) are generated as they're necessary. This all works good (and generating terrain meshes can be deffered to another thread), but I'm drawing a blank as to what would be the best way to texture the generated terrain meshes. There are a whole bunch of different terrain types in the game world, each with a diffuse and normal map. It's quite unlikely, but since it's procedural it's possible to encounter 5+ terrain types intersecting at one chunk (or > 10 textures).
The options I've considered are:
1) Generate the texture by hand and then pass it to the video card. This works, and is my current implementation, but calling Texture2D.Apply() absolutely destroys my framerate. It seems unreasonable to use this after a scene is loaded.
2) Render a blended surface onto a RenderTexture and apply that to the ground. This seems to be fast enough to be practical when I tested it, although it seems like it might not be the best solution. I'm guessing you could get screwed if the textures got unloaded too.
3) Custom shader, possibly using multiple passes to handle cases where lots of textures stack up. I think it's doable, although I don't really have knowledge of writing shaders, nor do I know how it would work performance wise.
Any other ideas? I'm not really sure the best way to go about it. It doesn't need to be technical, I can probably work it out as needed, I'm just not sure on the best approach.