Palshift Analyzer v2.00 (public v1.00)

This would be the forum for questions about how to work with mod making tools which can be a problem of its own.

Moderator: Paul Siramy

Post Reply

0
No votes
 
Total votes: 0

User avatar
Nefarius
Retired Admin
Cherub
Posts: 11607
Joined: Sat Jun 15, 2002 8:13 pm
Location: Where the blood forever rains
Contact:

Hand-picked

Palshift Analyzer v2.00 (public v1.00)

Post by Nefarius » Sun Apr 08, 2007 10:29 pm

Download: dload.php?action=file&file_id=1451
Source: dload.php?action=file&file_id=1452


PalAnalyzer
v2.00 (public release 1.00)
By Nefarius


Whats this?
-----------
This tool allows you to create palshift.dat files with the same precision
blizzard created their own (or at least close to that precision and ease).
Unlike PalShifter you don't have to undergo the mundane task of manually changing
every single entry via long trial and error sessions.
PalAnalyzer allows you to edit the palette in an image editor of choice,
then save the result as PCX and let the tool compile it into a D2 palette again,
this offers you any form of image manipulation, be it colorization,
channel mixing and whatnot to give your monsters some nicer colors.
But thats not all, PalAnalyzer can also export palettes to *.TXT format,
so you can change specific indexes in a spreadsheet program,
or quickly copy/paste palettes without the need of a hex editor.


Notes
-----
This program requires Allegro v4.2
All files must be inside the same folder (duh)


Disclaimer
----------
I don't take any responsibility regarding anything whatsoever that happens
throughout usage (or lack of such) of this application, it's your fault,
live with it or die.


Extracting a Palette Into a TXT Table
-------------------------------------
In Analyzer.ini change the mode to dat2txt, specify the name of the
PalShift.dat file in the input line, and the desired name for the
produced txt file in the output line (both with extension).
Then simply launch the program.


Compiling a TXT Table into a Palette
------------------------------------
In Analyzer.ini change the mode to txt2dat, specify the name of
the TXT table in the input line, and the desired name for
the produced palette file in the output line (both with extension).
Then simply launch the program.


Extracting a Palette into PCX format
------------------------------------
At any point during execution, if you hit F2, the currently loaded
palette will be extracted into an array of PCX files with the name
following this syntax: <base_file_name> <underscore> <index> (for example
palshift3_03.pcx).


Compiling a Palette from PCX files
----------------------------------
After you extracted a palette and edited it in a image editor,
you must apply the D2-palette to it (included with this tool for Paintshop Pro (psp.pal),
for a Photoshop palette see our file center), while PalAnalyzer will attempt to
find the nearest color, it's not going to 'work as expected'
most of the time if you don't apply the D2-palette. After the images are done
open Analyzer.ini, change the mode to pcx2txt, and change the input line to the 'prefix'
of the images (that is, if you called the images palshift3_00.pcx
throughout palshift3_07.pcx (note: you must start with 00), then use the prefix "palshift3"
(without the quotes of course). Now launch the program.
PalAnalyzer will automatically create both a *.TXT table and a *.DAT for you.

NOTE: If you experience problems, try to save the
PCX as 16BIT instead of 8BIT after applying the D2 palette.

NOTE: You might notice that PalAnalyzer will 'shift' some indexes that are unchanged,
these indexes in fact point to non-existant colors that are not part of the units palette.
(These colors are act specific).


Other Stuff
-----------
By default shifted indexes are shown in magenta, to reveal shifted indexes press F1.
Use left and right keys to navigate throughout the sub palettes.
Last edited by Nefarius on Sun Apr 08, 2007 10:32 pm, edited 1 time in total.
''(...) The game can basically be considered unhackable. '' - Blizzard Entertainment (30th May 2000)
Black Omen Productions | MetalStorm: Progress Report | Screenshots

User avatar
Paul Siramy
Retired staff
Principality
Posts: 2828
Joined: Sat May 25, 2002 2:39 pm
Location: La Garenne Colombes (near Paris)
Contact:

Hand-picked

Re: Palshift Analyzer v2.00 (public v1.00)

Post by Paul Siramy » Mon Apr 09, 2007 11:38 pm

Interesting tool. But some questions.

* when remaping the pcx new palette into the Diablo II regular palette, do you preserve the index 0 to stay 0, whatever the new color it is ?

* when remaping new palette into regular palette, do you handle act-dependant colors ? I supose that since you're using the palette "units.dat" you indirectly handle them, but I wanted a confirmation.

* I check the source code. I see that your formula to find the nearest color is basic. It don't use the fact that human eyes are more sensible to green, than to red, and than to blue. Do you just forget it, or was it on purpose ?

* by incorectly using the "units.dat" as the input palette (mode=dat2txt ; input=units.dat ; output=units.txt), I find some "-1" in "units.txt", looks like a bug to have values outside the range [0;255] tough.

* I didn't understand clearly your code when it read the 768 bytes of a pcx 's palette. Are you aware that after all the header, and pixel datas in the pcx file, and right before the palette at the end of the file, there's a "magic" byte to skip ?

Just as a bonus, here's a function I used in one of my program, to find the nearest (best fit) color within a palette, given an input color components :

Code: Select all

int my_bestfit_color(PALETTE pal, int r, int g, int b)
{
   int  i, min_idx;
   long dr, dg, db, min_dist, curr_dist;

   
   // init
   dr = r - pal[0].r;
   dg = g - pal[0].g;
   db = b - pal[0].b;
   min_dist = dr*dr*76 + dg*dg*150 + db*db*28;
   min_idx  = 0;

   for (i=1; i < 256; i++)
   {
      dr = r - pal[i].r;
      dg = g - pal[i].g;
      db = b - pal[i].b;
      curr_dist = dr*dr*76 + dg*dg*150 + db*db*28;
      if (curr_dist < min_dist)
      {
         min_dist = curr_dist;
         min_idx = i;
      }
   }

   return min_idx;
}
It don't use floating point arithmetics, and no sqrt() nor pow() functions, so it's quick. And it handles the eye properties : luminance = 30% red + 60% Green + 10% Blue. The eye is more sensible to luminance than the actual color. Well... you need to make your own test anyway ;) Normally the coefficients are R=0.299, G=0.587 and B=0.114.
Last edited by Paul Siramy on Tue Apr 10, 2007 12:02 am, edited 2 times in total.

User avatar
Nefarius
Retired Admin
Cherub
Posts: 11607
Joined: Sat Jun 15, 2002 8:13 pm
Location: Where the blood forever rains
Contact:

Hand-picked

Re: Palshift Analyzer v2.00 (public v1.00)

Post by Nefarius » Tue Apr 10, 2007 12:12 am

* when remaping the pcx new palette into the Diablo II regular palette, do you preserve the index 0 to stay 0, whatever the new color it is ?
Didn't do checks on that part, but AFAIK D2 will always use color 0 for palette index 0, even if it is shifted, at least I think I saw that when looking at the palshift code.

* when remaping new palette into regular palette, do you handle act-dependant colors ? I supose that since you're using the palette "units.dat" you indirectly handle them, but I wanted a confirmation.
In units.dat all the act dependant colors are pure black like color 0, the tool maps them to color 0 (as they don't occur inside any animation that uses palshift, aka monsters - no monster is act specific), this shouldn't matter.

* I check the source code. I see that your formula to find the nearest color is basic. It don't use the fact that human eyes are more sensible to green, than to red, and than to blue. Do you just forget it, or was it on purpose ?
Not on purpose, it's the best I could get to with my experimenting, I'll play around with your code and include this to improve it ;) Thanks.

* by incorectly using the "units.dat" as the input palette (mode=dat2txt ; input=units.dat ; output=units.txt), I find some "-1" in "units.txt", looks like a bug to have values outside the range [0;255] tough.
-1 means that 'no shift' occurred ;)
The .txt file lists only shifted indexes with a number, unshifted ones are -1

* I didn't understand clearly your code when it read the 768 bytes of a pcx 's palette. Are you aware that after all the header, and pixel datas in the pcx file, and right before the palette at the end of the file, there's a "magic" byte to skip ?
It doesn't read the palette from the PCX files, it reads units.dat, it checks if the file is exactly 768 bytes (aka 256 pairs of 3 RGB values).
Last edited by Nefarius on Tue Apr 10, 2007 12:30 am, edited 2 times in total.
''(...) The game can basically be considered unhackable. '' - Blizzard Entertainment (30th May 2000)
Black Omen Productions | MetalStorm: Progress Report | Screenshots

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12062
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U

Hand-picked

Re: Palshift Analyzer v2.00 (public v1.00)

Post by Myhrginoc » Tue Apr 10, 2007 3:00 am

Would it be possible to add a feature: importing .trn files from D1?
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Nefarius
Retired Admin
Cherub
Posts: 11607
Joined: Sat Jun 15, 2002 8:13 pm
Location: Where the blood forever rains
Contact:

Hand-picked

Re: Palshift Analyzer v2.00 (public v1.00)

Post by Nefarius » Tue Apr 10, 2007 4:10 am

Hmm, yes that would indeed be very desireable. I'll see if I manage to pull that off. To do this I need to know what colors the standard D1 units palette contained, the rest shouldn't be too complicated (except maybe for the fact D1 unit palettes didn't contain as much green as D2 palettes, and vice versa, D2 palettes are rather devoid of yellow).
Last edited by Nefarius on Tue Apr 10, 2007 4:48 am, edited 2 times in total.
''(...) The game can basically be considered unhackable. '' - Blizzard Entertainment (30th May 2000)
Black Omen Productions | MetalStorm: Progress Report | Screenshots

User avatar
Alkalund
Retired Admin
Throne
Posts: 7597
Joined: Sun May 26, 2002 5:54 pm
Location: Toronto, Ontario, Canada
Contact:

Hand-picked

Post by Alkalund » Sat Apr 14, 2007 9:18 am

Just spotted this thread on the news, nice little program.
Just as a bonus, here's a function I used in one of my program, to find the nearest (best fit) color within a palette, given an input color components :
In case you ever feel like playing around and pushing this to the next level of accuracy, consider the CIEDE2000 color difference formula; Paul might remember it, from back in 2004 when I did some mathematical studies on the D2 palettes.

User avatar
Nefarius
Retired Admin
Cherub
Posts: 11607
Joined: Sat Jun 15, 2002 8:13 pm
Location: Where the blood forever rains
Contact:

Hand-picked

Re: Palshift Analyzer v2.00 (public v1.00)

Post by Nefarius » Sat Apr 14, 2007 11:06 pm

Yea, id like improving the code ;)
''(...) The game can basically be considered unhackable. '' - Blizzard Entertainment (30th May 2000)
Black Omen Productions | MetalStorm: Progress Report | Screenshots

kiddemik1416
Posts: 5
Joined: Thu Jul 05, 2018 12:58 pm
Romania

Re: Palshift Analyzer v2.00 (public v1.00)

Post by kiddemik1416 » Thu Jul 05, 2018 7:47 pm

is not working your app

kiddemik1416
Posts: 5
Joined: Thu Jul 05, 2018 12:58 pm
Romania

Re: Palshift Analyzer v2.00 (public v1.00)

Post by kiddemik1416 » Wed Jul 11, 2018 3:38 pm

salut ma in plm e cineva aici care stie sa faca modding sau site asta e pus asa la misto aici ....
unde plm sunt admini cand ai nevoie de ei?
le-am lasat si mesaje si nu raspunde nimeni


Post Reply

Return to “Tools”