Sign in to follow this  
Mortizar

A Height Map artifact

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this