Hello Guest

Author Topic: Multiple sprite colors in practice  (Read 5001 times)

1337Rooster

  • Newbie
  • *
  • Posts: 9
    • View Profile
Multiple sprite colors in practice
« on: August 10, 2013, 07:34:59 pm »

I like the idea of being able to change the colors on a sprite.


Approach #1
1. Create one version of your sprites
2. Use scripts to change color.

Problem with this approach. As far as I can tell the way to change the sprite color applies a blending algorithm with the new color. The guy in this example gets some decent results, but its not quite perfect he doesn't really look like the reference image, and his whites are blending by a lot. Maybe there are a few options here to tweak but I'm not sure if you get the control you want very easily?
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1924.msg9505.html#msg9505
This approach is nice because you can make the sprite animations once.

Approach #2
1. Create a different sprite for each color (Either doing this manually in photoshop or some sort of external script of your own modifying your sprite sheets (I imagine a replace sprite color/flood fill thing might not be to hard to write a python script for).
2. Create a separate sprite collection and animations for each other.

The problem with this seems to be that you need to create new sprite collections and animations multiple times (maybe a lot depending on how many colors you use). But you get a bit better control over how the sprites will look.

I like option 2, but I wonder if there is a workflow to make adding the different color sprites a bit easier? Maybe if I make the animations once, copy them and just toggle the sprite collection this would work? If I keep separate sprite collections for each color and keep sprites with the same names?

I'm just wondering what has worked well in practice for other users?


Edit:
Approach #3
Maybe there is a plugin to change the way colors get modified and I could create an in game way to write my own find and replace colors on tk2d sprites. Does something like this exist?
« Last Edit: August 10, 2013, 07:39:24 pm by 1337Rooster »

profanicus

  • 2D Toolkit
  • Full Member
  • *
  • Posts: 167
    • View Profile
Re: Multiple sprite colors in practice
« Reply #1 on: August 11, 2013, 12:37:47 am »
Not sure this really helps but approach #1 is the simplest method.

When you change sprite colours you are changing the colour of the vertices on the mesh that the texture is mapped to. Those vertex colours have to be blended/combined with the pixel colours somehow, and multiply is a pretty common method. You just need to make the source art to accommodate. Basically you paint in grayscale, and any white pixels will end up the exact colour you set the sprite colour to be, whereas darker pixels will darken the sprite colour by however dark they are. Just remember that pixels can only get darker, never brighter in this mode.

In that example you linked to, the result would have been a lot closer if ealtorfer had changed his source art as it is quite dark. And as Unikron said in that post, there are different blending modes you could use by changing the shader. For example if you used additive it would add the vertex colour to your source pixels instead of multiply, and you would paint your source art dark since it can never get any darker with an additive mode.

In any case, anything more complex than this that does not involve just making separate sprites is going to involve writing shaders.