- Home
- Programming ZEMAX
- User Defined Features
- How to Create a User-Defined Scattering Function
- Home
- Non Sequential Ray Tracing
- Sources, Splitting and Scattering
- How to Create a User-Defined Scattering Function
How to Create a User-Defined Scattering Function
- By Sanjay Gangadhara
- Published 21 February 2008
- User Defined Features , Sources, Splitting and Scattering
- Unrated
Generating the statistical description of a scattering distribution described by BSDF
If the scattering model is provided in terms of the Bi-Directional Scatter Distribution Function (BSDF), then the integrals necessary to relate the random numbers to the scatter angles include an extra cosq factor:
I = ∫∫ BSDF(q,f) sinq cosq dq df
The cosine factor arises from the fact that BSDF is defined in terms of the irradiance falling on the surface, and thus requires use of the projected surface area (Ap = A*cosq). Otherwise, the procedure for determining the scatter angles q and f is identical to the procedure described in the previous section.
Let’s look at a simple example – the case of a Lambertian scattering source. For such a source, the BSDF is constant for all angles, equal to 1/p. I is then given by:
I = ∫∫ BSDF(q,f) sinq cosq dq df
= (1/p)*[∫ sinq cosq dq]*[∫ df]
= sin2q*(f/2p)
The total integrated scatter is calculated by setting the limits of integration from 0 to p/2 in q and from 0 to 2p in f:
TIS = [sin2q (0:p/2)]*[f/2p (0:2p)] = [1-0]*[1-0] = 1
Therefore I is already normalized. Since the BSDF is separable in q and f in this case, it is straightforward to determine the scatter angles from the random numbers:
RN1 = sin2q; q = sin-1(√RN1)
RN2 = f/2p; f = 2p*RN2
The trajectory of the scattered ray s with respect to the surface normal n is given by:
sn = cosq
sp = sinq*cosf
sq = sinq*sinf
where p and q represent the coordinate axes on the plane perpendicular to the surface normal. The trajectory of the scattered ray in (x,y,z) space is easily determined from the known components of (n,p,q) in this coordinate system:
sx = sn*nx + sp*px + sq*qx
sy = sn*ny + sp*py + sq*qy
sz = sn*nz + sp*pz + sq*qz