Author Topic: FlxShaderCamera  (Read 2570 times)

goshki

  • Active Member
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
    • Vigeo Games
FlxShaderCamera
« on: Fri, May 6, 2011 »
Hi there! Lately I've come across the UltimateBlendModeShader library 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!



The screenshot may be a little obscure, so you can see it in action here.

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.

The usage is plain simple: just copy the 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 file. There are also some explanations on the repository's main page. Or just ask here! ;)
« Last Edit: Mon, May 9, 2011 by goshki »

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: FlxShaderCamera
« Reply #1 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!

goshki

  • Active Member
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
    • Vigeo Games
Re: FlxShaderCamera
« Reply #2 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