Jump to content


Photo

Retro Palette Swap Shader - New Palette Tool! Now Supports Tiles!

shader gm:studio

  • Please log in to reply
221 replies to this topic

#1 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 18 July 2013 - 01:11 AM

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.  

Download Link

Tutorial Video on how to use the Tool

 

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!

YoYo Marketplace Link

 

 

Alright, If you are new here, start reading from here:

 

Welcome to Retro Palette Swap Shader 2015!

 

 

 

DOWNLOAD LINK

old version (max 22 colors)

 

"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:

 

Download Link for Palette Builder Tool

 

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.

 

Draw!

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.

 

Please Enjoy!

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.

  • 15
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#2 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 20 July 2013 - 01:58 AM

How did I miss this, looking really good. A few people actually requested this, I wonder if they've seen it yet.

 

Very cool


  • 0

#3 MancVandaL

MancVandaL

    GMC Member

  • GMC Member
  • 213 posts
  • Version:GM:Studio

Posted 20 July 2013 - 01:57 PM

Nice. Could come in very handy. Loving some of the things that can be done with shaders.


  • 0

#4 BlaXun

BlaXun

    Slime Online Creator

  • GMC Member
  • 2750 posts
  • Version:GM:Studio

Posted 22 July 2013 - 03:46 PM

Very cool!


  • 0

iBNKRoX.png


#5 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 22 July 2013 - 04:06 PM

Glad at least some people might find this useful.  Anybody have any code critiques?  How about implementation critiques (like, maybe you don't like that you have to build the palettes as sub images or something...)?


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#6 krele

krele

    GMC Member

  • GMC Member
  • 640 posts
  • Version:GM:Studio

Posted 23 July 2013 - 12:36 AM

No critiques here, it's really great :)

 

Props on using secret of mana II sprites :D


  • 0

If I helped you, you can help me back :3

Brocoola


#7 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 07 August 2013 - 09:05 PM

If I call the palette_set_my_palette(my_palette); script rapidly, the game tends to bog down, then the shader dies. The game speeds back up if i switch back to the 0 palette, but the swapping of the shader never returns.


  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#8 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 08 August 2013 - 04:31 AM

If I call the palette_set_my_palette(my_palette); script rapidly, the game tends to bog down, then the shader dies. The game speeds back up if i switch back to the 0 palette, but the swapping of the shader never returns.

Yeah... I was afraid of that.

 

In all honesty, I did something a little stupid.  Every time you use 'palette_set_my_palette()' the next time it tries to draw the sprite,it detects that the palette has changed and it reloads all of the color information from your palette sprite.  The problem with that?  Well, it relies on "surface_get_pixel()" which may be the single slowest function built into gamemaker. 

 

So, here's what I'm gonna do.  I'm gonna re-write this a little bit and make it so that you load all color information into a data structure once, and only once, and then this should work MUCH faster... I'm kinda stupid for doing it the way I did it in the first place... I guess I didn't see much of a reason to cycle between multiple palettes rapidly, but I mostly built this for my own purposes and didn't really think about different use cases.

 

Check back in a bit, and I'll have an update for this that should resolve that problem, although sadly you might have to alter your implementation slightly.  But thanks for the feedback, I appreciate it.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#9 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 08 August 2013 - 08:33 PM

wow, seriously awesome shader.

just the thing i needed.


Edited by sebastiankit, 08 August 2013 - 08:34 PM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#10 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 09 August 2013 - 05:43 AM

Yeah, I was trying to use it on a network platformer that changed palettes depending on the player. and since one object is drawing all the players... calling it 4 times a step... :3


  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#11 andreasng

andreasng

    GMC Member

  • GMC Member
  • 121 posts
  • Version:GM:Studio

Posted 11 December 2013 - 10:56 PM

this is very well done! thanks alot


  • 0

#12 esco

esco

    GMC Member

  • GMC Member
  • 306 posts
  • Version:GM:Studio

Posted 15 January 2014 - 03:01 AM

Would be very nice if it wasn't slow. I put about 32  objects with 40 * 32 sprites in the room and tried it; game comes to a screeching halt. If would be AWESOME if there was a way to combine Xot's color shading/change shader with the ability to use colorpal images like in yours.


Edited by esco, 15 January 2014 - 03:02 AM.

  • 0

Esco... the original New Yorican and creator of the Castlevania: SOTN Hacked Project!
THIS PROJECT HAS BEEN MOVED OVER TO UNITY3D AND I NO LONGER POST HERE! MANY THANKS TO EVERYONE WHO HELPED ME ON THESE FORUMS, YOU GUYS ARE AWESOME! :)
This engine once completed will be released to the community and will hopefully be of great use to a lot of you platform game creators out there!
Link to the Project: http://sotnhacked.wordpress.com

Link to the DeviantArt Page: http://esco1979.deviantart.com/


#13 Xor

Xor

    @XorDev

  • GMC Member
  • 1346 posts
  • Version:GM:Studio

Posted 15 January 2014 - 04:56 AM

Would be very nice if it wasn't slow. I put about 32  objects with 40 * 32 sprites in the room and tried it; game comes to a screeching halt. If would be AWESOME if there was a way to combine Xot's color shading/change shader with the ability to use colorpal images like in yours.

Perhaps you could draw all of the objects to a surface and draw the surface with the shader effect. Maybe not. I don't know.


  • 0
I'm on Twitter as of March 2016 (@XorDev).

#14 Copy X

Copy X

    GMC Member

  • GMC Member
  • 67 posts

Posted 10 February 2014 - 04:36 PM

For some reason I get a ton of errors trying to run it, saying that scripts and stuff are missing even though they are all there.


  • 0

#15 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 10 February 2014 - 07:35 PM

Yeah, sorry all.  This is horribly out of date, and honestly, poorly implemented.  I plan on getting it back up and running sometime in the near future (as I will want to use it on my current project).  So I recommend against downloading and using this unless you want to just see how I did it and make it better yourself.

 

Going to update the original post with this message.


  • 2
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#16 Copy X

Copy X

    GMC Member

  • GMC Member
  • 67 posts

Posted 10 February 2014 - 08:21 PM

Thanks, that sounds like a fun challenge and I'm reading through it now. Looks great otherwise. I'm going to try to get it to work and for backgrounds too. :)


  • 0

#17 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 20 February 2014 - 08:11 PM

Interesting. 

 

I'd like a flexible colour swapping system that can work both on individual sprites (for sprite palette swapping) and for the output of a surface (to manipulate the whole screen's colours using only those colour values I store in an array for various effects such as fade to blacks).  My game projects I'd like to use it in have 16 colours max on screen so would only need that many (though for other projects I may need more).  I'd like to see what you come up when you redo this shader concept.


  • 0

#18 crusaderdesignproject

crusaderdesignproject

    GMC Member

  • GMC Member
  • 291 posts
  • Version:GM8.1

Posted 29 June 2014 - 09:26 PM

I apologize. I'm getting a 502 error. Server issue it seems. Can we get a re-up?


  • 0

twitter.com/RetroKoH

Game Maker user since 2002

PRIMARY PROJECTS (As of Spetember 2014):
Sonic Triad (Studio PR1 COMING SOON) - Sonic the Hedgehog Mega Drive Disassembly Editing Studio. HIATUS DUE TO MOVING


#19 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 30 June 2014 - 05:47 PM

Alright, everyone.  It only took a year, but I finally redesigned this thing.  The main post has been updated with a new download link.


  • 3
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#20 Toastline

Toastline

    GMC Member

  • GMC Member
  • 28 posts

Posted 06 July 2014 - 10:14 PM

It runs for me, but pressing up and down did not do anything. : (


  • 0

#21 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 06 July 2014 - 10:25 PM

That is... super weird.  Uhh... are you sure your keyboard is plugged in?  I mean... look at the code.  All it does is change one variable.

 

Look in the compile window.  Do you see the message "Shader did not compile correctly. Crap.", because if so, you need to install the latest version of direct X.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#22 Toastline

Toastline

    GMC Member

  • GMC Member
  • 28 posts

Posted 07 July 2014 - 12:06 AM

Yeah, keyboard's working fine. I tried using other methods to change that variable, and didn't see any changes in the sprites.

 

I didn't see any messages like that!


  • 0

#23 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 07 July 2014 - 12:07 AM

And you have ran other shaders and they work fine?
  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#24 Toastline

Toastline

    GMC Member

  • GMC Member
  • 28 posts

Posted 07 July 2014 - 01:33 AM

Yeah. I've only tried a few, though.

 

Edit: I tried reinstalling my graphics drivers, and now it works! Computers are strange beasts sometimes.

 

Cool shader!


Edited by Toastline, 07 July 2014 - 01:47 AM.

  • 1

#25 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 07 July 2014 - 01:53 AM

Glad you got it figured out!  Thanks for givin' it a shot.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#26 Copy X

Copy X

    GMC Member

  • GMC Member
  • 67 posts

Posted 16 August 2014 - 02:23 AM

You know if this will work on tiles? They seem unaffected.


  • 0

#27 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 16 August 2014 - 03:04 AM

Uh, you would need to be drawing the tiles manually rather than letting game maker just draw them whenever it feels like it.  Alternatively you could apply the shader in the post draw event to the application surface like you would any other "full screen" shader.

 

The most important thing is that you call pal_swap_set before you draw what you want drawn, and then call pal_swap_reset after you are done drawing whatever it is.  As long as you satisfy that, it should work on anything that game maker can draw.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#28 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 11 October 2014 - 04:34 PM

This seems pretty cool! I didn't even know it was possible to achieve an effect like this in modern graphics systems that actually maps colors to pixels instead of palette indices!

 

Might be a bit cumbersome to set up exact-matches for the colors, but I think I know a way around that (paste the palette in the Spare Page, then go through each image and replace two colors at a time using the Color Replace tool, when done with those colors bring up the Spare Page again and copy 2 new colors, etc). So basically ensure the same colors are applied to everything. So no biggie, basically.


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#29 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 11 October 2014 - 08:38 PM

Yeah, it can be a bit tedious to maintain consistent palettes across your sprites.  I've certainly had my share of "Did his hair just change color mid attack?" moments.

 

In photoshop, I typically copy and paste my palette directly onto the same layer as the sprite I'm trying to "normalize" (Off to the side or something).   Then using the magic wand with a 0 tolerance  and the contiguous option unchecked I ctrl+click every color in the palette.  After selecting the whole palette, you should have all of the pixels that don't match your palette outlined (because they aren't selected).  0 Tolerance & Contiguous disabled are your friends when working with palettes with many tools.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#30 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 11 October 2014 - 08:42 PM

I make most of my sprites in the GMS sprite editor, it feels (WAY!) more suitable for pixel art than Photoshop/GIMP anyway. It has a wand tool to nowadays, though, so the tip still applies.


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#31 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 01:39 PM

Yeah, it can be a bit tedious to maintain consistent palettes across your sprites.  I've certainly had my share of "Did his hair just change color mid attack?" moments.

 

Not if you use decent graphics software that has proper indexed palette functions that can save, load, remap palettes (both on the image and the current custom brush), check for duplicates, compact, and so on.

This be one of many areas the GM sprite editor is still majorly lacking in.

 

 

How do I run this example anyways?   I imported the GMZ as a new project to get a feel for how it works but I get this when I run it.

 

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_palette_manager:

undefined value
 at gml_Script_pal_swap_add_palette (line 11) - if(ds_map_find_value(Pal_Map,argument[0])==0)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_pal_swap_add_palette (line 11)
called from - gml_Object_obj_palette_manager_CreateEvent_1 (line 3) - pal_swap_add_palette(angela_palettes_wide);

Edited by Carnivac, 17 October 2014 - 01:41 PM.

  • 0

#32 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 01:55 PM

Yeah, sorry.  A recent change to DS_Maps broke some stuff... If a key didn't exist in a ds_map previously, it would return 0, now it breaks.  You can get it to sort of work if you change that line to: if(ds_map_exists(Pal_Map,argument[0])) but even then it still has some issues.  Working on it right now to figure out what is going wrong.

 

 

I use Photoshop for my sprites now, but I'm curious what you use.  I also run into those problems because I'm not an artist, and typically steal my art from old SNES game sprite rip sites (not proud of that, but it makes it so I can spend more time programming and enjoying what I'm working with).  If I were creating my own sprites it would be easier to maintain palettes.

 

Anyway, I'll make another post when I get everything up and running again.


Edited by Pixelated_Pope, 17 October 2014 - 01:56 PM.

  • 3
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#33 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 02:14 PM

Nobody ever reads my signature. :P

 

 

And yeah I can't get this to work myself.  I've never understood the DS stuff.  I'll have to wait for you to do it. :P   Already using a palette swap method as I think I mentioned to you some time ago but this looks very different and I want to give it a proper testing.  One issue I have with my current one is that for large areas of colour swapping (such as the whole gameplay screen changing colours) it can get slow.  I want to see if yours has any speed issues or not.


Edited by Carnivac, 17 October 2014 - 02:15 PM.

  • 0

#34 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 03:50 PM

Hey, it's not our fault.  Your pixel art is so eye catching that we immediately open your portfolio links and never get down that far!

 

Alright, it's updated.  But I've noticed that on certain computers/graphics cards (specifically my new laptop...) the color comparisons aren't consistent, sadly.  I don't know if this is just a driver issue on my end, or something more... bad.  So try it out, hopefully it works for you, but even if it does... it might not work for someone else, so it's difficult for me to recommend it for your project when I don't understand what makes it work or not work on certain computer/videocards.

 

As far as speed issues... I'm not sure what would cause mine to slow down.  I've had 50 small (8x8) characters on screen all using different palettes and it seems to work great.  Give it a shot for your full screen stuff and let me know how it performs.  


Edited by Pixelated_Pope, 17 October 2014 - 03:51 PM.

  • 2
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#35 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 04:24 PM

Heh thanks.

 

Ok that's working.  Not sure what you mean about the color comparisons not working properly.  Things look fine here.    I'll try and incoporate it into my RoboCop project (as that's the one that has much of the colour switching done at moment) when I got a bit of free time as an alternative to the current technique and apply it to the full screen colour swapping part (like the fades or pause screen) and see what happens to the frame rate. 


Edited by Carnivac, 17 October 2014 - 04:25 PM.

  • 0

#36 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 04:49 PM

The color issue ended up being a specific problems with the configuration of my laptop that switches between an awesome video card and a crappy one as needed to conserve battery.  It didn't know to use the awesome one.

 

So, yay.  I look forward to seeing your test results.

 

Not sure if it's something you'll need to use, but I also added a new script to the project: pal_swap_override_color(index,new color).  This will allow you to manually set the replacement color for the current palette for a specific color in that palette.  So, it could be possible to make custom palettes without needing to change your palette sprite or provide a new palette.  Just another way to do things.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#37 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 05:01 PM

Actually I am seeing some odd issues that I didn't notice before, sorry.

 

DceD9tV.png

 

Darkest hair colour and the dress don't seem to change colours. 


  • 0

#38 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 05:06 PM

Yup, that's what I was seeing.  What sort of graphics card do you have?  Are you, by chance, working on a laptop that has a graphics card as well as a built in card?  I had to use my nvidia control panel to force my Nvidia card to be selected by default and that fixed it for me.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#39 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 05:10 PM

Yup, that's what I was seeing.  What sort of graphics card do you have?  Are you, by chance, working on a laptop that has a graphics card as well as a built in card?

 

Yep.  No idea what graphics card it is.  Just one of those integrated jobbies.  Never really had issues with it til this. 


  • 0

#40 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 05:15 PM

Yup.  Integrated graphics cards don't work for this.  Apparently they aren't precise enough to identify certain colors.  *Shrug*

 

If you right click on your desktop you might have an Nvidia Control Panel option.  If so, click on it.  Then click on Manage 3D settings and then set the preferred graphics card to "High Performance".  If you have an AMD card, then there's probably a similar option the catalyst controller.

 

Here's a screenshot of said option.

PqNHh1q.png


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#41 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 05:21 PM

It just says Intel Graphics Options and there was a 3D setting that went between Performance and Quality but I tried all 3 values and nothing changed.  Oh well.   It's weird it picks those colours to ignore though.  The darkest hair colour seems random enough but the whole dress group seems a bit specific.


Edited by Carnivac, 17 October 2014 - 05:21 PM.

  • 0

#42 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 05:26 PM

Yeah, I really think it just comes down to the graphics card's precision.  Since I identify colors by using color_get_red()/255 which gives me an red value between 0 and 1... and according to the debugger these values can be up to 10 decimal places!  If your graphics card is just rounding those numbers off or something, it wouldn't get an exact match and that color wouldn't be replaced.  So that's why it seems to be specific colors.  It is odd that the entire dress seems to be affected by this, but I'm fairly confident that it's just a coincidence with the colors in the palette.  I might be able to go in and modify the palette and the sprite to different colors and get it to work.

 

Bummer that it doesn't work on your laptop. But I would still be really curious about how it would work in your project... and it might work with your palettes (maybe) and will most likely work on a different computer after implementation.

 

What's the palette swap system you are using now?  I wanna see if I can reproduce this with a different system.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#43 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 05:42 PM

http://gmc.yoyogames...68#entry4512037

 

Though I modified his code to use sprites as palettes rather than backgrounds (cos importing a sprite of many subimages is much much much quicker than tediously loading in single background pieces and having to name them all). 


  • 0

#44 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 06:22 PM

It looks like he is doing some pretty complex color conversions... converting RGB to HSL and what not... it seems to fix those errors we are seeing with mine...  Maybe I'll message him and see if I can get some help with mine.  I don't need all the features that his supports (I prefer my simple implementation) but would love to figure out how to fix this issue.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#45 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 17 October 2014 - 06:30 PM

Yep, may as well share ideas to build a better product.   :) 

 

I gonna be very busy this weekend with non-computery things so I'm in no rush. 


  • 0

#46 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 17 October 2014 - 08:38 PM

Haha!  Got it!  It was what I thought: crappier cards aren't as precise, so looking for direct equals isn't guaranteed.  I changed the shader to find the difference between the current pixel color and the "searching for" color, and if the difference is below a certain threshold (0.00000005 so... pretty damn close), it will replace the color.

 

Original download link has been updated, but here's another link: https://www.dropbox....e Swap.gmz?dl=0

 

I also added in an example of that palette color override I was talking about.  Hold down space and it will change the character's hair to blonde regardless of the palette. 


Edited by Pixelated_Pope, 17 October 2014 - 08:45 PM.

  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#47 gadgetmawombo

gadgetmawombo

    GMC Member

  • GMC Member
  • 330 posts
  • Version:Unknown

Posted 28 October 2014 - 07:54 AM

WOW! This shader is amazing, and there's no issues on my end! Seriously cool, I can't wait to implement this into my current project! And I'll certainly give credit although I can tell you right now that I woulda paid a couple bucks for this one on the marketplace, easy!


  • 1

Merv%20combo_zpsklyiqgwb.gif

39134.png


#48 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 29 October 2014 - 10:10 PM

Hehe.  Thank you.  I'm excited to see how it works in your project, and if your signature is any indication, your art is spectacular!  I'd put it on the marketplace just to get it more visibility, but I wouldn't feel right about charging anything for it.  This community has been so awesome, it feels good to have something even remotely valuable to give back.

 

Let me know if you run into any issues or have any further questions or feature requests as you implement it.


  • 3
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#49 gadgetmawombo

gadgetmawombo

    GMC Member

  • GMC Member
  • 330 posts
  • Version:Unknown

Posted 01 November 2014 - 05:55 PM

The only issue ive run into is a 22 color cap...I modded the shader to handle more colors with your instructions, but for some reason if i do more than 22 the shader crashes during compile.

22 colors is pretty good so far but id rather have 32 colors to be safe. Right now ive had to compromise which colors i want to change with certain characters that have more colors...Nevertheless its an awesome shader and has been really helpful so far in my project! Thanks for making it!


Edited by TsukaYuriko, 02 November 2014 - 01:27 PM.
Double post merged

  • 0

Merv%20combo_zpsklyiqgwb.gif

39134.png


#50 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 01 November 2014 - 07:01 PM

Hmm... I'm surprised to see that limitation.  I'll look into it.  There might be a limitation in GLSL or whatever with how I'm doing things (my problem, not GLSLs)...  Thanks for giving it a shot.

 

[edit] Yup...  I'm pretty sure my problem is the stupid long if else statement...  I'll see if I can think of a better way to do it.

 

[Edit 2] Yeah... I don't think I can fix this.  Because of how simple the system is to set up and use... this is apparently a limitation of my implementation.  There is another palette swap shader that is much more... full featured.  I'm sure it does not have this limitation, but as a result implementing it in your system might (emphasis on might) be a bit more difficult.

 

Here's a link.

 

I apologize for this limitation.  This is my first and only shader I've ever written, and it would probably make a more experienced programmer vomit all over their shoes.  But thanks for giving it a shot and helping me discover this limitation.  I'll update the main post with this information.


Edited by Pixelated_Pope, 01 November 2014 - 08:49 PM.

  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 





Also tagged with one or more of these keywords: shader, gm:studio