Coder Social home page Coder Social logo

jan-van-bergen / gpu-raytracer Goto Github PK

View Code? Open in Web Editor NEW
763.0 18.0 42.0 394.26 MB

GPU Raytracer from scratch in C++/CUDA

License: MIT License

Cuda 0.20% C++ 73.55% Objective-C 0.06% C 26.17% Batchfile 0.01% GLSL 0.01% Python 0.01%
cuda compressed-wide-bvh svgf mitsuba raytracing bvh sbvh opengl raytracer ray

gpu-raytracer's Introduction

CUDA Pathtracer

Stormtrooper Monster Sir Muttonchop

Interactive CUDA pathtracer that implements a variety of rendering techniques.

Features

  • Wavefront rendering, see Laine et al. 2013
  • Multiple BVH types
    • Standard binary SAH-based BVH
    • SBVH (Spatial BVH), see Stich et al. 2009. This BVH is able to split across triangles.
    • BVH4 (Quaternary BVH). The BVH4 is a four-way BVH that is constructed by iteratively collapsing the Nodes of a binary BVH. The collapsing procedure was implemented as described in Wald et al. 2008.
    • BVH8 (Compressed Wide BVH), see Ylitie et al. 2017. Eight-way BVH that is constructed by collapsing a binary BVH. Each BVH Node is compressed so that it takes up only 80 bytes per node. The implementation incudes the Dynamic Fetch Heurisic as well as Triangle Postponing (see paper). The BVH8 outperforms all other BVH types.
    • BVH Optimization. The SAH cost of binary BVH's can be optimized using a method by Bittner et al. 2012.
    • All BVH types use Dynamic Ray Fetching to reduce divergence among threads, see Aila et al. 2009
  • Two Level Acceleration Structures
    • BVH's are split into two parts, at the world level (TLAS) and at the model level (BLAS). This allows dynamic scenes with moving Meshes as well as Mesh instancing where multiple meshes with different transforms share the same underlying triangle/BVH data.
  • SVGF (Spatio-Temporal Variance Guided Filter), see Schied et al. Denoising filter that allows for noise-free images at interactive framerates. Also includes a TAA pass.
  • Participating Media (homogeneous)
    • Intuitive, artist friendly parameters: Instead of the usual σa and σs parameters the more intuitive C (multiscatter albedo) and mfp (mean free path) parameters are provided. The σa and σs parameters are then solved for using Van de Hulst albedo inversion. (See Hitchhikers Guide to Multiple Scattering)
    • Multiple Importance Sampling* (MIS): Sample scattering distance for each wavelength using MIS (see Wrenninge et al.)
  • Importance Sampling
    • Next Event Estimation (NEE): Shadow rays are explicitly aimed at light sources to reduce variance.
    • Multiple Importance Sampling (MIS): Explicit light sampling (NEE) is combined with standard BRDF sampling using MIS to get the best of both.
    • Cosine weighted direction sampling for diffuse bounces.
    • Microfacet sampling as described in Heitz 2018
  • Mipmapping: Textures are sampled using mipmapping. Mipmap sampling is done using ray cones (see Möller et al. 2012, Möller et al. 2019). Primary rays perform anisotropic sampling, subsequent bounces use isotropic sampling.
  • PMJ02 Sampling: The low discrepency sampler by Cristensen et al. 2019. Sequences are decorrelated using Cranley-Patterson rotations with blue noise.
  • Hot Reloading: When F5 is pressed the CUDA module is recompiled from source to allow for interactive debugging and development.
  • PBR Material types
    • Diffuse (Lambertian)
    • Plastic (Specular on top of diffuse)
    • (Rough) Dielectric
    • (Rough) Conductor
  • Energy Preservation: Kulla-Conty approximation for multi-scattering is implemented for Dielectrics and Conductors such that they pass a furnace test.
  • Mitsuba XML Scene support: A custom Mitsuba XML parser is included to load scene files. Custom loaders for OBJ and PLY files are available.

Screenshots

SVGF Denoising SVGF: Raw output of the pathtracer on the left and the filtered result on the right.

Kulla Conty Multiscatter Kulla Conty Multiscatter for dielectrics comparison: at the top single scatter, at the bottom multiscatter approximation.

Staircase Marble Still-Life LEGO Bulldozer Glass-of-Water Kitchen Candles Editor

For more screenshots, see the Screenshots folder

Usage

Camera can be controlled with WASD for movement and the arrow keys for orientation. Shift and space do vertical movement. Various configurable options are available as command line arguments. Use command line option --help to see an up to date list.

Dependencies

All dependecies (headers, libs, and dlls) except CUDA 11.0 are included in the repository. The project requires that the CUDA_PATH system variable is set to the path where the CUDA SDK is installed.

Scene Sources

gpu-raytracer's People

Contributors

jan-van-bergen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpu-raytracer's Issues

Building on CUDA 10.2. Problem with CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES.

First of all thank you Jan for this great library!
I try to build this on my old GPU (CC 3.0 and CUDA 10.2 as maximum compabilility). I solved some problem with "--std=c++17" or __ldg but I can't to solve a problem with exception:

CUDAKernel.h line 120 failed with error CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES! too many resources requested for launch

I get exception on calling the execute_material_kernel. I checked parameters of cuLaunchKernel and it's fine.
If I disable scene.has_diffuse, scene.has_plastica and scene.has_dielectric I get a black scene but everything works. I am trying to decrease some value: BATCH_SIZE, PARAMETER_BUFFER_SIZE, WARP_SIZE, MAX_REGISTERS, width and height the screen, bounse/samples, scenes but nothing helps. What parameters of scene could I change for my weak configuration? :(
Thank you!

imask and meta field in BVH8 converter

According to Ylitie et al. 2017, each BVH8 node stores an 8-bit imask field to indicate which of the children are internal nodes.

So I think variable node_internal_count in line 309 and line 307 should be replaced by variable i. Figure 5 in the paper shows this pattern.

case Decision::Type::INTERNAL: {
node.meta[i] = (node_internal_count + 24) | 0b00100000;
node.imask |= (1 << node_internal_count);
node_internal_count++;
break;
}

Thanks.

General questions

Dont know where else to ask this, but i wanted to ask as this project is super impressive
I was wondering where you learned about how to implement all these things in this project, as its something i am interested in myself
also for building the CWBVH, does it use SBVH or the standard binary BVH? if it uses the standard binary BVH, where did you learn how to implement that, as i am trying to myself(to work up to CWBVH), but keep having issues
Also also, while i dont see anything in the code, i was wondering if theres a way for me to visually see the BVH itself? again, trying to implement it into my own project to learn, but as I dont know what the original looks like, its hard to see where im going wrong
Thanks! and sorry for the trouble

[Question] Samples

Hey :)

I've been working on a small hobby path tracer in my spare time (https://github.com/knightcrawler25/GLSL-PathTracer) but reached a point where path tracing in a pixel shader doesn't suffice anymore when it comes to performance and large scenes lol. Came across your project some time ago but re-visiting it now, I see tons of features and its bloody fast too even on my old Maxwell card. Very impressive! The clean code in your repo looks like a really good source for me to learn. So, wanted to thank you for sharing this :) Would it also be possible for you to share sample scenes from the readme (some of the more complex ones with participating media etc which do not have a Mitsuba scene file available) to play around with as it would be easy to gauge performance that way and also since it's rather difficult to convert them from the original.

Thanks again,
Asif

instances in CWBWH

Hello!
How processed instances in CWBWH?
How this nodes is marked in cuda and c++?
Thank you

Does it render in real-time?

Hello,

I am interested in real-time raytracing for a project that I am working on now and was wondering if your code renders in realtime?

Thanks

How to actually build this?

Hello, I wanted to build this application but there are no build instructions, no makefile and no CMake files which would have made the process obvious. This obviously looks very cool and I want to play with it.

qbvh and other bvhs

Is qbvh fast in traverse?
Is qbvh builder use sah and bins on building stage?
Is qbvh faster then others?
Which bvh is faster in traverse and building and quality?

An error occurred during Reset buffer sizes

Your work is excellent, but I found that the program has been stuck in the global_buffer_sizes.set_value(*pinned_buffer_sizes); statement in the Pathtracer.cpp when I run it after compiling. Do you know what the problem is and how to solve it?

Why add a dummy node in SBVH?

sbvh.nodes.clear();
sbvh.nodes.reserve(2 * triangles.size());
sbvh.nodes.emplace_back(); // Root
sbvh.nodes.emplace_back(); // Dummy
sbvh.nodes[0].aabb = root_aabb;

At line 53, why a dummy node is inserted?
In my opinion, only the memory of root node should be allocated before calling build_sbvh().

Thanks.

Will the latest CUDA 12.01 work?

Hello again,

I know that the original developer has passed but was not sure if you had picked up any development on this, or were you just posting for Zuen to keep it online.

I really like the quality of the results that I see on the Github site for the GPU-Raytracer and would like to do some work with it towards seeing what it might take to integrated it into the 3D engine that I am working with now, as well as to see what potential and effort it might take to make it really a quality real-time ray tracing engine.

I'm sure that this will be much more work than it sounds above, but the results could be simple amazing and could lay the groundwork for a simpler 3D engine that could actually compete with Unreal Engine and CryEngine to name a few. (Maybe wishful thinking, but you never know.)

Any way I see that a dependency for Windows 10 is CUDA 11 and I was wondering if you had tried to compile it to run with CUDA 12.01 (latest) version?

Thanks again.

Problems with SBVH construction

When trying to run without modifying any code, because there is no .svbh file, SBVH will be built automatically, but an error will be reported during the build process:

Assertion failed: goes_left || goes_right, file E:\Codes\GPU-Pathtracer-master\SBVHBuilder.cpp, line 253

At this time,BVH_TYPE=BVH_CWBVH.

If you use the release mode to build, although there will be no error, it will be permanently stagnant and will not be rendered.

Stuck in operation

Your project is excellent. But when I try to run it, I get stuck on line 984 in Pathtracer.cpp( global_buffer_sizes.set_value(*buffer_sizes); ). Do you know what happened and how to solve it? Thank you.

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.