Skip to content

Proof of concept demo for Async Vulkan GPU shaders in Godot 4.3

License

Notifications You must be signed in to change notification settings

granitrocky/Raytracing_Godot4

 
 

Repository files navigation

Raytracing using Compute Shaders! (Updated to Godot 4.3)

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.

Relevant files

  • 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 a TextureRect node
    • This is used to display the compute output on screen

IMPORTANT Note

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!

YouTube video (includes code explanation)

Watch the video

References and Resources

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

My Socials

NekotoArts NekotoArts

If you like my stuff, consider a sub to my channel?

About

Proof of concept demo for Async Vulkan GPU shaders in Godot 4.3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • GDScript 53.3%
  • GLSL 46.7%