PopcornFX v2.19

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
  1. Home
  2. Docs
  3. PopcornFX v2.19
  4. Scripting reference
  5. Quick start

Quick start

To create a new script node, right-click in a nodegraph and search for the Script node.
Then, with the new script node selected, add any input or output pins you want using the propertygrid:

Scripting quick-start: Create in/out pins

You can use the inputs to compute values that you then assign to the outputs.
Inputs and outputs can have the same name. If unused inside the script, the input will “pass-through” to the output that has the same name.

Note that the input & output names have to follow the usual naming constraints like in shader languages, C or C++: No spaces, no special characters, only letters or digits, and cannot start with a digit.

 

IMPORTANT: When you modify a script, you will need to apply the changes, using Ctrl+Enter
When there are changes to apply, an asterisk will appear next to the script in the nodal editor breadcrumb:

Apply script: No changesApply script: With changes

 

Here are some examples of simple scripts, next to their nodal equivalent:


Manually compute vector length

Returns the length of the input float3 vector.
You can find all the builtin math functions in the Builtin functions page.

 

Script node Input/Output setup:
Scripting example 1: Input/Output setup
Everything “by hand” using vector components:
Scripting example 3
Everything “by hand” but a bit shorter:
Scripting example 3
Using the dot-product function:
Scripting example 3
Using the length functions:
Scripting example 3
Equivalent using nodes in a template, three different ways:
Scripting example 3: Nodal version

 


Non-linear random value remapped with a power function

This changes the probability of the random value, so that values closer to zero appear more frequently than values at the high-end of the range:

 

Script node Input/Output setup:
Scripting example 1: Input/Output setup
Short way to write the script:
Scripting example 1
More verbose way with intermediate variables:
Scripting example 1
Equivalent using nodes in a template:

 


Random value using custom probability curve

Remaps an uniform [0,1] random value to a custom probability distribution represented by a custom curve, using the ‘sampleCDF’ function of the curve object.
You can see all available member functions on the Samplers page, and for curves specifically on the Curve Sampler page.
Note: If you do not explicitly declare the sampler input as being of type dataCurve, there will be a compile error in the script until you plug an actual curve object in the Curve input pin, because the default auto type will be evaluated as a bool when nothing is plugged in, and bools do not define a sampleCDF function.

 

Script node Input/Output setup:
Scripting example 2: Input/Output setup
One way to write the script:
Scripting example 2
Equivalent using nodes in a template:
Scripting example 2: Nodal version
Was this article helpful to you? Yes No

How can we help?