Faster voxel rendering

Moderator: GZDoom Developers

User avatar
shino1
Posts: 60
Joined: Mon Dec 17, 2018 1:18 am

Faster voxel rendering

Post by shino1 »

Currently, voxel rendering in GZDoom is very inefficient. I'm of course not complaining, it's amazing that we even got it in the first place, so I wholeheartedly thank the team for that. However, while it's suitable for simple objects like medkits or switches, it becomes problematic when trying to use it for monsters, like some mods already do - like Solace Dreams, so it's not like it's not being used.
So, here is my idea - historically, some games that used voxels (and similar techniques like heightmaps) didn't draw actual 3D cubes, but simply drew a uniform-colored, unshaded square to represent the voxel was there. So, here's my idea - can't GZDoom do the same? Just draw a particle of the color that the voxel has set to represent the voxel - that alone could speed up drawing voxels considerably, since particle is much more efficient than a 3D cube. Similarly, there would be less computing expense on shading, because you could shade entire voxel model at the same level based on lighting of a sector, the way sprites are lit by making all colors at once darker/brighter. Finally, to speed things up even further, maybe additional optimization could be written where voxels that are completely surrounded by other voxels, aren't drawn - though of course if that'd be too much work I'd understand skipping that. Choice of voxel rendering style could be a toggle in the options, between the 3D style and faster particle style.
While currently voxels aren't used that much by mods, I imagine adding a different option that works better on lower-end computers could change that. I myself thought of making a mod porting all classic Doom monster sprites into voxels, but the fact that not that many people's computers could handle so many complex models puts me off from doing that now.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Faster voxel rendering

Post by Graf Zahl »

Voxel rendering in the software renderer uses original Build code, which nobody understands. So that cannot be fixed.

Voxel rendering in the hardware renderer creates a single vertex buffer for each voxel and renders one entire voxel object with a single draw call. It cannot get any more efficient than that. What you suggest would require position calculation of every single particle that gets rendered which would be magnitudes slower than the current method.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Faster voxel rendering

Post by Nash »

Interesting. I also thought that rendering a voxel as a square billboard would have been faster VS a 3D cube. Guess it won't make much of a difference, performance-wise.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Faster voxel rendering

Post by Graf Zahl »

You are making the age old mistake here to assume that the rendering on the GPU is the bottleneck. It isn't. The real bottleneck is passing the data from the CPU to the GPU. With a static mesh this is a one-time operation being done up front as a vertex/index buffer pair. The actual rendering is just setting up a rotation matrix and a single draw call

But with a set of billboarded particles this needs to be done on the CPU for each single particle. So even assuming that the rotation math is a little simpler here you can probably get 10 particles out in the time it takes to do the full matrix setup and that single draw call for the mesh.

And if you think of the third option of creating a billboard image from the voxel like the software renderer and then draw that, you'll end up adding even more overhead because you now need a texture upload for every single frame.
User avatar
Rachael
Posts: 13793
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Faster voxel rendering

Post by Rachael »

I think it's important to point out that modern games these days typically render tens if not hundreds of objects in a single scene that are much more complex than GZDoom's voxels ever be - even with all 12 triangles per vexel.
User avatar
shino1
Posts: 60
Joined: Mon Dec 17, 2018 1:18 am

Re: Faster voxel rendering

Post by shino1 »

Well, thank you for the reply at the very least! This has been educational.

Return to “Closed Feature Suggestions [GZDoom]”