Palette

Started by Babar, Tue 07/06/2005 11:26:35

Previous topic - Next topic

Babar

I am working on a game using the Insta-game pack, so if any of it's creators can answer, it would be great. The problem is, although I load the palette included in the pack as a room, and unlock all the colours, when I import a sprite (specifically the lil poncho-fied alien), some of the shading disappears. What is going on?

Also, a question in general about palettes, how exactly do they work? The directions on how to load them is in the manual, but I don't understand WHAT exactly those little slots are. For example, when I load the palette in the insta-game, it causes a large number of the little slots to be filled with colour. Are these the room independant colours only? Aren't they a few too many for just the characters and items? Can I lock the ones that involve colours that aren't in the sprites I am using?

What about the slots with the X's on them? The tick says that they are room dependant. Does that mean that I can load rooms which have colours that I haven't unlocked? Does that mean that I can load a room with only as many colours as the boxes with X's on them? Or do all the rooms have to have colours only from the palette?

I hope I haven't been mistaken in posting this here. Has it been completly explained somewhere else?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

monkey0506

Perhaps those colors aren't included in the palette?  Try changing to hi-color and see if you still lose the shading.

As for the palette, as far as I know that's the only colors you can use in your game.

Gilbert

Unlock sufficient amount of palette slots, select them (you can keep shift pressed to select a group of slots) and then import palette colours from the graphics .PCX's.

Babar

Nope, monkey, if I do it in hi colour, the shading still appears. I think the colours probably are in the palette, because the palette was made FOR those sprites. But I can't be sure. That is why I asked for some instagame person if they could help.

Gilbot, I got that part, but does that mean that I import only those colours that will be universal (room independant)- for characters, sprites and icons- or that I have to import the colours used in the rooms as well?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

If they are colours that are used only in rooms, you don't need to do that. Those slots with 'X' are for rooms, which can be different in each room file.
When importing a background for a room, I think what it currenly does (assume you're not using exact palette import), is something like:
for each colour used in the BG file:
1. if there's an exact match in the room independent slots (those without 'X'), just reassign the pixels of the imported BG to that slot.
2. if that colour does not appear in the room independent slots, two things may happen:
  (a) if there's at least one free room dependent slot (those with 'X'), assign such a slot to that BG colour,  then reassign the pixels of the imported BG to that slot.
  (b) if there're no free room dependent slot left, reassign the pixels of the imported BG to some closest colour from the current palette (doh!)

Babar

Thanks for the run through Gilbot. I appreciated it. Got the answer I was looking for. As for the specific sprite palette problem with the insta-game, monkey was right. It turned out that the palette just didn't have the proper colours.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

monkey0506

I figured that might be it.  Even though the palette was created for these sprites, some things do slip through the cracks at times...  Glad I could help. :=

Babar

OK, I got another question now. The game I am planning only has about 2 or 3 rooms, including the title screen. Would it somehow be advantagious (faster, or taking less space) to place ALL the colours required in the game into the palette?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

You meant, together with the room colours?
I think it won't make much difference.

Babar

Ok, I have a new problem now.
I wanted to make some sort of a "time warp" screen, like in Space Quest 4). You know- moving through rainbow colours and such.

Since I was using 256 colour, and the manual even mentioned that it is possible to achieve this effect, I attempted it.
First I made a background of about 10-12 colours, going in vertical lines, and looping back to the colour at the start. They basically followed R-O-Y-G-B-I-V order. I then loaded this into the AGS editor, and unlocked the colours. I put the cyclepalette command in the repeatedly_execute, with the starting and ending slot numbers of the colours I had unlocked.
Unfortunately, it didn't work. When I tested the game, all it looked like was blinking bars. There was no "flow".

Ok, so as a test I made another background. I used the photoshop gradient to make a rainbow warp display across the screen. I saved it as GIF and loaded it into the AGS editor. I had to remove almost all the other colours because this screen took up a lot of slots. This time the "flow" was better, but for some reason the brightest slots in each colour apeared right at the end. So there was this small collection of colours moving together disrupting the rest of the flow. Also, the brightest colours in the BG didn't move at all. They stayed in their place for some reason.

Can anyone help me find the problem? The 2nd bit was just a test, I can't realistically do it like that, because it uses too many colours. Also, how do you take screenshots ingame, so that I can show you the problem properly?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

Well, photoshop is just retarded for true 256 colour images.
To archive best results (especially when you're using palette effects) it's advisible to use a graphics editor supporting 8-bit mode natively and can manage the colours used in the exact slots. This way, you can arrange your gradients at desired slot, and when importing into AGS, always use exact palette import to ensure the editor won't remap your colours so to mess up the slots.

Babar

#11
hmm....while we're at it, how exactly do you reduce a hi-colour image to 256 (or less) in Photoshop?

Also, what can you do so that your colours get imported in an exact order in the palette editor? So that when you cyclepalette it doesn't look crazy?
BTW, I am using the eric method to import colours into the palette editor (loading the  colours as a background image and unlocking the colours). How do you actually use the import palette function?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

I don't use Photoshop, but there're something like "colour depth" option I think.

As I mentioned before, all you need to do is to use EXACT PALETTE IMPORT features.

For backgrounds, to import the background with exact palette just click the last button in the room menu (V2.62 or before), or choose it from the room pulldown menu (V2.7+).
For sprites, just uncheck "remap colours to palette" during import.

This is what will happen during exact palette import:
1. if you import a background with exact palette, what the engine does is:
  - for that room, the room dependent colour slots (the 'X' ones) are set to whatever they appear in the import file (so, for example if colour #144 is purple in your image file, and #144 is a 'X' slot, it will be set to purple in the room's palette), room independent slots remain as-is lik they're shown in the palette screen of AGSedit.
  - the image pixels are imported without modification (like for example, pixel (10,50) is of value 35 in the file, it will also be 35 in the imported background). NOTE: if the background file uses colours from the room independent slots and say if the slot 48 was blue in the file but that slot is set to red in AGSedit those pixels will all appear red after import.

2.  if you import a sprite with exact palette, what the engine does is:
  - the image pixels are imported without modification, no change is done to the palette. NOTE: For room independent colour slots, if the colours in the file are different to what is set in AGSedit, they'll appear as whatever they are set to in AGSedit, if a sprite uses room dependent colours, it's possible that they'll be different in different rooms.


So, to use exact palette import successfully you must make sure that the image files follow:
1. The colours of the roomindependent slots appears exactly as how they're set to in AGSEdit.
2. If it's a sprite image file, make sure it won't use room dependent colours.
(With exceptions, if you really know what you are doing)

The best way to make your images keeping these rules is to make themnatively in 256 colours, using a programme that actually supports such modes (like DP, Grafx2, etc.). It's not advisible to draw such images using hi/true colours and then reduce their colour depth, though Photoshop may be able to convert an image to the above requirements with some tweaking, in my opinion it's not worth doing so.

Babar

#13
Actually Gilbot, importing a background image with "Exact Palette" matches up all the colours in the new background to their nearest match in the palette. At least that is what it does with me.

I'm using a greyscale image now, and it seems to be working (even though it is really ugly due to thick bars and b&w). However, here is what happened when I tried to import this BG:


When I unlocked the colours from the palette, they came out like this:
http://www.2dadventure.com/ags/palette-bab.bmp
(The colours I unlocked are the ones at the bottom).

As you can see, the colours slots are not in order, so cyclepalette doesn't work nicely with them. It just causes the bars to flash in random colours.

So...um....help?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

#14
No, and since the colours are all moved to the end of the paletteÃ,  it's possible you choosed ordinary "import background" instead of the correct "import abckground (exact palette)".

1. The Gif you provided had the palette slots messed up already (really messy). Just check it with a REAL (no crappy photoshop, sorry) programme to see how they're arranged (well, using just irfanview is enough to check that already).
2. Since the Gif uses the first half of the palette slots and those colours do not match the ones preset in the AGS editor, if you import it with exact palette it will appear severely messed up (tested, trust me).

Edit:
Try this instead:


Note also that exact palette import for background is the rightmost icon in V2.62 or older (the icon on the left of the [animating backgrounds] button), while for V2.7+ you have to access it through menu item:
Room -> import background (exact pal)

Babar

Thanks alot Gilbot! Works now. I guess I was just peeved that after having paid so much for Photoshop, it turned out that it doesn't work for this case.

I used your image, and imported it into AGS with the exact Palette option. I unlocked all the colours. Turned out that they required more slots than available.
So I reloaded it without the exact palette option, and they required much fewer colours (178-255). I don't pretend to understand what I did, but it worked. Flows beautifully now.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Babar

Ok, I'm having problems again. I made it so that if a certain button is pressed, GlobalInt 3 will be set to 1, and the player will go to the warp screen, where (after checking GlobalInt 3) the palette will cycle from 153 to 230.
I also made it so that if the player presses another button, GlobalInt 3 will be set to 2, and the player will go to the warp screen, where (after checking GlobalInt 3) the palette will cycle from 230 to 153.

I did this so that with the first button it will appear that the screen is animating towards the left, and the player is moving towards the right. With the 2nd button, the screen should animate towards the right, and make it appear as if the player is moving to the left.

However, the 2nd button doesn't work. If I click it, the warp screen comes up, and doesn't animate at all.

Can someone help me find the problem?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

#17
Which version of AGS are you using?
For versions before V2.61 the function CyclePalette() works only for one direction, which was fixed since V2.61.
You may just upgrade your game to V2.62, or make a custom function yourself, like:
Code: ags

function CycPal(int start, int end) {
Ã,  int cycinc, cycind;
Ã,  color cyctmp;
Ã,  cyctmp.r=palette[start].r;
Ã,  cyctmp.g=palette[start].g;
Ã,  cyctmp.b=palette[start].b;
Ã,  if (end>start) cycinc=1;
Ã,  else cycinc=-1;
Ã,  cycind=start;
Ã,  while (cycind!=end) {
Ã,  Ã,  palette[cycind].r=palette[cycind+cycinc].r;
Ã,  Ã,  palette[cycind].g=palette[cycind+cycinc].g;
Ã,  Ã,  palette[cycind].b=palette[cycind+cycinc].b;
Ã,  Ã,  cycind+=cycinc;
Ã,  Ã,  }
Ã,  palette[end].r=cyctmp.r;
Ã,  palette[end].g=cyctmp.g;
Ã,  palette[end].b=cyctmp.b;
Ã,  UpdatePalette();
Ã,  }

(This is actually codes directly copied form my game, with minor changes, I had to use it because I am using V2.6SP1 for my game and it's me who reported the problem, I can't remember well, the palette probably cycles in the opposite direction as the original CyclePalette() but I won't care)

Gilbert

#18
Quote from: Babar on Fri 24/06/2005 13:02:22
I used your image, and imported it into AGS with the exact Palette option. I unlocked all the colours. Turned out that they required more slots than available.
So I reloaded it without the exact palette option, and they required much fewer colours (178-255). I don't pretend to understand what I did, but it worked. Flows beautifully now.
Since my last post was long I decided to make a new post about this issue.
Actually you don't need to care about it, that background was made quickly with DP, it used only slots 176 through 254, though the other slots had some colours in them, they're never used, so you can just ignore them, importing it with exact palette is fine, because fortunately it seems the colours of the gradient don't clash with those of the room independent colours, if they do, there's a chance that the bg would be messed after import if you didn't use exact palette.

Babar

#19
Weirdly enough, Gilbot, I am using Version 2.7 (the new one).
I tried your function, but I hope you'll forgive me, I am not a frequenter of custom-made functions. I imported the function in the script header, but it doesn't recognise the variables. Do I have to import them too? Or declare them?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

SMF spam blocked by CleanTalk