GithubHelp home page GithubHelp logo

rt's Introduction

rt

My Golang implementation of The Ray Tracer challenge book by Jamis Buck.

image The Golang gopher, 3D model by Takuya Ueda, Go Gopher by Renee French.

image (multisampling and soft shadows)

image (the good ol' dragon, soft shadows. Note that the dragon model uses surface rather than vertex normals)

image

(depth of field)

Description

This is my WiP implementation of the Ray tracer as described in the book "The Ray Tracer Challenge" by https://pragprog.com/book/jbtracer/the-ray-tracer-challenge plus a few extras.

Changelog (and performance fixes)

Just to keep track of which fixes were done when, kind of...

  • 2020-03-19: Pass pointers to arrays for certain method calls
  • 2020-03-16: Assembler impl of vector * matrix multiplication through c2goasm
  • 2020-03-06: .MTL materials hack
  • 2020-02-29: Depth of field
  • 2020-02-25: Soft shadows and multisampling
  • 2020-02-23: BVH
  • 2020-02-21: Bounding boxes for groups and CSGs (based on bonus chapter from book)
  • 2020-02-20: Refactor to use arrays instead of slices for Matrices and Tuples.
  • 2020-02-19: Use sort.Sort instead of sort.Slice
  • 2020-02-15: Soft shadows and multisamling (feature-branch)
  • 2020-02-05: Pass job per line instead of pixel
  • 2020-01-10: Reduce allocations, cache stuff in render contexts
  • 2019-12-28: Cache inverse
  • 2019-12-25: Multi-threading using workers

Features, State etc

I think I've got all the features from the book covered, including:

  • Depth of Field
  • Soft shadows with Area Lights
  • Bounding boxes / BVH
  • Spheres, Cubes, Cones, Cylinders, Planes, Triangles, CSGs
  • Phong shading etc
  • Multiple light sources
  • Shadows, Reflection, Refraction, CSGs
  • Groups
  • Triangle render and .obj/.mtl loading

There's some unfinished / WiP stuff such as a YAML loader NOT compatible with the .yaml format used in the book!

While all test cases from the books should be implemented, they may at times point at old (unused) implementations of certain features that I havn't gotten around to fix yet.

Performance

Quite naive implementation, has some basic caching of Inverse matrices, multi-threading using worker pool and some various measures to avoid allocating memory. Still loads of stuff to do since the allocation-heavy parts of the code really seems to kill performance. Nevertheless, the optimizations I've done since start resulted a reference render going from 3m14s (single threaded) to 0.8 seconds (8 threads).

Things left to try:

  • Pre-compute triangle normals from .OBJ models
  • Eliminate allocations
  • Optimize AABB intersections

License

MIT, see LICENSE.md

rt's People

Contributors

eriklupander avatar

Stargazers

 avatar Tristan Morgan avatar  avatar Chris avatar Andy Wang avatar Xavier Belanche Alonso avatar  avatar DT avatar Peter Hooper avatar Jiawei Yang avatar David Sauer avatar Matt Chia-wen Chang avatar Jorge Gomez avatar Sascha avatar  avatar Luis Geniole avatar Omar Magoury avatar LinShaocong avatar ginuerzh avatar E-Tiger Studio avatar Théo Crevon avatar west avatar abdul dakkak avatar

Watchers

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