mkpal.pl script needing change?

F4Browse, CATE, Tacedit, Terrainview & TheaterMaker etc utility related

Moderators: Lone Wolf, Snake Man

Post Reply
User avatar
Sherlock
Lt. General
Posts: 1167
Joined: 2006-05-24 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: All, I (try) to edit everything.
Location: Arizona, USA

mkpal.pl script needing change?

Post by Sherlock » 2006-11-27 02:47:00

Ok guys...was looking through a discussion at freefalcon website talking about the changes to the L2/O2 when it was changed to a 4Byte format. The driver was the number of fartiles possible. Under 2Byte it was limited to 64,767 fartiles. With the change to 4 byte format the number of fartiles was increased to a max possible of 4 Gigs of fartiles. Now with that known, take a look at the mkpal perl script that Codec made (this script is used to create the fartiles.pal file for use with the texture.bin and texture.zip files):

code:

Code: Select all

#! /usr/local/bin/perl -w
# perl script
# to make JACS pal files into fartiles.pal format

# usage
# mkpal.pl <file> > file.pal

push(@ARGV, "-") if (@ARGV == 0);
open(FH, $ARGV[0]) || die "Can't open $ARGV[0]: $!";
$line = <FH>;
die "Not a JASC-PAL" if ($line !~ /^jasc-pal/i);
$line = <FH>;
die "Wrong version pal" if ($line !~ /^0100/i);
$line = <FH>;
die "Not 256 entries" if ($line !~ /^256/i);

binmode STDOUT;
# make the palette
while (defined($line = <FH> )) {
        chomp($line);
        my($r,$g,$b) = split(' ', $line);
            print pack("CCCC", $r, $g,$b, 0);
}
# put the default number of fartiles on the end.
print pack("VV", 25685, 27714);  
Look at the last two lines. Is there any perl smart guy out there who can say whether the "default number of fartiles on the end" in this script are set too low. And just what the heck do both numbers mean/do, i.e., "25685, 27714"?
Sherlock
Victurous te Saluto

ranger822
Banned user
Posts: 389
Joined: 2004-07-27 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: All, I (try) to edit everything.
Location: Beautiful Virginia

Re: mkpal.pl script needing change?

Post by ranger822 » 2006-11-27 12:18:00

fartiles.pal is for pcx tiles.

User avatar
Sherlock
Lt. General
Posts: 1167
Joined: 2006-05-24 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: All, I (try) to edit everything.
Location: Arizona, USA

Re: mkpal.pl script needing change?

Post by Sherlock » 2006-11-27 16:46:00

Hi Ranger,
Yes, I know. My modifying is for AF. It still uses PCX files for its tiles.
Sherlock
Victurous te Saluto

User avatar
Sherlock
Lt. General
Posts: 1167
Joined: 2006-05-24 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: All, I (try) to edit everything.
Location: Arizona, USA

Post by Sherlock » 2006-12-08 19:15:40

Bump...
any perl gurus out there who can answer this?
Sherlock
Victurous te Saluto

Malc
Lt Colonel
Posts: 294
Joined: 2000-12-24 23:01:01
Location: England
Contact:

Post by Malc » 2007-01-20 10:52:02

I could be wrong Sherlock, but I think you're way off base here.

The number of fartiles useable has nothing to with the palette with which they are created. Whether you have 64,000 or 4 million fartiles is irrelevant - the way the AF terrain engine (i.e. 256 color .pcx) works is it always uses a 256 color palette to draw the fartiles with. The palette is an average of all the colours used in each tileset.

Ultimately, there is no need to ammend the script to account for the extra fartiles allowance. To summarise the process...

- Create/Make new tiles
- Create a single bitmap with one example of tile from EVERY group in your texture.zip (including the default Koreas you choose to use)
- Reduce this bitmap to 256 colors
- Save palette
- Process palette with mkpal.pl script

Job done.

User avatar
Sherlock
Lt. General
Posts: 1167
Joined: 2006-05-24 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: All, I (try) to edit everything.
Location: Arizona, USA

Post by Sherlock » 2007-01-20 18:22:46

Malc wrote:I could be wrong Sherlock, but I think you're way off base here.

The number of fartiles useable has nothing to with the palette with which they are created. Whether you have 64,000 or 4 million fartiles is irrelevant - the way the AF terrain engine (i.e. 256 color .pcx) works is it always uses a 256 color palette to draw the fartiles with. The palette is an average of all the colours used in each tileset.

Ultimately, there is no need to ammend the script to account for the extra fartiles allowance. To summarise the process...

- Create/Make new tiles
- Create a single bitmap with one example of tile from EVERY group in your texture.zip (including the default Koreas you choose to use)
- Reduce this bitmap to 256 colors
- Save palette
- Process palette with mkpal.pl script

Job done.
Thanks Malc,
Appreciate your viewpoint on this. I posted this when I was "grabbing at straws" trying to find a fix for the shadows on the terrain in AF when we brough ODS, etc., into AF. I've since figured out the answer.

The script probably doesn't need to change as I once thought. But I am not "in the know" enough to say definitely one way or the other. :)
Sherlock
Victurous te Saluto

Rambo
Newbie
Posts: 10
Joined: 2007-10-20 16:55:49

mkpal.pl

Post by Rambo » 2007-11-23 00:03:45

Why this problem??

mkpal.pl new-fertiles.pal fertiles.pal

Result:
not a jasc-pal at c:\...........\mkpal.pl
line 9, <FH> line 1.

the new-fertiles.pal, it was created with JASC Paint Shop Pro 8 saving palette in .pal.

The list mkpal.pl is correct??

Rambo

User avatar
Luk
Brig. General
Posts: 455
Joined: 2007-04-23 09:59:36

Post by Luk » 2007-11-23 10:01:47

Sherlock wrote:
I posted this when I was "grabbing at straws" trying to find a fix for the shadows on the terrain in AF when we brough ODS, etc., into AF.

Can be I am out of topic now. But when I had similar problem with strange shadows and colours (artifacts) i the theatre (including horrible "stairy" horizont), it was solved very simply by "Estimate Tile Colour" command in Terrwiev (Operations rollout). I was really confused by that problem and had red a lot of topic and posts, but this was only slution I discovered by chance. And it added very nice and soft colour gradients blended with tile textures - darker in valleys, somewhere little to green, somewhere to brown. This colour variation added some liitle irregularity to the repeatitive textures, I desired.
I have tested it in AF too.

Luk

Closter
Captain
Posts: 154
Joined: 2007-01-07 00:13:42

Post by Closter » 2007-11-29 20:44:35

Luk, could you show us an example of the differences; the "before" and "after" of this option?. I am very interested in the use of the X1 or fog/haze value in L2 file and what you say seems promising
Image

User avatar
Sherlock
Lt. General
Posts: 1167
Joined: 2006-05-24 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: All, I (try) to edit everything.
Location: Arizona, USA

Post by Sherlock » 2007-11-29 22:27:56

Closter wrote:Luk, could you show us an example of the differences; the "before" and "after" of this option?. I am very interested in the use of the X1 or fog/haze value in L2 file and what you say seems promising
All,
I could be wrong about this but my research from a couple of years ago indicated (I believe anyway) that TerrainViews "Estimate Colors" command did not affect the X1 value. Only the X2 and X3 values. The only utility I've found that could change the X1 value is CATE. Just my 0.02 worth.
Sherlock
Victurous te Saluto

User avatar
Luk
Brig. General
Posts: 455
Joined: 2007-04-23 09:59:36

crazy advice

Post by Luk » 2007-11-30 19:47:09

Luk, could you show us an example of the differences; the "before" and "after" of this option?. I am very interested in the use of the X1 or fog/haze value in L2 file and what you say seems promising

Heh, excuse me I mix up it a little bit.
Yes, what I wrote about colours is true, but I have forgot the details.
It was abot Year ago...

At first, I made some small changes with terrain (peaks). It messed up normals.
Result in F4AF:

Image
Image

Then I was very sad, because of those artifacts. I did not know I have to
fix the normals. So I tried everything, included "Estimate Colors" command. It added beautifull colors to the surface (it was headache to find old images on my HDD :lol:
Image
Image
Image
Image
Have you seen the iridescence?

Then I found a solution - normal fix
I fixed the terrain, but color blend continued(remined) ?sry my English is poor). It is not so strong, but still noticeable.
Fixed terrain here:
Image
Image
Image

I have added a picture from default Balcan terrain (I dont have PMC Eu in this Laptop). I cant see colour mix(same time about 9:00):
Image

So howto achive this?
1,corrupt the normals
2,Estimate Colors
3,Fix the normals
he he Perhaps It is all little bit crazy and randomly.

I wellcome any help about how to handle X1 X2 X3 values exactly by some bitmap (Cate).
For example in northwest Bohemia, there were military airport at Zatec during the Cold war (called MERKUR, pilots called it Korea) - and it was common for that place everywhere was coal smoke (heavy industry there).

Luk

P.S. I have added last image - out of topic
I have found it by chance.
Its about hand tiling - pitty it is unuseable (impractical for tile replacements)
Image

Closter
Captain
Posts: 154
Joined: 2007-01-07 00:13:42

Post by Closter » 2007-12-01 22:10:40

Very impressive, Luk! That's exactly what I wanted you to give us, some pictures to understand your assertions.

Those colors come for sure from the X1 value, but It is not clear how are they calculated. There is a thread hereHow is X1 palette value calculated? with very interesting discussion on topic. As you can see in the pictures, I made some trials with the effect that different values of X1 causes over the look of the terrain. In fact, not the usual layered fog in valleys seems affected, but as you say the "iridiscence" (lacking a better word).

The way I put those values into the L2 was through Terrainview, but tile by tilel, not using "Estimate colours". I wanted to create an artificial pattern that reflected the effect.

Perhaps your use of that menu option created those changes, not needing your screwing of the normals, perhaps that screwing was needed for the variations to arise. So in that case is clear that the variations are based in the values of X2 and X3, but again, how is it done?

I keep interested in the way of making fog to be shown, and this thread Fog is being reversed-type problem discuss the problem. I see in your pictures there is fog in the valleys as usual, perhaps you know something more about this.

I have a guess, the use of the Xn value, that tells us the angle with the horizontal (I don't remember right now if it'is X2 or X3). Values near 90º wichever they are and heights under some value, could represent the way the sim puts the fog out.
Image

User avatar
Luk
Brig. General
Posts: 455
Joined: 2007-04-23 09:59:36

Post by Luk » 2007-12-02 01:09:35

I think so - the X2 and X3 values are behind it.
But I dont know more than You about X1. I am sorry.

I have seen your posts in past - especially this part with extracted greyscale bitmap of the X1 value is very interesting!
You wrote:
Happy Easter!
This is interesting. I've been able to extract the X1 info from some L2 files, as a greyscale bitmap.
This is what you can see....

How did You to achive this?

By the way - I mailed with Blueprint and he told me, LxNormalfix can handle bitmap (can write it to Lx file!) It is something I try to find more then year...
But there is no help with this program. When I typed /? in command line, nothing happened too... :cry:
Luk

P.S. I will add that off-topic picture I have spoiled.
I dont like broken posts.
Pitty all my pictures will be dead in the near future. I have quite difficult time now. I am changing habitation - going from Prag to country village and must change net provider if there is any.. hehe (and my wife will breed in a while...) So thats why I have to find "background papers " as fast as possible.
Perhaps the image has some topic relation - you cannot see any "iridiscence" there. I have captured it after second pass of "estimate colours" with fixed normals yet. It washed out the colours I think..(not sure)
Image

Closter
Captain
Posts: 154
Joined: 2007-01-07 00:13:42

Post by Closter » 2007-12-18 00:00:16

Luk wrote: I have seen your posts in past - especially this part with extracted greyscale bitmap of the X1 value is very interesting!
...
How did You to achive this?
I have not written down the exact process, but from the top of my head:

1.-Run Pathmaker (Not Run Terrainview), and load theater.l2 file. Select correct (same size as your theater) theater name.
2.-File-Save L2Matrix -->Export theater.l2m, is big - like 9 MB for a 64 theater.
Size will be: byte number = {n * X * Y + n} with n = 7 (2 bytes ) or n = 9 (4 bytes); X = width (1024, 2048, 4096); Y = height (1024, 2048, 4096);

3.-Run a graphic program like photoshop, able to read raw images.
4.-Load the .l2m file as a raw image, you must specify size 1024 x 1024 and 7 or 9 channels, perhaps a 7 or 9 byte header (something like that), and interleave. Always for a 64 seg. theater
5.- There are 7 or 9 channels loaded, example red 1 byte, green 1 byte, blue 1 byte, alpha1 1 byte, alpha2 1 byte etc. The relevant one is alpha2 or alpha4, the fifth or seventh value. You could see a X1 greyscale image enabling that channel and disabling the others.
6.-Image is flipped, but clear.
Last edited by Closter on 2007-12-20 01:49:42, edited 1 time in total.
Image

User avatar
Luk
Brig. General
Posts: 455
Joined: 2007-04-23 09:59:36

question

Post by Luk » 2007-12-19 12:42:22

"2.-Export theater.l2m"

How can I export that file? I can only export region - in Operations rollout.
When I export whole theater file, it has "l2c" extension.
Luk

Closter
Captain
Posts: 154
Joined: 2007-01-07 00:13:42

Post by Closter » 2007-12-20 01:55:29

Sorry, I was wrong. It was Pathmaker the proper tool for making the l2m file. The post is fixed now.

PD.: That last picture was great! The very example of how to tile. I don't expect CATE doing it easily(or at all), but that is exactly the kind of look I want for a theater...
Is it made by hand?
Image

User avatar
Luk
Brig. General
Posts: 455
Joined: 2007-04-23 09:59:36

Post by Luk » 2007-12-20 15:03:53

Thank you!
I did it the way you told, and its ok.
But I will continue our discusion here:
viewtopic.php?t=21366
This thread is about scripting ...:oops:

for that image - thanks :), yes I did it by hand in terrview
I tried to minimalize "repeating feel". But this attemp is quite problematic
because it makes use of AF tiles here - they are clever in one thing - they have all the same main background-field colour. So I used few airbase tiles for variation.
And an other tile set can have other colours...incompatibile
I did not understand to standard Korea wet farmland tiles. Why they exist?
They have no transitions??, but it is for an other topic.
BTW - the biggest problem in CATE is, this program is not able to make "narrow diagonal" connections (in simple way), I use with hand made tiling very often. Those tiles are in almost all texture packs and they can be subtituted.

Luk

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests