Home Technical Talk

Is there a quick way to make a color palette texture?

grand marshal polycounter
Online / Send Message
Alex_J grand marshal polycounter
Like this for example:


The only way I can see to make something like this is manually by making a lot of boxes and filling each one. There has to be a quicker way, right?  There are some palette generators online but they only produce a handful at a time and seem geared towards home decor. 

I'd like to be able to designate a number of swatches, like 256 for example, and then maybe some sort of input for general theme.

There is enough stuff online that can be used but how did people make these in the first place? I could probably code one in unreal come to think of it, but i figure by 2024 there has to be some nice refined tool to do this sort of thing, right?

Replies

  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    solved -
    easy way in affinity photo is to open the swatches panel, then in the options you can import a palette from an image, and you can set up to a 256 color palette. So you can composite a few images together that have the colors you desire. 

    Then just set the display size of the palette to large and screenshot the swatches, and can arrange into a new texture.
  • Eric Chadwick
    Part of my first job was making palettes, in Autodesk Animator Pro. That thing was awesome for manipulating palettes.

  • pior
    Offline / Send Message
    pior grand marshal polycounter
    I must say I do not understand the original question (and I do use such palette textures, a lot).
    What do you mean exactly by *making* them ?

    Making such a palette usually means ... well, building it, by filling the slots (regardless of their size : 1 pix or more) with the specific limited colors that one needs.

    I don't quite see how extracting a palette from an image could help here, since it would result in way too many nearly redundant colors (unless one runs some kind of filter after the fact to simplify the result down to a handful of colors).

    Could you explain more precisely what you are actually trying to do ?

  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    @pior it's for making a texture to use for game assets. For example a 256x256 image that has X amount of unique color swatches. If you are familair with the popular Synty asset packs, I believe they do a similar thing. For a flat color art style, uv shells are just scaled way down and placed over a color swatch. 

    If it was a palette of like 64 colors it is easy enough to just make it manually, but I want a few hundred colors, and also do want some subtle gradients, and also want to be able to iterate on the palette easily. 

    The solution I found above works out pretty well for me because I can just grab some images with a palette that I like and get X number of samples from it, add it to the texture and then check it out in game. So it's pretty fast and effective.

    example: 

    A lot of the colors are redundant here, but I prefer to have plenty to choose from while experimenting, and then once I've completed most of the work, can cut out the stuff not being used. But as you can see with this character, having two colors that are close in hue/value are needed so that I can do subtle, fake lighting.
    The way I am working right now is that each column of colors is a palette for a level, so each level has a 64 color palette. That's a minimum I start from and if I find that I really need more then I may adjust but thats the big idea.
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Yeah, I am very much aware of the tech, I use it extensively myself. It's a fantastic way to make clean looking lowspec assets, or even blockouts to be sculpted/refined later.

    I guess the confusing part is that if you are at a stage where you need a lot of colors without optimization yet, then you might aswell start from a *universal* palette, as opposed to something extracted from an image.

    Or even, you could start from a big 2048 or 4096 texture where you can simply drop the source reference image(s). That way you can source, say, the gold of the headband directly from the reference illustration - and with plenty of room to spare to place little swatches to the side as the need arises. Working from a "real" palette early on could prevent all that.

    And then later on you can then optimize into a very compact palette for the real, final asset. Anyways, there are plenty of ways to go at it for sure.
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    dunno if it'll speed things along a bit but 

    aseprite will create a palette from an image you load and then let you save it out to png or whatever.  iirc photoshop can do this too. (example attached)

    i imagine you could use that to filter out the final result as well


  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    @pior
    i thought about using images directly but the only thing is that then i have to scale a uv shell down to a single pixel, otherwise I think it can pick up multiple colors? 
    I know that I've seen you mention a workflow like this before, just wanted to explain what I am doing completely for the sake of clarification and posterity. Are you able to show any such "color palette" textures that you've used before? Just curious to see palette-to- final models and how much a legit artist can do with it since I'm kind of new to this style. 

    @poopipe thanks I will check that out
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Well when bringing in a reference image you could for instance create little dabs where you want to extract the colors from. Overall what I am trying to get at is that going for a "real" palette directly can prevent this kind of flexibility. But that said it seems to clearly work well for you, so my point is moot really :D

    For final optimized assets there are a few different ways that I know of : 

    - Using a universal palette, like Joey Carlino does. I personally haven't tried this but this seems quite clever since he only needs/uses a single texture for all his characters apparently.


    https://www.youtube.com/watch?v=O6HQhs-gk50

    - There's also the hybrid approach consisting of having palettes *and* graphics directly in the same texture. Pretty much Dreamcast-era tech, as seen in Jet Set Radio, Space Channel5, and more recently Lethal League Blaze and BombRushCyberfunk. This allows lighting fast creation of characters since there is no need to cut in lips, eyes, and so on. If anything this could be used for the initial block-in, before cutting in all the details in geo to reduce everything to a palette.



    - On my end I use two kinds of palettes for final optimized assets : swatches for clothes/gear with two to four values for each color to create light/shade easily ; and gradient strips for metals and skin, for finer value control.



    Since texture data can be easily baked from one UV channel to another, all kinds of source textures can be used initially really : concept art illustrations, sloppy temporary palettes with roughly painted dabs of color, and so on. Basically anything that allows for the fastest iteration, *before* optimizing into proper palettes.

    I am not saying that converting images to palettes wouldn't necessarily work btw - I just don't quite see how this saves time since things need to be "properly palettized" for the actual final assets later down the line anyways, requiring to move things around manually. But admittedly I haven't tried that one specific approach in practice, and I probably should/will :D
  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    thanks @pior

    i just making it up as i go along. you are right, at this stage having an actual palette texture isn't needed, i just just figured it would be the simplest thing to start with. But there is a lot of good ideas I can look at in your post too, it's a good idea to have some gradients there in the texture as well, i hadn't considered that. 
  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    pior's examples of gradients and universal palette inspired me. Here is what I've come up with for now, it might actually just be what I stick with. Since the motivation for this isn't to fit the game onto a floppy disk, but rather just for workflow simplication, here is a texture that works pretty well and gives you most any color you can want, and its easy enough to get hue or luminance tweaks just by shifting the UV shells.   

    Some redundacy can be removed but if I can get color for entire game in one 2k texture I am not worried about, but of course you can tidy it up as you see fit.

    To make this I just found an online color picker, zoom the UI in pretty large, shift the hue and take screenshots. Paste into Figma because figma can grid arrange items easily. 

  • zetheros
    Offline / Send Message
    zetheros sublime tool
    I don't know if this method is good or not performance-wise; I'm assuming one gradient texture is more performant though and complex materials less so. Have you thought of assigning material instances to individual mesh components, and just using a colour vector parameter? This will allow you to change colours on the fly, spawn procedural items and so on
  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    zetheros said:
    I don't know if this method is good or not performance-wise; I'm assuming one gradient texture is more performant though and complex materials less so. Have you thought of assigning material instances to individual mesh components, and just using a colour vector parameter? This will allow you to change colours on the fly, spawn procedural items and so on
    Well it's a single texture for the entire game. I do have to use material instances for anything that wants something unique beyond the texture. Like for example, I have an EnemiesCommon material instance, and a lot of enemies can just use that, but if I want to tweak the tint or add an overlay or whatever on some enemy, then I derive a material instance for that. 

    So as it stands right now, all materials derive from a common master material, and then branch into like 2-3 material instance chains, and it goes 2-3 deep. I'm not sure how many it makes, but probably less than a hundred unique material instances for the entire game. And it seems like this single gradient texture can supply all of the colors.

    using a color vector and unique material instance for every color would save me one texture, but workflow becomes more onerous I think, because then I have to work between maya and unreal to build and iterate on the characters, whereas with the texture I can work entirely in maya and have 1 to 1 parity with unreal (since its flat colors and I have removed all color grading.) And then also, if I want multiple gradients to be used, and for it to be in object space, a shader to do that becomes more complex. 

    I am doing that with the environment pieces though because those tend to be more simple, and when i apply a gradient it's usually to an entire large piece, like an entire building. So it makes sense to do that in shader, whereas it would be difficult to do with a texture. 

    It is feasible to change to that for characters as all I would need to do is apply materials per UV shell, but I think because it complicates workflow I'd only do it if I really needed to. I am thinking that performance is going to be a breeze though since there is no lighting and it's a low-actor count game. Even when this game was prototyped using normal PBR textures at high resolution, performance didn't really become an issue. But I only target PC since it's out of my scope to go beyond that.


  • pior
    Offline / Send Message
    pior grand marshal polycounter
    That's a pretty cool idea indeed, and could be a handy compromise.

    If anything one great side effect of this technique (as a whole) is that changing things down the line later if needed is really easy. I recently had to revamp some of my source textures in order to unify a bunch of assets (completely changing the location of some of the swatches/gradients hence also modifying the UVs of multiple assets at once), and it was really straightforward. Making variants of assets (or even completely new assets from kitbashing others) is also painless. This iteration speed alone makes this kind of gameart more artistically interesting than highend sculpting/baking IMHO.

    The only suggestion I'd have would be to leave a bunch of room on this texture (perhaps freeing up half of it ?) in order to have space for some more unique swatches/gradients. Perhaps also adding a purely black and white gradient in there too.
  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    @pior yeah the speed and simplicity is just wonderful. Very fun way to work. 
    good idea to leave some blank "working space" available. 
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    You could (in theory) encode all your colours/gradients as a curve or 1dLUT , mark up the various different "material  IDs" with vertex color and offset them with parameters on the material instance to index into the curve. 

    bit of a waste of effort though imo :D 



  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    now that's hardcore, lol
    sounds like something to do if game was going to switch or mobile, but if that is the case, then I am rich and I hire somebody who already knows how to do such things, haha
  • iam717
    Offline / Send Message
    iam717 interpolator
    he said it was solved but for those that do not have af fin ity photo:
    For future people looking into the same thing.  (i was going to post but saw the solved)




  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    Alex_J said:
    now that's hardcore, lol
    sounds like something to do if game was going to switch or mobile, but if that is the case, then I am rich and I hire somebody who already knows how to do such things, haha

    its quite simple to implement, the effort is in setting the rules around what a material ID means.

    It's no more complex than dealing with a single indexed color palette but we stopped doing that for a reason..
  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    iam717 said:
    he said it was solved but for those that do not have af fin ity photo:
    For future people looking into the same thing.  (i was going to post but saw the solved)

    There's a lot of things online that can generate a simple palette from an image, but the one in affinity photo can grab up to 256 colors from it. I assume photoshop has similar or probably more featured than that. 

    The color gradient which gives a gradient both with value and saturation is found if you google color picker: 
    note that it seems to be a google specific thing, if you search with bing or whatever this doesn't appear
    the nice thing about this is that you can zoom your browser to make it as big as you need - I couldnt find another gradient like this that can be made large. THe good thing about this type of gradient is that you can scale UV shells horizontal for a saturation gradient or vertical for value, and diagonal for both (works kind of good for a fake metallic look)

  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Well, FWIW : 


  • iam717
    Offline / Send Message
    iam717 interpolator
    Alex_J said:
    iam717 said:
    There's a lot of things online that can generate a simple palette from an image, but the one in affinity photo can grab up to 256 colors from it. I assume photoshop has similar or probably more featured than that. 

    The color gradient which gives a gradient both with value and saturation is found if you google color picker: 
    note that it seems to be a google specific thing.

    Should i delete the links then?(u wud have to also since you quoted) pior's comment made me face palm, how could i forget that! i got used to the save for web gif version... :(
  • Alex_J
    Online / Send Message
    Alex_J grand marshal polycounter
    no reason to delete them, can still be helpful 

    some of my important discoveries came from comments where somebody mentioned tool or workflow offhand
Sign In or Register to comment.