Jump to content

Sprite Shader


jordanwallwork
 Share

Recommended Posts

I'm currently working on a 2d game which allows users to customise the colours of their players tshirt by specifying a main colour and an accent color. What I was hoping was that it would be possible to use a shader to render it so that it uses the red channel to set the main color and the green channel to set the accent color (ie. 0 = white, 255 = main/accent color) and possibly use the blue channel to allow shading (ie. 0 = base color, 255 = black).

Firstly, does this sound like a feasible approach? The other idea I had was to have 3 separate sprites for main color / accent color / shading, tint them and layer them. This'd be much easier but I decided it'd be kinda clunky and far less performant, especially when I have multiple characters animated and running around the screen.

Secondly I could do with some advice on how to actually achieve this in phaser 3 (currently 3.12.0)! Things I've explored (but can't can't quite fit to my scenario) are:

  • Palette swapping. Not suitable as I want to be able to use greyscale values in the RGB channels to allow blending colours
  • Filters, as in phaser 2 (examples). These don't seem to work in phaser 3, there's no filter method on scene.add
  • Effect Layers, as mentioned in this devlog from April 2017. These look super promising, yet apparently scene.add.effectLayer isn't a function either

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...