Quantcast
Channel: Jean-Marc Le Roux
Viewing all articles
Browse latest Browse all 27

Anamorphic Lens Flare

$
0
0

Update: I've just pushed a new SWF with a much better enhanced effect. I've tweaked things like the number of vertical/horizontal blur passes - which are now up to 3/6 - but also the flares' brightness, contrast and dirt texture. I think it looks way better now!

Tonight's experiment was focused on post-processing. My goal was to implement a simple anamorphic lens flare post-processing effect using Minko. It was actually quite simple to do. Here is the result:

minko_anamorphic_lens_flare_vipermarkII_2

The 1st pass applies a luminance threshold filter:

public class LuminanceThresholdPass extends Shader
{
    private var _postProcessing : PostProcessingShaderPart;
 
    public function LuminanceThresholdPass(renderTarget  : RenderTarget  = null,
                                           priority      : Number        = 0.0)
    {
        super(renderTarget, priority);
 
        _postProcessing = new PostProcessingShaderPart(this);
    }
 
    override protected function getVertexPosition():SFloat
    {
        return _postProcessing.vertexPosition;
    }
 
    override protected function getPixelColor():SFloat
    {
        var rgb			: SFloat	= _postProcessing.backBufferPixel;
        var rgbToLuminance 	: SFloat 	= float3(0.2126, 0.7152, 0.0722);
        var luminance		: SFloat	= dotProduct3(rgb, rgbToLuminance);
 
        return multiply(
            _postProcessing.backBufferPixel,
            greaterEqual(luminance, sceneBindings.getParameter('luminanceThreshold', 1))
        );
    }
}

Then I use a multipass Gaussian blur with 4 passes: 3 horizontal passes and 1 vertical passes. The trick is to apply those 5 passes (1 luminance threshold pass + 4 blur passes) on a texture which is a lot taller than wide (32x1024 in this case). This way, everything gets streched when the flare are composited with the rest of the backbuffer.


Viewing all articles
Browse latest Browse all 27

Trending Articles