Dec 11, 2017 - VR Light Saber

Lightsaber VR!!



This past week I've been busy with jury duty but during my lunch breaks I started working on something that has been bugging me for a while. The telekinetic "grab" or "pull" mechanic gets very unstable when it transitions from pulling to grabbing. That's because there is no change in behavior except a slight reduction in the velocity of the pulling force.  In the back of my mind I knew that I needed to switch to a fixed joint, and I've been putting it off for a while.

To get started on this mechanic I wanted to start with a clean scene because I actually think it's easier to develop from scratch than to retrofit a new feature into an existing setup. So, in a clean scene I decided to build a crude model of Mjolnir a.k.a. Thor's Hammer, because I like the way he is able to summon the hammer whenever he wants it and it comes flying into his hand.


But my original inspiration for this force pulling effect is inspired by the jedi in the Star Wars films. So, the Mjolnir "model" (2 cubes haha) quickly morphed into a hybrid hammer/lightsaber because I couldn't be bothered to do any modeling ;)  I quickly added "light trails" and lightsaber sound effects to sweeten the effect.  The light trails were inspired by the After Effects Saber plugin. I showed this to my friend, BPD, and he sent me a link to a model pack which coincidentally came from Andrew Kramer whose Saber plugin inspired the blade trails effect. So, now I had a lightsaber model and one thing led to another and I made a VR lightsaber.

I captured video throughout the week and assembled a progression reel which I find interesting. It might reveal something about my creative process.

Lightsaber Progression:
1) hammer/saber grab


2) hammer/saber with blur in VR


3) lightsaber with outline, glow and displacement


4) lightsaber with more glow, more aggressive displacement


5) more blur samples (i.e. smoother follow), stable base hum with pitch-shifting based on movement, the glow looks good but I don't remember if I did anything new.

Blade trails:

Early in the week I started looking at Andrew Kramer's Saber plugin (for after effects) tutorial to get inspiration for the light trails. https://www.videocopilot.net/blog/2016/03/new-plug-in-saber-now-available-100-free/

The way I achieved this was creating a procedural mesh (a single quad just to keep things simple). First I wrote a script to have 2 non-renderable objects follow the tip and base of the saber blade.  They were designed to follow on a .042 second delay which is meant to emulate 24fps which is the frame rate of traditional films. The lightTrail script adjusted the vertices of the quad to match the samples taken.

As with most new things I learn in Unity there was one small stumbling block. It isn't enough to generate your quad and adjust the points at every frame. You also need to update the bounding box. If you don't, your points might move outside of the bounded region and fail to render. So, tweak your points and then run mesh.RecalculateBounds().

Glow:


I took advantage of all of the shader stuff I learned the previous week and used the outline and displacement features to achieve the bright look. I ended up boosting the blade color to take advantage of HDR and bloom which is available in the postprocessing stack. This time I learned that there is a _Time variable available inside the shader language so I used that to animate the displacement.

Wonky Ground reflection:


In some of the clips the groundplane appears to be lit by the lightsaber. This was a happy accident and also a cheat and also not correct. The color of the blade was being sampled by the reflection probe and then reflected off of the groundplane. I'd like to find another more accurate solution to add light emitted by the lightsaber.

Audio:

The way I approached the audio was by taking a recording of a lightsaber and clipping off the head, tail, and middle. The most important thing is to make the middle clip loopable. Then I control when each audio clip gets triggered and it really helps to complete the illusion of a light saber. It sounds so simple but it's also very effective.  I always put sound in my game mechanics as early as possible because so much of the experience is outside of the view, especially in VR.


What I'm drinking:

Industrial Arts Wrench IPA



Comments

Popular Posts