Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two questions about spectral rendering and output #318

Open
StefanMenzel opened this issue Jan 25, 2022 · 6 comments
Open

Two questions about spectral rendering and output #318

StefanMenzel opened this issue Jan 25, 2022 · 6 comments

Comments

@StefanMenzel
Copy link

Hello,

First of all, thank you for the great book. It is a really useful read to understand spectral rendering in particular and the maths behind tracing. I have two questions that are hopefully easy to answer.

  1. How easy is it to modify the code to save spectral images as output instead of XYZ (or RGB)?
    From what I gather, I would 'just' have to grab them before the SampledSpectrum method ToXYZ computes XYZ from the spectra (the Rieman sum for equ. 5.1, chapter 5.2.1). I am aware the amount of data would much larger (eg 20 times that of RGB for 20 spectral points). It would be great to have this as a cmake option in pbrt v4.

  2. How easy is it to integrate optical dispersion, i.e. wavelength dependence of refractive index for realistic camera lenses?
    The realistic camera works well, but I would like to try and add dispersion to the lens materials. Would it be ok to have a look-up table n(lambda) and grab the corresponding refractive indices from it for each wavelength while tracing instead of assuming the refractive index as constant?

I am trying to get a feeling on how deep the coding rabbit hole is for those two suggested additions. (few lines of code or engine rewrite)

@StefanMenzel StefanMenzel changed the title Two question about spectral rendering and output Two questions about spectral rendering and output Jan 25, 2022
@mmp
Copy link
Owner

mmp commented Jan 25, 2022

  1. Won't be an option in pbrt-v4, but it will be an exercise in the book. :-) One issue is that there isn't a widely adopted image file format standard for such images, though there's been recent progress on that front. It should be fairly easily to implement in pbrt-v4 via a new Film implementation.

  2. This should be quite easy, like tens of lines of code in RealisticCamera. You need to terminate all but the primary wavelength via a call to Spectrum::TerminateSecondary() and then do whatever you decide to figure out the IOR at each lens interface intersection. (The Cauchy equation or Sellmeier equation could be useful; see https://wiki.luxcorerender.org/Glass_Material_IOR_and_Dispersion#Refractive_Index_and_Dispersion_Data for useful discussion.)

@KelSolaar
Copy link

Hey Matt,

For 1, what about the EXR extensions proposed by Fichet et al. (2021): An OpenEXR Layout for Spectral Images

Cheers,

Thomas

@mmp
Copy link
Owner

mmp commented Jan 26, 2022

@KelSolaar yep, that seems like the leading contender at this point!

@StefanMenzel
Copy link
Author

thank you both for helping! It is good to know that both points 1. and 2. are rather easy to integrate.

For output I will probably just store all spectral data in the color channels of a couple of exr files for now.
The Cauchy/Seilmeier fitting functions for dispersion look good. I was going to use a polynomial fit or just do a lookup table, but this looks better or more widely recognized.

@mmp
Copy link
Owner

mmp commented Mar 1, 2022

FWIW I've implemented Fichet et al's OpenEXR spectral encoding in pbrt-v4 and just pushed it to github.

@StefanMenzel
Copy link
Author

Thanks for that! Definitely looking forward to the v4 book release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants