All the topics I've found were about continuous rendering of textures (the same thing the RenderToTexture demo is about) or rendering the textutre only once.
But what I want to do is to use a number of texture layers to generate a texture for a terrain patch. (I use want to use my own terrain mesh, not a terrain scene manager.) So instead of having to render multiple textures multiple times on my terrain I want to create the texture and a vertex buffer for my patch. Thus basically I need to generate submeshes together with static textures when I notice I need them (when they come in view, according to some error metric), but I never need to change the mesh or the texture. It may have to be deleted if it goes out of view though (in which situation it might be recreated afterwards).
Pseudo code:
Code: Select all
// create a texture for a terrain patch containing 16x16 tiles
create an empty 256x256 texture
create a temporary vertex buffer to render to this texture
render vertex buffer to out texture using base layer material // (eg. mud)
for each transparent layer:
// render transparent layers like grass, rocks, snow here
set alpha values and vertex colour values in vertex buffer
render vertex buffer using additional materials
delete temporary vertex buffer
use created texture
