18 August 2020

8bit And 16bit Color Palettes

It took me quite a while to understand how 8bit and 16bit palettes work.

To spare you the search, I've decided to write this guide.


Motivation

Creating authentic 8bit and 16bit graphics requires understanding palettes. There are programs and algorithms, which transform your images into 8- or 16bit. Since algorithms cannot guess the intention behind the color choice and miss the context, creating them yourself is more flexible and results in higher quality. It also prevents the loss of details due to quantization. Additionally, to some, pixel-art is about control, and creating the palette gives such.


8Bit Graphics

During the era of the Nintendo Entertainment System, the technology worked with 8bit. Therefore the color of a pixel is represented by eight ones or zeroes. Today a pixel carries up to 32. You might be familiar with the red, green, and blue or RGB, where we split a color into three components. However, dividing 8bits into three colors is ambiguous. That's why there are formats for palettes. RGB332 is the most common for 8bit. It means we assign 3 bits to each red and green, and two bits to blue. A lighter orange would be 111 100 01, which would be 7 for red, 4 for green, and 1 for blue. That's nearly 0, so almost black.

comparisonBlackAndOrange
Comparing the colors.
Left: Black; Right: Our Orange


What Is A Palette

Better idea: We map each RGB value onto a level. 

For example, let's map the following blue levels:

00 -> 0

01 -> 79

10 -> 155

11 -> 255

The color levels (right-hand side) the bits map to is our palette. Back then, hardware limited us to use one palette for all drawn on the screen at the same time. Years later, the Super Nintendo Entertainment System was released. Powered by 16bit, our capabilities increased immensely! A typical format for 16bit is RGB565. Today we use 24bit ("true-color") and the RGB888 format. Some formats use RGBA, followed by four numbers, where A (="alpha") stands for the transparency.

Side note: The sum of the numbers does not need to add up to the number of available bits. Ergo RGB333 is a valid format for 16bits.


Creating A Palette From Colors

Using preexisting colors to create a palette takes three steps. First, choose a format. Then add them to your palette.

Let's use the following colors for an 8bit palette of the format RGB332:


Red
Green
Blue
Black   
000
Color 2
212211198
White  
255255255
Color 4
248216198
Color 5
248197198
Color 6
232173159
Color 7
979943
Color 8
11723473

The format gives us 3 bits for red and green and 2 bits for blue. The formula for the number of representable levels is 2bits. That is enough for 23 = 8 levels of red and green each and 22 = 4 levels of blue. However, our colors have six unique levels of blue (0, 43, 73, 159, 198, 255). Therefore we can't represent all eight colors.


Quantization

Quantization, the third step, will help us here. For this one, we'll merge close color levels.

Our two colors:

248 red, 216 green, 198 blue            232 red, 173 green, 159 blue

will then (for example) become:

248 red, 216 green, 198 blue            232 red, 173 green, 198 blue

By choosing a good looking and distinguishable color level, we can optimize this better than an algorithm. Then we continue adding all needed colors and quantify them to our palette. Now with our palette created, we can color the pixel art.


Tips And Tricks

Reminder: In 8bit and 16bit video games, everything on-screen at the same time uses one palette. Therefore use the same palette for all associated sprites.

The difference between darker colors is harder to notice. Thus use less dark color levels.


Examples


senkoPixelArt16Bit
Senko Pixel Art, 16Bit Palette (RGB565)
 drawn by GreenyNeko

This pixel art of Senko uses an RGB565 palette with the following color levels:

Color1234567891011121314151617...32
Red097126155174197205212222227232248----

Green04654608399106163173188197207211216224234255...-
Blue0434860738893101118159175198236255--



Notice that there's still space in the palette marked by the "-"s.

Senko Pixel Art, 8Bit Palette (RGB332)
drawn by GreenyNeko


This one uses an RGB332 palette with the following color levels:

Color12345678
Red097126155174197212248
Green4683106156173197216234
Blue43106175198


16 June 2020

Mobile, Mobile or Mobile Games?

The "graphics" versus "aesthetics" misunderstanding between players and developers isn't the only problem. Even developers confuse each other with terms like Mobile, Mobile, and Mobile Games. Though, this issue arises from the ambiguity of abbreviation. The full terms would be games on mobile devices, games developed for mobile devices, and mobile context-aware mobile games. But what is the difference? Why are they all just called "Mobile Games"? And how to categorize games like Diablo Immortal, Merge Dragons, Weather Farmer, Emulators, Pokemon GO and Candy Crush?

Mobile Games as Games On Mobile Devices

Showing a game with simulated analog stick and buttons.
Non-natural input on smart-phone.
https://pixabay.com/photos/game-play-mobile-game-android-game-4622800/
"Games on mobile devices" is the broadest category. If a game is available for a mobile device, such as a phone or tablet, it is a mobile game, more accurately, a mobile device game, which abbreviates to a mobile game. Ported games are a massive subcategory of these. Their typical controls are buttons and analog stick simulations, like in Diablo Immortal or Emulators. As such, they can't belong to the next category.



Mobile Games as Games Developed For Mobile Device

Showing a game that uses touch to drag and swap candy
Natural input on smart-phone.
https://www.piqsels.com/en/public-domain-photo-jfxiz
A game designed for mobile devices uses device inputs naturally. Since a game developed for a console is a console game. A game developed for a mobile device is a mobile game. Hence the confusing terminology. An example of natural input on smartphones would be tapping to select an object, or dragging your finger over the screen to move an object. However, natural-input does not match all games. Thus, "one does not simply [develop an MMORPG on mobile]"[1]. Merge Dragons and Candy Crush are games developed for mobile devices, but not the next one since they don't use contexts.


Mobile Games as Context-Aware Mobile Games

Showing a game that uses GPS and AR as contexts
Game using GPS and area context
https://www.flickr.com/photos/140521268@N03/27947940226
When using the device's position, surrounding area, light level, etc.. We get a context-aware mobile game, specifically, a mobile context-aware mobile game. Since it is a game and contains "mobile" twice, it is a mobile game. Researchers are still researching these relatively new mobile games, but they already provide a plethora of possibilities. Their era got initiated by Pokemon GO. And present features such as considering weather-data like in Weather Farmer.[2]

Conclusion

Now you know about the different mobile games. You understand why they're called mobile games. And you know their differences and what determines their category. Keep in mind these categories do not determine the game's quality, though they relate to their uniqueness. You don't see games using your location or weather on a computer, for example. That wouldn't work well either unless the player is using a laptop.

[1] Lord of the Rings - One Does Not Simply Walk into Mordor Meme
[2] Technical University Munich: IN0040 Social Games

29 May 2020

We All Might Possess Eri's Quirk From My Hero Academia

Occasionally, I watch Youtubers review games or animes, and I saw the episode discussing Eri's Quirk. On the same day, I talked with another person about my fasting. Then I realized the connection. But, let's clear things up first.

Who Is Eri And What's Her Quirk?

"My Hero Academia" is an Anime playing in a world where people are born with special abilities, called quirks. They pass these down through genes. In the fourth season, they rescue a girl named Eri. Her ability rewinds a person's body to a previous state. Using it too much will revert the person to a baby and eventually to stop existing. While this sounds like a bad thing, rewinding injuries is possible as well.[1]

Just Fantasy Right?

So, reverting injuries, returning your eyesight, undoing cancer, etc.. Living forever. These all seem surreal, but they're not far fetched. Our bodies heal and repair themselves already, which is done by reproducing cells. However, every time reproduction happens, there can be errors, mutations, and damage, the current principal behind aging. There's a solution, though.

Longevity Genes - Core Of The Quirk

The longevity genes repair the damage done to the DNA during reproduction. However, living organisms have two modes of living. The "growth and reproduction" mode, during good times, and the "protect and repair" mode, under severe conditions. These conditions can be reached by eating less in general, eating less meat, being uncomfortable cold or hot, and during high intensive exercising.[2] During the latter, the genes will slow down aging, But, the quirk doesn't only slow it. It also stops and undoes aging.

Gene Therapy

dna, building, block, nature, gene, medical, built, blue, animal themes, animal
Image of DNA from
 https://www.pxfuel.com/en/free-photo-jrtql
Using gene therapy, scientists reset the epigenome of mice, resetting their age. However, when not careful, the cells may become pluripotent ones. Meaning they don't know their purpose yet - being tumors. Switching this procedure on and off on mice worked well. Unfortunately, given the approximately 37.2 trillion cells of a human[3], we're not there yet. But now it doesn't seem as far fetched anymore.

So, In Comparison

To recap and compare. Both Eri's quirk and gene therapy can revert cells to a previous state. Allowing the healing of damaged cells, blindness, cancer, and more, enabling us to live forever. Additionally, they both share the problem of resetting too far. But neither scientists nor Eri, have figured out how to control this. We're unable to revert a lot of cells at the same time, while Eri isn't able to control the intensity or ending it. Another difference is, we don't need to evolve this quirk. It's already built-in for us.


[1] My Hero Academia: Season 4 Episode 13 & 14
[2] How to Slow Aging (and even reverse it) - https://www.youtube.com/watch?v=QRt7LjqJ45k
[3] https://www.wonderopolis.org/wonder/how-many-cells-are-in-the-human-body
Liked the post? Noticed an error? Wanna discuss the content or leave a comment*? You can join or check into the discord to do so! (*Note: Comments are disabled to avoid saving user data on this website.)
>> Join Discord

About Me

My photo
I'm a junior game developer and software developer and I created this blog to share my ideas, thoughts and whatever I'm working on or doing.