Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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  
  Limited Palettes  (Read 3846 times)
0 Members and 1 Guest are viewing this topic.
Offline coltonoscopy

Junior Member


Medals: 2



« Posted 2013-04-07 00:40:45 »

Hey all! Haven't posted in a little bit.

Basically, I've made the switch to libgdx and I enjoy it quite a bit. I also recently read up on my pixel art theory and the like and have grown fascinated with the idea of using limited color palettes. In particular, this resource has made me realize what I've been looking for for quite some time:

http://www.pixeljoint.com/forum/forum_posts.asp?TID=12795

My question is--in addition to the fact that you maintain visual consistency throughout your piece and lend a (perhaps subjectively) nice element of aesthetic pleasure to your pixel art--is there a performance gain to be had with using a limited color palette? The above work shows the use of 16 colors, which is frankly quite amazing and works pretty well, but I'm thinking more along the lines of pursuing 256 colors after doing some posterizing tests and such with GIMP on some game art I've picked off Google. I'm still learning a lot about graphics but want to know if having a limited palette could lend a boost in performance through libgdx, or least OpenGL, more specifically. I apologize for my naivete! Thank you in advance for your help and suggestions.

Colton

Straight flippin.
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2013-04-07 00:47:32 »

If you used a different colour format than RGBA8, then maybe it will take up less RAM. But otherwise I don't think so.

Offline coltonoscopy

Junior Member


Medals: 2



« Reply #2 - Posted 2013-04-07 01:04:09 »

I see what you mean. I know the Color class in libgdx can set its integer representations to 16, 24, and 32-bit, but I don't see any 8-bit options. I'm just trying to think if it would be worth settings something like that up by hand for any sort of gain. I can't imagine the gain would be extreme, but it would be nice to be able to take advantage of a 256-color palette in that regard. :]

Straight flippin.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #3 - Posted 2013-04-07 01:05:50 »

http://www.opengl.org/wiki/Image_Format

Just found this by using google. Maybe it will help.

Offline arnaud_couturier

Senior Member


Medals: 2
Projects: 1



« Reply #4 - Posted 2013-04-07 01:20:52 »

Yeah, except from the memory savings, you won't gain much (if any) performance, as today's cards and architectures are tuned for 32-bit colors.
And the memory savings will be negligible if you use pixel art. A 32x32 sprite costs nothing, even at 32-bit color depth:

32pixels x 32pixels x 1byte = 1kb for 8-bit (256 colors)
VS
32pixels x 32pixels x 4bytes = 4kb for 32-bit (true colors + alpha).

So I'd say you'll always be safe with pixel art and OpenGL.
Correctly using sprite sheets will have a lot more impact.
Offline coltonoscopy

Junior Member


Medals: 2



« Reply #5 - Posted 2013-04-07 01:30:54 »

http://www.opengl.org/wiki/Image_Format

Just found this by using google. Maybe it will help.

Appreciate it. Didn't really have what I was looking for, though. I was thinking more along the lines of indexed colors, which I read more about through just the Wikipedia article and was able to learn a bit more about it. I may do some research into it with OpenGL, but arnaud's information suggests it may not be worth the time.

Yeah, except from the memory savings, you won't gain much (if any) performance, as today's cards and architectures are tuned for 32-bit colors.
And the memory savings will be negligible if you use pixel art. A 32x32 sprite costs nothing, even at 32-bit color depth:

32pixels x 32pixels x 1byte = 1kb for 8-bit (256 colors)
VS
32pixels x 32pixels x 4bytes = 4kb for 32-bit (true colors + alpha).

So I'd say you'll always be safe with pixel art and OpenGL.
Correctly using sprite sheets will have a lot more impact.

I see, I see. At least I know where to focus my efforts! ;] Thanks!

Straight flippin.
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #6 - Posted 2013-04-07 01:40:06 »

Indexed colours only reduce file size. Once the file is loaded, every single pixel will have a 32-bit int for it's colour, unless you use a different format. Unfortunately that also decreases your available choices before you even make a palette.

But yes, as said, the difference is not worth it.

Offline coltonoscopy

Junior Member


Medals: 2



« Reply #7 - Posted 2013-04-07 01:43:14 »

Indexed colours only reduce file size. Once the file is loaded, every single pixel will have a 32-bit int for it's colour, unless you use a different format. Unfortunately that also decreases your available choices before you even make a palette.

But yes, as said, the difference is not worth it.

I was under the impression that was not the case, otherwise it would just make sense to use 32-bit color to begin with. My understanding is the pixels are rendered based on offsets rather than storing their own color data. Here's an excerpt from the Wikipedia article:

"Indexed color saves a lot of memory, storage space, and transmission time: using truecolor, each pixel needs 24 bits, or 3 bytes. A typical 640×480 VGA resolution truecolor uncompressed image needs 640×480×3 = 921,600 bytes (900 KiB). Limiting the image colors to 256, every pixel needs only 8 bits, or 1 byte each, so the example image now needs only 640×480×1 = 307,200 bytes (300 KiB), plus 256×3 = 768 additional bytes to store the palette map in itself (assuming RGB), approx. one third of the original size. Smaller palettes (4-bit 16 colors, 2-bit 4 colors) can pack the pixels even more (to 1/6 or 1/12), obviously at cost of color accuracy."

Article for reference: http://en.wikipedia.org/wiki/Indexed_color

Unless I'm misunderstanding what it says?

Straight flippin.
Offline arnaud_couturier

Senior Member


Medals: 2
Projects: 1



« Reply #8 - Posted 2013-04-07 02:05:00 »

HeroesGraveDev is correct, he said "unless you use a different format".
You can tell in what format an image will be stored in graphics memory, when you load it with glTexImage2D for example (google it and you'll find all the color formats listed).

OpenGL fixed pipeline does have support for palettes and color indices (never used it though, and I dunno how do it with shaders either), but it's rarely used, because nowadays it's not worth the hassle. I doubt LibGDX uses it, it probably just tells OpenGL to store all pixels in graphics memory as 16, 24 or 32bit, without using color indices, to keep things simple. You'd have to code directly with OpenGL to use its palette capabilities.

Just work in 32bit color depth, that way:
- you have all the colors you want
- you lose no performance, and almost nothing in terms of memory
- you have alpha
- you don't have to worry about anything, it'll work (tm)

Limit your palette on the artistic side, when you create your images/sprites, NOT on the technical side, which just brings more troubles than benefits.
Offline coltonoscopy

Junior Member


Medals: 2



« Reply #9 - Posted 2013-04-07 02:13:33 »

HeroesGraveDev is correct, he said "unless you use a different format".
You can tell in what format an image will be stored in graphics memory, when you load it with glTexImage2D for example (google it and you'll find all the color formats listed).

OpenGL fixed pipeline does have support for palettes and color indices (never used it though, and I dunno how do it with shaders either), but it's rarely used, because nowadays it's not worth the hassle. I doubt LibGDX uses it, it probably just tells OpenGL to store all pixels in graphics memory as 32bit, to keep things simple. You'd have to code directly with OpenGL to use its palette capabilities.

Just work in 32bit color depth, that way:
- you have all the colors you want
- you lose no performance, and almost nothing in terms of memory
- you have alpha
- you don't have to worry about anything, it'll work (tm)

Limit your palette on the artistic side, when you create your images/sprites, NOT on the technical side, which just brings more troubles than benefits.

I see. That makes sense, especially considering the fact that I would like to be able to incorporate colored box2dlights, shaders, Post-Processing, and whatnot, but it was nice to at least think about it and figure out why it wouldn't work. Thanks!

Straight flippin.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gimbal

JGO Knight


Medals: 25



« Reply #10 - Posted 2013-04-11 18:04:17 »

It might be interesting to view the Another World 15th anniversary edition Making of video (which is French, but with subtitles), which talks about the subject of using a limited color palette (16 colors) to still create something that breathes atmosphere. That game in particular was a huge success in that department.

part 1: http://www.youtube.com/watch?v=hWBV08FTXFw
part 2: http://www.youtube.com/watch?v=PPDN-tE7vQ0
Offline coltonoscopy

Junior Member


Medals: 2



« Reply #11 - Posted 2013-04-11 21:34:50 »

It might be interesting to view the Another World 15th anniversary edition Making of video (which is French, but with subtitles), which talks about the subject of using a limited color palette (16 colors) to still create something that breathes atmosphere. That game in particular was a huge success in that department.

part 1: http://www.youtube.com/watch?v=hWBV08FTXFw
part 2: http://www.youtube.com/watch?v=PPDN-tE7vQ0

Awesome, that sounds very interesting! I'll give it a watch. :] Thanks!

Straight flippin.
Offline Krux

Junior Newbie





« Reply #12 - Posted 2013-04-27 20:49:36 »

don't waste your time to store images in a different format than rgba 32 bit. It just makes things more complicated. The performance improvement can be done in most games with the correct usage of modern opengl (no glBegin, glMatrixMode, etc). There was something called color index mode, but it is deprecated, if you want it back you need to implement the color lookup in the fragment shader. Texture compression is something you could use.
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.

pw (37 views)
2014-07-24 01:59:36

Riven (38 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00

Cero (60 views)
2014-07-16 00:42:17

Riven (57 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!