appleseedhq / appleseed

A modern open source rendering engine for animation and visual effects
https://appleseedhq.net/
MIT License
2.21k stars 330 forks source link

Add a "Fresnel Blend" BSDF model #149

Open dictoon opened 12 years ago

dictoon commented 12 years ago

This BSDF model would be similar to the BSDF Mix or BSDF Blend models, except that the blending weights would be computed via Fresnel equations.

We already have code implementing Fresnel equations: https://github.com/appleseedhq/appleseed/blob/master/src/appleseed/foundation/math/fresnel.h

I would suggest using the real Fresnel equations, not the Schlick approximation.

The inputs to the Fresnel Mix BSDF model would be a pair of BSDFs and a pair of spectral (i.e. colored) IORs.

It would be nice to factor out the code common to the Mix, Blend and Fresnel Blend BSDF models.

wilimitis commented 5 years ago

This is a bit dated, but I studied the pbrt implementation when building out a bsdf for my personal lighting engine (though it ended up being more similar to Appleseed's BSDFMix (which randomly selects one of the components to sample based on a weight)), so I think would be in a position to try and tackle the FresnelBlend portion of this if it's still interesting (at least for appleseed core).

wilimitis commented 5 years ago

The following formulation comes to mind: given two BSDFs, bsdf1 and bsdf2, and two IORs, ior1 and ior2

evaluate(...) {
  F = fresnel(ior1, ior2, cos_theta)
  w1 = F, w2 = 1 - F
  value = bsdf1_value * w1 + bsdf2_value * w2
  pdf = bsdf1_prob * w1 + bsdf2_prob * w2
}

my thinking of this does not intentionally incorporate a "spectral IOR", as you've mentioned above, but the preexisting code in math/fresnel.h utilizes SpectrumType for eta, which seems to imply spectral IORs are supported to some degree.