Skip to content

jallmenroeder/sh_fit

Repository files navigation

BRDF fitting for Linearly Transformed Spherical Harmonics (LTSH)

THIS IS A WORK IN PROGRESS REPOSITORY

Implementation of the BRDF approximation process for LTSH. This Code is reimplementation of the code used in my Bachelor's Thesis with improved sampling. The original python implementation used code not intended for publication, so I decided to do an improved reimplementation in C++. Currently, the implementation has issues that make the resulting fits less desirable than the original fits from the python implementation. The LTC fitting implementation contains a lot of NaNs and the LTSH quality is often worse than that from the python fitting. However the code shows how we generally approached the problem and might help people doing further research with LTSH. I hope to find the time to fix the implementation and make it a true improvement of the python version.

Dependencies

The code is built using CMake and C++14. It depends on the GLM library and GSL for the minimization algorithms and SH evaluation. I work under Linux and the repo should build if the libraries are installed. I did not focus on builds on other platforms.

How to use

In the main function you can either give a clamped cosine function or a spherical harmonic function of arbitrary degree to the fitting process. The fitting process is executed in parallel by the threadpool and handles initialization with params from LTC by Heitz et al.. The actual fitting happens in the LTSF class. Here the matrix for the linear optimization of the SH coefficients (or the constant norm factor for LTC) is created by multiple importance sampling the target BRDF and the cosine weighted hemisphere. The non-linear optimizer for the parameters of the linear transformation uses this function to explore the parameter space. The configuration of the non-linear optimizer is changed throught the constants at the beginning of LTSF.cpp. If you want to fit a different BRDF you can implement it against the BRDF.h interface and use it in the constructor of the LTSF class instead of the GGX BRDF.
As always there a lot of things I would do different if I would implement the repo from scratch again but one has to move on at some point. If you have questions regarding this repo or LTSH in general do not hestitate to get in touch with me (contact info is provided at my website).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published