Skip to main content
GameDev.net gamedev.net
🔒 Locked

A Height Map artifact

Started by Mortizar Jun 8, 2006 at 9:05 AM 1 replies 900+ views
Original Post
Mortizar
Mortizar
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
Caste
Caste
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.
Mortizar
Mortizar

thx that got it working

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.