Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.58k stars 240 forks source link

LOD custom scaling #379

Open liamgolly opened 2 years ago

liamgolly commented 2 years ago

I am designing a large LOD voxel terrain, and I was trying to increase the LOD0 render range to be as large as possible. My project currently uses a LOD count of 16, and I found that the LOD distance increases the distance for each lod. I was wondering if it was possible to customize the range for each of the LOD switches, i.e. 96 units from LOD0 -> LOD1, 48 units from LOD1 -> LOD2, etc.

Zylann commented 2 years ago

Not yet, but it could be implemented to some degree. The distance increases because blocks are twice as big, and the further away blocks are, the longer the distance will be until a lower LOD actually becomes needed. Maybe that factor could be exposed (defaulting to 2?).

If you expect being able to set a custom distance for every level, it might be error prone: keep in mind it will not always be respected, because if configured too small it can cause the terrain to render badly or even get stuck because a block is not allowed to subdivide if it does not have neighbors of the appropriate LOD around it (would otherwise create cracks and sometimes mess with editability). LOD distances need to be high enough to allow that to happen.

Why do you need to increase LOD0 distance? Is it for quality, or being able to edit far away? (if the latter you could use "full load mode" to edit anywhere, although it turns off streaming). 16 lods is absurdly large, that means a single chunk is about 1000Km across. You would need 64-bit floats for physics, and yet the renderer isn't even able to stay stable beyond the 10Km mark https://github.com/godotengine/godot/issues/58516. You'd need a very high far clip as well and maybe also a high near clip which might be undesirable considering glitches it would cause.

liamgolly commented 2 years ago

There is no reason to increase LOD0 distance other than for quality, and the reason for the absurd amount of lods is because I was looking at making a demo space game, and trying to render multiple absurdly large objects (>6000km radius) at once. As far as I can tell in my use case, I only really need LOD0/1/2 (for on planet), and then ideally it would jump to LOD15 as fast as possible (for off planet). Im still pretty new to godot and I wasn't aware of the renderer distance instability, so thats definitely a good point to keep in mind.

Zylann commented 2 years ago

I would highly suggest you prototype your idea at the scales you want using a basic sphere in place of planets (sounds like you didnt test anything yet and went straight to full-on voxels?), because it will likely show you all the other problems you need to face