values inside L file - X values

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

Moderators: Lone Wolf, Snake Man

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

values inside L file - X values

Post by Luk » 2007-12-20 15:01:46

Recognizeing and handeling values inside L file - X values

I used Closters way fot L2 Korea file reading
(for understanding how it works)
Closter wrote:
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.

I did it 9 chanels, 8bit, 9 header
This is what I got:
1) 2) 3) chanells
RGB - this is red only(245palette), but green is very weak(allmost black) and blue pure black- so I did not posted them.
It looks as tilin data I think..?
Image

4)
Alpha1 is pure black

5)
Alpha2 (210palette) - it looks like grayscaled elevation gradient until some hight (about 3000ft??) and then noise:
Image

6)
Alpha3 (28palette)- for me very interesting channel it looks like
elevation DEM grayscale, but it has only 28 palette dept.
Is there some way, how to extract it at least 16bit from L2?
Image
Because it is very dark, I have added it again as whole Korea (but edited range, for better appearance):
Image

7)
Alpha4 (158palette)
It looks like some tilling info again ...?
Image

8)Alpha5 (256palette)
Very interesting and strange - it looks like shaded ("boosted") relief..?
Image

9)Alpha6 (150palette)
This one handles haze values in my opinion (intuition only)
It looks like some normal map - only one picture with some relation to haze for me (perhaps 5) Alpa 2 too?)...
Image
_________________________________________________________

It will be great, if we will be able to extract at least 16bit grayscale for edit from L2 file. But it is not so necessary for me now, because I have found some other way in past few days. I am working on some hi-res grayscale bitmap for Eu theater now and I am able to put it inside Lx - thanks to BaldEagles LxNormalfix. It will be SRTM ( degraded 90m - 250m) resolution map up to the about 60 Lat, then 1km GTOPO interpolated (no SRTM data there).
I was able to stitch those data sources and they match theater perfectly!

Now I am making detailed BMP with land cover for CATE, and still thinking about some new tile-sets.

I want to make other bmp for "iridiscence" and I hope I will be able to
put it inside L2 by CATE. The purpose of it is to make Mediterian fields more dry- to yelow/brown, some more green -Swiss and so on. Then colour Alpian rocks somewhere to grey, somewhere orange -Dolomites...

Next step is to understand haze handling clearly. Now I think haze is influenced only by monochrome palette, so I will be not able to simulate colored smog areas as I wanted. But It would be possible to set haze as in profi theaters ...
It is not problem for me to make some normal map as in last picture (9),
but is it really haze?

Luk

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-12-20 15:53:48

Luk,
This is very, very interesting what you are doing here. I don't profess to understand it all (I never did grasp the concept of Alpha layers.... :( ) but I've wondered for a long time how the X1 value in the L2/O2 affected the look of the haze in sim. Please keep reporting what you find! :)
Sherlock
Victurous te Saluto

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

Post by Closter » 2007-12-20 22:20:34

I am glad to see your interest in this issue. Perhaps I can explain some of the questions. I previously see the images but don't publish them all.
Firstable, look at this info that Sherlock wrote time ago:
Sherlock wrote:
I think this may answer your question:

File formats are as follows:

O2 file: 4Bytes per Record
DWORD(LONG) - L2 byte Location

(This file essentially, represents the SEGEMENTS of the theater, starting a 0,0 in the LOWER LEFT corner, to 63,63 in the UPPER RIGHT. Each of the DWORD(LONG) Records points to the location in the L2 file (in BYTES), that the 16x16 Tiles that make up each segment, begins. Like the O2 files, the order of the 16x16 segement records in the L2 is, starting at Lower Left, going to Upper Right)

L2 File: 9Bytes per Record
DWORD(LONG) - Texture Offset Number
WORD(INTEGER) - Elevation
BYTE - Palette
BYTE - X1
BYTE - X2

(Bytes 1-4 hold the Texture info, this what you want! 5-6 hold the elevation (in ft), 7, palette, 8 and 9 have something to do with the Normals, and you dont need to worry about them either!)

and

L2 Record
2-byte
===============================
WORD Texture;
WORD Elevation;
BYTE Palette;
BYTE X1;
BYTE X2;

4-byte
===============================
DWORD Offset;
WORD Elevation;
BYTE Palette;
BYTE X1;
BYTE X2;

WORD = 2 bytes
DWORD = 4 bytes
BYTE = 1 byte

O2 Record
2-byte & 4-byte
===============================
long (4 bytes) Pointer to each Section in L2.

Section = 16 x 16 x size of L2 record

And looking at that structure then, the only thing a 4byte structure does, is allow a larger number of textures to be used? Not that I want to mess with that area of it... Just the elevation stuff... And that shouldnt require messing with the O2, should it?


The L2 Offset points into fartiles.raw. With the more diversified tiled theaters, like the Balkans, the 16-bit offset was limited to 64,767 fartiles (Blkans has ~102,000 fartiles). Making the Offset a 32-bit integer extended the number of fartiles to 4+ gig tiles.

The O2 offsets (pointers) change due to the size (bytes) of a L2 section.
--------------------------------------------------------------------------------

Note these were originally posted at the FreeFalcon forums (the old site) and the links I have are no longer working. So I am reposting this information for use here. I think the original posters were Zaggy and Dr. Fred "BaldEagle" Balding....
So L2M is a merge of the O2 and L2, and thats why we can use it as a bitmap format, but is a less packed format than originals.

For each pixel there are 9 bytes (4byte theater) or 7 bytes(2byte). Your example is 9 bytes.

-RGBA1 are the 4 bytes that represent the Texture offset, as a conversion from 2 byte, there is no data in B and A1, that's ok. AFAIK Korea is only 2200 tiles so it only needs 12 bits, that means only 0-16 values in the G byte, meaning dark image. As a different grey for each kind of tile, is somehow related to tiling...

-A2 and A3 are the elevation, in inverse order LSB-MSB, so elevations under 255 feet are well represented in A2, but over that we only see the least significant bits, then it seems random. In A3 we see OK elevation, but as highest summit on earth is Everest (29000ft) and Korea is not that high, values are only 0-32 meaning low contrast and dark image.

-A4 is our X1 palette. It seems related to X2 and X3, and probably to tiling and elevation. How? I don't know.

-A5 is our X2 value. It seemed like this value is the heading, where, over the compass, is the tile looking.

-A6 is our X3 value. It seemed like this value is the angle over the horizon, how is the slope of the terrain, the bigger (white) the flatter, like the sea, pure white. Darker areas mean more slope. But I don't agree on the direct correlation with the haze value, perhaps code corrected this with some limit or it is used the offset too. I don't know, we have to research this.

Keep going.
Image

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

Post by Luk » 2007-12-26 00:12:43

Ok, I see some basic problems here.
1)signification of stored values
There is some little obscurity in Closters and Sherlocks value marking

Sherlocks old topic format description:
BYTE Palette;
BYTE X1;
BYTE X2

Closters previous post:
-A4 is our X1 palette.
-A5 is our X2 value.
-A6 is our X3 value.

I understand it - Sherlocks X1 is Closters X2 (A5)...Am I wrong?

2) we dont see exact values here, only some roughly graphic representation of stored values. Is it possible to extract only part of file, but 16bit at least? I dont have much experience with raw import - Photoshop is notifying to set less layers in case of 16bit import - but the result is messed up then. I should setup it much more clever...
I am sorry, I am not a programmer, some my computer basic knowledges can look funny => BYTE - does it mean the value can be only 0-256? :oops: In that case we dont need 16bit import for X values of course...

---------------------------------------------------------------------------
As we can see on picture bellow, X2 and X3 values really store only angle information - in horizontal and vertical directions. Angular value in horizontal plane match elevation map exactly. So there is no colour info. This is A5(direction) blended with A3 (high map):
Image

Only single value with colour info is Alpha4 and I think this one should be modified by "estimate colour" command. This value would be 0-256 colour palette(no matter is representated by 256grayscale here). I have no idea about connection with haze. I did not see coloured fog in F4 for a long time. But I have seen coloured terrain surface - "iridiscence". Perhaps the theaters a I have seen in near past did not have set colours properly. There was some yellow and grey colored fog in 1998 F4 I think.
We have to explore that X1 palette at first. Where it is stored and how can be changed...I have a feeling its not full colour circle (not same for all theaters), but choosen colour scale with some conection to tile palette.
If I can remember corectly, there was some palette file DEM2Terr was pointing at early stage of creation process - just a flashback...


BTW - how can I edit my previous posts?
Luk

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

Post by Closter » 2007-12-26 19:20:39

1) To your question: my answer is yes. But not that important, they are only names, if in one piece of code it is called "X1" and then in another one "u2"..., we know what we are talking about. Here you have the thread where perhaps the confusion starts. How is the X1 value calculated?


2)I guess you want to play with elevation You can work with that two alpha channels, leaving active those and then you must transform the picture as a 16 bit greyscale image, and then export as raw. Roughly that's the way.

Byte means values 0-255, and 16bit import has a meaning for offset and elevation only.

Coloured fog could have a connection with skyfix, but I don't have researched that.

Somebody said that palette is stored at the end of the .map file, but I have not been able to extract it or simply check it.

Your picture is interesting as it resembles slightly a lightened relief map, what was the operation you applied between two channels?
Image

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

Post by Luk » 2008-01-14 23:59:16

Hi Closter, I was away. The operation was simple "multiply" with about 50% visibility if I can remember correctly.
Luk

Joe Labrada
1st Lt
Posts: 111
Joined: 2002-07-09 22:01:01
Gaming Interests: Falcon 4.0
Editing Interests: Terrains
Location: Spain
Contact:

Post by Joe Labrada » 2008-05-22 14:42:22

Closter wrote:
9)Alpha6 (150palette)
This one handles haze values in my opinion (intuition only)
It looks like some normal map - only one picture with some relation to haze for me (perhaps 5) Alpa 2 too?)...
img]http://members.upc.cz/francek/raw/A6_150colours.gif[/img]
Very, very interesting. Thanks, Closter.

____________________________________________
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests