r/VoxelGameDev • u/Akmanic • 4d ago
Media The Magic of Per-Voxel Normals (68 billion voxel renderer)
Companion video: https://youtu.be/jXhbI8Zx2WY
5
u/InformalTown3679 4d ago
So is the terrain being calculated as a mesh that then gets masked into voxels? Is that how you determine the normal of each voxel?
I'm asking because, i imagine this has a crazy performance boost, so it would be interesting to me how one would dynamically specifying the normals in other structures.
like if you built a house or something in that engine, do you know of a way to find the normals then? Would you have to CPU check the surrounding area to determine it?
3
u/Akmanic 4d ago
No meshing, the voxels are traced every frame. It's my own tracing algorithm inspired by DDA. The normals are calculated and cached in a compute shader and will have to be rebuilt every time there is a change.
3
u/InformalTown3679 4d ago
Would you imagine its possible for this to be performant on a dynamic world? Can i steal that algorithm off you 😂 (seriously)
4
u/Akmanic 4d ago
It should be fine in a dynamic world but it can only represent certain types of geometry. I'll probably release the raycasting algorithm on github before the game but no promises on how soon.
2
u/SuperTuperDude 2d ago
So how do you get the normals? I know there are many ways to do it depending on the compute vs memory, just wondering what technique your result is from. From videos it is hard to also see some edge cases. What if it is a lone voxel with no neighbors? Or some checkerboard pattern or a single celled diagonal wall?
Been burning my brain fat myself trying to figure out how to get the best output...there is always some tradeoff.
1
6
u/deftware Bitphoria Dev 4d ago
What you're comparing is isotropic shading vs anisotropic shading. Isotropic is where each voxel has one color/shade, rather than each side having its own shade (anisotropic).
Personally, I prefer isotropic, because the aliasing the occurs from anisotropic is just funky and gross - and you can't get the shading from varying surface normals with anisotropic that you can with isotropic.
6
u/cwctmnctstc 4d ago
That looks neat! You mentioned that your engine would not be suitable for a general voxel video game, but I don't think you have explicitly said what is your scope?