Jump to content
Sign in to follow this  
zukov

L3dt and maplegend.png

Recommended Posts

so like, the title i have a question about the maplegend,png the file reference of layer.cfg.

in L3DT you may export the attribute map for the mask map in terrain builder, with this export you have also a palette. txt file with relative RGB code

if you use this palette in layer.cfg

what is, in this case, the purpouse of maplegend.png?

https://www.youtube.com/watch?v=smEczW6IXJ0

Share this post


Link to post
Share on other sites

what is, in this case, the purpouse of maplegend.png?

The actual maplegend has no purpose except of the fact that it is a required file within the sourcefolder. TerrainBuilder (as well as Visitor) wont generate layers without it.

But it is nonetheless a helpfull file as it tells one which RGB code one may want to use for certain textures.

Share this post


Link to post
Share on other sites

thanks! i had the same suspect that is the real reason ;)

Share this post


Link to post
Share on other sites

MapLegend.png is actually an integral part of the layers creation process and it's used basically to "reclassify unknown mask colours"...

I explained the entire background to it - in painful detail.... long long ago, in a terrain thread far, far away... So I'll copypaste it in here...

** Remember - this explanation dates back to Visitor 3 days, so it mentions "More than 4 colours" several times...

With Terrainbuilder, we can now use 5 (+ normals), or 6 colours, but apart from that, the same concepts and principles apply....

The maplegend.png is a tricky thing designed to automatically assign surfaces to masks which contain colours that aren't already defined in layers.cfg - and we don't really use it for that...

For us it simply has to be present - you can use absolutely any colour you like for any surface...

That was the short version - the long version is...

When you "import sat & mask" (or "Generate Layers" in TB), Visitor/TB looks at each pixel of your mask in turn and analyses the rgb values, then it looks in Layers.cfg for a definition matching those values - if it finds one - it assigns that surface to that pixel and moves on...

If it doesn't find that colour defined in layers.cfg - it goes to the maplegend graphic - reading just the top line of pixels (which is why you can have writing underneath) - it locates this colour it's found - then it tracks left and right along that spectrum - looking for the nearest colour to the "odd" one it's found which does have a definition in layers.cfg - and it assigns that surface to that pixel...

So - really - you don't have to be as tidy with mask colours as you'd think... Visitor doesn't care how many colours are on there - if it doesn't find a colour defined, it'll use the next nearest defined colour, as dictated by maplegend - it only has problems if it finds more than four colours per segment which are defined - then you get clashes.

EG: - you have a mask with 4 colours - red, blue, green and black - and you paint a big yellow stripe across it.

Then - in your layers.cfg you define a surface each for red, blue, green, black and yellow.

When you import the mask there may be some areas with 5 colours in the one segment - Visitor can't handle that and freaks out - you get clashes...

EG2: - you have a mask with 4 colours - red, blue, green and black - and you paint a big yellow stripe across it.

Then - in your layers.cfg you define a surface each for red, blue, green and black. You don't have yellow defined.

When you import the mask Visitor will assign surfaces as normal until it hits yellow - there's no definition in Layers.cfg for yellow so it looks to maplegend - finds yellow, then looks left and right until it finds a colour that is defined - and uses that...

You don't get clashes and, in game, you'll get whatever surface Visitor decided was the "nearest to yellow"...

So what the hell use to us is that?

Well - not much... to us...

But - imagine you're BI... you just paid big bucks for a Sat image and a matching "land use layer" - it's basically - a mask - there's often 30 or 40 colours on there, and they come with a "legend" telling you which colour is which.... starting to sound familiar?

If you fed a layer like that into Visitor, using a layers.cfg with only 4 actual colours defined, everytime it hit a colour it didn't recognise it would go look at maplegend and find the nearest defined colour, and if you had a maplegend with the colours you're actually using strategically placed along the spectrum - you could control how undefined colours get translated... Better still - if you could define TWO colours for something common like grass, then any undefined colours falling between those two grass "bracket colours" would be assigned to "grass" (remember it tracks both left and right when looking for "nearest colour)...

Let's look at one of BI's own "mapLegends" now and see if it makes more sense...

mapLegend.png

Notice the "catchalls" at the extreme top and bottom - white and black...

Also notice both "rock" and "grass" defined twice - "bracketing" less important land-use categories that may have been defined on our hypothetical "ready made mask layer"..

Any areas on that original "ready made mask layer" shaded for "Mountain Pine", "Mountain grass" "Basalt" or "Sandstone" may be "undefined colours" so they'll all end up "rock", since either way that Visitor tracks along maplegend - they're all between "rock" brackets...

So it's a readymade 30 colour mask in, and a automatic 4 colour result out basically...

If you read the Wiki carefully on this topic it also mumbles something about "blending" and that it "wasn't used much" so I'm not sure if there might have been some other original intention behind this whole palaver as well...

Still.... there you go... the Big Explanation... kinda disappointing, huh?

I spent ages figuring it all out only to realise the information wasn't really of much use to us... You are still best being neat with your masks, counting colours per segment by eye, and it pretty much doesn't matter which colour you use for which surface as far as our purposes are concerned...

Still - now you know...

...and probably wish you didn't...

;)

B

Edited by Bushlurker

Share this post


Link to post
Share on other sites

thanks Bush, i want to know and the knowledge, sometime, can give to me a new job ;)

Share this post


Link to post
Share on other sites

whats the easiest way to make sure you dont accidentally create extra colors when using the brush in photoshop to edit your mask?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×