The Daily Click ::. Forums ::. Klik Coding Help ::. Palette Swapping Using HWA (Pixelshader)
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th March, 2013 at 07/03/2013 17:53:43 -

Just thought I'd demonstrate an idea I've been experimenting with...

http://sdrv.ms/14ygEpU

The first part is a little tool that loads a 256 colour .GIF image file, and from that generates two other files:
* A 16x16 palette image, containing the original 256 colours.
* A copy of the original image with a modified palette, so that pixels are replaced with their palette index. So for example, if palette index 10 is pure red, all red pixels in the image are replaced with the color RGB:10,10,10.

The second part is a pixelshader that can load the palette image at runtime.

So the step by step process would be:
1. Create your 256 colour GIF image (if your object is animated, make sure you include all the animation frames in the same image).
2. Generate the special palette and image files.
3. Import the special image file into MMF2.
4. Edit the palette file to make all your different versions.
5. Apply the desired palette file as an HWA effect parameter.

It's still rather glitchy at present (having a lot of trouble with transparency), but seems like it has potential.

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
9th March, 2013 at 09/03/2013 05:24:14 -

That's pretty cool. I've just been parting out my sprites, removing all the color information then using the tint shader on the different parts, but a palette swap would probably be a little less wasteful.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th March, 2013 at 09/03/2013 13:36:20 -

IIRC, you need your sprites to be made from lots of pieces anyway, because that's how your animation system is built - so what you're doing sounds like a sensible way to go.
This is really more for retro games. It could be applied to individual objects (eg. to change the colour of a character's clothing), or to whole layers (eg. to change a desert level into an ice level).

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
13th March, 2013 at 13/03/2013 20:41:48 -

Actually, all my sprites are rendered, the animation system I use is based on two parts, one for the template based art, and another to control how the animation runs in MMF2. If I were brilliant enough, I could probably program up a system for the first part, which would probably allow me to input even more complex animations.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal
   

Post Reply



 



Advertisement

Worth A Click