viktor-ferenczi / godot-voxel

Voxel rendering for Godot 4.3 (GPU, shader, DDA algorithm)
MIT License
80 stars 4 forks source link

How does this work? #3

Open halotroop2288 opened 10 months ago

halotroop2288 commented 10 months ago

I like this plugin approach to voxel rendering, as opposed to the much bigger Godot Voxel Tools module, because it can be loaded on custom builds of the engine without rebuilding the engine.

I am quite confused where the voxel data comes from though. In the examples it seems the TexturedVoxelMesh only takes images as inputs, and if the voxel data is coming from those, I don't understand how I would manipulate it at runtime... Or ever, really. Seeing as the spec doesn't seem to be described anywhere in this repo.

I would really like to try using this plugin if you could clear that up for me. Thanks!

viktor-ferenczi commented 3 months ago

The voxel data is loaded as multiple Texture2DArray instances. There is a method to overwrite an entire layer (one item of the array) at a time, which allows for partial updates of the 3D texture. I did not use it on actual voxel textures yet, but had a benchmark to measure the copying speed, which was unsatisfactory. That's why I gave up that time with trying to modify the voxel volumes at runtime.

I plan to fix this plugin for Godot 4.3 later this year and maybe getting more of the features working again.

viktor-ferenczi commented 3 months ago

Regarding documentation: Please take a look into the shader files in the plugin. They have the in-memory image format documented. It even has some PBR code for (rough) MagicaVoxel compatibility, just the vox loader is currently missing from the repo (it stopped working with Godot).

viktor-ferenczi commented 3 months ago

Godot 4.3 compatibility has just been merged to main. No vox loader yet, but it will eventually come as time allows.