Navigation: Scripting Reference Manual > Script Examples > Examples - Scatter Model Script Command

 

Examples - Scatter Model Script Command

 

Contact Us: fredsupport@photonengr.com

 

These examples cover the basic FRED scripting commands involving scatter models:

"Add" - adds a new scatter model to the existing list,

"Find" - used to determine the identifier of an existing scatter model,

"Get" - retrieves information from an existing scatter model,

"Init" - initializes a structure with default values, and

"Set" - sets properties of an existing scatter model.

 

The scatter model structures listed below contain the parameters required to fully define the model type:

T_ABGSCATTER

T_BLACKPAINT

T_DIFFUSEBINOMIAL

T_DIFFUSEPOLYNOMIAL

T_GAUSSIANSCATTER

T_HARVEYSHACKSCATTER

T_KCORRELATIONSCATTER

T_LAMBERTIANSCATTER

T_MIESCATTER

T_PHONGSCATTER

T_SCATTER

T_SCRIPTSCATTER

T_TABULATEDSCATTER
 

While each model has a specific set of numerical parameters dictated by its functional description, every model has a name and description as well as three Boolean parameters "ApplyRefl" (default=True), "ApplyTrans" (default=False) and "HaltIncident" (default=True).


 

"Add" a Scatter model

Regardless of type, "Adding" a scatter model requires the same set of steps:

Declare the appropriate structure.

Set the desired parameters of that scatter model structure.

"Add" the model.

 

For example, a Black Paint model is added as follows:

 

Dim s As T_BLACKPAINT
Dim id As Long

s.Refl = 0.05
s.Name = "New Flat Black Paint Model"
s.Description = ""
s.ApplyRefl = True
s.ApplyTrans = False
s.HaltIncident = True

id = AddBlackPaint(s)
Print "The index of the new scatter model is ", id


 

"Find" a scatter model identifier

Finding a scatter model identifier requires only that the model name be known. For example, the following statement finds the identifier of a scatter model named "MyPhong".

 

sname="MyPhong"

id = FindScatter ( sname )


 

"Get" a scatter model

The Get operation retrieves properties of a specified scatter model and places them in a structure.

 

For example, the following lines "Get" the properties of the predefined HarveyShack scatter model found in each FRED document. The Find operation is used to determine the scatter model identifier. Note that a structure must be declared to hold this information. Consult the specific model type

 

Dim Hscat As T_HARVEYSHACKSCATTER

Dim s$

 

s = "Harvey Shack"

sid = FindScatter(s)

 

GetHarveyShackScatter sid, Hscat

 

Print "The b0 value is ", Hscat.b0

Print "The rollover L value is ", Hscat.L

Print "The slope S value is ", Hscat.S

Print "Model name is ", Hscat.name

Print "Model description is ", Hscat.Description

Print "Apply to reflection? ", Hscat.ApplyRefl

Print "Apply to transmission? ", Hscat.ApplyTrans

Print "Halt the incident ray? ", Hscat.HaltIncident


 

"Init" a scatter model

The 'Init" operation serves to initialize a scatter model structure with its default values. See the individual scatter model descriptions for a detailed list of defaults for each. Note that the defaults include not only numeric values. Initializing a model includes giving it a name and description as well as setting whether the model is used in reflection, transmission or both and whether an incident ray will be terminated or not.

 

To initialize a Diffuse Polynomial model requires only

 

Dim dp As T_DIFFUSEPOLYNOMIAL
InitDiffusePolynomial dp

 

or to initialize a scripted scatter model,

 

Dim scrpt As T_SCRIPTSCATTER

InitScriptScatter scrpt


 

"Set" a scatter model

The "Set" operation can be used to either replace specific parameters in a scatter or in conjunction with an "Init" operation to restore default values.

 

In the following example, a T_ABGSCATTER structure is declared to hold the model parameters. The structure is then initialized to hold the default values of an Abg Scatter model. The identifier of an existing scatter model "abgscat" is found using FindScatter whereby the default values are restored with SetAbgScatter.

 

Dim s As T_ABGSCATTER
InitAbgScatter s
 

sname="abgscat"
sid = FindScatter(sname)
 

SetAbgScatter sid, s

 

In this example, the "Set" type is used to replace specific parameters in an existing scatter model named "abgscat". Note that a structure is declared to hold existing model parameters and then loaded into that structure using a "Get" operation. Once loaded, specific parameters (A & G coefficients in this case) are set to desired values then the "Set" operation is executed.

 

sname="abgscat"
sid = FindScatter(sname)

 

Dim sabg As T_ABGSCATTER

GetAbgScatter sid, sabg

 

sabg.Acoef=0.002

sabg.G=2.2

 

SetAbgScatter sid, sabg


See Also….

Advanced Raytrace

Basic Raytrace

Coatings

Curves

Elements

Entity Info

General Ray Data

Gratings

Importance Sampling

Linear Transforms

Materials

Ray Buffer Handling

Ray Data Get/Set

Ray Path

Raytrace Control

Sources

Surfaces

 

 

 

 

 

 

 

 

 

 

 

Copyright © Photon Engineering, LLC