Visual Effect Breakdown – Lasers

Lasers are an important part of our game, so since they’ve got a big visual overhaul, I thought it’d be interesting to break it down and see how all the elements work together.

This week has been a bit of an ‘everything’ week where I’ve been fixing all sorts of miscellaneous bugs and minor improvements across the whole of the core of the game. In particular handling some of the tricker edge cases for portalling when the player has eyes either side of a portal and looks through a series of other portals at the same time. More interestingly I’ve also been working on our new laser visuals and making them feel exciting and dangerous.

Lasers go all the way back to the Hatton Garden Heist, where they were just simple (barely) textured cylinders. They didn’t even move or damage you, they were really just to make things a bit more colourful.



Lasers in Hatton Garden Heist – not our most visually impressive work
For UD1 we reworked the lasers and now were an active part of gameplay and could move and damage you. However visually they were still just a couple of cylinders with a single colour each and an impact point. It worked with the art style we were going for but was a bit crude.



Unseen Diplomacy 1 lasers – more threatening but not visually dangerous
For UD2, I wanted them to feel a bit more like real-world lasers, but also to have a bit more life to them. They should feel dangerous and not something you want your head (or any body part) near! So starting from scratch, here’s the reworked visuals.



New UD2 laser effect – feel them crackle and avoid getting yourself burnt!
One thing I’ve definitely found is that for visual effects, layering them up is the best way to make something that really feels alive. It can be difficult to see sometimes how a finished effect like a laser or an explosion in a game is really just a set of simple effects, each building on top of the others and each adding different colours and movement. Also for VR games the result has to feel like an actual volume – effects made out of particles and flat quads work great in non-VR games, but in VR it can be easier to see the tricks and this breaks the illusion.

Breaking it down the new laser is a mix of layered geometry, custom shaders and particle systems. The core is a tube of geometry with a laser shader to get the right kind of soft fade on the edges but still keep a strong core of light in the center. Separate scorch and burn decals are spawned at the collision, aligned with the collision surface to provide an impact cue.

An important bit of polish is a trick we’ve lifted from Smash Hit Plunder – the shader will fade the laser out over a few centimeters close to the camera, so you don’t get an ugly line clipping through your view when you stick your head in it, again another thing that tends to break immersion. It’s technically more efficient to do this in clip-space, but here I calculate it in world space so that the input values (as seen in the inspector) are all in world units, which is much easier to make them super accurate to how we want it to behave. Want to implement it in your own VR game? Steal this shader code:

  float CalcCameraFade(float3 worldPos)
  {
    // Depth offset pushes the fade away from the camera (so we can push it past the near plane)
    // Depth scale affects the overall range of the fade (but still a linear fade)
    // Do the calculations in world space so shader inputs are in world units

    float dist = length(worldPos - _WorldSpaceCameraPos);
    float normDist = (dist - _DepthOffset) / _DepthScale;
    return saturate(normDist);
  }

Sparks use unity’s particle system in full physics-collision mode. This is expensive compared to normal particles but the numbers are low and this means they’ll bounce off actual geometry and feel reactive. A good trick is to split this particle system in two and have a fully simulated one with low particle count, and a cheaper one with non-simulated particles as filler. However I haven’t done this here as too many spark particles became distracting and overpowered the whole effect.

Smoke is another particle system, this time using a soft-particle shader. Soft particles are great for particles that will probably clip through nearby surfaces – this can look ugly in a flat game but it’s even worse in vr.
This requires a depth pass to be rendered before normal rendering, so it has some overhead, but we’ll be sharing it between lots of effects so it’s an important step we have to optimise for.
Finally some dust motes spawned along the actual laser beam provide a subtle trail. Here the laser component has to update the emission shape (a line emitter) in realtime so the particles spawn in the correct place as the laser moves.

Put it all together and you get this:


Of course this is just the visuals for the laser, none of the gameplay effects are implemented yet! But here I wanted a strong visual design as an art reference and having the laser raycasting behaviour implemented makes the rest a lot easier.

We’re still figuring out what new environmental hazards we want you to be avoiding in UD2 – pop into our Discord and let us know what you want to dodge and sneak your way past!