This is a proof of concept project demonstrating a new Vulkan GPU command RenderingDevice::check_status()
that returns false
if the computation is still ongoing and true
if the computation has completed.
- The raytracing compute shader is
RayTracer.glsl
ray_tracer_simple.gd
contains:- Code to setup a new compute pipeline
- Create storage buffers and texture buffers in a uniform set
- Encode the buffer data as bytes and add them to the buffer
- Dispatch the compute shader (specifying the number of workgroups)
- Read back output data from relevant buffers
- Finally,
ComputeOutput.gd
takes texture data as bytes and displays it on aTextureRect
node- This is used to display the compute output on screen
The current implementation is a (terrible) GLSL port of the articles made by David Kuri.
I am aware that the raytracer doesn't look great right now. I will push updates to this repository whenever I'm able to fix it.
For now, please use this repository as a reference or a learning resource to understand how to make Compute Shaders in Godot 4!
Kuri, D. (2018, May 3). GPU Ray Tracing in Unity – Part 1. Three Eyed Games. http://blog.three-eyed-games.com/2018/05/03/gpu-ray-tracing-in-unity-part-1/
Möller, T., & Trumbore, B. (1997). Fast, Minimum Storage Ray-Triangle Intersection. Program of Computer Graphics. https://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/pubs/raytri_tam.pdf
Scratchapixel. (2014, August 15). Ray-Tracing a Polygon Mesh (Ray-Tracing a Polygon Mesh (Part 2)). https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-polygon-mesh/ray-tracing-polygon-mesh-part-2
Whitaker, R. B. (2009, January 21). Creating a Specular Lighting Shader. RB Whitaker’s Wiki. http://rbwhitaker.wikidot.com/specular-lighting-shader
If you like my stuff, consider a sub to my channel?