| Previous Topic (None) | Up (Contents) | Next Topic (Blending Particle File Sequences Using Krakatoa Particle Flow Operators) |
Using Krakatoa Particle Flow File Operators
- 1 Using Krakatoa Particle Flow File Operators
Introduction
Krakatoa 1.1 introduced a set of Particle Flow Operators designed to load saved Particle Sequences (PRT, CSV and BIN files) back into 3ds Max including support for dynamic particle counts, in other words, handing of particle birth and death.
The following tutorial will explain the basic concepts and workflows of these Particle Flow Operators including the Krakatoa File Birth, Krakatoa File Update and the Krakatoa ID Test operators.
Creating and Saving the Particle Flow
For our test, let's create a very simple particle flow emitting raindrop-like particles over 100 frames, colliding them with a ground planar Deflector and Spawning circles at collision while deleting the parent and then deleting the spawned particles by age. This will give us a system with varying particle count and multiple events including birth, spawning and deleting of particles.
Creating the Particle Flow
- Start a new 3ds Max scene.
- Create a default PF Source on the ground plane with width and length of about 40x40 units.
- Move the PF Source up along +Z by 50 units.
- In the Emission Rollout, set the Viewport % to 100.0.
- In the System Management rollout, set the Viewport Integration Step to Half Frame to match the Render Integration Step.
- Create a Deflector Space Warp in the ground plane with a size of 140x140
Adjusting the Particle Flow
- In the Particle View, change the Birth operator to emit 100 particles from frame 0 to frame 100.
- Change the Speed operator to 100 units
- Delete the Rotation operator
- Delete the Shape operator
- Change the Display operator to "Lines" and the color to cyan (128,255,255)
Spawning Particles On Collision
- Add a Collision Spawn test after the Speed operator
- Pick the Deflector from the scene as the collision object.
- Set the Collision Spawn to emit 50 Offsprings.
- Drag a new Speed operator into the Particle View to create a new Event.
- Wire the Collision Spawn to the new Event
- Set the Speed operator to Random Horizontal and Speed value of 50.0
- Add an Age Test to the same Event, set it to Event Age and Test Value 10 +/-3
- Drag a new Delete operator to the Particle View and wire the new Event to the Age Test.
Saving Particles To File Sequence
- Open the Krakatoa GUI - if prompted about setting the current renderer to Krakatoa, answer with No to use the Defaults.
- Switch the Particle Render Mode to "Save Particles To File Sequence".
- In the Save Particles rollout, click the [...] button and specify an output path. Save with .PRT file extension.
- Right-click the SAVE PARTICLES button and select "Active Segment [0-100]" to save 101 frames.
- Press the SAVE PARTICLES button to process the particles - should take a couple of seconds to save all files.
Loading the Particle File Sequence Back Into Particle Flow
- Create a new PF Source either in the scene or in Particle View.
- Replace the default Birth operator with Krakatoa File Birth.
- Replace the Position operator with Krakatoa File Update.
- Delete the Rotation and Shape operators.
- Set the Display operator to "Circles" and Red color.
- In the Krakatoa File Birth, click on the [...] button and pick one of the files from the saved sequence.
- In the Krakatoa File Update, click on the [...] button and pick one of the files from the same saved sequence.
Since by default all positions are loaded in World Space, the circles should appear around the original particles from the first particle system. But if you scrub farther in the time line, the loaded particles will not die but remain in the flow.
I Can See Dead Particles...
To remove the particles that have been killed off, we have to use the Krakatoa File ID Test operator.
When the Krakatoa File Birth is loading a file, it compares the particle Born IDs stored in the ID channel with the IDs already loaded into the flow. If an ID does not exist in the flow but does exist in the file, the particle with that ID will be added to the flow, in other words, "born". If a particle ID was available in the flow but does not appear in the file sequence anymore, that particle can be considered "dead" and this fact is marked in a dedicated Krakatoa-specific particle data channel called "FileID" by setting the ID value to -1 instead of a positive or zero value.
The Krakatoa File ID Test operator can be used to test the values in the Krakatoa-specific "FileID" channel and send out particles whose IDs fall in a specific range. The default settings of the Test send out any particles with a value below 0, in other words, the "dead" particles.
- Add a Krakatoa File ID Test to the second particle flow.
- Drag and Drop a Delete operator into Particle View.
- Disable the Delete operator for now and wire the Krakatoa File ID Test to the new event.
- Set the Display operator in the second event to "Dots" and Green color.
You will notice that all particles that should have died are now green dots, while the red circles mark only alive particles from the first flow:
- Enabling the Delete operator in the second event will remove any particles that do not exist in the original flow anymore based on their negative FileID value:
Loading Velocities
By default, the Krakatoa File Update operator will load only the Position and ID channels from the file sequence. But our file sequence contains a lot more channels - all the default channels set in the Channels rollout of the Krakatoa GUI including Velocity, Color, Density and Normals.
If we would render the loaded particles in Krakatoa, they would appear on the correct locations on each frame, BUT they would not motion blur at all because we have not loaded any velocities.
- To specify which particle data channels to load from the files, select the Krakatoa File Update operator and press the Channel Setup button.
- In the modeless floating dialog, check the >Velocity channel in addition to >Position and >ID. By default, the data will be loaded into the Velocity Target Channel with Blend of 100%, thus overwriting any existing velocity data.
- Now, if we would change the Display operators of the loaded particles to show Lines instead of Dots, we will see that the particles have correct velocities, but they are slightly offset relatively to the original particle system.
This is caused by the fact that Particle Flow first updates all operators (including the loading of Positions and Velocities), and then integrates all particles, calculating new positions based on the old positions and velocities. A possible fix for this would be to load the positions and velocities and modify the positions backwards during the loading process to counteract the later integration, but the conscious decision was made not to do this to avoid code complications. The actual difference between the two systems, esp. when rendering with motion blur of 180 degrees, is minimal and becomes negligible at finer Integration step settings. The screenshots below show the second system set to 1 frame and 1/8 frame Integration Steps in the Viewport:
Transforming The Loaded Particles
By default, the Krakatoa File Birth and Krakatoa File Update operators will load the particles in world space, matching the original particle system's position regardless of the location of the PF Source of the loading system. But we can use the "Link to Object TM" to use the PF Source's transformation in space to load the particles with different positions and orientations.
- Select the Krakatoa File Update operator and check the Link To Object TM option.
- Notice that when the PF Source 02 is aligned to the world origin, the option makes no difference.
- Now move that PF Source 02 50 units along the world X axis and scrub the Time Slider to update the particles. You will notice that the whole particle system shifted by 50 units.
- Rotate the PF Source 02 at -90 degrees around the world Y axis and change the time to update.