Generating terrain patch textures

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Attis SH
Kobold
Posts: 28
Joined: Sun May 18, 2003 9:42 am
Location: Budapest, Hungary

Generating terrain patch textures

Post by Attis SH »

I've checked a lot of threads about render to texture topics, but I can't find the answer I'm looking for.

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
(Look for Dave Hill's masters thesis at http://www.magma.ca/~dhlf/research.html)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

Just generate the images you need in a simple RGB(A) memory buffer using any technique you like, then copy them up to a texture when you're done, perhaps using TextureManager::loadRawData if you only need a once-only upload. Azathoth has more options for modifying this later (through HardwarePixelBuffer) but I don't think you need that.
User avatar
Attis SH
Kobold
Posts: 28
Joined: Sun May 18, 2003 9:42 am
Location: Budapest, Hungary

Post by Attis SH »

That's a very simple approach, so simple I haven't even thought about it. :) I will give it a try, but I don't think it will be fast enough.
Post Reply