Jump to content

GPU Voxel Downsampling with Compute Shaders


Josh

2,368 views

 Share

For downsampling of GI voxel data, I found that a compute shader offers the best performance. The first step was to add support for compute shaders into Ultra Engine. :cool:

I've never used these before but I was able to get them working pretty quickly. I think the user API will look something like this:

//Load compute shader
auto module = LoadShaderModule("Shaders/Compute/test.comp.spv");
auto shader = CreateShader();
shader->SetModule(module, SHADER_COMPUTE);

//Create work group
int workercount = 8;
auto workgroup = CreateWorkgroup(shader, workercount, workercount, workercount);

This is not using my final formula. It's not even using bilinear sampling, it's just using a single sample from the previous mipmap. But it's basically working:

ezgif-2-061891157e.thumb.gif.1812a31ea119828562be696181bc12b2.gif

Next I will fix up the downfilter sampling and then we can start doing GI and reflections again. Basically, we are in exactly the same place we were a month ago, except now the voxelization process is instantaneous, and will work with animated models and objects in motion. Below is a shot of the results I was getting previously:

metal.jpg.ea25a3d33ff801442fc453e21b074360.thumb.jpg.996c03aaecd6253ebefe67710a3ec80f.jpg

It will be very interesting to see this working with animated models. Maybe we can remake the first level of Quake 2 and compare it to the RTX version.

I'd like to thank Vilém Otte for his helpful advice with this.

  • Like 4
 Share

5 Comments


Recommended Comments

54 minutes ago, Genebris said:

Do I understand that correctly? Reflected visuals are geometry that got voxelized and then polygonized back?

The first part is correct, the geometry is rasterized / voxelized into a 3D texture. The reflection is a bunch of texture lookups into that texture.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...