playMaker

Author Topic: ColorMaskFill FSM  (Read 2038 times)

PolyMad

  • Hero Member
  • *****
  • Posts: 553
ColorMaskFill FSM
« on: April 27, 2013, 10:35:15 AM »
Hi!

So, finally I can give a little contribution to the community, hope somebody will find this helpful!

It's a part of a camouflage generator system.

It does not generate a brand new camouflage texture, but it allows the user to choose the colours he wants to use on a selected texture that works as a mask.



The inputs are:
  • RGB texture (marked read/write)
  • color 1
  • color 2
  • color 3


The output is:
  • RGB texture (marked read/write)



The FSM replaces the RGB channels in the original texture using the 3 colors chosen by the user and writes the result on another texture.



Limitations:
  • only square textures, but you can easily split the X and Y components and change the loop actions
  • only RGB channels considered, I'll work on Alpha later on if needed (I hope somebody will help me make a much faster script by using the graphic functions of Unity, this should be a thunder of 1/1000 of second, and probably also a dedicated shader for my game)
  • long times: generation of a single 1024 texture takes around 5 seconds. Not too much for a single texture, but too much if you have 10 of these to build!



2 versions are included in the package: the optimized one and a schematic one, good to learn and understand what's going on (and to spot my highly inefficient code flow :D).

Tell me if you like it!

And... I'm looking for help, I'm building a game similar to World of Tanks, anyone interested? :)
« Last Edit: April 27, 2013, 12:05:56 PM by megmaltese »