RSS< Twitter< etc

Baking Lighting And Particle Relighting In Krakatoa For CINEMA 4D

Last edited on April 15, 2014

Level: Intermediate


The following tutorial discusses the ability of Krakatoa for CINEMA 4D to compute lighting during Particle Saving to PRT files. This lets you bake the scene lighting with the particle asset and re-render the particles without the need for a lighting pass at render time. 

The Base Scene

We will use the base scene containing a PRT Volume of the Stanford University's Buddha statue scan.

You can download the mesh in .OBJ format from here

  • Start a new CINEMA 4D scene.
  • Merge the HappyBuddha.OBJ file into the scene - use Scale of 2.54 when importing.
  • With the mesh selected, go to Main Menu > Plugins > Krakatoa > Krakatoa PRT Volume to convert the mesh to a point cloud.
  • Change the Voxel Subdivisions to 1.
  • Check the Enable Jittering checkbox.
  • Disable the display of the mesh in the viewport to see the PRT Volume's points.
  • Create a TargetLight, change the Type to Parallel Spot.
  • Under Defails tab, change the Outer Radius to 500 cm, Inner Radius to 300 cm.
  • Assign Krakatoa as the current renderer.
  • Open the Options tab of the Krakatoa Render Settings and change Final Pass Density Exponent to -2.
  • Render.

RESULT: About 5.8 million white particles will be generated, lit by a white light, and rendered.

Saving To Disk With Lighting Included

Now let's save these 5.8 million particles to disk, and include the lighting information in the file! 

  • In the Render Settings dialog, switch to the Output tab of the Krakatoa settings.
  • Switch the Render To drop-down list to Save Particles to File Sequence mode.
  • Enter _prelit_ in the Save Particles Token. This will append the token to the PRT output filename.
  • Check the Compute Lighting Channel checkbox!
  • Make sure the Export Channels panel has Density and Normal checked. Color and Velocity make little sense when saving a PRT Volume because it has no velocity, and defaults to White anyway.
  • Either save the scene to a C4D file, or specify an explicit location in the Save options of the Render Settings dialog to define where project files will be saved.
  • Press SHIFT+R to render the active project. 

RESULT: Since Krakatoa is set to save particles, a PRT file will be saved to the project or explicit saving folder.

Loading The Pre-Lit Particles

Now let's load the saved particles back using a PRT Loader, and turn off the original source objects. 

  • Disable the PRT Volume object.
  • Create a new PRT Loader from the Main Menu > Plugins > Krakatoa menu.
  • Pick the PRT file saved in the previous step.
  • Note that only a fraction of the particles will appear in the viewport, because the Display tab of PRT Loader has the checkbox Enable Display Particle Limit checked by default. Uncheck it to load all 5.8 million particles!
  • To speed up the display, you can also switch the Display Load Mode to Every Nth Particle and set Percent Of Render Count to a lower value like 10 or 20.
  • With the PRT Loader selected, right-click it and add a Krakatoa Channel Copy Tag.
  • Set the Source Channel Selection to <CustomChannel> and enter Lighting in the Source Channel Name. Note that the Available channels would list Position, Normal, Lighting and Density as available channels. You can copy the name from the list to save yourself some typing...
  • Set the Destination Channel Selection to Color. 

RESULT: The viewport will show the particles with color taken from the Lighting channel, thus reproducing the lighting calculated during the saving in the previous step!

Rendering The Pre-Lit Particles

Now we can try to render the particles without using interactive lighting. For this, we will need to copy the Lighting channel into the Emission channel and render the particles as self-illuminated (incandescent). 

  • In the Copy Channel tag, change the Destination Channel Selection to Emission.
  • In the Render Settings > Krakatoa > Options tab, check Ignore Scene Lights and Use Emission. This will skip the lighting pass and will use only the own light stored in the Emission channel (taken from the pre-saved Lighting channel!)
  • Render 

RESULT: The PRT Loader will load all particles including their own baked lighting and will produce the EXACT same result without calculating lighting at render time!

Relighting / Remapping The Baked Lighting

We can use the Gradient option of the PRT Loader Display tab to remap our Lighting at will! 

  • Select the Copy Channel tag and switch it to copy from Color to Emission.
  • In the Display tab of the PRT Loader, select <Custom Channel> for Color Mode.
  • In the Source Channel, type in Lighting.
  • Switch the Gradient Input Type to Magnitude or X. Since R,G and B in Lighting are the same, and the Magnitude of the Lighting will also be normalized, they both produce the same result. Magnitude Squared on the other hand will produce a square curve bias.
  • Check Use Display Color In Renderer

RESULT: The viewport particles will be mapped to the blue-red gradient based on the black - white gradient in the Lighting channel! Rendering the particles will produce the same result because we copy the Color to the Emission.

Obviously, we can change the gradient to ANY colors to remap the Lighting at render time!