L3DT users' community
Large 3D terrain generator

Using L3DT in VBS2/ArmA workflow

Any and all chit-chat regarding L3DT.

Using L3DT in VBS2/ArmA workflow

Postby ALuomala » Mon Jan 31, 2011 5:49 pm

Hey all, I have been trying to implement L3DT into my VBS2 workflow (and the same workflow, at it's basic, can be used in ArmA, albeit the steps that involve Visitor4 can't be used (as that particular software is only for use in VBS2)). After Aaron has created some new plug-ins, scripts, graphs, etc, things have really come along to a point where one can bring in a real-world terrain and modify it with L3DT's built in tools, plus with some external software (such as GlobalMapper (GM) which is included with the VBS2 suite; and image manipulation tools such as PhotoShop (freeware tools such as GIMP should work, but I will use PS for my examples), and create much more realistic terrains than is currently possible with V4.

There is quite a bit of importing, exporting, saving, changing formats, etc required, so be forewarned!!

Step 1: Importing a VBS2 terrain into L3DT
a) Export the terrain that you wish to work on. It can be exported as ASC or XYZ (L3DT has the ability to import/export in these formats).

b) Import this heighfield into L3DT (File>Import > Heightfield (HF)

c) Generate Design Map (DM) : Operations > Design map > Generate from HF (relevant steps for these 2 steps are here: link . This step is neccesary due to the Calculations process that is needed to further modify the terrain (if you wish to create Attribute Maps, for example, to either create custom terrain textures, or perhaps if you wish to create a geotypical terrain from existing terrain, and don't want to spend a lot of time in PhotoShop mucking about with textures, brushes, etc.

d) It might be desirable (but not neccesary) to import your satellite imagery, to aid in viewing your terrain. I have had problems in the past with using full resolution sat imagery (4096+ pixels), and it is recommended to use 1024 x 1024, but I have successfully imported 2048 x 2048 imagery. You can use PS to accomplish this (Edit>Image Size), or V4 (File>export>Imagery and then select a Resolution (m/px) value that will bring you down to this range (2.0 m/px to bring a 4096 x 4096 image down to 2048 x 2048)or use GM (Export Raster/Image Format, select JPG/PNG/BMP/TGA (your choice), and select the Sample Spacing that will bring it to 1024 x 1024 (or 2048 x 2048). I have tried large values, and they appear on the screen, albeit tiled incorrectly, and the result is a soup-sandwich. Unless Aaron has improved the ability to go larger than 2048x2048, stick with these values. The texture is there to guide you with editing the terrain, and won't be part of your final VBS2 project.

At this point, you can get into Saphire (similar to Buldozer, as it is the 3D viewer/editor), by selecting the '3D' button in the menu bar, and start modifying the terrain. There is a user guide here, but I will highlight the basics below:

    Keyboard movement: A,S,D,W (standard keys for FPS games), and E and R to raise/lower viewpoint (can be remapped to fall in line with VBS2 keys, if desired)

    Viewmodes: 'M' to toggle between Texture, Poly, and Wireframe mode

    Edit Heightfield: 'H' to bring up editing menu. User Guide for heightfield editing tools [img=http://www.bundysoft.com/wiki/doku.php?id=plugins:sapphire:userguide:hf_edit]here[/img]

    Teleport: 'T' to bring up teleport menu (it works off of bottom left/south west corner being 0,0, and uses x,y values to place avatar). You can create and save different teleport points, as it can be a little difficult to navigate around quickly. Similar to 'Bookmarks' in V4.

    Transportation mode: 'Spacebar' toggles between Hover and Walk. Pick whichever method you want to move around the map (on foot, or as a helicopter).

    Turbo mode: 'Tab' key. Similar to holding down Shift in VBS2. Speeds up lateral/vertical movement of camera/avatar.

    Clip mode: You can select 'Clip -' or 'Clip +' from the menu bar at top. This will clip what distance the terrain is drawn at. If you are getting slow FPS (frames per second) while moving, select 'Clip -', and less terrain will be drawn. Keep in mind that L3DT draws the terrain very roughly at first, and then starts improving the view as you get closer to the point you wish as you slow down (or stop) the movement. This can be a little disconcerting at first, as it appears that your highly detailed terrain (if that is the case) is nothing but large chunky blocks. I would recommend moving around in Wireframe or Poly, not in Texture mode.

e) Once you have finished editting your terrain, you will want to export it so it can be brought back into VBS2. Select 'File>Export>Export Active Map Layer (or Ctrl+E), as long as your heighfield map is currently selected; or Export>Export Map Layer, and a window will pop open, with the different layers available to be exported. Select Heightfield. Then, in either event, select ASC or XYZ format, a new file name (don't want to overwrite your working VBS2 map data, right?!?) and then export. Note: I have had problems in the past, associated with exporting the wrong size of heightfield. I am not 100% convinced that I am still doing it correctly, as VBS2 and L3DT handle the sizes of heightfields differently. What VBS2 calls 1024x1024, L3DT calls 1023x1023 (due to the nature of starting at 0,0 instead of 1,1 for the bottom left X,Y values, I believe). This has caused me grief in the past (ending up with -32000m values on the bottom/right boundaries, which caused huge problems when I ran a smoothing pass over the whole map). Anyway, Aarron recommended adding 1 to each value (1025x1025 for a 1024x1024 map), which can be done by putting a check-mark in the box for 'Re-size for export' and then applying this corrected value. Your mileage may vary, so be forewarned, and ensure that archive your original files in case you run into problems in the future. Once you have exported your file, you can drag and drop it into V4, rebuild your terrain there, and try it out. I highly recommend keeping track, via archiving and using meaningful file names, of your modified terrains, in case things go awry. I have found that I threw caution into the wind one too many times, and overwrote previous files (in the interest of being able to use the "Refresh content from source" function in V4, rather than exporting as a unique name, importing and rebuilding). Learn from my mistake(s)!!!

Step 2: Using overlays to modify terrain

Note: The steps outlined here require the latest build of L3DT (v2.9 build 8 (31st of Jan, 2011), as the capabilities discussed aren't available prior to this build.

a) Create an overlay to modify your terrain. I tried to do this in GM only, as I know that many people/organizations don't have PS, and aren't permitted to use unauthorized software (GIMP, etc). It can be done, and may be desirable, particular if you wish to use existing data (SHAPEfiles, imagery, etc) that you received or created. The problems that I ran into are that there are many more steps required to accomplish something that can be done much faster in PS. I will go through the basics, using PS, and at some point I may include instructions to use GM to accomplish this (and it may be required to go into PS to clean up the imagery (add feathering to edges; add some noise (for randomness); stretch/twist/pinch/otherwise manipulate the shape(s); add gradient(s).... this one is a huge must-do, IMO, as it will allow for a gradual increase in values, rather than a drastic increase from max/minimal vertical values.

i) You can use your satellite imagery as a template
ii) Ensure that the image is kept in 2^2 format (it doesn't have to be the same size as your satellite imagery, as it can be stretched to fit, but it makes a certain amount of sense to keep things simple by using the same sat imagery size). If you don't do this, remember the scale change (i.e if you go from 4096 x 4096 to 1024 x 1024, you will need to remember this for step D below).

b) One thing to keep in mind when creating your overlay is to create a black background (which will have a value of 0m when we are done with it) and use white (or shades of grey) for your terrain modifying effects. The beauty of L3DT is that we will be able to change the min/max elevation quickly, so the overlays that are created can have different values whilst using the same image(s).

i) You can do this in PS easily, but if you use GM use these steps: using your project frame SHP file (exported from V4, and then imported into GM), select the frame, Edit the display properties for the shape (RMB on shape>Edit Area Feature>Feature Style, select 'Specify Style......' and select 'Customize....', Fill Pattern changed to 'Solid Fill' select pure black colour (RGB values of 0,0,0), Border Style to 'Null' (not critical when using black, but you will need to do this for any other colour, or you will have a black border), and unselect "Show Label for this Area").
ii) You must do this step if you are using GM to create your black background AND you wish to use GM to create your overlay: you must export your frame as an image, and then bring that image (PNG) back into GM. If, for example, you create an area shapefile in GM to use as your overlay (lets say you copy a contour from your map) and wish to colour this white (using the same method from step i above), the shapefile will not show up over the black frame shapefile, but will show up over the black PNG image that you exported.
Note: The biggest problem I can see with using GM (without PS involvement), is the lack of applying a gradient to the image that you create. It would be solid white, this creating an immediate step from 0m (the black) to whatever the maximum height you will set in step d below. This may be what you want: creating walls, ditches, etc, but if you are adding rolling hills, for example, you are going to want to use gradient effects to smooth the transistion.
iii) Once you have completed you overlay shape(s), have these shapes (coloured white by now) showing above the black background (i.e make sure that the black PNG file is at the bottom of the stack, or last drawn), and then use the process from step 1d above to export the imagery to be used as your overlay.

c) Optional: One other thing that you may wish to create, but it isn't neccesary for this tutorial, is a mask that will allow only certain areas to be modified. Not really neccesary in this case (as we will create black (0m) areas that won't effect the final heightfield), but you could use another method to achieve the results we will get, by combining a completely different heightfield (i.e of another area in the world completely) and then use a mask to only allow a portion of that to be applied to your initial heightfield. This is a more advanced technique, and I may touch on it later in this tutorial, or in the future. The key to creating a mask is this: black blocks, white allows the imagery to come through. You can use greyscale values to feather the mask (i.e use a gradient effect in PS), so that the effect isn't as drastic as it might be if you have a stark transition from a value of 0m (pure black) to 255m (pure white), which you would get if you don't modify the heightfield that is generated.

d) Import this new overlay as a Heightfield into L3DT. Note: You must close out (and save) your project, and start fresh here. Select 'File>Import>Heightfield.' Select your overlay (image) that you created. Select the file (PNG/BMP/JPG/TGA/etc) and then select 'Next' and set the horizontal scale to make this heightfield match your VBS2 heightfield. I normally use a 1:1 ratio here (i.e 4096m x 4096m satellite imagery and overlay size, so I use 1m for the horizontal scale), but if you chose a different value, enter that here (i.e if your chose to make it 1024x1024 vs 4096x4096, enter 4m).

e) Now for the min/max heights. If you wish for the maximum change to you heightfield to be 5m, and you used pure white (255,255,255) as part of your overlay, the highest point on that overlay (255,255,255) will be equal to 5m. If you want that point to be 50m, select 50m as your maximum elevation. This allows you to use a single overlay to try out different values, and then pop into L3DT to see if that value is correct. However, each overlay will have to be saved with a given maximum height value. It might be prudent to create a number of different overlays of the same shape, with a different set of maximum height values. This will save you a lot of time down the road if you discover that, for example, 5m just wasn't enough height on the terrain feature you are trying to create. To do this, first go with one value (say 10m), and finish off the step. Leave 'Wrap Edges' unchecked.

f) Once you have completed the import process, you will end up with a black heightfield, with your shape that you created. You can take a look at it now, if you wish, by going into Saphire (select '3D' from menu bar). You could edit this shape now, if you wish, and then export it, but for the sake of this tutorial, we will export it.

g) Go to File>Export>Export Active Map Layer (or hit Ctrl+E) and export this file as a HFZ (L3DT format) file. This file will now become a heightfield map that you can blend with your VBS2 terrain.

One point here: due to the way that the Merge Heighfields functionality works in L3DT, you don't need to create separate overlays if you want to subtract terrain (i.e create valleys, ditches, rivers, etc) using your overlay. You will be using whichever modifier that you want to apply (Add, Subtract) and if you select Subtract, it will remove Xm (your maximum height) from your terrain (with the maximum value being the pure white (255,255,255) value, and all the way down to 0m (pure black)). So, you wouldn't need to create inverse masks (which are needed in some application to carry out subtraction modifiers).

h) Optional: If you want to create a number of overlays, each with a different maximum height (e.g. 1m,5m,25m,50m), you can go into your heightfield parameters and change these and export them in turn. To do this, select 'Operations>Heightfield>Change Vertical Range' and then select a new maximum range. It would be prudent to append the maximum range to your overlay name on exporting them (i.e 'overlay10mMax', 'overlay25mMax') to keep track of these files.

j) Once you are ready to try out your new overlay, you will need to close out your L3DT session (where we created the overlay heightmap: you can save that file as a project, but it isn't neccesary, as we exported the heightfield), and then open up the L3DT project we created with our VBS2 terrain.

k) Once that is complete, you will do a MergeHeightfield action: Select File>Import>Merge Heightmaps'. You will first need to select the heightmap file that you want to overlay onto your existing VBS2 heightfield. After that you have the option of selecting a Mask Image (in this case we don't need to, as we will be applying the whole thing to our map (the black areas will add 0m.... in other words, no change to those areas). Again, this is a more advanced feature, and there may be occasions where you wish to use it.

m) Now the critical part: 'Blend Mode'. I will only discuss 'Add' and 'Subtract' for the purposes of this tutorial. Ensure that you select 'Add' or 'Sub', or you will end up with the default action of 'Replace' which would replace your VBS2 heightfield with your overlay. Likely not something you want to happen. Again, 'Add' will add your overlay to your heightfield, and 'Sub' will remove your overlay shape from your terrain. Use your imagination to think of the possibilities this has brought.

n) You can leave the 'Stretch to Fit' checked, or change the values in 'Reset Map' size in the Overlay Heightfield size. As for Position Offsets, X and Y are greyed out, and if you change the values for Z, it will effect your initial heightfield (i.e if you put 20m in the Z field, it will raise that heightfield by 20m.... not something that you likely want to occur).

p) Once that is done, L3DT will do it's magic, and you will end up with a modified Heightfield Map. Depending on the severity of your elevation change, it may or may not be apparent in the 2D window, so you will likely want to take a look in 3D. Start up Saphire, and look at your new changes. It help to get right down to ground level to see the changes, and toggle through Poly, Texture and Wireframe modes (using 'M' key) to see what it looks like. If you aren't satisfied, you can exit Saphire (hit 'Esc' key) and then select "Undo" from the menu bar. Note: it is wise to either save the project before going through major changes, or select "Bkup" (backup) from the menu bar, and then "Rest" (restore) to undo any changes. Resist the urge to do a lot of modifications in Saphire to your initial effort (there are only so many Undo steps available ;) until you are satisfied. Again, if you aren't happy (let's say that 5m max height wasn't drastic enough), you can always Undo to remove your change, and then go through the steps (starting at 2k above) using the other heightfields that had the different values applied (for maximum elevation).


I think I will leave this tutorial at this stage. I will add more to it (perhaps the steps required in PS to apply gradients, but, to be honest, there are probably a million such tutorials out there, likely much better than I can create, so it may be worth your time to Google-fu your way to victory on that front). Once Aaron comes up with the ability to modify the Attributes map (so that you can use the MASK_LCO files created/exported out of V4 (or V3)) more easily (presently, it is very difficult to simply take the MASK_LCO.png file and bring it into L3DT so that you can create your own custom Attributes Map (and thereby create custom texture maps), I will document how one can import one of these maps directly into L3DT for use as an attribute map (with some editing of parameters, obviously, to tell L3DT what terrain type/texture that you want in the areas that are red, green, yellow or blue on your map) and if need be, how to modify the MASK_LCO.png file in either PS (changing colour values to become valid L3DT colours) or GM (using SHAPEfiles exported from V4, and making these shapes have valid colours, as per the standard GM method of creating imagery from SHAPEfiles).

Any additions to this workflow, or questions, feel free to post below.

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: Using L3DT in VBS2/ArmA workflow

Postby ALuomala » Mon Jan 31, 2011 10:36 pm

Here are some images to illustrate my tutorial points above.


Image
In GlobalMapper I selected an area based on the contour intervals. To create contour intervals in GM, carry out the following steps: 1) Ensure that you have a heightmap selected (ASC, XYZ, DTED, etc), select File>Generate Contours, and then fill in the areas as neccesary. I would recommend determing the rough height that you wish to create contour lines for, put that in the range selection, and have a reasonable contour interval (5m?). If you wish, you can put a check in the box and select Only Generate Contours at Specified Height (265m, for example). You don't have to get too crazy on the horizontal resolution, but bringing it to a lower value (1 or 2m) will give you a more accurate shape. There are other areas you can check/uncheck, but you shouldn't need to get too fancy for this exercise.

Image
I then turned the contour interval into an area feature. To do this, select the contour line with the Digitizer tool, RMB and select Advanced Feature Creation Options>Create New Area Feature From Selected Line(s). You will then end up with a new area feature (it will be generated in the User Created Features layer, so if you don't see it, make sure that you have that layer visible (check mark in box).

Image
After it was an area feature, I changed the default settings to make the area pure white.

Image
I left the border around the shape so that you can see it better in this image.

I then exported the peak image as a PNG. Ensure that you select "Make background pixels (void) transparent" so that you don't have to remove the beige background colour in PS. It is important to export it using the frame size of your project: 4096x4096 for example. You can use "Reset to Last Exported Bounds" in Export Bounds tab, if you have valid settings, or enter the boundaries of your project. Otherwise, you will only export an image the same size as the shape you create. You want (presumably) to have your overlay to be covering the exact area in your terrain heightfield.

Image
I then imported the image into PS. I did two different types of overlays: the first is a wall based on the shape of the contour line. I selected the shape layer in PS (holding Alt (Win) or Command (Mac)) and made a selection, then created a new layer, and selected Selection>Modify>Contract, and brought in the selection area 10m by selecting 10pixels (1m = 1 px). I then flood filled this selection using pure black (so it will have a value of 0m in the overlay). I also used this same overlay, using Sub instead of Add to create a 10m deep ditch instead of walls.

Image
10m walls
Image
10m ditch

Image
The other overlay I created was a peak to replace the original peak. I created a bunch of layers, each using a slightly smaller contraction value, and filled each layer starting with black, and increasing upwards with lighter and lighter shades of gray, having the highest (smallest) shape have a pure white fill. (To make it look "fuzzy" I applied a bunch of Gaussian blur filters, so it wouldn't have an obvious stepped/terraced effect. In this way, I was able to stay true to the original contour line. I think it would be difficult to use traditional gradient fills, due to the shape, but I would use gradients on simpler shapes (circles or square shapes). I also had luck with applying a simple gradient to a circle shape, and then using various PS tools to shape it to my intended shape (Skew, Distort, etc in CS4 and lower; the Puppet Warp tool (in CS5) is incredible, so I would recommend that route (take a traditional shape, apply a simple gradient, and then bend the heck out of it as neccesary with the Puppet Warp tool) to give it a nice organic shape with consistent gradient effect. If I were going to create a large number of odd shaped features (using the contraction/fill technique), I think I would create a PS Action to speed up this process.


Image
Image
Here are views of the original peak (textured and poly) to give you an idea of what the final result will be.

Image
10m Added to Peak

Image
Image
25m Added to peak (2 photos)

As per the optional step above, I created 2 heightfields for my peak: my first has a maximum elevation of 10m, and the second is 25m. Because I did these in advance, after viewing the first (10m addition), I decided it wasn't enough of a peak (I selected "Undo" to remove the 10m addition), so I added the 25m peak right away (without having to go back into my overlay heightfield, changing the maximum value, exporting, etc, etc). This isn't particularly realistic, as this would likely make the peak considerably taller than what the peak would like be in real-life, but depending on the source data you receive, something drastic like this might be in order to create a more realistic effect. As well, you can use the various brushes to knock some height off as neccesary (Perlin noise, smooth, etc), or add other effects.

One note: I have relied heavily on imagery of the area that I am currently working on (via GoogleMap, Panaramio, FlickR, etc), and I know that the data I have is not very good (terrain is way too flat and smooth for an area that is mountainous and in a river valley, in my case), so it becomes somewhat of an artistic endeavour, versus a straight technical exercise, to ensure that your final VBS2 terrain is as close to the real thing as possible. Getting reference photos first hand (i.e walking the ground, taking photos, video, using GPS, etc) would be ideal, but in many cases you will never see the area that you are creating.

Granted, some of these effects could have been created in V4. For example, to create the 10m high wall/ditch, first in GM, using the contour line, I could have created a line feature, added a 5m buffer to it (giving it a width of 10m) and then exporting the SHAPEfile to V4, selecting this new area shape and selecting the vertices underneath the shape, and adding 10m (or another value) and repeat as neccesary. However, that particular functionality is broken ATM in V4 (only works once per session), and there is no way (that I can think of) to pull off the peak effect (or conversely, using the 'Sub' functionality to create a crater instead of a peak). In either V4, or in traditional editing in L3DT, there would be a lot of manual editing to get a reasonable effect, and by that point, your terrain would be "damaged", so that you would have to save a terrain file every few minutes. The way I illustrated above, is in a sense like "non-destructive" editing in PS: you are using the overlay, and if you don't like the results, do an Undo (or Restore), and try again. As well, one thing that I like, over manual editing, is that you can limit the amount of addition/subtraction via the max height of your overlay file. I find it is very easy to start hacking away at the terrain, and ending up with a mess, as it is sometimes hard to gauge scale when working on terrain (a 2m addition/reduction doesn't look like much when "painting with the brush" but it becomes a large mountain (or huge ditch) very quickly). I would LOVE to see the ability to use overlays as brushes in L3DT (i.e create a brush that can take a image like I created for my peak, scale it to be any width I want, select a max depth/height, and then apply that to my map), but I can imagine that is a lot of work, and Aaron does need to sleep sometimes, right?!

My next effort is going to be taking my project map area, extracting the erosion effects (from satellite imagery), and applying these to my project map via the MergeHeightfields (with overlays and masks). Let's see V4 do that!!! Didn't think so..... I will post results of that experiment when I get to that stage (with how I accomplished it, of course).

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: Using L3DT in VBS2/ArmA workflow

Postby Oktyabr » Fri Feb 18, 2011 5:27 pm

Thanks for the tutorials and tips!

I'm new to mapping for Arma 2/OA/CO and trying to master the workflow of going directly from a (fantasy) terrain in L3DT to V3... Your tutorial is a big help!
-------------------------------------------------------------------------------------------
"Free time" is only free if your time has absolutely no value.
Oktyabr
New member
 
Posts: 3
Joined: Thu Feb 17, 2011 6:45 pm


Return to General discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron