Krakatoa Options¶
Available in: Krakatoa v1.0.0 and higher
Overview¶
- The Krakatoa Options operator can be used to transfer data from the scripted float channel and the scripted vector channels into the density and color channels respectively.
- This effectively allows for scripted control of the shading of Krakatoa particles.
Usage¶
Using A Script Operator¶
- Add a Script Operator to the flow.
- Enable the scripted float in the on ChannelsUsed event handler by:
on channelsUsed pCont do (
pCont.useFloat = true
- Enable the scripted vector in the on ChannelsUsed event handler by:
pCont.useVector = true )
- In the on Proceed … event handler, set the particle’s scripted float values (X should be replaced with a fixed or computed value in your code):
on Proceed pCont do (
pCont.particleFloat = X
- In the on Proceed … event handler, set the particle’s scripted vector values (X,Y and Z should be replaced with fixed or computed values in your code):
pCont.particleVector = [X,Y,Z] )
- Add a Krakatoa Options operator to the Particle Flow Event.
- Select MXSFloat->Density to scale the particle’s density channel by the value in that particle’s scripted float channel.
- Select MXSVector->Vertex Color to set the particle’s vertex color channel to the value in that particle’s scripted vector channel.
Using A Data Operator¶
- You can also get the same effects using the Data Operator.
- This is the recommended approach because it is orders of magnitude faster than running a script to fill in the data in the Scripted Float and/or Scripted Vector channels.
- When using a Data Operator, it is more efficient to write directly into the Vertex Color channel than to use the Scripted Vector channel.
- In that case, the Krakatoa Options Operator is not necessary or the option MXSVector->Vertex Color should at least be unchecked.
- When writing to the Density channel which is not a native Particle Flow channel, you still have to use the Data Operator to write to the Scripted Float channel and use Krakatoa Options with MXSFloat->Density checked to copy the data for Krakatoa to see.
IMPORTANT! Remember to disable any Material operators if you are intending to render the colors stored in the Vertex Color channel of the Particle Flow directly.
Rendering Vertex Color Channel Through A Material¶
- The Material is the top-level color source in Krakatoa, followed by the Vertex Color channel, then by the node’s wireframe color (ie. the Display Operator).
- If you do use a material in Particle Flow, the colors from the Vertex Color channel can be accessed within the material by adding a Vertex Color Map (Channel 0) to the diffuse map channel.
- This requires each particle to evaluate the material in the shading context which is a lot slower than writing the Vertex Color data directly into the Krakatoa Color channel.
- On the other hand, you can use the Vertex Color Map in combination with other Maps to blend the particle colors of multiple sources, so the Material approach, while slower, is a lot more flexible.
