Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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 2860 times)
0 Members and 1 Guest are viewing this topic.
Offline JESTERRRRRR

Senior Devvie


Medals: 7
Exp: 1 year



« 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: 355
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?

Offline JESTERRRRRR

Senior Devvie


Medals: 7
Exp: 1 year



« 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: 355
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?

Offline JESTERRRRRR

Senior Devvie


Medals: 7
Exp: 1 year



« 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: 56
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).

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

JGO Kernel


Medals: 138
Projects: 4
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: 40
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (23 views)
2014-11-25 12:00:59

SHC (21 views)
2014-11-25 11:53:45

Norakomi (19 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (67 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!