Sign in to follow this  
sirSolarius

Computing distance for LOD

Recommended Posts

I'm writing some code for basic LOD and detail mapping, and I want to get the distance between my camera and the chunk of terrain (or whatever else the object might be). Is there any other way to do this except to do the distance formula? I was thinking about just taking the distance between the camera and each quadtree node, but I may have a chunk of terrain that straddles the quadtree splitting line and that could screw things up. I guess my question is, how do most people do this? It seems costly to compute distance for each 33x33 chunk of a 1024x1024 terrain every frame.

Share this post


Link to post
Share on other sites
Just sort tiles into quadtree using its center coordinates. there should be no problem. btw computing distance for every tile is not a big deal. you do not even need to take care about all, but the visible ones (you should be able to find them through the quadtree). Once visible tiles found, calculate the distance square between the camera and each object. its 3 multiplications and 2 additions per tile. not a big deal...

Share this post


Link to post
Share on other sites
just in case you miss the subtile important word, i've quoted the above with some emphasis: =)

Quote:
Original post by orbano
calculate the distance SQUARE between the camera and each object.


i.e. use distance squared instead of the actual distance. you'll still get a meaningful number without the expense of the sqrt function.

-me

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this