RayTracer : Differentiable Ray Tracing in Julia

RayTracer.jl is a library for differentiable ray tracing. It provides utilities for

  1. Render complex 3D scenes.
  2. Differentiate the Ray Tracer wrt arbitrary scene parameters for Gradient Based Inverse Rendering.


Download Julia 1.0 or later.

For the time being, the library is under active development and hence is not registered. But the master branch is pretty stable for experimentation. To install it simply open a julia REPL and do ] add RayTracer.

The master branch will do all computation on CPU. To try out the experimental GPU support do ] add RayTracer#ap/gpu. To observe the potential performance gains of using GPU you will have to render scenes having more number of objects and the 2D image must be of reasonably high resolution.


Only rendering is currently supported on GPUs. Gradient Computation is broken but will be supported in the future.

Supporting and Citing

This software was developed as part of academic research. If you would like to help support it, please star the repository. If you use this software as part of your research, teaching, or other activities, we would be grateful if you could cite:

    title={{RayTracer.jl: A Differentiable Renderer that supports Parameter Optimization for Scene Reconstruction}},
    author={Avik Pal},

Contribution Guidelines

This package is written and maintained by Avik Pal. Please fork and send a pull request or create a GitHub issue for bug reports. If you are submitting a pull request make sure to follow the official Julia Style Guide and please use 4 spaces and NOT tabs.

Adding a new feature

  • For adding a new feature open a Github Issue first to discuss about it.

  • Please note that we try and avoid having many primitive objects. This might speed up rendering in some rare cases (as most objects will end up being represented as Triangles) but is really painful to maintain in the future.

  • If you wish to add rendering algorithms it needs to be added to the src/renderers directory. Ideally we wish that this is differentiable but we do accept algorithms which are not differentiable (simply add a note in the documentation).

  • Any new type that is defined should have a corresponding entry in src/gradients/zygote.jl. Look at existing types to understand how it is done. Note that it is a pretty ugly thing to do and becomes uglier as the number of fields in your struct increases, so do not define something that has a lot of fields unless you need it (see Material).

  • If you don't want a field in your custom type to be not updated while inverse rendering create a subtype of RayTracer.FixedParams and wrap those field in it and store it in your custom type.

Adding a tutorial/example

  • We use Literate.jl to convert examples to markdown files. Look into its documentation

  • Next use the following commands to convert he script to markdown

julia> using Literate

julia> Literate.markdown("examples/your_example.jl", "docs/src/getting_started/",
                         documenter = false)
  • Add an entry to docs/make.jl so that it is available in the side navigation bar.

  • Add an entry to the docs/src/index.md Contents section.



Getting Started Tutorials

API Documentation