Archived

This topic is now archived and is closed to further replies.

Question on Vertex Arrays and terrain engine

This topic is 5239 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using a display list right now for my terrain engine. I can't see any way to have multiple textures for different heights unless I use one texture and call different texcoords. I dont' want to do this and was wondering if their is any other way to go about using one texture for each type of terrain. e.g. dirt, rock, snow, grass, ect... I know that once the display list is compiled your hosed for changing it, so thats why I was wondering about vertex arrays? What I would really like to use is GL_ARB_VERTEX_BUFFER_OBJECT if anyone could help out with how the coding works with VBO's that would be great instead of using vertex arrays. Thanks [edited by - Mars_999 on August 7, 2003 3:21:52 AM]

Share this post


Link to post
Share on other sites
i have implemented a terrain engine in which the geometry is stored in the standard GL vertex arrays....it seems to work ok, but when i can get motivated i will transition to the VBOs...


anyway, the problem of texturing your terrain is more easily solved:

- during initialization you need to make an alphamap for each texture you want on the terrain, these maps can be low resolution, and you basically want the alpha value for each pixel to be based on some function of the height at that pixel.
- set up for multitexturing and put the first alphamap in the first unit, and the first texture in the second
- render the entire terrain
- put the second alphamap in unit one, second texture in unit two, disable depthmask, enable alpha blending, set depthfunc to GL_EQUAL, render terrain again
- repeat for each texture

i hope this has at least given you a vague idea of what i mean, if not i will try to enlighten ou more after i have offlined my brain for a few hours..

i have a pic of my new terrain engine here:
http://people.umass.edu/rwhall/te1_6.jpg

Share this post


Link to post
Share on other sites
texturing depends on how many texture units you have to work with and what you want to do. using two passes for just two textures shouldnt be necessary on any card newer than.. well.. a long time ago.

to get as many textures as i can i ended up with this:
unit 1: base texture with texture weights in alpha channel
unit 2: normal map for lighting
unit 3/4: grass/rock textures

using shaders, combiners or whatever the steps would be:

A:
interpolate u3+u4 by using alpha from 1
add u1 ("stretched" to [-1,+1])
B:
do dotproduct of 2 and primary color (or wherever you stored your light direction)
modulate with light color (stored wherever)
C:
modulate A and B

result looks like this: Pic

Share this post


Link to post
Share on other sites
Mictian are you using floats instead of int for your map size?


for(float z = 0.0f; z < MAP_Z; z +=.5f)
{
for(float x = 0.0f; x < MAP_X; x +=.5f)
{
}
}


to render more polygons to get a smoother terrain? And if so are you just taking the value of the 0,1 and averaging them out and assigning that value as the height for .5 increments?

Share this post


Link to post
Share on other sites
no, my terrain is based upon a heightmap, and i do not widh to interpolate between values, as this would be no smoother than using those discrete values i already have...when i mentioned my use of floats in terrain i meant that my heightmap is made up of floating point values, this is what makes it smoother...


i.e.

typedef float heightdata_t;

heightdata_t * m_pHeightmap = new heightdata_t[ m_nSize * m_nSize ];


[edited by - mictian on August 7, 2003 11:29:06 PM]

Share this post


Link to post
Share on other sites
but making the heightmaps a lot bigger. i decided that shorts would be enough. considering the highest peak is at 8800m i could store heights up to 10000m with a "resolution" of 15cm. on the other hand, when you store the geometry it will most likely be as floats anyway.

Share this post


Link to post
Share on other sites