3
$\begingroup$

I want to add spectral rendering and dispersion to my pathtracer. I found the Hero Wavelength paper but I have trouble implementing this. This is how I understand the process and where I am stuck:

  • When generating a ray, randomly sample a hero wavelength $\lambda_h$ with probability $p(\lambda_h)$. Is uniform sampling good enough?
  • Now, generate $C$ other wavelengths (a spectrum) using the rotation function $r_j$. Do we generate $C$ others, or $C-1$ so that in total there are $C$ wavelengths?
  • In the integrator when the BSDF contribution is evaluated, sample one of those $C$ wavelengths and call it $\lambda_s$. Does this include the hero wavelength? Are they sampled uniformly?
  • Evaluate the BSDF for $\lambda_s$ and add the contribution, weighted by the MIS weight and the probability of choosing this wavelength. How is the MIS weight computed? The paper says: $w_s(X_i, \lambda_i^s) = \frac{p(\lambda_i^h) p(X_i | \lambda_i^h)}{\sum_{k=1}^C p(\lambda_i^k) p(X_i | \lambda_i^k)}$ but where does the probability $p(X_i | \lambda_i^k)$ come from? Do I have to evaluate the BSDF direction for each wavelength to get a probability of choosing this path?
  • Generate the next path direction based on the BSDF and the hero wavelength.

My current implementation doesn't really differ from the single wavelength per ray model and has lots of coloured noise. As for the dielectric, I do:

  • compute IOR based on wavelength and the dispersion formula for a given material
  • compute fresnel with this new IOR
  • use a wavelength to RGB conversion to compute the material contribution

enter image description here

$\endgroup$
2
  • $\begingroup$ Not the most informative comment, but if you are not obliged to use hero sampling in anyway, try first sampling visible wave length range uniformly. It takes more time to render scenes but way easier to implement. Your color values just transform into power values as floating points that fills the visible wave length range. I can show post a link to a project of mine in github as well if you like ? $\endgroup$
    – Kaan E.
    Jan 7, 2021 at 5:06
  • $\begingroup$ 1. Uniform sampling is fine, but you can do better. 2. You want C total wavelengths. 3. The hero wavelength should be picked before any ray intersections happen. You don't change the hero wavelength between bounces. 4. The basic idea is that you have C BSDF evaluations (one per wavelength), C BSDF pdfs etc, but the direction of the new ray is based on the hero wavelength ONLY, and then combine results later with MIS. $\endgroup$
    – 64_
    Feb 10, 2021 at 14:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.