Jump to content
  • Advertisement
Sign in to follow this  
Mortizar

A Height Map artifact

This topic is 4515 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 have been working on height maps for a bit now and got to working. The only thing is I get a wird artifact when i render it. Everything is fine except for one end of the height map has some polygons that shoot stright down. what i mean is its rendering at a certain height then the next vertex drops by 30 for no apparent reason. Not sure if anyone can help me with this or not, hopeing someone ran into this problem befor and can help me out. Will list my render code below. The Height map is 512 * 512.

void Terrain::RenderByBruteForce(void) {

	if(HeightData == NULL) {

		return;
	}//end HeightData == NULL if

	if(WidthX == 0) {

		return;
	}//end WidthX || WidthZ if

	if(WidthZ == 0) {

		return;
	}//end WidthX || WidthZ if
	
	float Xvalue, Zvalue, Xplusscalevalue;
	int x, z;

	for(x =  0; x < WidthX - 3; x += DetailScale) {
		glBegin(GL_TRIANGLE_STRIP);
		for(z = 0; z < WidthZ - 1; z += DetailScale) {

			Xvalue = (float)x/WidthX;
			Zvalue = (float)z/WidthZ;
			Xplusscalevalue = (float)(x + DetailScale)/WidthX;

			glTexCoord2f(Xvalue, Zvalue);
			glVertex3f((float)x, GetHeight(x, z), (float)z);

			glTexCoord2f(Xplusscalevalue, Zvalue);
			glVertex3f((float)(x + DetailScale), GetHeight((x + DetailScale), z), (float)z);

		}//end z for
		glEnd();
	}//end x for

}//end RenderByBruteForce




editing it to include a screen shot, not a great one. description of your image

Share this post


Link to post
Share on other sites
Advertisement
Look at this part of your code:

for(z = 0; z < WidthZ - 1; z += DetailScale)

//it probably should be:

for(z = 0; z < WidthZ - 3; z += DetailScale)


And if that doesn't work either, you might just set the area being drawn to 511x511, that caused the same error in my engine once.

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!