N.O.V.A 3 type bokeh effect: shader to show texture on light areas only?

There are a lot of questions on Unity Answers about replicating Battlefield3 style bokeh, camera dust and scratch effects but I haven’t found an answer to a specific related effect. Any input or advice would be appreciated – am I on the right track? I’m trying to replicate the bokeh effect found on the iOS game N.O.V.A 3.


Ignoring the horizontal lens flares, just the bokeh looks to be a simple tiled texture with alpha. That is simple enough, apply a texture to a plane in front of the camera and you have a bokeh effect however its static and doesn’t react to the light in the scene. In the N.O.V.A 3 example the bokeh only shows up in areas where the background is light and is completely transparent in dark areas. Note there is a falloff transition on the effect, so the bokeh carries on past the edges of the light source.

I’ve assumed this can be accomplished via shader? However, my scene does not contain any actual lighting as everything is baked for performance with iOS being the target platform. Is there a shader that will render an alpha texture with less alpha on light areas and more alpha on dark areas of the background? I’ve run through the gambit of default shaders including the particle shaders, so I imagine something more custom is required?

Am I on the right track or is there another technique?

You’re half right. Full-screen effects that require buffering such as bloom or SSAO are usually the first thing to go when it comes to mobile optimization, so it’s probably safe to assume you won’t be sampling the actual scene brightness.

Fortunately, shaders which combine an alpha with a texture are common in Unity mobile development-- see Madfinger’s optimization tutorial for examples such as the smoke pouring out of the wrecked ship.

In fact, the Shadowgun example is full of hints on how to fake bloom by putting actual 2D planes in front of light sources, with shaders designed to make them partially or fully rotate to face the camera.

TL; DR: Combine one static tiled texture with a second texture’s alpha, make it additive, and slap it on a geometry plane. Then put one of those planes in front of each of your light sources, with some shader magic to make them turn to face the camra. The horizontal lines work the same way-- if you can do one, you can do both. Refer to Madfinger examples for a variety of subtly different custom shaders that work along these general lines.