Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

New Asset Store Package for Retro Sprites with Palette Swapping

Discussion in 'Assets and Asset Store' started by figs999, May 21, 2013.

  1. ZakWoolley1

    ZakWoolley1

    Joined:
    May 28, 2014
    Posts:
    10
    It doesn't work with sprite renderer.
    .
    The one on the right is what it's supposed to look like.
     
  2. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Greetings DrZakwaky,

    I'm sorry that you're having this problem. First thing though, can you please confirm that all of the textures involved have their import set to point filtering? This looks very much like what I see when I accidentally leave on bi-linear filtering, because it is definitely "sort-of" working, the colors just appear to be offset.

    Cheers,
    Chance Wees
     
  3. ZakWoolley1

    ZakWoolley1

    Joined:
    May 28, 2014
    Posts:
    10
    Yeah, it's all set to point rendering.
     
  4. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Could you please email me a copy of the asset files. Specifically the original texture, the palette map, and the color palette. Also what version of Unity are you using? My email address should be in the readme file included with the package.
     
  5. ZakWoolley1

    ZakWoolley1

    Joined:
    May 28, 2014
    Posts:
    10
    It's sent. I'm using version 4.6.1f1 of unity pro.
     
  6. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Thanks. I'll take a look at it now.
     
  7. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    115
    I'm glad to see this extension is still supported as I'm about to buy it now :)
     
  8. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    @ DrZakwaky: I just responded to your email with a fix. It was just a minor configuration issue, so everything should be good to go if you follow the instructions I sent. Be sure to let me know if you have any other problems!

    @tosiabunio: Always glad to help out my customers. Let me know if you have any questions :)
     
  9. Adam Kozłowski

    Adam Kozłowski

    Joined:
    Mar 7, 2013
    Posts:
    4
    Hi,
    We just got that plugin, and I got technical question about animation:

    Using "Palletize selected textures" creates me pmap without slices (all animation frames are on one atlas, of course).
    How to transfer or keep my slices which are used in animations?
    Would be great to keep all current work done on sprites and anims and just recolor them.

    Is it possible?
     
  10. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Hi Adam,

    This shouldn't be a problem at all. The best way to do it is to simply close or minimize unity, and then navigate to where those files are with your computers file system explorer. Then rename the original file to have an suffix "_original" or something similar. Then rename the "_pmap" file to have the original file's name. Make sure that _pmap file is in the same folder as the original file as well.

    When you re-open unity it will re-import the sprite using the renamed pmap file automatically. It does this because all of the sprite slicing information is store in the .meta file and not the image, so renaming the image file will just replace the old asset without issue as long as the image is the same size.

    Thanks for letting me know this was causing you issues! I hadn't anticipated this use case. I'll make a new version of the palletizer script that does this automatically.
     
  11. Adam Kozłowski

    Adam Kozłowski

    Joined:
    Mar 7, 2013
    Posts:
    4
    Thank you for reply and solution!
    It works, but we've bought plugin which is exporting and importing sprite sheet data - Easy Sprite Sheet Copy :)
     
  12. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Are there any interoperability issues with that plugin? Or is everything working now?
     
  13. Adam Kozłowski

    Adam Kozłowski

    Joined:
    Mar 7, 2013
    Posts:
    4
    I've wrote you an e-mail, still have some problems with output pmap and setting material.
     
  14. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    @Adam: I replied to your email. Looks like it was just a simple configuration issue as well.


    I'm going to try and set some time aside this weekend to make a visual walkthrough for this plugin, since it seems like most people are having similar issues when setting up sprites.

    If anyone has any particular part of the configuration steps that were confusing to them, let me know. I'll be sure to go over it in detail in the walkthrough.
     
  15. Adam Kozłowski

    Adam Kozłowski

    Joined:
    Mar 7, 2013
    Posts:
    4
    Thank you very much! Guys, you need to be careful and double check your sprite settings!
     
  16. emongev

    emongev

    Joined:
    Jul 5, 2012
    Posts:
    36
    So i see the material is changed from the default sprite material, does this mean that the drawcalls are increased?
     
  17. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Possibly. Since you have to use a material that has a special shader on it, if you were to use both it and the default sprite material they would not be able to be batched together. But all sprites using the OldSkool shader material would be batched together, so if you used it for all of your assets, it would still be one draw call per sprite texture used.

    *Edit*
    You will also suffer one additional draw call per pallette texture that you use. But if you were to do colorization in your assets, you would most likely duplicate your sprite atlases and suffer this draw call anyway AND take a memory hit.
     
  18. emongev

    emongev

    Joined:
    Jul 5, 2012
    Posts:
    36
    Oh okay, and as a random comment and question, since your website is down (or appears to be down), is this plugin still supported? :)
     
  19. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Yep, still supported. I try and deal with customer issues as soon as possible. Sorry about the website, I'll have to check on that.
     
  20. kathode

    kathode

    Joined:
    Jan 15, 2013
    Posts:
    63
    Before I purchase, I have a question about performance if you don't mind taking a minute to answer. I'm currently doing palette swaps using this method from a Unity conference session:

    Code (CSharp):
    1. void LateUpdate () {
    2.  
    3.         var subSprites = Resources.LoadAll<Sprite>("Characters/" + spriteSheetName);
    4.  
    5.         foreach (var renderer in GetComponentsInChildren<SpriteRenderer>())
    6.         {
    7.             string spriteName = renderer.sprite.name;
    8.             var newSprite = Array.Find(subSprites, item => item.name == spriteName);
    9.  
    10.             if (newSprite)
    11.                 renderer.sprite = newSprite;
    12.         }
    13.     }
    14.  
    I can have 20+ enemies on screen at once, and I'm seeing this pop up near the top of my profiler sessions. Would your method improve performance of this feature?
     
  21. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Vastly! The method you are using is not a true "palette swap", rather it is a sprite swap.

    Swapping sprites is a fairly heavy operation that involves a lot of steps "under the hood", including swapping texture and object data into memory, and re-initializing the sprite renderer and it's colliders.

    This package doesn't ever change the actual sprite that you are using for the objects, and instead only changes a very small texture. Not only does this mean that the system doesn't have to swap the memory used for your multiple full sized sprite sheets, but it doesn't have to keep a single full color sprite sheet in memory at all.

    On top of that, if you're not satisfied with it's performance or the support I offer if you run into any problems integrating it with your project, I'm always happy to give a refund :)
     
  22. kathode

    kathode

    Joined:
    Jan 15, 2013
    Posts:
    63
    Great to hear thanks. I am definitely not seeing the performance I want so this is something I'll be trying out in the next few days.
     
  23. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Your code is iterating through ALL sprites trying to find ONE .... and it's doing this every frame, for every sprite you are trying to swap... terribly inefficient algorithm. Keep an active list somewhere of the sprites you want to modify then you can just directly access them without having to search for them every time.
     
  24. kathode

    kathode

    Joined:
    Jan 15, 2013
    Posts:
    63
    Your code is iterating through ALL sprites trying to find ONE .... and it's doing this every frame, for every sprite you are trying to swap... terribly inefficient algorithm. Keep an active list somewhere of the sprites you want to modify then you can just directly access them without having to search for them every time.​

    Haha, it came straight from a Unity programmer! But yes, it's clearly not production code. I had actually forgotten about how bad it was until I started profiling.
     
  25. matthewlebo

    matthewlebo

    Joined:
    Mar 16, 2016
    Posts:
    7
    Is this still supported? Also, what would be the proper workflow if I have a single character whose animations (already created, and don't want to lose) that span 12 different sprite sheets via sprite renderer. And will Compressed setting work for my sheets with this asset? (Unity v5.3.2)
     
  26. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    Hi, Yes this package is still supported. I have received no complaints about it being incompatible with the current version of Unity. If you run into any problems with integration let me know and I can help out as soon as possible.

    There are no issues with multi-sheet sprites, as long as you palettize each of the sheets textures and apply the shader and palette to the sprite renderer. When you palettize your sprites, the tool will output a palette image that contains all of the color data from the original sprite sheets and one "palette map" per sheet. The palette maps are the same dimensions as the original sheets and just need to be swapped into the sprite animation as the image sources in place of the originals. You then set the sprite renderer to use one of the palette shaders and assign the palette image as the source for the 2nd shader image input.

    Unfortunately you cannot use compressed image files when using the palettizer due to technical limitations of the shader. You must use specific uncompressed image formats when using the palettizer. That said, palettization with this tool is, in effect, compression.

    If you use the recommended 64 color or less (Alpha8 format output) version of the palettizer, the resulting sprites will typically use less memory than if you we're to use a full color compression method.

    If you need to use more than 64 colors in your sprites then you will be forced to use full, uncompressed, image files for the palette maps. If you want to palette swap rich-color sprites that are relatively small, this can be an ok option, but this is not recommended for use with large sprites, for obvious reasons.
     
  27. matthewlebo

    matthewlebo

    Joined:
    Mar 16, 2016
    Posts:
    7
    Can I use one pallet map for all the sheets? Also is there any trial version or refund if it wont work for my situation?
     
  28. figs999

    figs999

    Joined:
    Oct 27, 2012
    Posts:
    50
    One palette map (the texture/image file) is generated per sheet. These just replace the original texture files in the sprite definitions, the same way that you use one texture per sheet when setting up a sprite in unity normally. The palette (the color definitions) is used across all of the sheets that you palettize simultaneously.

    Unfortunately I don't have a trial version, and don't typically offer refunds due to the risk of people simply using the package anyway. But I'll be happy to offer you assistance with integrating it with your project if you decide to buy it.

    If your sprites meet the following criteria you should have no problem with integration:
    -Are 64 colors or less
    -Use the standard Unity Sprite implementation ~or~ are simple texture planes
    -Are power-of-two dimensions (not normally a requirement, but still a good guideline)
    -Do not require anti-aliasing or bi-linear filtering
     
  29. masterchafe

    masterchafe

    Joined:
    Oct 2, 2011
    Posts:
    59
    How would I go about reversing a palettization process of a Sprite sheet? I made alterations directly on the generated texture, and now I'd like to turn it back into the original 64 colour png image so I don't lose my changes. Cheers!
     
  30. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    706
    Hello, is the author still supporting this product?

    I am wondering if I should grab this from the asset store, but it seems like the author haven't replied to the above poster's question since last month.
     
  31. JaseofBase

    JaseofBase

    Joined:
    Jun 12, 2017
    Posts:
    14
    Hey there, is this still being supported? Does it work with Unity 5x?

    Need to know before I buy it, thanks!
     
  32. kathode

    kathode

    Joined:
    Jan 15, 2013
    Posts:
    63
    The author seems to be gone, but it's still functioning fine for me in 5.4.1.
     
  33. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    115
    Works fine in 5.6 as well.
     
  34. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Is it possible to use this asset for 90's style color/palette cycling? I'm trying to create this effect using color cycling rather than animation:

     
  35. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Since there is no "live" indexed color display mode, what you have to do nowadays is a realtime remapping from "index" data to palette data, like in a shader, with a base offset to cycle the mapping.
     
  36. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    So, is it possible with this pack, but with some effort to get it working? Or would it require a whole different method?