<p>I am trying to implement Beer's law according to <a href="http://www.eng.utah.edu/~cs6620/beers.pdf" rel="nofollow noreferrer">this</a> page in dielectric material but I am not sure have done it correctly as the image does not suggest so.</p>

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

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

<p>Below is the code and the image. </p>

<p>Could anyone shed some light if I have gone wrong. Thanks.</p>

<pre><code>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) &lt; 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() &lt; 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);
    }
}
</code></pre>

<p><a href="https://i.sstatic.net/4jgjp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4jgjp.png" alt="enter image description here"></a></p>

<p><strong>Update:</strong></p>

<p>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. </p>

<p>Thanks.</p>

CC BY-SA 3.0
2018-04-23T02:05:04.360Z
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
CC BY-SA 3.0
2017-07-25T18:26:07.953Z
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
<pathtracing><global-illumination><material>
Beer's law in dielectric material
ali
# Beer's law in dielectric material

(Asked by: username_0 on 2017-07-24)

I am trying to implement Beer's law according to [this](http://www.eng.utah.edu/~cs6620/beers.pdf) 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);
    }
}

```

[![enter image description here](https://i.sstatic.net/4jgjp.png)](https://i.sstatic.net/4jgjp.png)

**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.

**Tags:** pathtracing, global-illumination, material

> **Comments:**
> **username_2**: 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?  
> **username_1**: 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.  

---

## 0 answers

