Smooth dielectric material

# Smooth dielectric material #

A smooth dielectric BSDF can be used to model transparent objects like glass, diamonds or water. Smooth dielectric either reflect light or let it pass through without absorbing its energy.

## Reference scene using Mitsuba 3 #

The following image shows an example of scene rendered with Mitsuba 3 that contains a sphere (the sphere in the foreground) with a smooth dielectric material:

The BSDF for the dielectric sphere is defined as:

<bsdf type="dielectric">
<string name="int_ior" value="bk7"/>
<string name="ext_ior" value="air"/>
</bsdf>


More details on the supported parameters in Mitsuba 3 can be found here.

## Fresnel equations #

One interesting question is how can we find out how much light enters our smooth dielectric material and how much light is reflected. This can be computed using Fresnel equations. The precentage $$R$$ of reflected light can be computed by:

$$R = r_\perp + r_\parallel$$ $$r_\perp=\frac{n_i \cos\theta_i - n_t\cos\theta_t }{n_i \cos\theta_i + n_t\cos\theta_t }$$ $$r_\parallel=\frac{n_t\cos\theta_i - n_i \cos\theta_t}{n_t\cos\theta_i + n_i \cos\theta_t}$$ $$\cos\theta_t=\sqrt{1 - (\frac{n_i}{n_t}\sin\theta_i)^2}$$ $$\cos\theta_t= \sqrt{1 - (\frac{n_i}{n_t}^2(1-\cos^2\theta_i))}$$ $$r_\perp=\frac{n_i \cos\theta -n_t\sqrt{1 - (\frac{n_i}{n_t}^2 sin^2\theta)}}{n_i \cos\theta +n_t\sqrt{1 - (\frac{n_i}{n_t}^2 sin^2\theta)}}=\frac{n_i \cos\theta -n_t\sqrt{1 - (\frac{n_i}{n_t}^2(1-\cos^2\theta))}}{n_i \cos\theta +n_t\sqrt{1 - (\frac{n_i}{n_t}^2(1-\cos^2\theta))}}=\frac{\cos\theta -\eta\sqrt{1 - (\frac{1}{\eta}^2(1-\cos^2\theta))}}{\cos\theta +\eta\sqrt{1 - (\frac{1}{\eta}^2(1-\cos^2\theta))}}$$ $$r_\parallel=\frac{n_i \sqrt{1 - (\frac{n_i}{n_t}^2 sin^2\theta)} -n_t\cos\theta}{n_i \sqrt{1 - (\frac{n_i}{n_t}^2 sin^2\theta)} +n_t\cos\theta}=\frac{n_i \sqrt{1 - (\frac{n_i}{n_t}^2(1-\cos^2\theta))} -n_t\cos\theta}{n_i \sqrt{1 - (\frac{n_i}{n_t}^2(1-\cos^2\theta))} +n_t\cos\theta}=\frac{\sqrt{1 - (\frac{1}{\eta}^2(1-\cos^2\theta))} -\eta\cos\theta}{\sqrt{1 - (\frac{1}{\eta}^2(1-\cos^2\theta))} +\eta\cos\theta}$$
float FresnelDielectricDielectric(float Eta, float CosTheta)
{
float SinTheta2 = 1 - CosTheta * CosTheta;

float t0 = sqrt(1 - (SinTheta2 / (Eta * Eta)));
float t1 = Eta * t0;
float t2 = Eta * CosTheta;

float rs = (CosTheta - t1) / (CosTheta + t1);
float rp = (t0 - t2) / (t0 + t2);

return 0.5 * (rs * rs + rp * rp);
}


TODO: write a test for fresnel…

## How to implement a BSDF for a smooth dielectric material? #

In the last sections we defined the following interface for materials:

strct BSDFSample {
Vector3f wi;
Vector3f wo;
}

class BSDF {
[[nodiscard]] virtual Color3f sample(BSDFSample& sample, const Point2f& sample_point) const = 0;
[[nodiscard]] virtual Scalar pdf(const BSDFSample& sample) const = 0;
[[nodiscard]] virtual Color3f evaluate(const BSDFSample& sample) const = 0;
};


We also defined a reflection coordinate system.

Some A smooth dielectric material is a type of material that reflects some part of the light it r

## Plan #

Diffuse -> Mirror -> Dielectic -> Smooth Conductors? Spectrum/ Skybox/AO for matieral probe scene