Jump to content
  • Advertisement
Sign in to follow this  
tritone

Variable Heightmap Rendering

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

Hello, I am working on a project to create a 3D graph of some image data. Basically it is a heightmap. The input data contains intensity (height), and from its position in the buffer I can calculate an X and Z coordinate. The data is at least 256 x 256, and can go up to 1024 x 1024. My question is : what is the best way to render this? I'd like to be able to render new data on the fly, so a display list is out. I think an octree might work, but there would be alot of overhead if the input data changes and I have to recreate the octree. Currently I am rendering this with triangle strips in a vertex array (see below), and getting a measly 5FPS with a 512 x 512 dataset (although I am not doing any frustum culling or anything like that). I'd also like to be able to run this on as many cards as possible. Here's the code I am using to create the array of triangle strips:
for(int iZIndex = 0; iZIndex < (m_iHeight - 1); iZIndex++)
	{
		if(bSwitch)
		{
			for(int iXIndex = (m_iWidth - 1); iXIndex >= 0; iXIndex--)
			{		

				SetVertexColor(m_fArray[iXIndex][iZIndex + 1], iCount);			

				m_pVertices[iCount].x = iXIndex;
				m_pVertices[iCount].y = m_fArray[iXIndex][iZIndex + 1];
				m_pVertices[iCount].z = iZIndex + 1;
				iCount++;	
				
				SetVertexColor(m_fArray[iXIndex][iZIndex], iCount);			
			
				m_pVertices[iCount].x = iXIndex;
				m_pVertices[iCount].y = m_fArray[iXIndex][iZIndex];
				m_pVertices[iCount].z = iZIndex;
				iCount++;

	

			}
		}

		else
		{
			for(int iXIndex = 0; iXIndex < (m_iWidth - 1); iXIndex++)
			{

				SetVertexColor(m_fArray[iXIndex][iZIndex], iCount);			

				m_pVertices[iCount].x = iXIndex;
				m_pVertices[iCount].y = m_fArray[iXIndex][iZIndex];
				m_pVertices[iCount].z = iZIndex;
				iCount++;

				SetVertexColor(m_fArray[iXIndex][iZIndex + 1], iCount);			

				m_pVertices[iCount].x = iXIndex;
				m_pVertices[iCount].y = m_fArray[iXIndex][iZIndex + 1];
				m_pVertices[iCount].z = iZIndex + 1;
				iCount++;

	
			}
		}

		bSwitch = !bSwitch;
	}




Then I set up the vertex arrays :
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);

	glVertexPointer(3, GL_FLOAT, sizeof(CVector3), &(m_pVertices->x));
	glColorPointer(3, GL_FLOAT, sizeof(CVector3), &(m_pVertices->R));


And finally I render:
glBegin(GL_TRIANGLE_STRIP);

	for(int i = 0; i < m_iTotalPoints; i++)
	{		
		glArrayElement(i);	
	}

	glEnd();


Any help or ideas would be greatly appreciated! Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Hello,

have a look to the geomipmapping technique.

http://www.flipcode.com/tutorials/geomipmaps.pdf

This will help (although i'm not sure your real problem does'nt come from your GL code - i'm way to DX -centric to help you in this case)

But nevertheless, with this "terrain" patch size, you should use a LOD technique. 1024x1024 is 2MTri. This is definitely hot :)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!