Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (683)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (750)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  White sprite then choose colour  (Read 3640 times)
0 Members and 1 Guest are viewing this topic.
« Posted 2012-06-15 23:34:11 »

I was looking at the sprites that come with 'Project Zomboid', and reading a news update about how they at first had problems having to bind so many textures (in openGL) so eventually made a sprite atlas (I think thats the correct term). Just one character has a huge number of frames, and I was wondering, can you not simply provide a white styled sprite outfit, then use colours (in the case for opengl, glColor4f()) to colour them? This is what I was intending on doing, or have I missed some concept that makes this a bad idea?
Offline ra4king

JGO Kernel

Medals: 435
Projects: 3
Exp: 5 years

I'm the King!

« Reply #1 - Posted 2012-06-15 23:35:34 »

How would you color each section of the sprite?

« Reply #2 - Posted 2012-06-15 23:37:40 »

If it was done in grey and white, for shape and shading, would then changing the colour not alter the bits appropriately? For this I mean clothing for example, so base human sprites then coloured top/bottoms
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel

Medals: 435
Projects: 3
Exp: 5 years

I'm the King!

« Reply #3 - Posted 2012-06-15 23:42:06 »

Yes, but a sprite usually has many parts of different colors, how would you color each one?

« Reply #4 - Posted 2012-06-15 23:46:13 »

I'd seperate each part into a different sprite, which in their case would still be far fewer sprites. Also for me, and them (thus far) for example, their tops are all the same shape, just different shades of one colour. Everything that isnt supposed to be coloured obviously would be alpha so uneffected (I believe?)
Offline Orangy Tang

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

« Reply #5 - Posted 2012-06-15 23:53:21 »

If you split everything up then yes that would work. However I don't think it was just the colouring that the Zomboid guys were having problems with - it was the combinatorial explosion of lots of different animations at different angles while holding different weapons and different colours. When there's that many combinations it starts to make much more sense to do things in 3d (even if you just render it out into sprites and don't use the 3d models directly).

If you just want to recolour things you can also go old school and do palette swapping tricks (although you might have to emulate that in a shader).

[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 3 years

« Reply #6 - Posted 2012-06-16 16:27:02 »

grrr. I need to use game libraries so i can understand these questions
Offline Oskuro

JGO Knight

Medals: 59
Exp: 6 years

Coding in Style

« Reply #7 - Posted 2012-07-26 15:43:39 »

The complexity when recoloring sprites really depends on how much color variation goes into it.

If the color variation is simple (For example, each section only has dark, normal and bright colors), you can just draw and color the sprite normally, and then programatically recolor each section (as you know the base colors beforehand).

For example, let's say you want to recolor your Space Marine's armor and pants, so you draw the sprite normally, paint the armor green (RGB: #00FF00) and the pants blue (RGB: #0000FF), with the three color intensities being percentages (Dark 25%, Normal 75%, Bright 100%). Of course you have to make sure the rest of the sprite does not use any of these values

Now, when the player decides the Space Marine desperately needs a pair of hot pink pants (RGB: #FEBFEF), your program needs to look for all the Dark Blue, Normal Blue and Light Blue pixels, and replace them with the corresponding Hot Pink values.

Alternatively, use indexed color, and alter the palette in game. Or maybe save your sprite images with two layers: Color and Brightness (Grayscale), then alter the colors and multiply by the brightness layer.

There are plenty of ways to handle this programatically. One recommendation I'd make, though, is that, unless the colors need to change during gameplay (In which case palette swapping might be the way to go), make sure to pre-generate the recolored sprites during the loading phase on a per entity basis, for performance's sake.

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

orrenravid (190 views)
2016-07-16 03:57:23

theagentd (261 views)
2016-07-11 14:28:54

Hydroque (345 views)
2016-07-06 05:56:57

Hydroque (493 views)
2016-07-03 08:52:54

GrandCastle (376 views)
2016-07-01 09:13:47

GrandCastle (367 views)
2016-07-01 09:09:45

CopyableCougar4 (422 views)
2016-06-25 16:56:52

Hydroque (401 views)
2016-06-22 02:17:53

SwampChicken (365 views)
2016-06-20 13:22:57

SwampChicken (298 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!