Flixel Forums

development => releases => Topic started by: goshki on Fri, May 6, 2011

Title: FlxShaderCamera
Post by: goshki on Fri, May 6, 2011
Hi there! Lately I've come across the UltimateBlendModeShader library (http://code.google.com/p/blendmodes4flash) and I thought it would be a nice addition to new Flixel camera architecture to have various blending modes done by shaders. :)

And thus, the FlxShaderCamera came to live!

(http://vigeo.pl/labs/flxshadercamera/flxshadercamera.png)

The screenshot may be a little obscure, so you can see it in action here (http://bit.ly/flxshadercamera).

Or if you'd rather just dive into the code, then I've set up a git repository where you can download it in one package with a test movie: http://github.com/goshki/FlxShaderCamera (http://github.com/goshki/FlxShaderCamera).

The usage is plain simple: just copy the pl/vigeo/flixel/FlxShaderCamera.as (http://github.com/goshki/FlxShaderCamera/blob/master/src/main/actionscript/pl/vigeo/flixel/FlxShaderCamera.as) into an corresponding folder in your source code (or strip the package and put it right into the root of source code) and instantiate a camera like this:

Code: [Select]
var zoom:int = 0;
var blendModeIndex:int = 0;
var camera:FlxCamera = new FlxShaderCamera( 0, 0, 100, 100, zoom, blendModeIndex );
FlxG.addCamera( camera );

and that's it! You've made yourself a beautiful shader blending camera. ;D

If you're interested in more details then take a look at FlxShaderCamera.as (http://github.com/goshki/FlxShaderCamera/blob/master/src/main/actionscript/pl/vigeo/flixel/FlxShaderCamera.as) file. There are also some explanations on the repository's main page (http://github.com/goshki/FlxShaderCamera). Or just ask here! ;)
Title: Re: FlxShaderCamera
Post by: Adam Atomic on Fri, May 6, 2011
for performance you might want to do FlxG.resetCameras() instead of addCamera(), otherwise you might be drawing everything twice - looks rad though!
Title: Re: FlxShaderCamera
Post by: goshki on Mon, May 9, 2011
for performance you might want to do FlxG.resetCameras() instead of addCamera(), otherwise you might be drawing everything twice - looks rad though!

Thanks, I'll look into that. :D