RayTracer : Differentiable Ray Tracing in Julia
RayTracer.jl is a library for differentiable ray tracing. It provides utilities for
- Render complex 3D scenes.
- Differentiate the Ray Tracer wrt arbitrary scene parameters for Gradient Based Inverse Rendering.
Installation
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:
@misc{pal2019raytracerjl,
title={{RayTracer.jl: A Differentiable Renderer that supports Parameter Optimization for Scene Reconstruction}},
author={Avik Pal},
year={2019},
eprint={1907.07198},
archivePrefix={arXiv},
primaryClass={cs.GR}
}
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
Triangle
s) 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 (seeMaterial
).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
tomarkdown
files. Look into its documentationNext 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.
Contents
Home
Getting Started Tutorials
- Introduction to rendering using RayTracer.jl
- General Attributes of the Scene
- Understanding the Light and Camera API
- Rendering Different Views of the Teapot
- Next Steps
- Inverse Lighting Tutorial
- Optimizing Scene Parameters using Optim.jl
API Documentation
Index
RayTracer.AccelerationStructure
RayTracer.BVHNode
RayTracer.BoundingVolumeHierarchy
RayTracer.Camera
RayTracer.DistantLight
RayTracer.FixedCameraParams
RayTracer.FixedParams
RayTracer.Light
RayTracer.Material
RayTracer.Object
RayTracer.PointLight
RayTracer.Sphere
RayTracer.Triangle
RayTracer.Vec3
RayTracer.rgb
Base.intersect
RayTracer.bigmul
RayTracer.camera2world
RayTracer.compute_screen_coordinates
RayTracer.convert2raster
RayTracer.edge_function
RayTracer.edge_function_vector
RayTracer.extract
RayTracer.fseelight
RayTracer.get_color
RayTracer.get_color
RayTracer.get_direction
RayTracer.get_image
RayTracer.get_intensity
RayTracer.get_normal
RayTracer.get_params
RayTracer.get_primary_rays
RayTracer.get_shading_info
RayTracer.get_transformation_matrix
RayTracer.light
RayTracer.load_obj
RayTracer.ngradient
RayTracer.numderiv
RayTracer.parse_mtllib!
RayTracer.place
RayTracer.place_idx!
RayTracer.rasterize
RayTracer.raytrace
RayTracer.reducehcat
RayTracer.reflection
RayTracer.reflection
RayTracer.set_params!
RayTracer.specular_exponent
RayTracer.specular_exponent
RayTracer.triangulate_faces
RayTracer.update!
RayTracer.world2camera
RayTracer.zeroonenorm
RayTracer.@diffops