Skip to content

grigoryoskin/vulkan-compute-ray-tracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vulkan compute shader based ray tracer.

Screen Shot 2021-08-01 at 18 36 16

ezgif-7-7a97c6e30f17

Ray tracer loosely based on raytracing in one weekend series, adapted for real time rendering on GPU.

How it works.

Overall project structure comes from my project template with some changes to enable compute functionality.

Compute shader renders the ray traced scene into a texture that gets displayed onto a screen quad with a fragment shader.

ComputeMaterial holds the target texture, data buffers, pipeline and descriptor sets.

The scene consists of a an array of materials and an array of triangles. Each triangle holds a reference to the material. Reference is just material's index in the array for ease of use on GPU.

BVH used to accelarate triangle search is a flat array too, since GPU doesn't support recursion.

TODOs:

  • Fix synchronization issues 😠
  • Glass materials.
  • Fog.
  • PBR materials.
  • Light sampling.
  • Render spheres.
  • Include spheres in bhv.
  • Try "roped" bvh to see how it improves performance.

How to run

This is an instruction for mac os, but it should work for other systems too, since all the dependencies come from git submodules and build with cmake.

  1. Download and install [Vulkan SDK] (https://vulkan.lunarg.com). Add $VULKAN_SDK environmental variable.
  2. Pull glfw, glm, stb and obj loader:
git submodule init
git submodule update
  1. Create a buld folder and step into it.
mkdir build
cd build
  1. Run cmake. It will create makefile in build folder.
cmake -S ../ -B ./
  1. Create an executable with makefile.
make
  1. Compile shaders. You might want to run this with sudo if you dont have permissions for write.
mkdir ../resources/shaders/generated
sh ../compile.sh
  1. Run the executable.
./vulkan

About

Interactive ray tracer made with Vulkan compute shader.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages