Solarus-Games English Forum

Solarus => Bugs & Feature requests => Topic started by: Shadowblitz16 on June 14, 2017, 05:12:09 AM

Title: (suggestion) color palettes and palette swapping?
Post by: Shadowblitz16 on June 14, 2017, 05:12:09 AM
can the devs add in color palettes and color swapping in solarus? it would be very nice to reduce the amount of sprites someone needs in there game
Title: Re: (suggestion) color palettes and palette swapping?
Post by: MetalZelda on June 14, 2017, 01:00:14 PM
It is already planned as pixel modification
Title: Re: (suggestion) color palettes and palette swapping?
Post by: Diarandor on June 14, 2017, 07:00:21 PM
Yes. In future versions it will be possible to access the pixels with functions get/set_pixel for drawables (surfaces and sprites), and with that you can easily code your own functions to modify the colors and do many other cool stuff. I guess that you will have to wait another year, more or less, until Christopho codes that.

What do you mean by color palettes?
Title: Re: (suggestion) color palettes and palette swapping?
Post by: oclero on June 14, 2017, 07:20:06 PM
I believe he's talking about palette swapping: http://wargroove.com/palette-swapping/
Title: Re: (suggestion) color palettes and palette swapping?
Post by: froggy77 on June 14, 2017, 08:14:42 PM
Thanks to the team, it will be a tremendous improvement.
I believe he's talking about a colorful array of donuts, ... a palette pallet of donuts  ;D

Title: Re: (suggestion) color palettes and palette swapping?
Post by: Diarandor on June 14, 2017, 09:04:23 PM
Quote from: Neovyse on June 14, 2017, 07:20:06 PM
I believe he's talking about palette swapping: http://wargroove.com/palette-swapping/

Ok, but for that I think that making new variants for the sprites is probably better (not a Solarus issue), unless there is too much customization and the number of sprites is huge... in that case it should better be done with code and the get/set_pixel functions.
Title: Re: (suggestion) color palettes and palette swapping?
Post by: Shadowblitz16 on March 22, 2018, 07:15:41 PM
I mean like built in editor/engine support for it not just set/get pixel functions for script
@Diarandor palette swapping is actually better then creating a bunch of duped sprites as it does the same thing with less work and takes less memory and space.
Title: Re: (suggestion) color palettes and palette swapping?
Post by: Satoh on April 12, 2018, 02:58:50 AM
if drawables could be accessed as arrays of bytes in a quick and efficient manner, it wouldn't be difficult to code a seek and replace function.

Better still if images could be defined from the start as palettized rather than full color, they could be altered by simply changing 32 bytes or so.

Really the only requirement for supporting palette swapping is allowing access to the memory that defines the image, which is something most engines don't do, presumably for either lack of necessity or lack of desire to deal with user-created issues.

I feel like a 2D pixellated engine would benefit a lot from handling this kind of interaction, but I also realize as a coder, how much hassle it could create.

If solarus ever picks up support for compiled shaders, it wouldn't be difficult to use a fairly lightweight shader to handle palette swapping...
however, shaders are their own box of problems to implement.

It all comes down to time and labor really.

Edit: one of the massive advantages palettes have over duplicated sprites, that hasn't been mentioned, is the ability to alter the colors of the sprite while it is in the middle of an animation, without losing track of frames or having to reload any sprites.
This is how the link-is-damaged flashing was achieved in in all of the 2D zeldas (and most 2D games from the 16 and 8 bit eras in fact).
This is how link can be flashing invincible, while still walking around. His palette would be replaced by red yellow and black or some similar series of colors.
This is also how a lot of water and fire animation was achieved. A single static image of a waterfall would exist in the game, and it would have a palette that rotated from dark to light.

This would be easy to achieve in a more modern way with per-object shaders. I've already written a very simple shader to do it, but I don't know how or if it is possible to apply it to anything in the engine as of now. The entity page is listed as mentioning shaders in the 1.6.0 documents' search, but it does not contain any references to shaders.