Jump to content

  • Log In with Google      Sign In   
  • Create Account


Calculating normals between heightmaps


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Zaoshi Kaba   Crossbones+   -  Reputation: 3619

Like
0Likes
Like

Posted 23 May 2013 - 12:56 PM

Hello,

 

First of all I wasn't sure whether to post here or in graphics forums; it's related to graphics but problem is general programming.

I need to calculate normals for heightmap (I know how it's done), however my heightmaps are stored separately (a lot of 128x128), so if I calculate normals individually they won't connect well where heightmaps join. I store heightmap data in this structure:

struct HeightmapData {
	XMVECTOR positions[constant][constant];
	XMVECTOR triangleNormals[constant][constant];
	XMVECTOR vertexNormals[constant][constant];
};

Currently I have function vector<Vertex*> getVertex(int x, int z) which loops through all heightmaps, finds all vertexes at (x,z) (they duplicate where heightmaps connect) and returns them, allowing me to basically unite all heightmaps into one big one. However that's extremely slow. Can anyone suggest a better way to correctly calculate normals between heightmaps?

 

Thank you in advance.



Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 3202

Like
1Likes
Like

Posted 23 May 2013 - 01:44 PM

Maybe you can implement a "virtual heightmap" class which has the the needed operations on it (e.g. "get me the height at (x, y)"), and internally delegates to the appropriate 128x128 height map. Then perform your normal calculations using that.

 

The one problem with that is that you have duplicated vertices along the edges. This shouldn't matter for retrieving the height (just pick any of them, since they should all have the same height). For setting back the normals at a particular location though, you'd need to set it for possibly multiple heightmaps.

 

 

Alternately, much easier would be to calculate your normals before you split your world into 128x128 chunks. Is that possible? In what form is the data originally?



#3 Zaoshi Kaba   Crossbones+   -  Reputation: 3619

Like
0Likes
Like

Posted 23 May 2013 - 02:29 PM

I think I understand what you're trying to say, sounds like it's going to work, I'll give it a try, thanks!

 

Originally it is in 128x128 chunks, currently I have stupidly large map, which results in 14 million triangles. Splitting it was the only option (or maybe just easiest).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS