Coder Social home page Coder Social logo

raytracing's Introduction

RayTracing

My personal project to implement a Monte Carlo path tracer in 1 month following Peter Shirley's ray tracing trilogy Ray Tracing in One Weekend, Ray Tracing: The Next Week and Ray Tracing: The Rest of Your Life.

This project has covered all the base techniques presented in the books. In addition, I added a few advanced rendering features and corrections to the original code, which makes it a (slightly) advanced ray tracing renderer :)

Demo Scene

Cornell box with volumetric clouds and a colored crystal bunny, 1024 ray samples per pixel DEMO

Advanced Features

Some avanced rendering features are missing from the trilogy or being presented in an introductory way. In this project, I tried to implement a handful of them while reimplementing the others with more optimized/performant algorithms.

Acceleration Structure

  • BVH using strict Surface Area Heuristic(SAH)
    The original SAH implementation yeilds suboptimal BVH structure when there are sticklike objects along the dominant axis, the strict SAH calculates surface areas along all 3 axes to determine the best possible BVH division. Debug marco has also been added to allow visualization of the BVH structure.
BVH of scene from the books, spheres BVH of custom mesh, triangles
BVH1 BVH2

Materials

  • Fresnel-Schlick reflectance for metal
  • Beer-Lambert absorption for dielectric
    Add ray absorption inside dielectric materials based on the Beer-Lambert law, absorption rate can be tuned for each channel of the RGB to create colored dielectrics.
  • Glossy material using Cook-Torrance BRDF model
    Physically based glossy material, each part of the Cook-Torrance BRDF is chosen as follows:
    F - Fresnel-Schlick
    D - GGX Trowbridge-Reitz NDF
    G - Smith GGX Disney
    GGX sampling is used as importance sampling for this material.
Glossy gold bunny, 1024 samples
BVH2

Cloud Volume

  • Worley noise
    Worley noise was implemented in addition to Perlin noise.
  • Non-uniform arbitrary cloud volume using 3D noises
    Cloud volume can be created with a mixture of Perlin and Worley noises and the ray sampling in non-uniform medium is done thanks to Woodcock tracking. I also extended the medium boundary code to accept non-convex shapes as boundaries.

Renderer

  • optimized random functions
    The original random 3D vector generation in the books adopted a loop and retry strategy, a loop-free method has been put in place to replace it.
  • expendable threaded rendering and fixed-size thread buffer memory
    A CPU worker thread pool designed for pixel-level rendering jobs that is scalable to maximize CPU core usage, with fixed yet adjustable memory consumption.
  • simple model loading and triangle mesh support
    A simple OBJ model file parser that supports limited OBJ data formats including vertices, normals and texture coordinates.

raytracing's People

Contributors

amaranthyan avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.