User Tag List

Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 38

Thread: Suggestions for how to "palette swap" ?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Suggestions for how to "palette swap" ?

    I am working with pixel art and wanted to know any suggestions for methods to have a set of colors that can be swapped at runtime to a new set of colors. This is on a per object basis. I also want to be able to use this with all the runtimes, so shaders aren't really an option.

    Has anyone got an example of a simple method to do this?

  2. #2
    Clicker Fusion 2.5 (Steam)Android Export Module (Steam)

    Join Date
    Dec 2015
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make a different frame for each colour pallet and switch to that frame?

  3. #3
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    643
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Record each color your sprite uses one pixel at a time in an animation called "palette" or something similar. This way you have a sort of "array" of colors side-by-side. What you want to do is switch the sprite to that frame, modify each color using RGB values of your choice and the "Get RGB at" feature. Now your whole sprite should be the new set of colors.

    Here's an example

    palette swap.mfa

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Casleziro: Thanks so much. I think this will do exactly what I want. And it also allow you to revert to your original palette if need be. How did no one post something like this before?

    On a side note, does anyone know if invoking the Replace Color action causes serious overhead on the CPU or GPU? I am going to use this on mobile platforms.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Wow, very cool idea casleziro!
    Going to use this in the future

    @ mobichan: I've tested casleziro example with our good old speed tester,
    seems like (as it is now, doing additional 3 nested loops)
    it's 90/120 times as expensive as doing a distance (phytagorean) expression-editor calculation

    while reverting to a single "replace color" trims this down to 35/40 times (arguably..)

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    So, after modifying the example to swap between a few palettes of my own (instead of random colors) I now see it is not possible to revert to a "default" palette. The replace color function will replace any instance of that color in the palette frame, essentially overwriting the default palette. Any idea on how to get around this? I wish there was a way to get the rgb from another frame or animation direction.

    Shrodinger: thanks for the speed test. I am currently using 4 palettes of 139 colors each. So I guess the hit won't be so bad. My game is turn based, so it isn't like there is much going on each frame. And I only set the color when an object is initialized. I was curious if the newly colored active object needed to replace that color every frame once a setRGB has occurred or if that is a one time cost and after that the loop is the only cost?

    I am attaching my current working file.

    EDIT: Is there a way to copy the image of one animation to another?
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    The only solution I can find to restore the default color to the palette is to load the palette image into the animation. Unfortunately, this has a slight delay when the load occurs, so trying to do something fancy like color cycling of the palette is not really ideal. But there is at least a way to restore the default palette. My solution mfa is attached.

    If anyone can find a more efficient way to do this that doesn't require an external file to be loaded, I would really love to hear it.
    Attached files Attached files

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Interesting, seems like it can't overwrite the same color, right?

    You could keep a "fake" palette as the first "base" palette, and keep second (or any) palette modification as the "official" standard palette for the object
    This is not exactly ideal... but maybe better than loading an external image

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Schrodinger: any idea how to accomplish what you suggest? Since this is relying on an animation frame, it seems any replaceRGB action will modify the frame's pixels. And I can't figure out how to access another image source when modifying the palette image. I guess I could store a list or array of rgb values, but using an image is so elegant.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Oh, sorry, you're absolutely right,
    forget previous suggestion, I misunderstood the complication

    Now I see... yes.. probably an array would solve everything
    you could keep the "image" structure, agreed it's very elegant,
    and maybe a little procedure to automate the process:

    start of frame >>
    cycle through palette width and height and store it in array

    i.e.
    X0Y0 = object ID
    X0Y1 = palette ID (x coordinate of palette image)
    X0Y2 = palette Y0 RGB value (first Y coordinate of palette image
    X0Y3 = palette Y1 RGB value
    etc.

    Then retrieving would need parsing the array..

    Not as straightforward and elegant but should work..?

Page 1 of 4 1 2 3 ... LastLast

Similar Threads

  1. Replies: 0
    Last Post: 29th October 2015, 08:42 AM
  2. Replies: 6
    Last Post: 18th August 2015, 02:23 AM
  3. "Cannot load joystick2.mfx" when "Compress the runtime" unchecked. Fine when checked.
    By DistantJ in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 14th September 2013, 09:44 PM
  4. "Bug" For Saving and Loading Frame Positions AND "Timer Glitch"?
    By Zarpo in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 27th March 2012, 12:40 PM
  5. Resetting the "Frame Palette"?
    By Crash86 in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 28th June 2009, 11:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •