Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 3.64 KB

README.md

File metadata and controls

48 lines (32 loc) · 3.64 KB

Raytracing using Compute Shaders! (Updated to Godot 4 beta 13)

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?