Git Product home page Git Product logo

raytracing_godot4's Introduction

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?

raytracing_godot4's People

Contributors

nekotogd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.