Terrain Heightmap Intersection

This topic is 1501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi all,

I'm searching the good way to compute intersection of ray and a heightmap.

I have the ray origin, the ray direction and the height on x/z of the terrain and the cell spacing (64 cells by patch).

I have searched a lot on google and I saw bresenham algo can be used but doesn't work good.

The second solution I saw is to use quad tree to intersect each patch and compute intersection inside it.

The question is for the second part of the algorithm, when you have the patch, what is the good way to find the intersection ?

Is it correct to compute each triangle of each cell (2 triangles per cell) and compute ray-triangle intersection like for a mesh ?

Thanks for the help

Edited by Alundra

Share on other sites

I'm not sure what's most commonly used, but your problem seems very similar to the problems encountered when doing real-time displacement mapping in shaders. The basic problem those algorithms solve is finding the nearest intersection between a ray and a heightmap tiled on an infinite plane, within some error tolerances. There would be some differences, e.g. your terrain wouldn't tile infinitely, so would also be restricted to some bounding box. Your ray may come from directions that wouldn't be encountered for a texture, e.g. inside the bounding box. You may also have tighter error tolerances than they allow. But it may be a useful start.

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch18.html

Share on other sites

The question is for the second part of the algorithm, when you have the patch, what is the good way to find the intersection ?
Is it correct to compute each triangle of each cell (2 triangles per cell) and compute ray-triangle intersection like for a mesh ?

so you want to find the point of intersection between your ray and the ground mesh, where the ground mesh is defined by a heightmap.

the simple way is to compare ray y to heightmap y at a given x,z.

for pixel precise, you'd want to go with ray vs triangle intersection against the 2 tris making up the quad of intersection.  dirxectx sdk includes a raypick sample that does ray vs triangle intersections on a mesh, which should get you the second half of your algo.  the sample may only be available in older sdk's such as june 2010 (dx9.0c).

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• Forum Statistics

• Total Topics
633289
• Total Posts
3011226
• Who's Online (See full list)

There are no registered users currently online

×