Friday, September 4, 2009

A new tiled terrain design

Hello
After many days of thinking hard on tile terrain finally find a good way to build the terrain.

Before start talking about algorithm I have to say I’m not implemented this algorithm yet and things may be change later.

TextureID:

For storing the tile texcoords I use one textureID with A32R32G32B32F format for storing the tile texcoords offsets then in the pixel shader I use it to map the tiles to the terrain.

I get the idea from Journal of Ysaneya.

No mipmap and texture filtering is needed for this texture.

Vertex:

I need one texcoord for my vertices and they start from 0 to number of columns/rows increase one per vertex.

How to map the tiles:

In the pixel shader I read the tiles offset and creates their texcoord.

X = 1 / number of columns in the tile texture
U = Uoffset + u * X;

For reading the Uoffset from TextureID I can use something like above formula.

X = 1 / TextureID size;
U = u * X;

No comments: