Skip to content

the 2016 polynomial wide angle optics paper code as git repo

Notifications You must be signed in to change notification settings

hanatos/lensoptics

Repository files navigation

Overview

The provided code can be used to find sparse polynomials transferring rays through a lens system.

It is part of our paper:
Schrade, E., Hanika, J., & Dachsbacher, C. (2016). Sparse high-degree polynomials for wide-angle lenses. In Eurographics Symposium on Rendering.

With the source code you can:

  • read lens definitions and (generic) polynomials,
  • fit a polynomial to a specific lens system, (optionally only a specified number of terms is chosen from the polynomial that best fits to the lens)
  • view the lens as well as rays traced through the lens system and compare the ray-traced rays to the output of the fitted polynomials,
  • generate code from the fitted polynomials to use it in your own renderer (includes aperture sampling for both path tracing and light tracing)

Dependencies

Our fitting algorithm uses the library Eigen and we use GTK+ and cairo for our viewer. Apart from that there are no external dependencies.

Building

We provide a Makefile for building the tools. Most of them require only a single source file and some common headers.

The headers in folder src include the following:

  • lenssystem.h: parse lens systems
  • poly.h: read and write (binary) polynomials and functions to evaluate and calculate derivatives
  • raytrace.h: trace rays through a lens system
  • raytrace_draw.h: same as raytrace.h, but draw lines while tracing (only for view)
  • gencode.h: helper functions to generate code from polynomials, e.g. for aperture sampling
  • spectrum.h: helper functions for approximating the refractive index for a given wavelength.

Description of the tools

  • genpoly: generates a generic polynomial with terms up to a defined degree and stores the polynomial to a binary file at a given path (fit loads polynomials from sorted.poly)
    example: ./genpoly 11 sorted.poly
  • parsepoly: reads a csv file containing terms of a polynomial system and stores them in binary format (as genpoly does)
    example: ./parsepoly poly.csv sorted.poly
  • printpoly: reads a binary polynomial file (e.g. the output from genpoly or parsepoly) and outputs the terms to console in a csv format (that could be read by parsepoly again)
    example: ./printpoly sorted.poly
  • fit: loads a generic polynomial from file sorted.poly and fits the coefficients to a specified lens.
    Additionally to the path to the lensfile arguments can be set to limit the maximum degree of terms (e.g. if sorted.poly contains terms of higher degree that should be ignored) and the number of terms per equation (if sorted.poly contains a larger number of terms and we search for a sparse solution).
    fit creates files lensfile.fit and lensfile_ap.fit containing the fitted polynomials for the outer pupil and sensor respectively. (These files have the same format as .poly-files and can hence, be inspected using printpoly)
    example: ./fit lenses/fisheye-aspherical.fx 11 28
  • view: reads and draws a specified lens. If fitted polynomials were calculated, i.e. if .fit-files exist, both the aperture polynomial and the outer polynomial are evaluated as well such that their output can be compared to the ray-traced reference.
    example: ./view lenses/fisheye-aspherical.fx
  • gencode: generate code from a fitted polynomial. Creates header files for evaluating the polynomials transferring rays to the sensor / aperture, and for aperture sampling.
    example: ./gencode lenses/fisheye-aspherical.fx
    For examples how to use the generated code see render/lens.h

About

the 2016 polynomial wide angle optics paper code as git repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published