# Post-processing Lightsabers in Blender

I've been studying JamesVillanueva's lightsabers for a while now, and have tried to recreate the effects in Blender. The trouble I'm having is with the blade in the compositor. Keep in mind that I'm also trying to animate it.

First off, this is the lightsaber I've created with help from Williamson's lightsaber tutorial. Obviously the color of the glow needs a little more work to be accurate, but that's not what I'm worrying about at the moment. This is also rendered in Blender Internal, but I'm going to switch to Cycles when I got everything prepared. The blade model is totally transparent, but its index is fed into the ID mask node.

I'm using two versions of Blender's Gaussian glow. The glow it creates is, unfortunately, omnidirectional. This is different than the glows Villanueva puts on his, where the white core continues into the saber emitter. Also, unlike his, my glow flows over and obscures part of the emitter. This also means that if prongs were placed on the emitter and closer to the camera than the blade, the glow would engulf them. What I'm looking for is something like this:

(source: James Villanua)

Where the parts of the model that are closer aren't affected by the glow, while those that are farther are.

Second, I'm trying to improve on Villanueva's method by having the glow applied to the reflection as well. A method to have the glow applied to the blade if it's covered partly by glass would be nice, too.

Anyway, help is appreciated for any of these questions. If there is a different way of going about this and getting the glow, like with Cycles materials, I'd be happy to know.

Here is what I came up with:

# Adding a glow without affecting close parts of the handle

• The handle mesh is on scene layer 6

• The blade and other objects are on scene layer 1

1. Create a material for the blade

1. Enable Transparent in Render settings > Film

1. Create two renderlayers, one for the handle and one for the blade

By setting the handle layer to be masked by the blade, we get the glow to be added behind the nearer parts of the handle.

1. Enable the Object index pass for the blade renderlayer, and set the Pass index of the blade to 1 in Properties > Object > Relations.

2. Composite nodes: (click for full size)

Result

# Reflections and refractions:

## Technique one

Without and with reflections and refractions blurred: (click for full size)

Limitations

• Reflections of reflections of the blade will not have glow applied. (likewise for refractions)

• The glow on reflections and refractions will be applied on top of reflections/refractions of the handle.

Here is a Blendfile for you to inspect.

## Technique two

• All objects except for the handle and the blade are visible on layer one

• Refractive or reflective objects are visible on layer 7 as well as layer 1

• Objects that are not refractive or reflective are visible on layer 3 as well as layer 1

• The blade is on layer 2

• The handle is on layer 6

1. Enable Transparent in Render settings > Film

1. Create four renderlayers: (click for full size)

1. Composite nodes: (click for full size)

Here is a blend for technique two

• Applies glow to inter reflections/refractions

Limitations

• Materials that are both reflective/refractive and something else (e.g. diffuse) will be blurred. The only way to really solve this with compositing is to put each partially diffuse/reflective object on its own renderlayer.

You could fix this particular example by adding separate materials for the glossy/diffuse aspects of the shader and separating with the Material index pass.

• The glow on reflections and refractions will be applied on top of reflections/refractions of the handle.

You could fix this by adding another renderlayer, but this will use up more render time and it may not be worth it for such a small detail.

• Simply beautiful. Thank you for answer the questions I asked and even those I didn't :) Nov 2, 2013 at 11:10
• I think I've thought of a way to fix the limitation of technique two, so obvious I don't know how I missed it..
– gandalf3
Nov 2, 2013 at 16:26
• You mean the material index pass? Nov 3, 2013 at 6:58
• @kizlink The material index pass won't work when the diffuse parts of the shader are in the same material as the glossy parts. (the above image with the checkered glossy/diffuse is made with a mix shader with a checker texture as the factor) The fix I mentioned won't work, I was thinking of dividing the diffuse pass with the glossy/transmission passes. (this doesn't work because the diffuse pass does not include reflections of diffuse bounces) The only way to solve this is by adding more render layers.
– gandalf3
Nov 3, 2013 at 18:59
• While trying to improve this setup to remove a few kinks I came across a bug. I'll keep updating this post.
– gandalf3
Nov 4, 2013 at 2:45

There is just one trick for this kind of effects: Scene-referred workflow. (i.e. using physically plausible values for emissions and forget).

Instead of going through so much contortions, the most effective path is to treat a lightsaber as what it is supposed to be: a saber. of light.

So it only takes a high intensity emission shader, using the colour you want for the saber. That's it. The rest is just a glare effect that will pick up the high intensity lights and create a nice looking glow. It works on reflections, refractions. Motion blur? No problem.

It's super fast to render, super easy to achieve. All you need is in the following screenshot: