Beer's law in dielectric material

I am trying to implement Beer's law according to this page in dielectric material but I am not sure have done it correctly as the image does not suggest so.

The formula is: I(s) = I(0) * pow(e, ln(A)*s)

'A' is said to be transmission coefficient which I am not clear what this is and what value I should use for it.

Below is the code and the image.

Could anyone shed some light if I have gone wrong. Thanks.

public override LightVector SampleBrdf(ISect isect, Random rand,
out LightVector woW, out double pdfDir, out double cosWo)
{
woW = LightVector.ZERO;
cosWo = 0;
LightVector n = isect.Thing.Normal;
LightVector tan = isect.Thing.Edge1;
tan.Normalize();
LightVector ts = n.Cross(tan);

//set wo to be incoming dir
LightVector wo = MaterialHelper.WorldToLocal(-isect.Ray.Dir, tan, ts, n);dir
LightVector refracted = LightVector.ZERO;
LightVector reflected = new LightVector(-wo.X, -wo.Y, wo.Z);

double F = Fresnel.Evaluate(rindex1, rindex2, MaterialHelper.CosTheta(wo));
pdfDir = F;

//Figure out which eta is incident and which is transmitted
double extCoeff = 1;
double etaI = rindex1;
double etaT = rindex2;
LightVector z = new LightVector(0, 0, 1);
if (MaterialHelper.CosTheta(wo) < 0)//existing
{
etaI = rindex2;
etaT = rindex1;
z = -z;
extCoeff = Math.Exp(-Math.Log(A, Math.E) * isect.Dist);
}

//Compute ray direction for specular transmission
if (!MaterialHelper.Refract(wo, z, etaI / etaT, out refracted))
pdfDir = 1;

if (rand.NextDouble() < pdfDir)
{
woW = MaterialHelper.LocalToWorld(reflected, tan, ts, n);
cosWo = MaterialHelper.AbsCosTheta(reflected);

return R * (F / cosWo);
}
else //refracted
{
woW = MaterialHelper.LocalToWorld(refracted, tan, ts, n);
cosWo = MaterialHelper.AbsCosTheta(refracted);
pdfDir = 1d - F;

return T * (extCoeff * (1d - F) / cosWo);
}
}


Update:

I was expecting to see the reflection of the light source at the ceiling on the glass. But it was my mistake in the caller method where the specular bounce contribution was dismissed.

Thanks.

• From a quick glance it looks like your application of Beer's law is correct. The image also looks reasonable to me. Can you clarify what you think is wrong, and why? Have you compared the same scene in another path tracer so you can tell if there are subtle differences? – Nathan Reed Jul 25 '17 at 18:26
• Try a large absorption coefficient ( say vec3(8,8,1) ), for thin objects like the ones in your screenshots it may not be thick enough to have much of an effect. – PaulHK Apr 23 '18 at 2:05