Computing distance for LOD

Started by
2 comments, last by capn_midnight 19 years, 2 months ago
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.
Advertisement
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...
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
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
you could probably figure out a way to interpolate LOD values for each tile, instead of calculating each one individually.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

This topic is closed to new replies.

Advertisement