Cubyz icon indicating copy to clipboard operation
Cubyz copied to clipboard

Investigate using `ARB_fragment_shader_interlock` extension for volumetric fog

Open IntegratedQuantum opened this issue 1 year ago • 8 comments

This extension seems to be widely available on intel and nvidia hardware. (sadly no support on AMD) There are some potential performance improvements from this (it would allow using an f11/f10 framebuffer), which could be especially helpful on the (generally weak) intel iGPUs. Furthermore it would also allow some visual improvements (support for denser fogs, less graphical glitches and maybe even lighting)

IntegratedQuantum avatar Dec 06 '24 17:12 IntegratedQuantum

I implemented a prototype in the impossible_fog branch. Functionally it works well and fixes the annoying problems of volumetric fog:

  • no more artifacts when looking at the fog backface (this also fixes the blooming pixel errors)
  • no more artifacts when the fog strength or fog distance get too large

I still need to check the performance impact and try out lighting.

IntegratedQuantum avatar Dec 06 '24 21:12 IntegratedQuantum

I have investigated the performance impact of this, and while the f11/f10 framebuffer does increase performance by ~600 µs on my intel iGPU test device, it is weight up by the ~500 µs cost of copying the depth buffer. Additionally there is an ~5-10% performance improvement in the transparent rendering step. However this does not matter much in the grand scheme of things.

Because it makes only such a small difference, I have decided that ti's not worth the extra code complexity for now. Maybe in the future, once more devices (most importantly AMD) were to support this extension, it might be worth another look, due to fixing some of the visual issues/limitations of fog.

IntegratedQuantum avatar Dec 08 '24 17:12 IntegratedQuantum

Is there a similar extension for vulkan?

codemob-dev avatar Nov 19 '25 21:11 codemob-dev

I believe there is an equivalent, but i dont think amd supports it either :(

OneAvargeCoder193 avatar Nov 19 '25 22:11 OneAvargeCoder193

Modern AMD GPUs do support this OpenGL extension on Windows (and Linux). Also on Linux, the Vulkan equivalent is supported on Polaris and later, as for Windows: https://www.amd.com/en/resources/support-articles/release-notes/RN-RAD-WIN-VULKAN.html

AbduSharif avatar Nov 20 '25 14:11 AbduSharif

Also on Linux, the Vulkan equivalent is supported on Polaris and later

Then it even works on my machine, another reason to push for Vulkan #102 support I guess.

Though either way we will still need to support older GPUs (device coverage on vulkan desktop is only around 40%), so there is no way around implementing a fallback path.

IntegratedQuantum avatar Nov 20 '25 15:11 IntegratedQuantum

so there is no way around implementing a fallback path.

What kind of fallback path would we have in case we implement this? Would it just be what we currently have + maybe some day/night cycle coloring?

OneAvargeCoder193 avatar Nov 20 '25 15:11 OneAvargeCoder193

the fallback would be what we currently have. Other than fixing a few bugs there should be no visual difference in the first implementation.

IntegratedQuantum avatar Nov 20 '25 15:11 IntegratedQuantum