[No] Faster voxel rendering

Moderator: GZDoom Developers

Faster voxel rendering

Postby shino1 » Sat Feb 20, 2021 11:58 pm

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.
shino1
 
Joined: 17 Dec 2018
Discord: shino1#6558

Re: Faster voxel rendering

Postby Graf Zahl » Sun Feb 21, 2021 1:26 am

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Faster voxel rendering

Postby Nash » Sun Feb 21, 2021 2:04 am

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
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: Faster voxel rendering

Postby Graf Zahl » Sun Feb 21, 2021 3:05 am

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Faster voxel rendering

Postby Rachael » Sun Feb 21, 2021 5:50 am

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
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Faster voxel rendering

Postby shino1 » Wed Feb 24, 2021 8:02 am

Well, thank you for the reply at the very least! This has been educational.
shino1
 
Joined: 17 Dec 2018
Discord: shino1#6558


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests