L3DT users' community
Large 3D terrain generator

Editing/importing Attribute layers

Got a problem or need advice?

Editing/importing Attribute layers

Postby ALuomala » Thu Jan 27, 2011 5:08 pm

I have been trying, unsuccessfully, to import a "mask" that was created for the Mil Sim product VBS2, into L3DT for use as a Attribute Map (AM). I exported an Attribute map out of L3DT, viewed it in PhotoShop (PS) and took note of the mode that the PNG needs to be in: 16bit greyscale (the mask file from VBS2 is 8bit RGB, and only allows for "pure" blue, red, green and/or yellow (0,255,255; 255,0,255; etc). I tried to simply convert my PNG file to the correct mode, and then import it into L3DT. I received errors of "invalid climate ID" (along with a few others). So, then I thought about creating my own climate ID's for my mask. I found this post which indicates that it doesn't matter the ID's are, as they are unique to each map.

So, is there a way to convert a previously created 8bit RGB PNG file so that it could be imported into L3DT??? I was thinking of assigning colour values from a L3DT created AM to my externally created mask (i.e swap out my blue colour (0,0,255) for an accepted colour (I sampled the colours from my L3DT AM and discovered (in the case of the map that I created, via the Walkthrough tutorial, which was desert-style)). Note: I tried this method, and it didn't work, although I noticed the Climate ID's changed (due to my reassigning colours??). I also tried manually editing the exported AM from my walkthrough tutorial. I sampled one of the colours used (it had a RGB value of 4,4,4... nearly pure black). After saving and importing this modified file, I had no errors pop up, but the layer is now a purplish single colour, not at all like the AM mask I exported (which had sand-coloured shades, as I used deset attributes. I noted thatt there is a '.amf.gz' file created when I save a "proper" L3DT project.

So I guess the bottome line is: 1) can I modify pre-existing external masks for use in L3DT; and 2) can L3DT creating AM's be exported outside of L3DT (in PS, for example) and then reimported into L3DT? I may have made a silly error somewhere (changing into a colour mode not supported by L3DT, but it doesn't appear to be the case).

Any help on this would be greatly appreciated, as I would love to be able to use existing masks (from VBS2, for example) and modify them for use in L3DT. This would bring me one step closer to being able to integrate L3DT into my terrain creation workflow (e.g creating realistic texture areas in L3DT to blend into my satellite imagery, rather than having to do this in PS).

Thanks,

Allan
Allan Luomala
SkyChasm Consulting - Military Simulation Terrain Specialist
http://skychasm-consulting.ca/
User avatar
ALuomala
Member
 
Posts: 18
Joined: Fri Dec 03, 2010 2:03 pm

Re: Editing/importing Attribute layers

Postby Aaron » Thu Jan 27, 2011 9:16 pm

Hi Allan,

External editing of the attributes map and importing back into L3DT is technically possible, but largely undocumented and effectively unsupported. However, I think I can add a 'nice' alpha map and/or index map importer to convert 3rd party mask maps into L3DT attributes maps. I'll pop this on the dev plan now, and may even have time to start on it today.

ALuomala wrote:I tried to simply convert my PNG file to the correct mode, and then import it into L3DT. I received errors of "invalid climate ID" (along with a few others). So, then I thought about creating my own climate ID's for my mask. I found this post which indicates that it doesn't matter the ID's are, as they are unique to each map.


I was perhaps a bit terse with that documentation; the codes may vary between maps, and their values don't matter much when using the 'export type list' function as intended (i.e. for export only), but that's not to say their values don't matter. These values tell L3DT which land type goes where, and therefore it matters very much what the IDs are. Each pixel value must exactly refer to a land type in a climate, and there is a strict format for this lookup. The 16 bit values are interpreted as a pair of bytes, where:
  • The first byte is the index of land type in its climate (see climate editor for list of land types in each climate)
  • The second byte is the index of the climate within the project's climate list (you can view or edit the project's climate list from the project file).
Each pixel in the attributes map must have a code that first indicates a valid climate ID (byte #2), and then indicates a valid land type ID within that climate (byte #1). The climate index is zero-based, whereas the land type index is 1-based (0 is reserved for an error code).


Importing attributes maps from RGB colour maps is similarly fraught, if not more so. The colour of every pixel must match exactly with the set display colour of a land type in a climate included in the project's climate list. The display colours are available in the land type editor window, via the climate editor.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Editing/importing Attribute layers

Postby Telarus » Fri Jan 28, 2011 1:30 am

Aaron,

Thanks, that clears up a few things, & I'd like to see an importer as well.

I'm also trying to edit an Attribute Map in an external editor (Photoshop). I built my design map with greyscale layers (blended with multiply blending), and I find it useful to see the greyscale terrain as an overlay (50% opacity) when I'm painting on Attributes. Specifically, I'm painting a riverbed not picked up by the water layer, so I have to follow terrain contours.

I've got photoshop setup so no pixel blending occurs when I'm painting (Pencil mode w/ some brush options set), and it's much faster with similar results to your spraycan setting. As long as the pixel values are valid, what would the simplest way to update the Attribute Map with the new pixel info be?
Last edited by Telarus on Tue Feb 01, 2011 12:40 am, edited 1 time in total.
Telarus
Doyen
 
Posts: 112
Joined: Mon Jun 01, 2009 12:34 am

Re: Editing/importing Attribute layers

Postby Telarus » Fri Jan 28, 2011 2:15 am

Ok, I have a basic workflow.

1) Export AM as PNG (greyscale OR color, doesn't seem to matter).

2) Edit in Photoshop with the Pencil Tool so you can lay down exact colors with no blending (make sure other options like opacity etc aren't set wrong).

3) Save New_AM as *.png

4) Import New_AM into L3DT using File>Import>New Map Layer, choosing the New_AM.png file and setting the import options to Attribute Map. Confirm that when you mouse over areas in the New_AM, L3DT displays the correct Climate Types in the statusbar for the new pixels.

5) Save the project. Then, using File>Export>Export Active Map Layer, export the New_AM as an L3DT Mosaic Map (check the 1st checkbox). Under Filename, hit the browse button. Browse to your projectName/AM/ directory and select the existing projectName_AM.mmf file. Hit Save, confirm that you want to replace the file. Click Next, select the correct Mosaic Size ( X * Y ), and enter "AM" under Map Name.

6) [This step is because you cannot select "reload" under the AM's Layer menu] After the old AM has been overwritten by the new AM, click File>Open. when it asks you to Save click NO (remember we saved it before overwriting the AM, but the old AM is still in memory). Select your project and Load it.

7) The new AM should appear in the Attribute Map tab, and you can now render a texture map from it.


Aaron, any easier way to do this?
Telarus
Doyen
 
Posts: 112
Joined: Mon Jun 01, 2009 12:34 am

Re: Editing/importing Attribute layers

Postby Aaron » Fri Jan 28, 2011 11:41 am

Hi Telarus,

In step 4, if you set the layer name to "AM" in the import window, this will overwrite the project's attributes map, so you won't need to bother with steps 5 through 7.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Editing/importing Attribute layers

Postby ALuomala » Fri Jan 28, 2011 4:08 pm

I had a few issues, and was going to go through what I did wrong, but I think that will just muddy the waters.

What I will point out are 2 things:

1) You have to name the layer "AM" (without quotes), otherwise this process won't work (you will be prompted to create a new Attributes Map when you select Calc).

2) I was able to have some success with creating a mask, using GlobalMapper, and exporting SHAPEfiles as imagery, but I was sure to use valid colours (as per default L3DT climates). I was initially having problems with importing (I was getting an error saying:
Code: Select all
L3DTio_FI::LoadMapFile error
 - unsupported bpp/mode for file type 'png' (bpp = 32, mode = 1, map type ID = 40)


I tried changing the export parameters (in GM) to 8bit, but I still came up with a similar error (saying bpp=8 instead of bpp=32), and that didn't work. I worked around this by exporting this PNG (from GM) into a PSD I had created (and somewhat successfully used for import into L3DT: I had invalid climates, due to some blending issues I created in PS), and then exporting this file as a PNG. So, somehow GM is giving invalid parameters, and I have to "filter" it through PS. Not sure if there is a setting in GM I can change, but I can live with this additional step, as it should only have to be done once or twice in a project.

So, I suppose the moral of the story is that existing L3DT AM can be edited externally, and successfully imported, as well as created in a 3rd party application (PS in this case) and the same can be achieved.

On a side note, I tried to be clever and create new climates, so that I could use my initial masks from VBS2 (the ones that used pure blue, yellow, green and red RGB values). I'm not sure if I am barking up the wrong tree, but I created new climate/terrains, and assigned them these pure colour values (0,255,255; 255, 255, 0; etc). I only had one colour come through successfully (the red), although it assigned a different terrain type than I assigned the red colour (brick is what came up). So, if one wanted to change the assignments of colours (overwriting default ones), how would one go about that??? In this way, I could keep my original VBS2 masks (as exported by Visitor4 (you can't change these colour values... that I am aware of), and just do some jigging around in L3DT to have the 4 colours come in as valid L3DT terrain types (green for a vegetation type, red for roads, blue for water areas, etc).

All in all, a very successful effort, and this brings me that much closer to using L3DT in my VBS2 terrain workflow.

Allan
Allan Luomala
SkyChasm Consulting - Military Simulation Terrain Specialist
http://skychasm-consulting.ca/
User avatar
ALuomala
Member
 
Posts: 18
Joined: Fri Dec 03, 2010 2:03 pm

Re: Editing/importing Attribute layers

Postby Telarus » Fri Jan 28, 2011 10:13 pm

aaron wrote:Hi Telarus,

In step 4, if you set the layer name to "AM" in the import window, this will overwrite the project's attributes map, so you won't need to bother with steps 5 through 7.

Cheers,
Aaron.


Knew I was missing something simple, thanks Aaron!

Allan,

I wish you luck! I'm exploring Unreal3 UDK terrain functionality right now and seeing if I can get L3DT into the workflow, so I'll be using alpha maps in a similar way. UDK already has some awesome texture 'splatting' features, and can even lay down layers (even mixed layers) of 3d props (grass/trees/etc) based on an alpha map.
Telarus
Doyen
 
Posts: 112
Joined: Mon Jun 01, 2009 12:34 am

Re: Editing/importing Attribute layers

Postby Aaron » Mon Jan 31, 2011 12:17 pm

Hi Allan,

ALuomala wrote:2) I was able to have some success with creating a mask, using GlobalMapper, and exporting SHAPEfiles as imagery, but I was sure to use valid colours (as per default L3DT climates). I was initially having problems with importing (I was getting an error saying:
Code: Select all
L3DTio_FI::LoadMapFile error
 - unsupported bpp/mode for file type 'png' (bpp = 32, mode = 1, map type ID = 40)



That cryptic little message means that L3DT can't load attributes maps from 32-bit PBG images, nor 8-bit PNGs (bpp=8). It can load them from 24-bit PNGs, but only using a messy colour lookup algorithm. This colour lookup is not at all guaranteed to find the land type you meant, since it looks through only the climates loaded into the project, and should two land types share the same colour, the results are undefined.

ALuomala wrote:On a side note, I tried to be clever and create new climates, so that I could use my initial masks from VBS2 (the ones that used pure blue, yellow, green and red RGB values). I'm not sure if I am barking up the wrong tree, but I created new climate/terrains, and assigned them these pure colour values (0,255,255; 255, 255, 0; etc). I only had one colour come through successfully...


I'm guessing your custom climate was not loaded into the project before you tried to import the attributes map. There are a couple of ways to load your custom climate into the project. The easiest way, I think, would be for you to back-calculate a design map for your heightfield using the 'Operations->Design map->Generate from HF' menu option, and select your climate on the on the 'design map parameters' wizard pane.

ALuomala wrote:...although it assigned a different terrain type than I assigned the red colour (brick is what came up).


The display colour set for brick is also red, so evidently you had loaded the 'artificial' climate into your project at some point in time.

ALuomala wrote:So, if one wanted to change the assignments of colours (overwriting default ones), how would one go about that???


I'm not sure it would be a good idea to document or support this method of importing the attributes map, since it's a kludge with some horribly tricky caveats. Rather, as stated above, I will implement a purpose-built importer that will include an interface in which you'll be able to choose directly which land types go with which colours. I'll post back here when it's ready for testing.

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Editing/importing Attribute layers

Postby Aaron » Thu Feb 03, 2011 9:35 pm

Hi Guys,

The good news is that I've got the new attributes map importer algorithm working OK. The bad news is that the user interface is not quite finished, and that I'm away all next week, so it wont be ready for testing until at least late Feb.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Editing/importing Attribute layers

Postby ALuomala » Thu Feb 03, 2011 9:54 pm

Thanks a lot Aaron. I could have used the new importer right away, but I will work on other things (using the mergeHeight with layers) in the mean time.

Thanks for taking the time to work on these things. I know that you have other things to work on (in preparation for vers 3.0), so it is greatly appreciated that you are working on these things for us, and communicating your progress. I wish I could get that type of support from other companies (**cough**BI Simulation**cough*) software that I paid a LOT more money for.

Thanks again,

Allan
Allan Luomala
SkyChasm Consulting - Military Simulation Terrain Specialist
http://skychasm-consulting.ca/
User avatar
ALuomala
Member
 
Posts: 18
Joined: Fri Dec 03, 2010 2:03 pm

Re: Editing/importing Attribute layers

Postby Aaron » Thu Feb 17, 2011 12:18 pm

Hi Allan,

I've added an attributes map importer interface to the latest developmental build of L3DT Pro. You can read all about it over here.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Editing/importing Attribute layers

Postby ALuomala » Thu Feb 17, 2011 3:19 pm

Thanks a million, Aaron! And here I was thinking that you were taking it easy the last few weeks!! :mrgreen:

This is going to help me out immensely, as I will be able to use existing data (SHAPEfiles) converted to imagery to help speed up creating my custom Texture Maps.

I really appreciate the extra work you put into making L3DT an outstanding product.

Allan
Allan Luomala
SkyChasm Consulting - Military Simulation Terrain Specialist
http://skychasm-consulting.ca/
User avatar
ALuomala
Member
 
Posts: 18
Joined: Fri Dec 03, 2010 2:03 pm

Re: Editing/importing Attribute layers

Postby ALuomala » Thu Feb 17, 2011 8:40 pm

One point, that I almost reported as a bug, was about exporting the Attribute Map (that was created from your import): If you export it as a PNG (I will get into why you would do this in a second), ensure that you select the options for PNG export, and ensure that ColourMapped is set to true. This way your PNG file will be in colour mode, not greyscale.

The reason I bring this up is that I wasn't happy with one of my choices, and I didn't want to have to go through the whole process again (matching the colours that I had given my map file to L3DT terrain materials), so I reasoned that if I exported this new Attribute Map as a PNG file, I could import it, let it do it's analysis magic, give the map the L3DT settings, and then simply change the one colour/terrain to what I wanted.

On a side note, I don't know if it would be possible to have L3DT "remember" what the colour values were used in previous imports. So, if I always use a blue colour (when I export SHAPEfile area shapes from GlobalMapper, for example), it would somehow remember what my previous choices were. Maybe like an import config file, that I would be able to save after I am done the import process. That would be stellar.

Another thing that I just thought of that might be handy, is if a colour chart could be printed out (or viewed onscreen) that shows the default RGB values of the various climate/land types (i.e temperate - sand has a value of 230,230,120). This way, I would be able to colour my SHAPEfiles in GM to match these values, so upon import there would be less work. Not sure if this would have prevented the need for this importer, but I suspect this importer would still be needed regardless (for every other circumstance, other than the one I just mentioned).

Super work, Aaron. Keep it up!

Allan
Allan Luomala
SkyChasm Consulting - Military Simulation Terrain Specialist
http://skychasm-consulting.ca/
User avatar
ALuomala
Member
 
Posts: 18
Joined: Fri Dec 03, 2010 2:03 pm

Re: Editing/importing Attribute layers

Postby Telarus » Thu Feb 17, 2011 9:05 pm

Wow, sweet addition Aaron.

Allan,

RGB codes are in the General Tab of the Land Type editor _in_ the Climate Editor window.

Link: http://www.bundysoft.com/docs/doku.php? ... edit:pane1

Not sure if there's an easy way to export a list.
Telarus
Doyen
 
Posts: 112
Joined: Mon Jun 01, 2009 12:34 am

Re: Editing/importing Attribute layers

Postby Aaron » Sun Feb 20, 2011 1:18 am

Hi Allan,

Thanks for your suggestions. I've updated the plugin again to incorporate these and other changes, which are all
described in the plugin thread.

ALuomala wrote:One point, that I almost reported as a bug, was about exporting the Attribute Map (that was created from your import): If you export it as a PNG (I will get into why you would do this in a second), ensure that you select the options for PNG export, and ensure that ColourMapped is set to true. This way your PNG file will be in colour mode, not greyscale.


The colour mapped mode is now default. Greyscale was used for historical reasons, and is seldom used now.

ALuomala wrote:On a side note, I don't know if it would be possible to have L3DT "remember" what the colour values were used in previous imports. So, if I always use a blue colour (when I export SHAPEfile area shapes from GlobalMapper, for example), it would somehow remember what my previous choices were. Maybe like an import config file, that I would be able to save after I am done the import process. That would be stellar.


Done. L3DT now loads and saves the colour palette as a text file (examples and description here).

ALuomala wrote:Another thing that I just thought of that might be handy, is if a colour chart could be printed out (or viewed onscreen) that shows the default RGB values of the various climate/land types (i.e temperate - sand has a value of 230,230,120). This way, I would be able to colour my SHAPEfiles in GM to match these values, so upon import there would be less work. Not sure if this would have prevented the need for this importer, but I suspect this importer would still be needed regardless (for every other circumstance, other than the one I just mentioned).


Also done. When L3DT saves the colour palette text file, it also saves a prettyprinted HTML file, such as this one, which you can then view in a browser whilst you edit your attributes map in another package.

ALuomala wrote:And here I was thinking that you were taking it easy the last few weeks!! :mrgreen:


Urgh, I wish. I spent a week in Canberra for a conference, which must be some sort of punishment for sins in a former life. On the up-side, I did get to see Saddam Hussein's golden AK47, so I shouldn't complain.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to Help and support

Who is online

Users browsing this forum: No registered users and 12 guests

cron