7.9. The TLSISroughPol scattering class
The scattering class TLSISroughPol is currently the key class used to simulate scattering events. It was used to model all materials relevant to this work. It represents a generic surface model that is able to model many different types of material interfaces ranging from transparent glass materials to opaque, coated surfaces. The method is usually initialised by providing the material interface data in the form of a TRCMaterialInterface object (see section 0) and specifying the reference direction of incidence (frontside or backside). As discussed above, the model essentially comprises a Fresnel module, a microfacet roughness module and a subsurface scattering module.

An overview of how scattering events are processed by the Process method of the TLSISrougPol class is depicted in Figure 105. The key processing steps, as indicated in the diagram, are:
(1) Using the parameters enteredTransparentMediumAlpha of the current ray (see section 7.3.1) and the distance between the current and the previous collision point, the probability for absorption is determined using equations (25) and (26). A potential absorption is sampled based on the integrated attenuation calculated along the path. In the case of absorption, the process halts (A1).
(2) The direction of the incoming ray and the reference vector for the polarisation state is rotated to the local (macroscopic) coordinate systems (see section 7.3.2) of the face hit. In the local system, the z-axis represents the surface normal vector 𝑛⃗ .
(3) If the roughness parameter of the surface is greater than zero, the orientation of a hit microfacet is sampled using the function sampleGGXVNDF. Based on the direction of the incoming ray and the surface roughness parameter, the function returns a random surface normal vector 𝑚⃗⃗ of the microfacet (see section 4.10.2). If the roughness parameter is zero, an ideally flat surface is assumed, applying 𝑚⃗⃗ ≡ 𝑛⃗
(4) To correctly perform the Müller matrix operations, the Stokes vector coordinates have to be transformed into the reference system of the microfacet (with 𝑚⃗⃗ as its z-axis). The Stokes vector transformation is performed by determining the rotation angle and then applying equation (67).
(5) The locally aligned Stokes vector of the incoming ray 𝑆 is multiplied with the Müller matrices for reflection and transmission (equations (64) and (65)) in order to determine the Stokes vectors of the reflected (𝑆 𝑅) and transmitted (𝑆 𝑇) ray.
(6) The total irradiance of the reflected and transmitted ray is contained in the first coordinate (𝑆0) of the related Stokes vectors. The parameters represent the Fresnel coefficients. Following the MC approach, they are used as probabilities to sample the outcome of the scattering at the microfacet:

The absorption is determined based on energy conservation. It reflects the absorption occurring at the material interface and will, therefore, only have a non-zero value if thin-films are present.
(7) Using a uniformly distributed random number and the determined probabilities R, T and A, the outcome of the scattering event is determined.
(8) The direction of the reflected ray is determined by applying the law of reflection, considering the incidence direction and the orientation of the current microfacet.
(9) Since no path splitting is applied (see section 7.1), the reflection path is followed with the full initial intensity. Hence, the Stokes vector of the outgoing ray is defined as the nomalised Stokes vector of the reflected ray (equation (62)).
(10) By calling the shadowing function for the chosen, correlated or uncorrelated surface roughness model (see section 4.10), the probability for an unobstructed path in the outgoing direction is determined. If the sampling determines that a further microfacet obstructs the outgoing path, the process returns to step (3) and determines a new microfacet based on the current direction. If the path is unobstructed, the process exits with a reflection event (R1). In this case, the reflected beam is polarised.
(11) Based on the current wavelength and the applied subsurface reflection model (see section 4.11.2), it is determined if the ray is scattered back directly below the surface.
(12) The subsurface-scattered ray is assumed to be unpolarised and diffusely reflected. The outgoing direction is sampled accordingly, and the scattering process is terminated (R2). Further A full spectral polarisation Monte-Carlo Raytracer RadiCal, D. Rüdisser 171 reflections or refractions on the microfacet structure are not considered, as it is assumed that the occurring subsurface scattering is the final result of multiple scattering events.
(13) If the material is defined as opaque by settings its transparent property to false, any ray penetrating below the surface is absorbed, and the raytracing terminated (A3).
(14) The new direction of the transmitted ray is determined, considering refraction at the microfacet. The angle of refraction is a by-product of the Müller-matrix generation in step (5). It is used to generate the direction vector of the outgoing ray.
(15) In the rather exceptional case that the microfacet refracts the light towards the incidence medium again, it is assumed that after one or more further scattering events, the ray will finally leaves the surface again. Therefore, this case is treated like the subsurface scattering event.
(16) In analogy to subsurface-scattering (12), the outwards refracted ray is assumed to leave the surface unpolarised with a direction following the ideal diffuse distribution.
(17) Since no path splitting is applied (see section 7.1), the transmission path is followed with the full initial intensity. Hence, the Stokes vector of the outgoing ray is defined as the nomalised Stokes vector of the reflected ray (equation (62)).
As can be seen in the diagram, the Process function can terminate in seven different ways:
(A1) The ray is (was) absorbed by attenuation in the medium on its path towards the current collision point
(A2) The ray is absorbed within the thin-flim stack applied on the surface.
(A3) The ray is absorbed after being transmitted below the surface.
(R1) The ray is reflected on the flat surface or a microfacet. The ray is polarised.
(R2) The ray is reflected on multiple scattering events below the surface. The ray is fully depolarised and diffusely reflected.
(R3) The ray is refracted towards the incidence medium within the microfacet surface. The ray is fully depolarised and diffusely reflected.
(T) The ray is transmitted, i.e. refracted into the second medium. The ray is polarised.
The function exits and returns the result value lsiAbsorbed, lsiReflected or lsiTransmitted. If the ray is reflected or transmitted, the polarisation, direction and origin of the TStokesRay object that was passed to the function are updated accordingly.