| Previous Topic (Matte Objects and Shadows Tutorial) | Up (Contents) | Next Topic (High Particle Counts Tutorial) |
Casting Shadows on Geometry
Your final composites will likely contain other geometric objects to be integrated with your particle passes. To assist in casting shadows on geometry rendered with other 3ds Max renderers, Krakatoa can store attenuation maps for each shadow-casting light. These maps can be assigned to the projection slots of your lights to project shadows from particles onto your scene objects.
The following tutorial demonstrates the basic workflow to combine particle passes from Krakatoa with geometry passes from other renderers like Scanline or mental ray.
Aladdin's Lamp
The Scene
- Let's start with a simple 3ds Max scene containing
- A Plane primitive as the ground plane
- A scaled and tapered Teapot primitive as the lamp
- Some more Teapots with different modifiers and settings as pottery scattered around the lamp
- A Particle Flow system was added to the scene.
- The Emitter was aligned to the spout of the teapot.
- The emitter was set to Circle and the Diameter to 1.0. Using Scale, it was adjusted to match the shape of the spout.
- The PFlow was set to emit 200,000 particles over 200 frames.
- An inverse Gravity force (buoyancy), a turbulent Wind and a Drag force were added to the PFlow via a Force Operator.
The result is a particle system that moves in an interesting way. These are the particles we will render in Krakatoa.
You can download the ZIP file with the initial source 3ds Max 9 scene from here.
Saving the Particles to Partitions
To speed up test renders, we will save 5 partitions with 200K particles each for a total of 1 million particles at the end of the shot.
- Set Krakatoa to override the particle color with white:
- Check Override Particle Colors,
- Set the drop-down list to Custom Particle Color
- Make sure the Custom Particle Color swatch is set to white.
- Change the Particle Render Mode to Save Particles To File Sequence
- Right-click the SAVE PARTICLES button and select the animation range from 0 to 200.
- Enter a save path in the Save Particles To File Sequence field using the PRT file format.
- In the Particle Partitioning rollout, set the number of partitions to 5 and hit the Generate All Partitions Locally button.
- Wait for all partitions to be saved (takes about 10 minutes, YMMV depending on CPU and harddisk speed).
Loading the Particles
Now we can load the saved particles using a PRT Loader.
- Select the Particle Flow emitter and turn it off.
- In the Krakatoa GUI, go to the Particle Loaders rollout and hit the Create New Loader..." button.
- By default, the Select Particle File Sequences To Add file dialog will open at the last save location - select one file from the saved partitions and click Open.
- You will be prompted about loading all 5 partitions - answer with Yes.
If you move the time slider, you should see the particles in the viewport now.
Lighting the Particles
- To get a nice spooky atmosphere, we use a spot light with greenish color and Cast Shadows checked. The Shadow Map size is set to 1024 - this will be used by both Krakatoa to calculate the attenuation maps, and by the Scanline Renderer for the shadows casting of geometry onto geometry.
- A secondary fill light is hidden below the plane and is illuminating the scene using a blueish-violet color and a Multiplier of 0.5. It does not cast shadows from geometry, only from particles (Krakatoa always calculates shadows from particles because light attenuation is an integral part of the lighting and volumetric shading if particles)
- To demonstrate the shadow casting from objects onto particles, we place a large vase in the way of the spotlight. It will be casting shadows onto the particles as they come out of the lamp. To enable this, open the Matte Objects rollout, select the large vase at the right side of the lamp (called "LargeVase02") and hit the Create/Update matte Selection Set - a new named selection set KrakatoaMatteObjects will be created and added to the list of Matte Named Selection Sets.
- We want the magic smoke coming out of the lamp to have relatively low density, but at the same time we would like to get good self-shadowing from particles onto particles. To achieve this, we will use different density values for the Lighting and the Final Pass.
- Check the >Use Lighting Pass Density Settings option
- Enter 5.0 / -2 in the Lighting Pass Density and 1.0 / -2 in the Final Pass Density controls.
Rendering the Particles and Attenuation Maps
The camera will be static for the first 100 frames, watch the particles come out of the lamp, then it will move around the lamp over the next 100 frames.
- Switch the render mode to Render Scene Particles
- Right-click the QUICK RENDER button, select Render Output Filename and specify an image file name to render to, for example Krakatoa_Genie_Lamp_Particles_.exr
- Make sure the Save Attenuation Maps option at the bottom of the right-click context menu of the QUICK RENDER button is checked.
- Press the QUICK RENDER to render 201 frames to disk.
Frame 100 of the resulting image sequence will look like this:
The attenuation maps will be saved in a sub-folder of the output path called \Shadows. The map for frame 100 will look like this:
Applying the Attenuation Maps to the Lights
Now we have our particle pass rendered. We can now assign the attenuation maps to the scene lights and render in another renderer like Scanline for example.
- Click on the KrakatoaShadows icon or alternatively open the Shadows On Geometry rollout and press the Shadows On Geometry Utility button.
- In the utility, the location of the attenuation maps should have been filled in automatically. If it is not there, you can alsways select a representative file from the \Shadows sub-folder of the output path we just rendered to.
- Press the ADD KRAKATOA SHADOWS TO THE SCENE button - this will create an IFL file for each shadow map sequence and assign to the projector slot of each light based on the light's and the attenuation map's name.
Rendering the Geometry Pass
Now that we have the attenuation maps applied to all lights, we can render a Geometry pass in the Scanline Renderer.
- Select "Default_Scanline_Renderer" from the drop-down list in the Switch Renderers group of controls.
- Press the Assign Renderer button next to the list - the renderer will be switched to Scanline.
- Open the Render Scene Dialog and check "Force 2-Sided"
- In the Render Output group of controls, press the Files... button and select a NEW file name to save to.
- Render the frame range from 0 to 200 as usual.
The resulting frames should show the shadows from the particles on the scene geometry:
Final Compositing
We now have the two passes - the Geometry rendered in Scanline and the Particles rendered in Krakatoa.
- Open Main Menu > Rendering > Video Post.
- Load the Geometry Sequence first - click the Add Image Input Event icon (arrow into rectangle), select the first frame of the Scanline rendering and make sure to check the "Sequence" checkbox in the Open File dialog to create an IFL from 0 to 200.
- Deselect the new entry in Video Post, then repeat the above operation, this time loading the Krakatoa rendering sequence.
- Select both entries and press the Add Image Layer Event icon (cyan and yellow intersecting rectangles). Select Alpha Compositor from the list and press OK.
- Deselect again and add an Image Output Event (arrow out of rectangle) and specify to file name and path to save to.
- Press the Execute Sequence icon (running man), make sure the Time Output > Range is set to 0 to 200 and press Render.
The resulting composite images should look like this:
Here is the final animation as Quicktime Movie