Jump to content
  • Advertisement
Sign in to follow this  
vpk

help on terrain rendering

This topic is 3668 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

hi can anyone suggest me some good terrain rendering tutorials..

Share this post


Link to post
Share on other sites
Advertisement
Which API? Which technique? If I'm not confused with another person, I guess you need a basis OpenGL heightMap terrain demo.

Google "OpenGL Terrain Generation" gave me this at the first hit:
http://www.swiftless.com/tutorials/opengl/heightmap.html

Basic OpenGL demo that loads an heightmap image, interpolate/smooths it (in case its a low resolution image, and you want to know the height in between the pixels), and uses a basic method to render the terrain with triangle strips and texture coordinates. No LOD or anything fancy, just a small basic demo.

Once you have this up and running, you can try adding a simple sunlight and normals to the terrain vertices (disable lighting at the first time, or you might end up with a black terrain!). Then play around with the texture coordinates to make tiles, make a nice camera navigation system, ... Ow, and be aware that the map uses +Y as the up vector. Sometimes people use +Z.

Greetings and succes
Rick

Share this post


Link to post
Share on other sites
i have gone thru the opengl tutorial, but as you said it does not have LOD etc

can u suggest some tutorial where i can find help for the same??

and how do i disable lighting?? and camera navigation??

Share this post


Link to post
Share on other sites
glDisable( GL_LIGHTING );

As for the camera navigation, basically every OpenGL where you can move has this implemented. Take a good look at the usage of gluLookAt, glLoadIdentity, etc. As for the keyboard/mouse control itself, use vectors. One vector for the position, another for the movement/view direction(s).

if keyBoard_Forward then
pos.x = pos.x + movementDir.x * speed * deltaTime;
pos.y = pos.y + movementDir.y * speed * deltaTime;
pos.z = pos.z + movementDir.z * speed * deltaTime;

// speed is the movement speed factor
// deltatime is the elapsed time between two frames
// movementDir is the (normalized) direction. You could use the same direction
// as your viewing direction here (not for strafe though)
// MovementDir could be made with the mouse cursor position on the screen

Sorry if I confuse you with another person/post, but didn't you ask before about terrain rendering? The terrain was not visible, etc. I would try to make a simple terrain first. Don't start with LOD or any other advanced techniques until you really understand the basics. That includes controlling the camera as well, since LOD has to do with the distance between terrain and camera. Once you have that, you could look at Vterrain, like Sjoerd posted.

Greetings,
Rick

Share this post


Link to post
Share on other sites
I'm surprised it hasn't been mentioned yet, but somebody built a nice terrain engine over here at Twenty Sided that was on digg for a while. He talks about the process of creating his terrain engine from scratch, and in under a month was able to create a fairly nice looking terrain engine that handles LOD. The project took a few modifications for me to compile, but it wasn't too complicated. I can't seem to run it for very well on my laptop anymore(I vaguely remember having it working several months ago) but my laptop has a horribly outdated integrated intel card, so it's not a good example of whether it works well or not.

hope this helps,
-Wynter Woods

Share this post


Link to post
Share on other sites
yes i had earlier posted regarding the terrain..

but since then i had been thru the opengl terrain rendering tutorial and had created a terrain using the same.
after that i would like to implement LOD and view frustum culling on the terrain.

so can u suggest some good tutorials??

Share this post


Link to post
Share on other sites
for view frustum culling is it good to use binary tree or quadtree??

i have been going thru 2 papers

real time LOD using ROAM by turner and CLOD terrain meshing using adaptive quadtrees

not able to make which one is good for LOD and view frustum culling??

do reply

Share this post


Link to post
Share on other sites
I'm using quad-trees for visibility determination (frustum culling), but whatever method you use for culling, it can be completely separate from your LOD mechanism. I'm doing something like geo-mipmapping, which is good for large terrain sets.

How large is your terrain? If its not very big you don't need LOD at all, just draw the entire thing in one go, or separate it into little cells so you can do frustum culling if you want to.

Whatever you do, try to avoid creating meshes or vertex/index buffers every frame - its better to do that at initialisation and then SELECT which of these precomputed cells to use each frame. That way the terrain stays on graphics memory and doesn't need to be altered every frame, thus saving bandwidth and CPU.

That twenty-sided tutorial is one of the best beginner terrain tutorials I've seen, you should check that out.

http://www.two-kings.de/tutorials/terrain/terrain01.html - this is ok, its DirectX though, but thats not hard to port to OpenGL.

http://www.chadvernon.com/blog/tutorials/directx9/terrain-generation-with-a-heightmap/ - this is pretty good, I used this one to make my first terrain renderer in DirectX/C++

Share this post


Link to post
Share on other sites
i have created a terrain using the opengl tutorial which is a very basic one.

in that, a raw file is read into a heightmap array and while displaying it reads directly from the array, creates triangles and renders it. i dont think it used vertex/index buffers.

do u think using vertex/index buffers is the better way to do??

here is the code which i am using:
for (mapX = 1; mapX < MapWidth; mapX +=4){
for (mapZ = 1; mapZ < MapHeight*3; mapZ+=4){
numtri++;
glBegin(GL_TRIANGLE_STRIP);
Height = HeightMap[mapX][mapZ];
glTexCoord2f(0,0);
glVertex3f(float(mapX),Height,float(mapZ));

Height = HeightMap[mapX][mapZ+4];
glTexCoord2f(0,1);
glVertex3f(float(mapX),Height,float(mapZ+4));

Height = HeightMap[mapX+4][mapZ];
glTexCoord2f(1,0);
glVertex3f(float(mapX+4),Height,float(mapZ));

Height = HeightMap[mapX+4][mapZ+4];
glTexCoord2f(1,1);
glVertex3f(float(mapX+4),Height,float(mapZ+4));
glEnd();
}
////

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!