adjusting LodNode based on camera FOV

I would like to add a feature which dynamically changes the distance at which LOD levels on an LodNode appear based on the field of view of the camera observing them.
For example you are zooming in on something with binoculars or a sniper scope: as the field of view narrows, the object takes up more of the screen and it should switch to a higher LOD that would normally show when you are closer to it.

I am looking for advice on the best implementation of said feature.
Option A: Have a setting on the camera/lens that is like a multiplier for the distances set on the LodNode. This is a more manual approach, you need to set this value whenever you set the FOV, but it also gives you more power because you could also tweak it for performance reasons (for example give the player a slider in the graphics options).
Option B: Have settings on the LodNode which sets the “ideal” FOV where it will use the distances as given, and adjust the distances based on how much the FOV is off from the ideal value. This way is more automatic, but I feel it is less powerful.
Or of course other suggestions are welcome.

Option A is kind of similar to the LODNode.setLodScale() function we’ve already got, so I can see that having a Camera.setLodScale() function as well would match that nicely. And I don’t see a problem with calling Camera.setLodScale() any time you also change the FOV.

So, consider that a vote for option A. :slight_smile:


OK that works rather well.
Here is my patch:

And here is a little code snippet showing the math for those wanting the behaviour described in option B:

fov = 30
ideal_fov = float(60)
lod_scale = math.tan(math.radians(value * (90 / ideal_fov) * 0.5))

Could this get patched into the repository? I’ve been using it for a while now and it doesn’t appear to cause any issues.