How is X1 palette value calculated?

Terrain / Theater editing

Moderators: Lone Wolf, Snake Man

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

How is X1 palette value calculated?

Post by Sherlock » 2006-11-29 05:39:00

Subject says it all. I need to find out how the the correct X1 palette value is calculated for storage in the L2 file. Is it related to the particular offset tile used at that location? If so, how?

thanks.
Sherlock
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: How is X1 palette value calculated?

Post by ranger822 » 2006-11-29 14:57:00

are you talking about the fog/haze values for X1, X2, and X3? It think you can use good old trial an error - try a few different value for certain areas - see how they look . . .

I asked a question at Frugals and FF about two years ago. . . no one knew the answer. I didn't mess with it.

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: How is X1 palette value calculated?

Post by Sherlock » 2006-11-29 15:15:00

Yeh, that's the value (X1) that I am talking about. Apparently Widowmaker had it figured it. I do know that in the old F4 source code that they referred to it as the "color index". So I am thinking is there someway to calculate a single color patette index number for a PCX graphic that ranges from 0-255 ? But there appears to also be a relationship to altitude as well so I'm at a loss.
Sherlock
Victurous te Saluto

Snake Man
Commander-In-Chief
Posts: 9354
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Re: How is X1 palette value calculated?

Post by Snake Man » 2006-11-29 15:58:00

Umm, didn't Terrainview do that automatically with one of the features I cant remember now, heh.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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: How is X1 palette value calculated?

Post by Sherlock » 2006-11-29 16:02:00

quote:Originally posted by Snake Man:
Umm, didn't Terrainview do that automatically with one of the features I cant remember now, heh.
Hi SM!
Yes, it does recalculate the X1 value when you choose the "Estimate Colors" option, but I am not convinced it is doing the proper calculation. I am wanting to find out how to calculate it so I can check TV and see if it doing it properly (or not) and then go from there.

You wouldn't happen to have the TerrainView source code from Codec would you? :) That might help me answer the question. Also, the CATE source code might have what I need in it...can you make that available?
Sherlock
Victurous te Saluto

BaldEagle
FreeFalcon
Posts: 20
Joined: 2000-12-28 23:01:01
Location: Las Cruces, NM USA

Re: How is X1 palette value calculated?

Post by BaldEagle » 2006-12-02 18:43:00

Here is a segment of the TV code that sets the tile color:

if (td->m_elevation <= 0)
td->m_u1 = 254;
else if (td->m_elevation < 160)
td -> m_u1 = 180;
else if (td->m_elevation < 660)
td -> m_u1 = 181;
else if (td->m_elevation < 1640)
td -> m_u1 = 182;
else if (td->m_elevation < 3280)
td -> m_u1 = 183;
else if (td->m_elevation < 6560)
td -> m_u1 = 184;
else if (td->m_elevation < 11480)
td -> m_u1 = 184;
else if (td->m_elevation < 16400)
td -> m_u1 = 184;
else if (td->m_elevation < 16400)
td -> m_u1 = 183;
else
td -> m_u1 = 155;

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: How is X1 palette value calculated?

Post by Sherlock » 2006-12-03 02:15:00

quote:Originally posted by BaldEagle:
Here is a segment of the TV code that sets the tile color:

if (td->m_elevation <= 0)
td->m_u1 = 254;
else if (td->m_elevation < 160)
td -> m_u1 = 180;
else if (td->m_elevation < 660)
td -> m_u1 = 181;
else if (td->m_elevation < 1640)
td -> m_u1 = 182;
else if (td->m_elevation < 3280)
td -> m_u1 = 183;
else if (td->m_elevation < 6560)
td -> m_u1 = 184;
else if (td->m_elevation < 11480)
td -> m_u1 = 184;
else if (td->m_elevation < 16400)
td -> m_u1 = 184;
else if (td->m_elevation < 16400)
td -> m_u1 = 183;
else
td -> m_u1 = 155;
Hiya BaldEagle!
Couple of Questions if you don't mind:

1. What is the variable "td" ? Is that the terrain elevation at the offset being examined by the TV code?

2. How did the values like "180", "181", etc., get derived? i.e., where did they come from? (I think I already asked you but in case I didn't phrase it clearly before let me ask again here).

Thanks!
Sherlock
Sherlock
Victurous te Saluto

BaldEagle
FreeFalcon
Posts: 20
Joined: 2000-12-28 23:01:01
Location: Las Cruces, NM USA

Re: How is X1 palette value calculated?

Post by BaldEagle » 2006-12-03 16:37:00

td is a struct that contains the offset, elevation, X1, X2 and X3. It is the data for the current/selected x,y location.

I assume that Julian worked out the color index as a function of elevation. BTW, the index is into the color table at the end of the Theater.map file.

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: How is X1 palette value calculated?

Post by Sherlock » 2006-12-03 17:29:00

quote:Originally posted by BaldEagle:
td is a struct that contains the offset, elevation, X1, X2 and X3. It is the data for the current/selected x,y location.

I assume that Julian worked out the color index as a function of elevation. BTW, the index is into the color table at the end of the Theater.map file.
Dr. Fred,
I guess I am just not getting it...sorry. :(
What's confusing me is that the X1 values in the AF terrain are not set on such a "macro" level as the TerrainView code shows. Each offset appears to have its own X1 value calculated for it.But it appears to use the same value over and over again when that tile appears at a x,y location in the terrain mesh.

I'm not understanding what "m_u1" or "m_elevation" are or what their relationship is to "td". Can you post their code declarations (is there an equation where they are all shown together or a list of equations that shows their inter-relationships)? Also, I assume you mean the color index when you spoke about "index is into the color table at the end of the Theater.map file."? Or some other index? Is there any way to pull that index out of the theater.map file in order to look at it?
Thanks!
Sherlock
Victurous te Saluto

BaldEagle
FreeFalcon
Posts: 20
Joined: 2000-12-28 23:01:01
Location: Las Cruces, NM USA

Re: How is X1 palette value calculated?

Post by BaldEagle » 2006-12-03 18:36:00

At point x1,y1 you have these data:
offset = m_offset
elevation = m_elevation
X1 = m_u1
X2 = m_u2
X3 = m_u3

At x2,y2 you have different data for that point. The m_xxxxxx is C-code-speak, not for you to worry about. :) Each point on the map has its own data.

If you see a correlation between tile (offset) and X1, it is probably because those tile at an elevation range that yields the same X1.

The data is stored in the L2 file in this order:
offset (4 bytes)
elevation (4 bytes)
X1 (1 byte)
X2 (1 byte)
X3 (1 byte)
so each point (x,y) has 9 bytes of data. The points data is stored by Sectors, which the O2 file point to (offset) in the L2 file.

TV reads each point's data into a structure (td) which has these components: m_offset, m_elevation, m_u1, m_u2, m_u3 (same as those in the file data and in the same order).

X1 = m_u1 = color index

You have to write your own utility to look at the colors in the Theater.map file. :)

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: How is X1 palette value calculated?

Post by Sherlock » 2006-12-03 19:17:00

quote:Originally posted by BaldEagle:
At point x1,y1 you have these data:
offset = m_offset
elevation = m_elevation
X1 = m_u1
X2 = m_u2
X3 = m_u3

At x2,y2 you have different data for that point. The m_xxxxxx is C-code-speak, not for you to worry about. :) Each point on the map has its own data.

If you see a correlation between tile (offset) and X1, it is probably because those tile at an elevation range that yields the same X1.

The data is stored in the L2 file in this order:
offset (4 bytes)
elevation (4 bytes)
X1 (1 byte)
X2 (1 byte)
X3 (1 byte)
so each point (x,y) has 9 bytes of data. The points data is stored by Sectors, which the O2 file point to (offset) in the L2 file.

TV reads each point's data into a structure (td) which has these components: m_offset, m_elevation, m_u1, m_u2, m_u3 (same as those in the file data and in the same order).

X1 = m_u1 = color index

You have to write your own utility to look at the colors in the Theater.map file. :)
Aha! I think I understand much more clearly now! Thank you for that "primer"! Very enlightening (and clear!).

Fair enough on writing the utility myself to pull the index info out of the theater.map file. However, can you provide the file format by chance (to make it much easier!)?
Sherlock
Victurous te Saluto

BaldEagle
FreeFalcon
Posts: 20
Joined: 2000-12-28 23:01:01
Location: Las Cruces, NM USA

Re: How is X1 palette value calculated?

Post by BaldEagle » 2006-12-04 00:32:00

Code emailed.

User avatar
Khronik
PMC Theater Developer
Posts: 51
Joined: 2006-05-02 22:01:01
Location: montreal quebec canada

Post by Khronik » 2007-01-04 20:55:16

Holy Batman!

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

Post by Closter » 2007-01-07 00:43:10

Hello! This is my first post in this forum, but I think I am lurking here from '02 or '03. As you can see in my signature, I help Ermes and Joe Labrada (and many others) in making a Spain Theater.

Seeing the above mentioned issues I have paid attention to the Malc's remark here ... (well, Sherlock answered him). OK, you're possibly right, but I usually see the fog more dense over the lower parts of the terrain, and lighter over the highest. I think it is a great tip.

Isn't it possible to be just the new X1 value the opposite, so New X1=255-Old X1 or NX1=0xFF-OX1 ?

It's just an idea, I am absolutely insecure about it

Thank you all for your efforts, you make our common sim hobbie better every day!
Last edited by Closter on 2007-04-09 11:53:56, edited 2 times in total.
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-01-07 00:51:02

Closter wrote:Hello! This is my first post in this forum, but I think I am lurking here from '02 or '03. As you can see in my signature, I help Ermes and Joe Labrada (and many others) in making a Spain Theater.

Seeing the above mentioned issues I have paid attention to the Malc's remark here ... (well, Sherlock answered him). OK, you're possibly right, but I usually see the fog more dense over the lower parts of the terrain, and lighter over the highest. I think it is a great tip.

Isn't it possible to be just the new X1 value the opposite, so New X1=255-Old X1 or NX1=0xFF-OX1 ?

It's just an idea, I am absolutely insecure about it

Thank you all for your efforts, you make our common sim hobbie better every day!
Welcome and great idea....
Sherlock
Victurous te Saluto

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

Post by Closter » 2007-01-22 18:44:59

This thread brings more considerations about the X1 calculation:

ReadL2 Util


It is devoted to the start of CATE and how it was conceived, but has many very interesting cross-references .
Image

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

Post by Closter » 2007-01-26 15:20:57

Another interesting post about the X1 issue see the end of the message.

Post of ComGP
Image

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

Post by Closter » 2007-04-09 00:58:06

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.

Original Korea:
Image
SP3 Balkans:
Image

Falcon AF Korea:
Image
Falcon AF Balkans:
Image

I think we can obtain correlations between these data and know how to obtain correct fog values for different terrains
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-04-09 03:43:42

Closter,
if you were a girl I think I would kiss you! :)


Way to go! What can I do to help out? I've been wanting to solve this for some time now...
Sherlock
Victurous te Saluto

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

Post by Closter » 2007-04-09 09:35:06

No kisses, Sherlock. My wife would go mad and leave me! :D

Please, edit some terrain with terrainview . In the same segment, with the same tile, use different values for X1. Use some 4x4 tiles area each value or something like that. Then try to see it in-falcon different times-of-day and make pictures of it.

What values! I don't know exactly, but I can tell you the more frequent values I see in the file.

Korea Original
Value: number of pixels

254: 554780 This is the sea value. Another Sea Value is 252 with 15789
201: 105307
192: 54643
190: 53393
181: 21994
213: 19550
179: 14117
117:
130:
20:
145:
.....

(It keeps going...)

This is the histogram for Korea X1 bmp:

Image

Korea AF

252: 582738 (Sea Value)
200: 90001
214: 78429
117: 58228
192: 53390
190: 25581
141: 20476
122: 15634
124: 12270
91:
147:
176:
179:
...





It seems to me the values that supposedly terrainview uses are not the same and only that are used in Korea.

I have looked for the differences and this is the file I have found:

Differences between Korea and Korea AF X1
Image

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

Post by Closter » 2007-04-11 23:42:36

This is an example of the effect that some values have in the fog. Picture is taken at 18:00 and fog value is 98% and fog level about 1000 ft, over south Tenerife Island.

The values are the most common in AF Korea L2 file.

Image

Image

If you look at second picture, you can see four rows of tiles, each one with different values in X1. There is one row with a value, one row with the default value from terrainview. The feeling is kind of a glow, and is only visible at a certain distance, because of it's only in L2, not in L1 nor in L3. The values must be brought into the other levels by a tool like sptinstall, I suppose.

The 117 seems to me really dark and dirty, like smoke fog, and 192 is the more similar to fog. 214 seems like enlightened, and 200 is not really felt.

The effect shows itself in the lower border of the tiles, between two tiles.
Perhaps squares can make it more evident...
Image

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

Re: How is X1 palette value calculated?

Post by Closter » 2008-11-18 20:25:40

Another step in this search. I've been able to create a palette with the file that Map Editor creates from a given terrain. The file is a bmp 24 bits, if I simply reduce colors to indexed, PhotoShop is not creating the palette right. I have to made it myself, one colour by one. Luckily I could save the palette at the end, it is single time work. Then I have put the palette in the greyscale bitmap from the X1 values for Korea shown before, and this is the outcome:

Image

If you don't see the image here it is:

Picture

I think it is a beautiful sight of the theater and reflects the different kind of terrains much better than the terrainview bitmap or the relief map.

Now we can think of a method to fill the L2 values to reflect this with other theaters.
Image

ccc
Chief of Staff
Posts: 4857
Joined: 2000-08-06 22:01:01

Re: How is X1 palette value calculated?

Post by ccc » 2008-11-19 01:28:56

wow yes - great job!

can this bmp be used for autotiling?

Return to “Terrain / Theater”

Who is online

Users browsing this forum: ClaudeBot [Bot] and 0 guests