The Script Coating is a general coating model which allows complex reflection and transmission coefficients to be computed based on ray position, angle of incidence, wavelength and the complex index of refraction of the incident and substrate materials, where the ray position is provided in the local coordinate system of the surface being intersected. The reflection and transmission coefficients are expressed in terms of magnitude and phase for both S-polarization and P-polarization.
The Script Coating can be created in the following ways: •Open a new coating dialog and select "Script Coating (coating defined by user script)" as the coating type.
The coating definition MUST be expressed in terms of an IF..THEN statement. Since FRED passes a Boolean into the routine to indicate whether the calculation is being made for a reflected ray or not, g_refl must necessarily act as the condition for this IF..THEN statement. A trivial example setting the reflectance to 0.9 and transmittance to 0.1 is shown here:
If g_refl Then 'reflection magnitudes and phases g_magS=Sqr(0.9) : g_phsS=0 g_magP=Sqr(0.9) : g_phsP=0 Else 'transmission magnitudes g_magS=Sqr(0.1) : g_phsS=0 g_magP=Sqr(0.1) : g_phsP=0 End If
Definition of script variables For coating reflectance: g_magS = |r^| and g_magP = |r||| For coating transmittance: g_magS = √(ps/pi)·|t^| and g_magP = √(qs/qi)·|t|||, where ps,i = ns,i cos(qs,i) and qs,i = cos(qs,i)/ns,i. Likewise, the phases for each polarization are derived from the expressions tan(dr) = Im[r] / Re[r] and tan(dt) = Im[t] / Re[t].
Example: Radial thickness variation See the <install directory>\Resources\Samples\Coatings\ directory of your FRED installation for an example of a scripted coating (coatingRadiallyVaryingSingleLayer.frd) which creates a single layer ZnSe coating with radial thickness variation.
In FRED, coatings and materials store information about the last evaluation that was made. For coatings, this would be the R and T components for a ray with a given wavelength, position, direction, etc. For materials, this would be the real and imaginary indices for a ray with a given wavelength, position, direction, etc. The advantage of storing this information is that if the current incoming ray has the same properties as the last ray, there is no need to re-evaluate the coating or material properties and the raytrace can proceed much quicker.
In the case of the scripted coating this implementation can potentially cause problems. For example, suppose the rays incident on the scripted coating all have the same general properties (position, direction, wavelength). The first ray will trigger a successful evaluation of the coating, but the subsequent rays, having the same properties as the first, would not trigger a new evaluation of the coating. If the scripted coating contained any elements of randomness (via a random number generator, for example), only the first ray in the queue would reflect this random modification. The rays following it would be modified in the same manner as the first ray.
When multi-threaded raytracing is used, rays on the same thread will exhibit the behavior described above.
At the start of a new raytrace, all coatings are flagged as requiring a new evaluation for the first ray that is encountered.
It is strongly recommended that the script make no modifications to other nodes in the FRED document.
If a change is made to the document during the raytrace by way of the scripted entity, the state of the document as seen by each individual thread of the raytrace will be inconsistently defined and the results of the raytrace may not be valid.
Coatings - General Sampled Coating Coatings - Polarizer / Waveplate Coating Coatings - Quarter Wave Single Layer Coatings - Thin Film Layered Coating Materials - Scripted Volume Scatter Materials - Scripted Gradient Index Material Scripted Scatter Model (surface)
|
||||||||||||||||||||||||||||||||||||||||||||||||