Jump to content
  • Advertisement
Sign in to follow this  
vpk

OpenGL terrain rendering

This topic is 3698 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, i would like to get some suggestions regarding terrain rendering. i am working on rendering a huge terrain from a file. the size of the file is 2.99mb. using opengl when i render it, the terrain is rendered on a small area whereas the actual terrain is of the size 16X16km. but on my pc window it is limited to small size only. how do i render it to a large area? is it possible by using LOD?? expecting a quick reply..

Share this post


Link to post
Share on other sites
Advertisement
Just rasie the scale factor. You might want to update your front/back clipping plane, if you encounter weird visual animalies (shimmering) or the triangles start to disappear in front of you.

Or just update your camera to go closer - the end effect is esentially the same ;-)

Share this post


Link to post
Share on other sites
what is the scale factor? i am using .rst file to read the height map

awaiting a reply

Share this post


Link to post
Share on other sites
when i navigate thru the terrain i am able to do it only to a small extent after a short distance the terrain ends. but i want it to be rendered on a large area.
what i get now is that the whole terrain has been limited to a smaller area.

Share this post


Link to post
Share on other sites
but i am not doing any clipping as of now.

i am just reading the height map and using Opengl rendering it.

thanks

Share this post


Link to post
Share on other sites
Quote:
but i am not doing any clipping as of now.

Actually yes you are, if you're using a non-orthogonal projection

Quote:
what is the scale factor? i am using .rst file to read the height map

The "scale factor" is just a multiplier for your x and z coordinates. A value like this is known as a scalar, hence the use of scale factor terminology. Instead of your first terrain point from the origin being at unit (1.0, 0, 0), with a scalar of 5.0 it would be at (5.0, 0, 0), so your terrain is now 5x "bigger" (with 5x less precision).

You must decide what a "unit" in world-space will represent (1 inch, 1 foot, 1 meter, etc.) and then scale everything accordingly. This scalar has to be paired with a meaningful perspective, so you will have to choose a near and far clipping plane distance accordingly.

Share this post


Link to post
Share on other sites
can i post a small part of my code which loads and displays the heightmap..
then maybe you can suggest where i am going wrong..


thanks

Share this post


Link to post
Share on other sites
Dude, it seems your trying to tackle something without enough information.

All GPU's do clipping. Right now its being clipped, you just dont know it. Are you using gluPerspective or glOrtho, glFrustum?, In these functions, they have a near and far plane. If after like 2m in front of your camera its cutting off, then make your far plane farther.

Scale factor means scale it bigger. You can use glScalef().

Of course I'm assuming this is the problem. Pictures help.

Share this post


Link to post
Share on other sites
thanks for your help and patience.

yes i am using
gluPerspective (100, (GLfloat)w / (GLfloat)h, 0.01, 500.0);

void DisplayHeightMap (void) {
int Height;
int numtri=0;

for (mapX = 1; mapX < MapWidth; mapX +=4){
for (mapZ = 1; mapZ < MapHeight*4; 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();
}
}
}

can u tell me how to upload the snapshot of my terrain??

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!