Sign in to follow this  

Barycentric heightmap

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

Given an x and z coordinate how is it possible to check which of two triangles it's over and get the y coordinate (elevation)?

This is for a heightmap.

I was using bilinear interpolation but it doesn't follow the polygons in cases where the two triangles don't follow one plane.

Share this post


Link to post
Share on other sites

I assume the two triangles lie in a square grid-cell and are connected by a single edge?

 

If so, first check on which side of the connecting edge the point lies: dot(point - pointOnEdge, cross(float3(0, 1, 0), edge) > 0).

Then plug the x and y values into the overlapping triangle's plane equation. (a*x + b*y + c*z = d) => y = (a*x + c*z - d) / -b.

Share this post


Link to post
Share on other sites
Sign in to follow this