LODNode and FadeLODNode

I’m writing some heightfield terrain code for Panda3D (screenshot: http://homepages.inf.ed.ac.uk/s0094060/Screenshot2.jpg, which I intend to release as soon as I can.

The main basic function I still needed to implement is multiple Levels Of Detail, both for the mesh and the texture. Currently I have two textures - terrain and detail, applied to a single mesh.

I’m looking into the source code to figure out how to use Panda’s LOD stuff as I don’t see any documentation. It would really help me if someone could give me a quick intro to the LOD functions though. What is LODNode used for and what is FadeLODNode used for? These seem to be the two LOD classes.

Currently I split my terrain into many patches and build each patch into a Geom. The Geom’s are then attached to GeomNode’s. I’m guessing what I would need to do for mesh LOD is attach each Geom to a LODNode as it’s immediate parent in the scene graph, for each patch of the terrain I’d attach multiple Geom’s representing the patch at different resolutions, then somehow tell the LODNode which Geom to use when.

For the textures I have no idea yet, unless I can simply apply different textures to the different resolution Geom’s.

Any guidance before I dig into the code?

Sure. Both LODNode and FadeLODNode work the same way in principle: they render exactly one of their children, according to the distance of that node from the camera.

The way it works is, you create the LODNode of whichever type you like, and then parent a number of different resolutions of a given model to the LODNode. Pay attention to which order to parent the children in.

Then you call LODNode.setSwitch() for each child you added, to specify the switching distance of each child. The parameters to setSwitch() are (index, in, out), where index is the 0-based index of the child in question, in is the farthest distance at which this child is visible, and out is the nearest distance at which this child is visible. (The naming of “in” and “out” is as if the object were coming at you from far away: it becomes visible at the “in” distance, and then becomes invisible at the “out” distance.)

The switch distances for the various children can be overlapping or non-overlapping, as you choose, but normally they are designed not to overlap, so that the “out” distance of one child is exactly the “in” distance of the next child.

The FadeLODNode works the same way, but when it transitions from one LOD to another one, it will smoothly fade the old one out while simultaneously fading the new one in. This means that for a short time both LOD’s are visible at once, but it helps to hide the “pop” effect that you get with the LODNode.

If you want to LOD textures, just apply a different texture to each different LOD.


Great! That sounds really easy, I’ll give it a try tomorrow.

So… I have some fairly decent patch-based procedural terrain generation code already done, with some work to add this LOD functionality what I will have sounds a lot like what is missing from this page of the manual:


I’m sure my supervisors would be happy for me to write a tutorial about my code once it’s done. I’m already supposed to be writing a presentation on it. Would you be interested in a submission for the manual?

Anyway, I suppose you’ll want to see the code. I hope to release it on the forums tomorrow, or soon in any case.

Every manual is good if it is correct and contains usefull information

We do welcome any submissions to the manual. You can make any additions you think are appropriate directly; the manual is actually a wiki. Click on the little dot below any page to log in.