Author Topic: (suggestion) color palettes and palette swapping?  (Read 845 times)

Shadowblitz16

  • Newbie
  • *
  • Posts: 3
    • View Profile
(suggestion) color palettes and palette swapping?
« 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

MetalZelda

  • Hero Member
  • *****
  • Posts: 544
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #1 on: June 14, 2017, 01:00:14 pm »
It is already planned as pixel modification

Diarandor

  • Hero Member
  • *****
  • Posts: 935
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #2 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?
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Neovyse

  • Administrator
  • Full Member
  • *****
  • Posts: 108
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #3 on: June 14, 2017, 07:20:06 pm »
I believe he's talking about palette swapping: http://wargroove.com/palette-swapping/

froggy77

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #4 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

« Last Edit: June 14, 2017, 08:17:15 pm by froggy77 »

Diarandor

  • Hero Member
  • *****
  • Posts: 935
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #5 on: June 14, 2017, 09:04:23 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.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Shadowblitz16

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #6 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.

Satoh

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: (suggestion) color palettes and palette swapping?
« Reply #7 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.
« Last Edit: April 13, 2018, 07:39:43 am by Satoh »
Patience is difficult and rarely thanked, but always appreciated, and sorely missed when absent.