Change Log for existing users (4-6-2015):
Tile support is now in. Use pal_swap_set_tiles(), preferably in the step event, to swap the range of tiles with the given palette. You can do this for as many tile ranges as you need to swap. Tile ranges should be depth ranges that only include tiles, with no objects moving around in the layers in between. So if you have a "background" tile layer and a "forground" tile layer, you would need to handle both of those as two separate calls with pal_swap_set_tiles, even if they use the same palette.
A new tool is now available for creating your palettes.
You no longer need to pass the shader name as an argument for pal_swap_set(). You can choose to not update that particular script and everything will still work fine, but I would recommend it if you don't have TOO many pal_swap_set() calls in your project. Now in pal_swap_init() I store a global variable of the shader index that is used in all future calls to the shader.
Finally, I have packaged everything up and thrown it up on the marketplace for a few bucks. You are free to download it from this thread and use it in your project (commercial or private) with no credit required. But, if you like what I do, and want to help support continued development, consider purchasing from the marketplace. Either way, thanks for giving it a shot, and I hope you make something awesome with it!
Alright, If you are new here, start reading from here:
Welcome to Retro Palette Swap Shader 2015!
"What is this?"
Retro Palette Swap shader is a bit more than just a shader; it is an entire system for managing, manipulating, and drawing sprites, surfaces, backgrounds, and tiles with a swapped palette.
Have you ever created a character in your game and wished you could change the character's hair or clothing color without adding a complete new set of sprites for every single one of that character's animations?
What about making a sprite appear on fire in a much more vibrant way than just putting a red or orange image_blend on it?
Maybe you've got a black outline around your sprite and want to make it red when the player mouses over it?
All of this and much more is possible with Retro Palette Swap Shader!
"What are the features?"
- Draw any sprite, surface, tile, or background with a specific palette!
- Use surfaces to build dynamic palettes on the fly! (Explanation Here)
- Gradually shift between palettes to create dynamic effects!
- No known color limit (although 256 is suspected)
- Easy to drop into any existing project.
- Fully commented example code.
- Helpful scripts for manipulating palettes
- Get the color count for a given palette.
- Get the number of palettes for a given palette sprite.
- Get a specific color out of a palette.
- Ongoing Development! Post here if you have any issues or feature requests, and I'll see what I can do to help.
- Free! Use in commercial products; no credit required. You guys are awesome. (Just don't try and claim at as your own. Not cool.)
- There is a marketplace listing if you want to purchase as a way to support continued development or show appreciation.
"How do I make it work?"
The example GMZ (link at the top or bottom of this post) is fully commented to help you get it to work in your project, but I'll step you through the basics.
Make sure your sprites use a consistent palette across all frames.
You could even have multiple sprites with different animations all for the same character that all share one palette. But every, single color across all of those sprites and sub-images needs to be consistent and represented in the "default" column of your palette.
Set up your palette sprites
There are two methods for creating your palette sprites. If you are comfortable with Photoshop or another graphics program, you may choose to build it manually. Here is a rough tutorial on setting up your palettes in photoshop.
The second method, which honestly might be better even if you ARE comfortable in Photoshop, uses a custom tool specifically built by me for use with the Palette Swap Shader. Here is a tutorial and a download link:
Import Scripts and Shaders from the Example Project
With the exception of the scripts in the "_Debug" folder, all scripts need to be imported into your current project.
The only shader that is required is the shd_pal_swapper, the other ones are just for the desaturate example, but you may want to keep them around for building custom palettes with specific effects.
Set Up The Palette System
Before you do any drawing with the palette swapper, you need to run the "pal_swap_init_system()" script. This will create several global variables that the shader will need to access before it can be used. Once you've done that, index any palettes that you plan to use pal_swap_get_pal_color() on. This allows you to quickly access the colors in a palette in the future for building custom palettes based on the existing palettes. I honestly don't recommend this, however. Using shaders to modify existing palettes to build custom palettes (as I show in my desaturation example) is a much better method than pulling the color data out of a palette, manipulating it somehow, and drawing directly to the surface.
Call the pal_swap_set() script, pass it the appropriate sprite or surface palette (and set the flag for either case). Draw something. Reset the shader with pal_swap_reset() or just shader_reset(). It's really simple.
Have any issues, post here and I'll be happy to help.
"I got it, but it isn't working."
Well, post here and I'll do my best to help you get it working. You may also want to scan this post to see if your issue has already been discussed. But here are some quick tips:
Q: "The example project doesn't seem to do anything"
A: Make sure you've installed the latest version of direct-x and video card drivers. I promise this works.
Q :"My sprite doesn't look any different when swapped."
A: Make sure the colors in your palette are EXACT MATCHES of the colors in your sprite. There is no "approximation"; the colors must be identical. Use the palette builder to help you find color inconsistencies in your sprites.
Q: "Only some of my colors are changing."
A: See previous answer.
Q: "Everything looks SUPER weird."
A: Did you turn off the "Interpolate Colors Between Pixels" option in the global game settings? This will not work at all with that option on, so if your game's aesthetic relies on that, you are out of luck; this won't work for you.
Q: "I implemented this into my project and it is SOOO SLOOOOW! What's wrong?"
A: I honestly don't know. Thanks to GamerXP everything seems to work REALLY fast right now, and have yet to really find any performance issues. But if you are having issues, post about them here and let's figure out what's causing it.
Q: "Custom palettes seem cool... but I don't really understand what's going on..."
A: Oh, they are super cool, but I totally understand you being confused. Here's a post where I try to explain them a little better, but feel free to post any issues or "how would I do this with a custom palette" type questions.
Special Thanks to Carnivac, gadgetmawombo, and LowchefBox for helping with testing and feedback!
And a very special thanks to GamerXP who, in all actuality, wrote the shader portion of this system.
Edited by Pixelated_Pope, 08 April 2015 - 04:04 PM.