Avokadoen / zig_vulkan

Toying with vulkan and zig
45 stars 1 forks source link

Idea: split material scatter and subsequent traversal into custom shaders #132

Open Avokadoen opened 2 years ago

Avokadoen commented 2 years ago

Test sending rays to buffers (one per material).

Have a inital ray cast shader which sends rays to each buffer

Then 3 shaders that performs their own custom scatter function and appends product ray to new buffers if they are not complet

This is to avoid branch divergence on materials and will unlock some async compute. It will also make the code more readable as it is an excuse to split code into multiple files (but this can be done anyways)

It's not necessarily faster than status quo and should therefore be heavily tested if implemented ...

This can also be extended to perform gradual bounce simulations in the future (caching rays)

Avokadoen commented 2 years ago

Indirect dispatch can be used to dispatch according to ray buffer size: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchIndirect.html