Full-color backgrounds

Started by hcf, 04/26/2010, 12:13 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

hcf

I am going to post here something that I have been working on. In case someone is interested and/or wants more information, let me know.

During my (short) life as an amateur PCE developer, when I programmed non-srolling games, I used to draw 16-color backgrounds (and invoke them with the infamous load_background method). But after many time I was thinking... "the PC Engine can manage 16 background palettes, and each palette can manage 16 colors... so why THE F*CK I am only using 16 colors in my backgrounds?".

So, I have tested methods to split a picture in several fragments, and use a different 16-color palette in each fragment. If we divide the screen in 16 sections, we can have a theoretical limit of 256 background colors on screen (16 palettes x 16 colors each one). I tried several methods to split the background image (by rows, by columns...) but my primary methods did not give good results, as there were nasty effects in the limits of every row or column. But finally I have seen that splitting the image by SQUARES, and converting each square to 16 colors, gives very decent results.

I tried to apply this in one of my past games (my old Vampire Story Demo) and here are the results: for example, in the third background the differences are clear. In the two backgrounds of the left, the differences are not as good. Also, I have seen that this methods is usefull in realistic backgrounds (like these ones) but not in cartoon-like backgrounds.

IMG

Arkhan Asylum

looks nice!

did you end up writing a utility to handle the splitting, or did you just wing it by hand?
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

#2
hehe cool hcf, i 'am also working on a converter, who's using multiple palettes (all 16 in fact) ..

And i have also an idea to show 512 colors pics on screen ..
 =D> to you ..

How many colors contain this pictures exactly ???

hcf

In fact I was writing that application... but then I saw that it exists yet!! It is ImageMagick, it's free, and it's awesome because it can do first all the split and then transform to PCX format. The bad thing is that it is 256-color PCX, so finally I must open all those PCX fragments with another program and convert them to 16-color PCX, but it is worth the time (maybe 10 minutes, and I have converted all the backgrounds of the game). If you decide to use Imagemagick, I can help you because I have fought versus that program a bit yet  :D

Nazi NecroPhile

Well done; that's a pretty big improvement.  8)

How many colors did each pic end up having after subtracting the inevitable duplicates?
Ultimate Forum Bully/Thief/Saboteur/Clone Warrior! BURN IN HELL NECROPHUCK!!!

hcf

My previous response was directed to Arkhan. Touko, I didn't read your post when I was writing mine, because we were writing almost at the same time  :mrgreen:

So, the application that I said that exists yet (ImageMagick) is the one that says Arkhan (a program that splits the image and converts it to 16 PCX images). I was not talking about the application that Touko is making, that obviously DOESN'T exist yet. By the way, Touko, I would love to see your results when you finish it!! And... these 512 colors are 256 in background and 256 in sprites, or are you preparing us another surprise?  =P~

As far as the number of colors that NecroPhile and Touko asked for, tomorrow I will try to get a program to count them. I have tried to analize the JPG that I have uploaded, but it seems that the JPG format has changed a bit the image, so it is not totally reliable. I hope to tell you tomorrow how many colors are using those enhanced backgrounds, as NecroPhile is right: some of the palettes repeat colors, so the total is not 256 at all... but I hope that it's much more than 16.

touko

#6
Quote from: hcf on 04/26/2010, 01:27 PMIn fact I was writing that application... but then I saw that it exists yet!! It is ImageMagick, it's free, and it's awesome because it can do first all the split and then transform to PCX format. The bad thing is that it is 256-color PCX, so finally I must open all those PCX fragments with another program and convert them to 16-color PCX, but it is worth the time (maybe 10 minutes, and I have converted all the backgrounds of the game). If you decide to use Imagemagick, I can help you because I have fought versus that program a bit yet  :D
Yes i know imagemagic ..
For multiple conversions you can use Xnview will convert you all your pcx at time.

Arkhan Asylum

#7
If you have Paint Shop Pro, it counts the colors!

I tried to do it but the uploaded pic is a jpeg, so that didn't work as planned.


Ill have to give image magick a shot, since I am very retarded at image-work.  :) lol
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

hcf

It's strange... I am not able to count the colors used. I executed the demo with Mednafen, and I captured the screenshot (Print Page key). I pasted it in several programs (Paint, Photoshop, Ultimate Paint...) but the number of colors allways is enormous ( >1,000 ). And I try to count the colors before saving the picture!! (in order to prevent errors in the conversion). Anyone has used a method to count colors in a PCE game, with good results? Maybe the output of Mednafen is not exact, and I must use another emulator?

In any case, I would like to post here another thing that I have been thinking of: besides the limitation of the number of colors that we can use (which is the point that I am trying to solve now) we must keep in mind that we have another limitation: the total spectrum of colors in the PC Engine is 512. See the following example:

IMG

The first picture is the original, the second is the conversion to 16 colors, and the third uses my method (16 palettes of 16 colors, by squares). You can see in the face of the kid that the increment between adjacent colors is very high, whereas in the original picture it is very smooth. The reason, in my opinion, is that the PC Engine does not have colors in the middle of the ones that is using. In other words: the number of "blue" colors that we have is limited, so even if we can choose 256 different colors, there is not a high amount of "usefull" colors for each image.

In this sample, we can see that our method gives better results than using only 16 colors, but we are very far of that theoretical limit of 256.

Arkhan Asylum

sometimes its better to just use 16 colors and dither it, to get a similar shading effect.


especially for human skin, and stuff like you posted.    16 colors, dithered properly, ends up looking as good as if you use many palettes.


as for color counts, count the colors BEFORE you emulate?

Otherwise, there is a screenshot button in mednafen, that saves images, I think it is F9.

That will give better screen dumps than Print Screen key
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

Yes this is normal with your technique, you cannot have 256 colors on screen ..

max 80/96 colors ..

Vecanti

Here are some images I had.  They are all converted to 9bit (512 possible colors)

The first are 16 colors (out of 512)  the second set are 256 (out of 512).  The 256 I didn't do using the 16 color separate section technique, but I might give it a try. I'd think the results would be somewhere in between the 2 below.

16 out of 512
/zji13d.jpg

256 out of 512
/9u50xs.jpg

Arkhan Asylum

Quote from: touko on 04/28/2010, 02:24 PMYes this is normal with your technique, you cannot have 256 colors on screen ..

max 80/96 colors ..
You can have 256 colors on screen for the background.

16 palletes * 16 colors = 256.
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

OldRover

The actual number is 15 * 16 + 1. 15 unique colors per palette, plus one common color. That comes out to 241, which is your max color count for tiles alone. 242 if you count overscan, but that's not really even a consideration if you're only using tile memory.
Turbo Badass Rank: Janne (6 of 12 clears)
Conquered so far: Sinistron, Violent Soldier, Tatsujin, Super Raiden, Shape Shifter, Rayxanber II

Arkhan Asylum

oh, yeah, that damn common color that I always frigging forget about because im a retard.
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

#15
Quote from: guest on 04/28/2010, 07:31 PMYou can have 256 colors on screen for the background.

16 palletes * 16 colors = 256.
Yes in theorie, but with hcf 's method is clearly impossible ..

Only way possible is to make tiles with your hands.

hcf

In fact, using all the 256 different colors (or 241) is not realistic. As NecroPhile said, in almost every picture there are repeated colors. It is very difficult to split an image in 16 sections, using a different palette in each section, and achieve that every section uses 16 DIFFERENT colors. It's very easy that some colors are repeated between different sections.

As far as the "common color", now I am astonished. Why is my method working? I convert the original picture to 16 different pictures of 16 colors, but I am not ensuring in any way that all the palettes have a common color. It's strange... I guess that the common color is the first of every palette, that is the "transparent" color, isn't it? As far as I know, the transparent color in tiles IS displayed (whereas in sprites it is not displayed).

Hehehe, Touko, I have seen that in this thread we are allways posting almost at the same time  :mrgreen:

touko

#17
Don't wory about color 0, all colors 0 of each palette are ignored and only color 0 of the first palette is displayed ..

Quote from: hcf on 04/29/2010, 06:51 AMHehehe, Touko, I have seen that in this thread we are allways posting almost at the same time  :mrgreen:
yes, it's my 6th sense  :---)
 :P

Arkhan Asylum

color 0 is the common color between all palettes.

Every palette should start with that color.


While it isn't really realistic to get 256 unique colors unless you do a rainbowy pattern, you can still refer to it as "256 color" because say you use pink up in the top tile, along with some blues.

and then you need to the pink down in the bottom, with a buncha reds....!

You HAVE to duplicate colors sometimes :)
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

OldMan

So call me curious. Assuming we have 241 colors (bg reserved), what would be a good way of doing the color-matching for a picture? Obviously, we are gonna get dismal results if we just chop the colors to 3 bits a piece. So, if we count the actual colors, and assign the most frequently used to seperate palettes, then split the image up, would that help ? And what would I have to do if I decided to dither things ?

I know I have a -very- limited choice of colors, but I think dithering would help there. Unfortunately, I don't now that much about matching colors, or what would be considered a 'good' match via dithering.

I was gonna try to write one of these converters using allegro, but couldn't think of a good general-purpose way to do it. Anyone have any suggestions?

Arkhan Asylum

I'll talk to you about it in a few hours when I show up at your house. :D


but the short version of it is, there are some dithering styles already present that I can show, that might help
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

Vecanti

Quote from: TheOldMan on 04/29/2010, 05:17 PMSo call me curious. Assuming we have 241 colors (bg reserved), what would be a good way of doing the color-matching for a picture? Obviously, we are gonna get dismal results if we just chop the colors to 3 bits a piece. So, if we count the actual colors, and assign the most frequently used to seperate palettes, then split the image up, would that help ? And what would I have to do if I decided to dither things ?

I know I have a -very- limited choice of colors, but I think dithering would help there. Unfortunately, I don't now that much about matching colors, or what would be considered a 'good' match via dithering.

I was gonna try to write one of these converters using allegro, but couldn't think of a good general-purpose way to do it. Anyone have any suggestions?
What are the tile sizes 8x8?   I could see where you have an image and the top is mostly blue say 200 x 40 pixels.  Optimially you would use 1 or 2 pallets for that whole section and then you have 14 or 15 pallets left for a much smaller section of the screen.  You could do some pretty good optimization, you're right it's just figuring out how to calculate it and implement it.

Arkhan Asylum

it will be tricky to implement well I think, since most of it is kind of on the fly when you do it by hand.

There may be color optimization algorithms floating around out there already.
http://en.wikipedia.org/wiki/Dither

There are some traditional dithering methods.

I like Sierra the most.
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

hcf

In fact I tested to do Dithering too, but I didn't get good results. I must try that Sierra method...

It's important to keep in mind that "my" method is not an alternative to dither: my method and dithering have diferent goals and you can use both methods. My method simply splits the original image in 16 sections and converts each section to 16 colors. At this time (when you convert images to 16 colors) you can use dithering or not. I tested it, and I get some good results but also some bad results. Now I'm going to post here one example of a bad result when dithering:

IMG

The first two images where made using two methods of dithering (FloydSteinberg and Riemersma) and the third does not use dithering. In the two images with ditheirng, the result is a bit fuzzy and IN MY OPINION does not give any positive points, and the image without dithering is very clear. But this is only my opinion, and maybe someone can like more the results with dithering. Also, I have get other examples where dithering gives good results. Besides, dithering seems very very good if you see the image from a far distance, but this is not our case  :wink:

@TheOldMan: that application for conversion would be interesting, although there are some programs that do image conversions yet. Maybe you would like to test them before starting to do that program on your own.  In fact, almost every image program can convert a picture to few colors (for example, to 16 colors or 256 colors). I have used the free Ultimate Paint, and it converts to 16-color PCX well (don't forget to check the "Transparent" checkbox if you are making sprites). Also, it has another checkbox for "dither", although it doesn't have several dithering methods, it only has one). Of course ImageMagick can convert and dither too (the fragments of the images of above were converted with ImageMagick).

In case that you are still interested in making that program, well... in fact the idea that you proposed is one of the main methods to make color reduction (counting the frequency of every color). At this point, the key is choose which are the representative colors. If you search in Google for "Color reduction" you will find lots of these methods.

@GobanToba: Yes!! If there is a big part of the image where you can use only one palette, then you will have the other 15 palettes for the rest of the picture. In this case, you will probably have to do the split manually. The method that I proposed in my first post was an automatic way to do it (dividing the image in 16 square sections) but of course the results can be enhanced with your idea.

Arkhan Asylum

Here are some 16 color, sierra dithered images.

IMG
IMG
IMG

Also, the Doom image in my MML test video, is 16 colors, Sierra dithered, and you see it turned out nice.

This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

The best way i think, is to make yourself a converter.

I dont like dither, pics seems to be dirty.

hcf

Mmm, Sierra method looks nice!! But I think that there are cases where dither gives good results, and other cases where results are not as good, but it is just my opinion. For example, in the sample that you posted of "Shadow of the beast" I don't like dithering, I think like Touko: the picture appears to be dirty. But for example, the picture of the mountain is beautifull!!!  :D   In general, I am not using dither in my conversions, but maybe it is better to do the two options in every picture, and choose the best.

By the way, which program did you use to make that Sierra algorithm? And... what does your "change of avatar" mean?  :wink:

Hey Touko, you did not post at the same time of me today. Were you sleeping?  :mrgreen:

touko

#27
Quote from: hcf on 04/30/2010, 05:03 AMHey Touko, you did not post at the same time of me today. Were you sleeping?  :mrgreen:
Lol, yes a little bit ..

Some parts in rtype pic are good, like spaceship, but for the 2 other pics, i dislike ..
In my opinion, dither must be applied to several parts of pictures, not entirely.

OldMan

I understand there are image programs that do the conversions, but I haven't found one yet that will take into account the palette limits of the pce. The goal of writing a converter program would be to maximize the number
of useable colors on screen (ie, tile palettes would have minimal duplicated colors).
So, if we have a high-color (256+) image, which we convert to the pce's 3/3/3 color range, we could then choose
the most frequently used 241 colors as a basis for the palettes; we would probably have to dither the image at this point to minimize the loss of detail.
Then comes the tricky part: we would have to divide the screen (and probably the palettes as well) into sections, ordering them by actual # colors required in that area. That way, we can allocate more sub-palettes to areas with lots of different colors. Then we go throught the sub-areas, and build the palettes to (attempt to) minimize duplicate colors in each sub-palette....

I'm not sure it would be the optimal solution; I think you're still going to end up with lots of duplicated colors among the palettes. I do think it could be done, though probably not very fast. And almost certainly not as well as if you hand-tuned the colors. I'll have to think a lot more about it, but maybe someday I'll actually try this.
I always want to know how things like that work :-)

touko

#29
Fragmare has made a good utilities for converting a 256 colors bmp picture in pce format (with 16 palettes) .

Actually i'am coding my own ..

Vecanti

Quote from: TheOldMan on 04/30/2010, 09:43 AMI understand there are image programs that do the conversions, but I haven't found one yet that will take into account the palette limits of the pce.
The closest paint program I have seen is on Amiga.  My friend made a video of it and that is what I use.
You can chose a 9bit total palette (512 colors) and then anywhere  from 2 to 256 colors at once.   Each R,G,B slider goes from 0to7. 
Basically when doing color choosing and dithering and things this makes it a lot more easy because you don't have to worry that you get a color that doesn't exist in PCE palette.  All colors available are always part of the PCE palette.  Still mostly manually work if you want to split it up.

Arkhan Asylum

Quote from: touko on 04/30/2010, 10:43 AMFragmare has made a good utilities for converting a 256 colors bmp picture in pce format (with 16 palettes) .

Actually i'am coding my own ..
actually, I think Tom wrote that converter, since fragmare isn't a coder :D

Unless hes holding out.



This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

Keranu

Quote from: guest on 04/30/2010, 06:26 PM
Quote from: touko on 04/30/2010, 10:43 AMFragmare has made a good utilities for converting a 256 colors bmp picture in pce format (with 16 palettes) .

Actually i'am coding my own ..
actually, I think Tom wrote that converter, since fragmare isn't a coder :D

Unless hes holding out.
If he's referring to RGB2PCE, tom didn't code that. I don't know who did, but I got it from Fragmare and passed it on to several people.
Quote from: TurboXray on 01/02/2014, 09:21 PMAdding PCE console specific layer on top of that, makes for an interesting challenge (no, not a reference to Ys II).
IMG
Click the banner to learn more about Alex Chiu and his "immortality rings"

OldRover

RGB2PCE is a good utility but it alone isn't enough. Tom has a couple of utilities of his own that are much more useful.
Turbo Badass Rank: Janne (6 of 12 clears)
Conquered so far: Sinistron, Violent Soldier, Tatsujin, Super Raiden, Shape Shifter, Rayxanber II

Arkhan Asylum

im talking about uhhh


something 2bmpsomething or other. lol


not RGB2PCE.
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

Yes i thought to rgb2pce ..  :mrgreen:

hcf

In fact, before doing "my" method of splitting the image, I was trying to create a program like that, but it is very difficult...  ](*,)

As the Old Rover said, the program that converts the image to the PCE colors is not enough. Besides doing that, the program must build also the map of palettes that we must import in our program. For example, something like:

const char pal_map[NUM_TILES] = { PAL0<<4, PAL0<<4, PAL1<<4, PAL2<<4 ...};

This map will say which palette will be used in each tile.

As I was saying, it was very difficult to create a program that divides the image in sections and optimizes the use of palettes automatically in every picture. For that reason I searched generic methods (splitting by rows, by columns...) and I found that splitting by squares was a decent method, because the similar colors usually are near (inside the same square), so using a different palette for a square (said for example 64x64 pixels) was the best result that I found. Of course, an optimization made automatically by a program would be awesome  :D

Arkhan Asylum

interestingly enough, It seems like alot of developers couldnt be arsed to bother either.


Alot of commercial games have just 16 colors in the background, expertly used of course.


:D

Goban, what Amiga paint program?

This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

Vecanti

Quote from: guest on 05/01/2010, 08:54 PMinterestingly enough, It seems like alot of developers couldnt be arsed to bother either.


Alot of commercial games have just 16 colors in the background, expertly used of course.


:D

Goban, what Amiga paint program?
Brilliance

Arkhan Asylum

Right, Im sure it is, but what is it called?



:D


that was corny.


I may have to find/fire that up on my A4000
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!