# Plotting Surface Particulate (Mie) Scatter

For most scatter models there is no difference in the BSDF values between transmitted and reflected scatter, and so there is no need designate whether a plot in transmission or reflection.

However, the Surface Particle (Mie) Scatter model is a volume effect having scatter components both forward and backward that may need to be accounted for in a plot of the BSDF, but the default plot in FRED will be for the reflected scatter only.

The FRED file included with this knowledge base article has an embedded script which writes out BSDF data to Microsoft Excel for plotting and accounts for application of the model in transmission.

## Script Overview

The embedded script creating the plot makes use of FRED’s ability to communicate with programs such as Microsoft Excel using COM and the ScatterEval scripting function. The pseudocode for the script is the following:

1. Find Mie scatter node and get its properties.
2. Create Excel application object and workbook
3. Begin loop over incident angles.
1. Set incident and specular direction vectors (accounting for transmission or reflection).
2. Begin loop over scatter angles.
1. Set scatter angle on range from -89.5 to 89.5 degrees
2. Calculate BSDF value from incident, specular and scatter vectors using the ScatterEval function
3. Write BSDF value to Excel
4. Plot the results in Excel

The coordinate system used for the incident, specular and scatter direction vectors is shown in Figure 1 below. In the case of transmission, the specular direction vector is the same as the incident direction vector. In the case of reflection, the specular direction vector changes sign in the z-direction.

Other than setting up the Excel objects and specifying the direction vectors, there are only a few commands in the script specific to the scatter model itself. The scatter specific script commandsused are:

FindScatter – Returns the node number of the scatter model.

ScatterPrepareForEval – Initializes a scatter model internally for evaluation. This must be run before a ScatterEval command.

GetMieScatter – Loads the settings for the mie scatter model into the T_MIESCATTER structure. The ApplyRefl structure member determines plotting in reflection or transmission.

ScatterEval – Returns the BSDF value for a given set of incident, specular and scatter direction vectors.

ScatterTIS – Returns the total integrated scatter for the requested mode