project reality header
Go Back   Project Reality Forums > PR:BF2 Mod Forums > PR:BF2 Community Modding > Modding Tutorials
17 Apr 2021, 00:00:00 (PRT)
Register Developer Blogs Project Reality Members List Search Today's Posts Mark Forums Read
Modding Tutorials Information and tutorials related to modding BF2.

Thread Tools Display Modes
Old 2015-05-13, 19:18   #1
PR:BF2 Developer
Supporting Member

Rhino's Avatar
Cool Advanced 3DsMax Lightmapping


I have been experimenting and refining Lightmapping with 3DsMax for BF2, for quite a few years now and I have been meaning to write up a tutorial on them for some time but never gotten round to it. After a few requests from fellow mappers and with the old 3DsMax LMing tutorial lost with, I've decided its time to put down all my techniques on paper for any future mappers who might be able to benefit from them.

First of all I want to state the advantages of 3DsMax Lightmapping for anyone unsure if its worth it, including the advantages that are new in this tutorial.
  • 3DsMax Lightmapping is generally a lot faster than Lightmapping in the BF2 Editor (depending on the type of lighting you use), with multi-core processing and 64bit support, especially for large complex maps, even after you take into account the extra time for importing your terrain and all the objects etc. I have also managed to make this process even faster than the traditional method of 3DsMax LMing shown in previous tutorials, with generating all three types of light together at once instead of individually as before with max.
    For Object Lightmapping the BF2 Editor generally takes around 3 and a 1/2 minutes to generate all the LODs of a single, complex static, where 3DsMax with Adv. Ray Traced Shadows takes around 2 and a 1/2 minutes for the same object and all its lod, saving a whole minute per object and in all taking around 70% of the time BF2 Editor takes. It should be noted thou that in full Ray Traced Shadows, which gives the best quality lighting, the lightmapping process dose take quite a bit longer at around 6 minutes per object and its lods.
    For Terrain Lightmaps the savings are even larger, depending on the complexity of your map of course, since the BF2 Editor really struggles to render lots of overgrowth on the terrain, like the example map in this tutorial. For a single patch that was 2/3 sea water and didn't have that many trees on it, the BF2 Editor took 11mins and 41secs, where 3DsMax with Adv. Ray Traced Shadows only took 2mins and 38secs, which is a massive saving of around 23% of the time the BF2 Editor took on the same patch. Even when it came to Full Ray Traced Shadows in 3DsMax it took quite a bit less time than the Editor, taking 8mins and 20secs for the same patch which really says it all.
  • The Quality of the Lightmaps is far superior, depending on the settings and lighting method you use of-course, especially when it comes to overgrowth when setup with transparent leaves (as per in this tutorial).
    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    Spoiler for More Comparison Examples:
    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

    BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

  • The Lightmap Sizes are far more optimized than standard BF2 Lightmap Samples since many small vBF2, and even PR Custom Statics, have super large lightmap samples for tiny objects, resulting in a 512x512 texture for a small detached house which can easily be lightmapped in 256x256 without much loss of quality and being the same light pixel ratio as the other statics on your map.
  • You have far more control over your lighting and how objects have an impact on your map and the end result of your lightmaps as well than with the BF2Editor.
  • "Point Light" (Man Made Light such as light bulbs in buildings) can be done far easier, with much more flexibility and with better quality than in the BF2Editor.
  • No requirement of "Lightmap Samples" for all your statics to be present in order to lightmap them, which also allows for lightmapping xpack objects etc (although it is now possible to generate samples for most statics using Bf2MeshView, but doing this, especially for a lot of objects, is very time consuming).
  • Full Lightmap Padding (with new scripts) which helps cut down lighting errors in the mipmaps and is something the BF2 Editor doesn't have (although dose have a little padding).

However there are a few disadvantages that you should be aware of:
  • Its a very complex process that for someone without any knowledge of 3DsMax and Rendering etc may struggle with but I aim to make this tutorial as straight forward as possible for any novices out there.
  • The setup process prior to lightmapping can be pretty time consuming with having to import all the static meshes of your map etc, especially if your going to setup all your overgrowth etc with transparent leaves etc as per this tutorial.
  • You need to manually set the lightmap sizes for each object, however pretty much all the statics in PR have been defined previously by other PR mappers and its only objects that aren't on the "Master Lightmap Sizes" List you will need to define.
  • Child Objects such as Ladders will not be imported with their parent meshes and will need to be added manually into Max in order to cast a shadow (and to LM them if they require that but you can't LM Children in the BF2Editor either and Ladders shouldn't be ladders)
  • Destroyable Objects can not be lightmapped in 3DsMax, at least not without a big complex work around and its best to generate them in the BF2 Editor with settings similar to those of 3DsMax. If a Destroyable Object has been made "non-destroyable" by code, then it will import the geom0 lods into Max and will lightmap them fine, but it will not import the geom1, wreck lods in and you will need to make 8x8px dummy lightmaps for the wreck lods which are required in order for the geom0 lod lightmaps to load ingame and will save quite a lot of LM space from generating them at full rez.

Overall if your willing to put the work in the positives far outweigh any negatives.

Before you Begin this Tutorial
Spoiler for Before you Begin this Tutorial and Lightmap your map in 3DsMax:
Before you start the complex process of lightmapping your map in 3DsMax, you should ensure your map is truly final and has been tested as thoroughly as you can get it, with ideally having it looked over by other PR Mappers for issues you may have missed since any changes to your map after you've done all the work of importing your map into 3DsMax are very hard to replicate in 3DsMax and I will not be covering this side of things in this tutorial either and your probably best of starting this whole, complex process again from scratch to ensure there are no issues, unless you know excatly what you are doing.

Its also worth noting that it isn't really worth doing 3DsMax LMs (Lightmaps) for a test build of your map either, unless lightmapping with the BF2Editor on Medium/Low settings for the test, or not having any lightmaps for the test, is really not an option since the work involved to get your map in a state to be Lightmapped in 3DsMax, probably isn't worth it if your going to have to do it all again from scratch a few weeks/months later, but I will leave that up to you to decide. You could always skip a few steps like making all the leaves of the trees transparent for just a test build and do Adv. Ray Traced shadows rather than Ray Traced Shadows, both of which will also speed up rendering time, but having non-transparent leaves will look really, really bad and worse than BF2Editor LMs in many cases.

As such, just be aware of what your getting yourself into before you start this process.

Requirements & Tools
Spoiler for Requirements & Tools:

For this Tutorial you will require the following:
Make sure all of the above are installed and working before you start this tutorial.

Optional Tools:
  • A Later version of Autodesk 3D Studio Max (3DsMax, and ideally a 64bit version) than v9. Any of the current version "should" work but the lightmapping scripts have only been tested with 3DsMax 2010 and 2012. This is technically a requirement for generating large terrain lightmaps since 3DsMax9 can only generate a max rez of 4096x4096 (ok for 2km and smaller maps) but with only being 32bits (there is a 64bit version of Max9 but its very buggy), it will struggle to cope. It should be noted that you will need to install the PR:BF2 3DsMax9 Tools to this version as well, in the same way you would for 3DsMax9.
  • BFMeshView - required to view lightmap samples for lightmap sizes.
  • NVIDA Windows Texture Viewer (WTV)
  • A Spreadsheet Tool - I will be using Google Sheets for this tutorial.

A few things to note about this Tutorial
Spoiler for A few things to note about this Tutorial:
Firstly I am going to be working with a "pr_repo" mod which is linked to our SVN Repository which is why you might see funny symbols on my folder icons etc but just ignore them and I will also be referring to the working mod as "pr_edit" in this tutorial for anyone not working our of the Developer SVN Server and if you see any reference to "pr_repo" in the screenshots etc just take note that is my working mod and just replace it with w/e your working mod it, be it "pr_edit" or w/e.

Converting your Overgrowth to Static
Spoiler for Converting your Overgrowth to Static:
Unfortunately 3DsMAx can't import the Overgrowth in your map, placed with the Overgrowth tool, directly from BF2 into 3DsMax. As such we need to convert every Overgrowth object placed with the Overgrowth tool to a static placed object, so then we can import it into 3DsMax.

First of all backup your Staticobjects.con with all your buildings, props etc in at least once before doing anything else, calling it something like Staticobjects_Final_*DATE*.con

We now need to first delete everything out of it in the editor (or you can do it outside of the editor by just deleting its entire contents with a text editor if you want to reload the editor). Simplest way to do this inside the editor is to go into the layer bit, right click on the main layer and click "select all in layer". Once that's finished (will take a bit of time) delete all the objects and ensure there are no staticobjects in any of the other layers (some times they can find there way in). Make sure all static objects in all layers are deleted and its worth checking your staticobjects.con after to ensure its empty of objects (will still have the "run" lines for your OG thou) and if it should look something like this:

Now this next part isn't strait forward as some of you will probably get this same error I do after lightmapping which disables your view which is a real pain in the *ss since it makes the bit after it 100x harder so I can't give you any pics of that part but I'll try and explain it as best as possible.

First position your camera/view so you can see your entire map (you may need to increase your editor VD settings to do so). Drag in a small simple object like a 1m crate and place it anywhere and lightmap it on low settings. Once its lightmapped, delete it right away.

You overgrowth will now be converted to staticobjects and should be selectable (even if you can't see it if your view is disabled like mine is). Drag a selection box over your entire map which your camera/view should be able to see if you positioned it before hand, note if your view is disabled you might not see the selection box and you should click and hold in the first corner and wait a few seconds before dragging out to ensure the editor has time to keep up with your input as its probaly running very slowly at this point. Once you've dragged the selection box across your map you will probably have to wait some time for the editor to select all the objects, and if you have the output bar visible you should see a load of "[Tweaker] Load Object (Object)" popping up over and over again in it.

Once all your OG is selected you will need to check "IsSaveable" box in the tweaker bar (green box = checked) and apply it to all objects in selection:

Once done save your objects:

Now if you look in your staticobjects.con now you should see all your overgrowth in it:

You should now rename your Staticobjects.con with all your OG in it to something like "Staticobjects_Overgrowth.con" and then put your proper Staticobjects.con backup (with all your buildings etc in), back into its orignal place.

3DsMax LMing Scene Setup
Spoiler for 3DsMax LMing Scene Setup:
First create a new scene and go to "Customise > Units Setup" and for LMing you need to set the Display Unit Scale to "Generic Units" and then click "System Unit Setup" and set "1 Unit = " to "1.0 Inches" then click ok. This will result in a scale of 1m (in BF2) = 10 Units (in Max). Its worth noting that for modelling and exporting I recommend using Metric Meters but for Lightmapping its best to use Generic Units.

Importing Your Terrain into 3DsMax
Spoiler for Importing Your Terrain into 3DsMax:
Once your 3DsMax scene is setup with the right units etc go to "BF2 > BF2 Lightmapping" and click "Load Land". Then browse to your map's main folder in /pr_edit/levels/*your map*/ and select/open your map's "Heightdata.con" file. It should now start to import your terrain, this may take a little time.
Tip: If you get a "Out of scripter memory" error, Open up the Listener Window (F11) and type in "heapsize += 1000000000" (without quotes) and you now should be able to import your terrain.

Once its done you should end up with something like this:

Now your terrain is imported, to help you distinguish and navigate it more easily, as well as a few things to help with LMing it later on, I would first recommend you first rename your terrain object from "Object01" (or something similar) to "_TERRAIN" and Convert your Terrain to an Edible Poly:

Next to make things easier to work with Apply an Optimize Modifier to your Terrain and set the Face Fresh to 1 to ensure it only optimizing the mesh without changing its shape.

Now you may need to clean up the edges (and possibly some other areas) of your terrain manually which may have been imported "badly", like these bits here in my case:

Now you can either fix these up manually in in max, but even thou these errors may not be visible to your in the BF2Editor, they are on your heightmap and this is what causes these invisible walls choppers/jets etc crash into around the edges of a map. As such, its best to fix them at the source, on the heightmap itself.

Load up Photoshop and open your map's "HeightmapPrimary.raw" file (backing it up first) with a channels count of 1, Depth in 16 Bits and the Byte Order to IBM PC like so:

Then it should look something like this, with the whiter the colour, the higher the terrain and the darker, the lower etc, and if you look at the edges you can clearly see the errors on the edges of the map:

Now its just a matter of cleaning them out using normal PS methods, although I would advise you work on a new layer above the BG layer so you can easily change any edits you make:

Once done resave your HeightmapPrimary.raw (making sure you have a backup of the old one first) in IBM PC Byte Order (you will possibly want to also save it in .psd format with the extra layer you've got somewhere too) and check your heightmap in the editor to ensure its all still good:

You may want to do a little bit of manual smoothing on some of the edges now to clean them up a little:

Once done with your edits / checking, make sure you save your terrain and Complied Terrain (File Re-Save if you haven't made any edits):

Now if you repeat the above processes of importing your terrain (deleting your old one first) and your terrain should be mostly cleaned up now. Mine still has a tiny lip and a little bit I missed on the beach but nothing to really worry about:

Remember to optimize and name your terrain again once your happy with your edits and if not, go back over them and fix them up again:

Convert your terrain back to an Edible Poly and then apply an "Unwrap UVW" Modifier to it. Click the Edit button in the modifier panel, go to face selection mode, select all faces (Ctrl+A) and then on the right in the modifier panel, in the Map Parameters rollout, hit the "Planar" button with "Normalized Map" Checked and it will UV your terrain in the same way it is ingame. Make sure that the North of your map is in the top of the UV etc. Once your happy click on the "Planar" button again and you can also uncheck "Show Pelt Seam" and "Show Map Seam" in the Display roll-out above it to make for easier viewing. Finally double check that your UVs are extended all the way to the very edge of the UV box, Best way to do this is to select the bottom left UV Vert, and ensure its at "U: 0.0, V: 0.0" and that the very top right vert is at "U: 1.0, V: 1.0". If the UVs do not extend to the very edges of the UV Window, then your generated terrain shadows later will be slightly offset from the objects of the map, especially at the edges of your map, and there will be a big gap around your map edges of a missing generated lightmap.

Once your happy with all that collapse that modifier and while this step is optional, I would now recommend applying your minimap as a texture to your terrain to first ensure your UV map is first correct and second to help you navigate your map more easily. First take a minimap render of your map in the editor, save it as a PNG and then selecting a unused material slot, set it to use a Standard Material (should be by default), expand the Maps Rollout and click on the "None" button next to "Diffuse Color", select "Bitmap" at the top of the list and then browse to your minimap file:

Now click "Go to Parent" in the top right, below the material slots, above the "Bitmap" button, then click the checker cube "Show Map in Viewport" button, rename the material to something like "Terrain" and apply this material to your terrain and you should have something like so:

Finally I would recommend now setting your Terrain's Object Color to something else other than white, I would recommend 100% black so when in edged or wire mode you can distinguish it more easily from the other statics, which will be imported, by default, with a white colour like your terrain was, and now in edged frame / wire mode you can much more easily see your terrain

Finally Save and Backup your 3DsMax Lightmapping Scene before you go any further.

Importing Your Statics into 3DsMax
Spoiler for Importing Your Statics into 3DsMax:
Next step is to import your statics into 3DsMax. Go to BF2 > Bf2 Lightmapping and hit the "Load Staticobjects.con" Button, then browse to your maps Staticobjects.con with all your buildings etc in it, then you will need to wait awhile while all your statics are imported, time depending ofc on how many objects are in your map and the complexity of those objects:

Once that is done you should have something a little bit like this:

I would recommend at this point that you Save and backup your 3DsMax Scene and restart your computer.

Importing Your Overgrowth into 3DsMax
Spoiler for Importing Your Overgrowth into 3DsMax:
Once your PC has restarted, before we import the overgrowth, to save ourselves a hell of a lot of time in the long run, you should go to your "EA GAMES\Battlefield 2\mods\pr_edit\Objects" folder and temporarily move the "vegitation" folder outside of your pr_edit folder, somewhere on your computer, so that the import scripts can't find the objects its trying to import, and instead just places a helper for them.

Once you've moved your vegitation folder load up 3DsMax again and with a brand new scene, with the same units setup as before, repeat the above process for importing statics into 3DsMax BUT importing your Overgrowth Staticobjects.con (Should be named something along the lines of Staticobjects_Overgrowth.con as per the "Converting the Overgrowth to Static" Step). We are using a brand new blank seen to make it easier on the importing script to do its job as for some reason it seems to slow down when the scene is already populated with lots of objects and we are going to merge the imported Overgrowth helpers into the proper scene once the importing has finished.

Once the importing has finished you should have something like this:

Now Save this max scene as the same name as your map but with an "_Overgrowth" suffix (mine is called "Jamaica_Overgrowth.max"), Back it up and finally move the "vegitation" folder you just moved out of your "\pr_edit\Objects" folder, back into it where it belongs.

Open up your normal Lightmapping Scene with your terrain and statics in and then go to File > Merge and select your scene with your imported Overgrowth Helpers in. Then click the "All" button in the bottom left to select everything and click ok and it will import all the selected files into your current scene.

I would then recommend adding the selected to a new "Overgrowth Helpers" Layer:

Then save and backup your LMing Scene.

Cleaning Up Your Objects
Spoiler for Cleaning Up Your Objects:
There are going to be a lot of objects in your files that you either don't want to generate lightmaps for, can't have them generated for, don't want them to cast a shadow on the map and so on. As such we want to sort the wheat from the chaff and to do this we need to go though all your import object types. This sounds worse than it really is since we are only talking about each type of unique object and not each individual static.

First hide all the objects on your map by simply not selecting anything then right click on the viewport and click "Hide Unselected".

Then right click on your viewport again and go "Unhide By Name" and go though your list, selecting objects to unhide which you want to change. For example this "Bundled Mesh" "civiliancar1", can't be lightmapped, but we do want it casting a shadow, but it also has first person and wreck meshes ontop of its normal mesh. As such first we should unhide it so we can work with it:

Next lets select and delete geom0 and geom2 and its sub tree by just typing in geom0 (1p mesh) into the search first, with "select sub tree" selected, and do the same for geom2 (wreck mesh), leaving just geom1 which is actually the only thing players see ingame in this objects current setup:

Now select the objects name, in this case "0" and then select inverse, which will select all the helpers, and delete them leaving only the mesh:

Lastly because in this rare case, the mesh name is bugged we should select all the meshes and go to Tools > Rename Objects and rename it to its proper name of "civiliancar1" like so:

Next example is I have a lot of static placed overgrowth in my staticobjects.con and as such I need to remove all the lods and helpers to ensure the script doesn't try to lightmap them, since it can't and because we don't want the lods casting shadows.

Same basic principles above I'll show you in pics, although this time I select the helpers for deletion by unchecking geom from the selection list:

Another example is the runway paving slabs which don't need lightmaps nor to cast shadows so just totally delete them and its helpers:

Last example is the wirefence series, since these can't be lightmapped (well they can be the lightmaps are screwy on them from non-proper lightmap UVs) but we do want them casting shadows. We are also later going to set the wire up on them to be transparent so they don't cast a solid shadow on the ground like they do in the Bf2editor and let some light pass though them. As such, we want to delete all but its LOD0 mesh.

Lastly for now I'm going to select all these objects we have unhidden that are left just to cast shadows and group them up into a Group called "_OVERGROWTH", since even thou some objects like the civi car in there aren't overgrowth, most of it is. Note this dose not include the Overgrowth helpers we have imported earlier, this is just the overgrowth etc we have sorted out from the main statics.

Creating Reference, Shadow Casting Objects
Spoiler for Creating Reference, Shadow Casting Objects:
Here we are going to be replacing all our current Overgrowth meshes, helpers and other objects with "Reference" objects that are setup with transparent materials etc so they cast the shadows we want them to. We unfortunately can't just slap a material on the current Overgrowth meshes you've imported since they don't have the proper UVs to do so. As such we must import some.

Note that after reading this section, it's worth reading post 2 in this thread as it contains a link to a max-scene already containing many completed reference meshes for you.

For my first example I'm going to fix up "af_palmbush_01". First we need to import the proper mesh so go to Bf2 > Bf2 Utilities and hit the "Mesh Imporert" button. Then browse to the location of the object and select its main .con file and it will import the mesh and its lods:

First thing to do is delete the unnecessary lods and helpers, just leaving the lod0 mesh, which you need to convert to an Edible Poly:

Now we need to setup the materials. If you struggle with this next bit I would advise you to read this tutorial here as it will explain how to use Multi-Sub/Object Materials like I'm going to be using:

First we need to find out what textures this object is using so browse to the mesh and open it with BfMeshView, or a similar program, and we can see that this OG object only has one leaf material, which is what we are interested in here, and its uses the "" texture.

Next select an unused material slot and click the "Standard" button in the top right, then select "Multi/Sub-Object" to change the material to that part. Click ok on the window that pops up and rename your new material to something like "Overgrowth":

Next in the first box right of 1 under name, put in the basic materiel name and this is going to be our bark material so call it "Bark" and give it a brownish colour so you can easily spot it:

Go to parent and call this material the name of the texture its using, which in this case is "leaf_af_palmtree_b_de" and then in the diffuse slot, put that texture in like so:

Now before we go any further we should just look at what Material IDs this object uses, go into face selection mode, scroll down to Polygon Properies on the right and open up the drop down box and you will see that it has two materials, 1 being bark and 2 being the left as we want so this doesn't need any changes:

But if we apply the current material to this the leaves aren't transparent but we do have the texture on them:

This is because we need to assign an Opacity Map by clicking the None Button next to Opacity, select bitmap and browse to the texture:

At first however nothing will change since the texture is trying to read the RGB colour for its transparency and its not in there, its in the alpha channel. As such in the Bitmap Parameters we need switch the "Mono Channel Output" from RGB Intensity to Alpha and now the leaves should be transparent like so:

Finally we need to give the leaves a backface since they currently don't have one, which you can see if we look up from underneath:

This is because Overgrowth in BF2 draw their back faces but in Max we need to give them some manually in order to ensure they cast a shadow. Select all the leaf materials (in this case there is only one) faces and then click the "Detach" button, select "Detach to Element" and "Detach as Clone", then hit the "Flip" button which will flip our cloned faces around, giving us the back faces we want:

Then I would recommend renaming these fixed up OG objects to have a prefix of "_REF_" so you know its a reference geometry which you will replace all the others with later.

Then continue to do this for all your overgrowth object types and other objects with transparent materials etc you have in your map and if other objects use the same textures, assign them to both use the same materials to save you time setting them up

Next object I'm going to fix up is the "jungle_palm_small_01":

Just do the same as above with putting the new leaf material, in this case the "nam_palmtreefrond_01_c" texture in the next available slot and apply the material to the object. But in this case there is a small issue since not all the material IDs match and the other leaf texture is on the trunk of the tree:

If we look at the face material IDs we can see that one of the bark textures is set to MatID 2, which is the leaf texture we did for the other one and we need to reassign it to our proper Bark Material, 1.

Now for the "kentia_palm_cluster01" its materials are a little odder with its leaf being material 1, which is our bark material, and the trunk being material 2, which is one of our leaf textures but we need it to be 1, our bark. The import thing here is not to by mistake assign the bark first to 1 as then you wont be able to select the leaf though materials since they will both be mat ID 1. As such you want to assign the leaf first to in this case, MatID 5 from 1 and then assign the Bark to 1.

For the Wire Fence series, which aren't overgrowth objects but statics with transparent materials, the process is more or less the same but with a few differences. The biggest difference is that because its not an Overgrowth object, it already has the back faces for the transparent materials so we don't need to clone and flip the transparent faces like we needed to do for the OG Objects.

First things we need to do like before is to import it, delete all the unnecessary helpers and LODs, leaving only the LOD0 mesh, then converting it to an edible poly and renaming it to have a "_REF_" Prefix. Then we need to go and find the transparent textures it uses, which is "common_alpha_01_de". Also its import to note that the alpha material in this case isn't the "Colour", channel 1 material, but the "Detail", channel 2 material, indicated by it being second on the list of materials.:

Before we get into that, assign the materials to our mesh and assign the non-transparent metal material to be the Bark material, and while yes it isn't Bark, the Bark material is just a generic material that isn't transparent so light wont pass though it and as such, it serves the same purpose here:

Now as you have probably noted in the above picture that even thou I've assigned the correct material to the wire, the UVs aren't right for it and the wire texture is wrong:

This is because as noted above, the texture is a detail, channel 2 material and is currently using the channel 1 UVs. As such we need to change the "Map Channel" to 2 so it uses the right UVs:

Now its just a matter of applying the alpha and a small trick I forgot to mention above is that you can clone your Diffuse Material by dragging and dropping it onto the other slot and then telling it to be a copy of the above material. Then all you need to do is change it to use the alpha material:

It is also worth noting that the Diffuse Material isn't actually necessary to apply for the rendering process, only the Opacity material but its easier to see what your working with and that the materials are correct with applying both.

One other thing you may want to consider is deleting the tiny bits of barb wire on the top, since these are so small they aren't going to cast any kinda shadow and are just going to slow down rendering time so its kinda worth deleting them and this can be applied to other objects that ONLY cast a shadow like these (if they also are meant to receive shadows and have a LM then you will be deleting faces that won't get shadows on them after its LMed) to speed up rendering time etc.

For the Civi Car, for its reference I'm not going to bother applying any transparent materials to it since the only transparent materials it has on it, is the windows and for them, its simplest we just 100% delete them as the light difference passing though is marginal, but far easier to process no faces than a transparent material. But you may wish to make sure that all the faces on the object are using MatID1 so if you do apply the material to it, it will only be the Bark Material:

Finally its worth pointing out that for overgrowth objects etc that have no transparent materials on them, or need no tweaks from their existing mesh to cast the right shadows, you don't need to import and fix up a Reference mesh to replace them with, since there is nothing to change. This is unless they have only be imported as a helper of course, as then you will need to replace them with a mesh but no need to fix up their materials if they have no transparent ones.

In total I have 45 Different Reference Objects required for my map:

Replacing Objects with Reference Objects
Spoiler for Replacing Objects with Reference Objects:
What we are going to do now is replace all different types of Overgrowth and other objects with the Reference Objects we have just made, type by type.

First unhidden your Overgrowth Group, ungroup it and unhide your Overgrowth Helpers layer and anything else containing objects you will want to replace that are not meant to receive lightmaps, keeping everything else, other than your Reference Meshes hidden.

First we are going to replace our "af_palmbush_01", since its the first one on the list alphabetically

Select the object by name, not including the "=0" at the end in your search since the helpers won't have that if they are in both, otherwise you wont select them, and since our Reference object is prefixed with a "_REF_" it wont be selected

Then go to MaxScript > Run Script and go into the bf2 folder in your scripts folder and select the "instance" script that is included in the PR:BF2 3DsMax9 v0.40 Tools and hit open. A small window will pop up, hit "Pick Master" and then hit "H" to select by name, select the Reference object you want to replace all selected objects with, which in this case is the "_REF_af_palmbush_01" mesh. Then hit "Make Instances" and it will replace our entire selection of "af_palmbush_01" with the "_REF_af_palmbush_01" mesh.

Once that has finished apply the "Overgrowth" Material to the selection (unless its something like the civi car 1 which doesn't need it and applying it will most likley mess it up from its MatIDs not matching the bark mat) and you should now see all these objects with transparent leaves

Carry on doing this until all your old Objects are replaced with the new Reference Objects

Once your done you should have something like this:

If you have FPS issues with all your Overgrowth using transparent textures in your viewport then you can temporarily assign a blank material to them and then before lightmapping, put the correct material back on but in order to do this you first must have all the objects compatible with your material, such as the logs and civi cars which currently in my case, are not. As such I'm now going set them up so they can have them applied to them without issue by first doing a search for all the logs in my map, by searching for "*log" (without quotes) which will then select all objects with the word "log" in its name, which in my case is two types of log, the "nc_deadlog01" and the "me_deadlog01":

Then to all my selected objects I'm going to apply a "Material" modifier and have it set all the selected objects to have Material 1 applied to all faces:

Then I'm going to do the same thing to my civiliancar1 and then if I select all my OG etc and apply a blank material to them they will all go grey and my FPS will increase:

And if I apply the material back onto the entire selection note how the cars and logs are now brown since they use the bark material

You can alternatively just go though each material and turn off the "show in viewport" button which then "should" still have the material render with its transparent leaves when doing the LMs but this takes longer than just swapping materials, depending on your system, how many transparent objects and materials you have etc.

Last things I would now recommend you do is first set all these objects to use a "Green" colour so you can easily see them from the other objects in wire frame view etc and then to add all these objects, except the Reference Objects, to the "Overgrowth Helpers" layer (I'm also going to rename mine to "Overgrowth") and also . Then finally I would also recommend you group them all up into an "Overgrowth" Group so they don't take up loads of room on the object selection list

Then do the same to the Reference objects, except give them a different colour like Yellow or something, make a new "References" layer for them, set the Layer so it isn't included in the render by clicking on the little teapot icon so it goes away and hide that layer since we shouldn't need them any more but best to keep them in the scene encase we do and since all the objects are now instanced to them, if we want to make any tweaks we can just change the main Reference object and have it applied to all the others

Sorting out your Statics for Lightmapping
Spoiler for Sorting out your Statics for Lightmapping:
First thing we will want to do is unhide all your LOD0 meshes of your statics. The simplest way to do this is go to Unhide by name, then do an object search for "*=0" (without the quotes) which will select all the LOD0 meshes we want to unhide

Next go to BF2 > Bf2 Lightmapping and hit the "Save/Update File" In the Lightmap Size Control Segment and call the .txt file something like "*YourMap*_LightmapSizes.txt":

Open that file it creates and it should look something like this, which is what it produced for my map:
hotel	 undefined undefined undefined undefined
house_high_02_v2	 undefined undefined undefined undefined
house_high_03	 undefined undefined undefined undefined
house_high_04	 undefined undefined undefined undefined
house_high_05	 undefined undefined undefined undefined
house_high_06	 undefined undefined undefined undefined
house_medium_02	 undefined undefined undefined undefined
house_medium_05	 undefined undefined undefined undefined
citybuilding_2a_part1	 undefined undefined undefined undefined
citybuilding_2a_part2	 undefined undefined undefined undefined
citybuilding_3a	 undefined undefined undefined undefined
housingblock_1_groundfloor	 undefined undefined undefined undefined
housingblock_1_midfloor_v2	 undefined undefined undefined undefined
housingblock_1_midfloor_v1	 undefined undefined undefined undefined
housingblock_1_topfloor	 undefined
house_double_02	 undefined undefined undefined undefined
house_double_04	 undefined undefined undefined undefined
citybuilding_4a	 undefined undefined undefined undefined
dock_straight_30m	 undefined undefined
dock_bend_122degs	 undefined undefined
house_detached_02	 undefined undefined undefined undefined
house_detached_03	 undefined undefined undefined undefined
house_detached_01	 undefined undefined undefined
house_low_01	 undefined undefined undefined undefined
house_low_03	 undefined undefined undefined
house_low_02_v2	 undefined undefined undefined
mi_hangar_mec	 undefined undefined undefined
xp1_airtower	 undefined undefined undefined undefined
fishingboat	 undefined undefined undefined undefined
boxesonpallet_01	 undefined undefined undefined
woodencrate_3m	 undefined undefined undefined
marketstand_1	 undefined undefined
parkbench	 undefined undefined undefined
plant_box	 undefined
phonebooth	 undefined undefined undefined
rockpile_1	 undefined undefined undefined
rockpile_large	 undefined undefined undefined
rockpile_medium	 undefined undefined undefined
rockpile_medium_02	 undefined undefined undefined
container_cl_blue	 undefined undefined
container_cl_green_trash	 undefined undefined undefined
container_cl_red	 undefined undefined
container_cl_yellow	 undefined undefined
container_op_yellow_cluster	 undefined undefined
basket_hoops	 undefined undefined
smallboat1	 undefined undefined undefined
smallboat2	 undefined undefined undefined
smallboat3	 undefined undefined undefined
lighthouse	 undefined undefined undefined undefined
tyre_stack_v1	 undefined undefined undefined
shack_v4	 undefined undefined undefined
boatwreck_small	 undefined undefined undefined undefined
pier	 undefined undefined undefined
car1	 undefined undefined undefined undefined
water_cart_v1	 undefined undefined undefined
palletstack	 undefined undefined undefined
bus_stop	 undefined undefined undefined
cafechair	 undefined undefined undefined
trash_dumpster	 undefined undefined
tvset	 undefined undefined undefined
lamppost_highway_01	 undefined undefined undefined
shack_v2	 undefined undefined undefined
construct_metal_plate	 undefined undefined
shack_v3	 undefined undefined undefined
lamp_post	 undefined undefined undefined
shack_v5	 undefined undefined undefined
spawn_shack	 undefined undefined undefined
shack_v1	 undefined undefined undefined
water_tower	 undefined undefined undefined
gb_carrier_invincible_back	 undefined undefined undefined undefined
gb_carrier_invincible_bridge	 undefined undefined undefined undefined
gb_carrier_invincible_front	 undefined undefined undefined undefined
gb_carrier_invincible_mid	 undefined undefined undefined undefined
gb_carrier_invincible_skijump	 undefined undefined undefined undefined
gb_carrier_invincible_interior_pt2	 undefined undefined undefined undefined
gb_carrier_invincible_interior_pt1	 undefined undefined undefined undefined
air_repairstation_no_supply	 undefined undefined undefined
mi_antenna	 undefined undefined undefined
mi_plane_stair	 undefined undefined undefined
mi_barrack_mech	 undefined undefined undefined undefined
bunker	 undefined undefined undefined
These are all the statics and their LODs in your map that can now be lightmapped, but currently each LOD has its lightmap size "undefined" and we need to define it.

First thing we need to do is merge our "Master LightmapSizes" file which has most of the static lightmap sizes already defined.

First Download this master_size.txt file (right click, save as) and Open it with a text editor, then paste it onto the end of your master_size.txt file and save it:

Now we need to sort all our objects by Alphabetical order and the simplest way I know to do this with also keeping each object using its LODs is to import this list into a Spreadsheet and for this tut I'm going to use Google Docs/Drive since most people should have that already and if not can use it, if nothing else.

First Create a new Spreadsheet on your Google Drive, then go to File > Import and select the .txt file you just saved and in the import file settings I would recommend you use "Replace spreadsheet" and for Separator character you need to set it to use a " " (a Space, without the quotes) as the Separator then hit import and you should have something like this:

Now with Column A Selected go to Data > Sort sheet by column A, A > Z and it will sort all the rows out into alphabetical order

And do a search in the file for "undefined" and you will be able to see if the settings are already defined in the master, like this "air_repairstation_no_supply" which you can see, is already defined by the row above it:

When you find one which isn't already defined, like the bunker here, copy it into the master .txt file like so:

Now we need to update the "undefined" lod lightmap sizes to the correct ones. The simplest way to find out what sizes it uses is to browse to the object's ligthmap samples and open them with BFMeshView, with the ".samples" being the LOD0 sample, ".samp_01" being the LOD1 sample, ".samp_02" being the LOD2 sample etc.

Once open you will be able to see the width and height of the lightmap settings in the top left:

Some of the lightmap samples for many objects are much higher rez than they need to be and in many cases you can make them much smaller, especially for the LODs which for this bunker LOD1 also has a lightmap sample size of 128 by default by we can make it 64 for this bunker with ease and 32 for LOD2.

If an object has a different Width and Height resolution then instead of defining them with just one number, you would put a * in the middle of the Width and Height, for example 256*64 for a lightmap texture width of 256px and a height of 64px. Note you should only define objects with different width and height width resolutions that have been setup to have them, which is only a few objects so far with custom Lightmap UVs, such as the Wooden Fence Series.

If you find an object without any samples then its a matter of best judgement and/or trial and error to finding the right lightmap size. It must be noted that the resolution for the width and height of each lightmap must be a power of two, ie either a value of 8, 16, 32, 64, 128, 256, 512, 1024 or 2048.

Once you have defined lightmap sizes for all the LODs of your statics into the Master Lightmap Sizes file, go back into max and go to BF2 > BF2 Lightmapping and by "Lightmap Size File" Hit the "..." button and select the "Master_LightmapSizes.txt" file you have updated with all your lightmap sizes. Then hit the "Apply Lightmap Settings" button and it will apply all these lightmap size settings to all the LODs of your statics.

Importing your Sun & Preparing your Lights
Spoiler for Importing your Sun & Preparing your Lights:
Now its time to finally get some light in here

Lets first start off by loading your sun from your sky settings. Go to BF2 > BF2 Lightmapping and hit the "Load Sun" button. Then browse to your map folder and select your "sky.con" file and by magic a direct light will be created in the location your sun is ingame

Now since this is a 4km map the light has been created far too close to the terrain, since the script for making it was only designed for 2km and smaller maps, and as such, the far sides of the map are basically behind the sun and wont receive lighting from it. As such the first thing you need to do, if your working on a 4km or larger map, is to move the sun further away, but without affecting its rotation at all. To do this, first select your "BF2_SunLight", then select the Move Tool (W) and then switch to Local Transformation mode in the dropdown box at the top. Now your "Gizmo" will be at the same rotation as your sun:

Now what you want to do is in the bottom centre, click the "Absolute Mode Transform Type-In" until it turns yellow which means its in "Offset Mode Transform Type-In". Then in the Z Axis box, type in 10000 (for a 4km map, larger maps will require more) and then your sun will be moved +10000 units (which is 1km) away along the Z Axis

Now to fix up your Sun's Light Settings. There are two main types of shadow casting methods to use for your Sun Light (and point light but we will come to that later) in 3DsMax. These are "Ray Traced Shadows" and "Adv. Ray Traced". I will go into more detail into these in a second but first, lets set up the common settings both of these methods use.

Select your sun and go into the modifier tab. First Check the "On" box under Shadows and for now leave the drop-down box under that on "Shadow Map" (we will be changing this in a bit t either "Ray Traced Shadows" and "Adv. Ray Traced"). Then under Intensity/Color/Attenuation, set your Sun's Light Multipler to 2 if its a sunny map (like mine) or 1 if its a cloudy map, or anywhere in-between but DO NOT go under 1 as you should never darken a map though lightmaps, when you can far more easily darken a map though the map's light settings and if its a night map, with no moon, you can fully get rid of the sun light by just setting the sun light colour to 100% black. Next we want to change the Sun Light Colour to 0, 255, 0 (RGB - aka 100% Green) in the box to the right of the multiplier, which will be white by default. This is because we are going to generate all the light types together and Sun Light uses the Green Channel in an RGB Lightmap Texture. Next in Directional Parameters, if your working with a 4km map, change the "hotspot/Beam" to have a value of 30000, more if its a larger map so it include the entire map (note the big circle around the map) in the image below. Other than that you can leave the rest of the settings at default but check them against my settings in the image below, with the exception of the Shadow Drop Down Box setting which we will get into next:

Now for the different shadow types and you will want to pick which ever works best for you and your map.

Ray Traced Shadows
Spoiler for Ray Traced Shadows:
This is the "High Quality, Slow Rendering" Option for anyone who has a really good computer and/or has a lot of time to be able to lightmap their map in, like if you have a spare computer sitting around which otherwise wouldn't be used and can lightmap solidly for a week or so. It should be noted that I would only recommend using this setting if your map is truly 100% final, being fully tested before hand and your absolutely sure that no changes are needed for it that will affect its lightmaps.

In this mode Object Lightmaps take around 6mins / object (and its LODs), when lightmapping a high rez LM for a complex object, and it takes around 3x Longer than "Adv. Ray Traced" and around 2x as long as the BF2 Editor's Final Quality Lightmaps.
But when it comes to Terrain, at least with a lot of Overgrowth on it, Ray Traced Shadow takes only around 5/7th of the time of the BF2 Editor with the BF2 Editor taking 11mins 41secs to render a patch, where 3DsMax with Ray Traced Shadows took only 8mins 20secs to Render the same patch.

Having said that the quality of these shadows is far superior than "Adv. Ray Traced" Shadows (and the BF2 Editor), and if you can put the extra time in, the results are well worth it:
BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

For this setting all the above settings remain the same from above, with the exception of changing the "Shadows" Drop Down Box to "Ray Traced Shadows" as per this image:

Adv. Ray Traced
Spoiler for Adv. Ray Traced:
This is the "Medium Quality, Fast Rendering" Option for anyone who doesn't have the time or a decent enough computer to do "Ray Traced Shadows". If you plan on changing your map in the future which will require the map to be totally re-lightmapped, then this is the option to pick.

In this mode Object Lightmaps take around 2mins 30secs / Object (and its LODs), when lightmapping a high rez LM for a complex object, which is around 1/3 of the time it takes to generate "Ray Traced Shadows" and almost 1/2 the time the BF2 Editor's takes on Final Quality Lightmaps.
When it comes to Terrain Lightmaps it is considerably faster taking only around 2/9th of the time of the BF2 Editor with the BF2 Editor taking 11mins 41secs to render a patch, where 3DsMax in Adv. Ray Traced took only 2mins 38secs to Render the same patch.

But the quality of these shadows is isn't as good as Ray Traced Shadows and with the exception of transparent leaf rendering, isn't that much better than the BF2 Editor's shadows and in some small cases, slightly worse, but that is mainly when the BF2 Editor generates a higher rez than you've set in 3DsMax. Overall these are still better quality than the BF2 Editors, especially if you have lots of overgrowth.
BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

BF2 Editor (Final Quality) ----- 3DsMax (Ray Traced Shadows) ----- 3DsMax (Adv. Ray Traced)

For this setting all the above common settings remain the same from above, with the exception of changing the "Shadows" Drop Down Box to "Adv. Ray Traced" and in the new "Optimizations" Roll out, turn on "Transparent Shadows" (to allow for the transparent leaf textures to work) and to set the Antialasing Threshold Colour to 100% Black.

For this tutorial I will be using "Adv. Ray Traced" Shadows since I'm trying to get this map done in the shortest time possible and I may be updating it later on with a few changes that may require new lightmaps to be rendered.

Now its time to import the Sky Lights we are going to use. Download this file here which has the recommend Sky Lights and Settings I'm going to be using in this tutorial and are at the very least a good base for your map for you to tweak from:

Then go to File > Merge and browse to and select this file, and import all the lights inside of it into your map:

Now there are two lights in this. The "_Sky01" which is your main sky light and produces pretty realistic light bounding affects which light up the outside more but still allows some light to filter into rooms though windows, doorways etc. The next light is your "_Ambient_Fill_light" which casts a flat light all over your map no matter if its at the bottom of the deepest darkest cave of your map, or on the roof of a skyscraper. This light is to ensure that the interiors of your buildings are not pitch black which if it was just the sky light working on its own, some areas inside would be. Currently the "_Sky01" has a Multiplier of 1 and the "_Ambient_Fill_light" has one of 0.4. If you want brighter interiors increase the "_Ambient_Fill_light" multiplier, and decrease the "_Sky01" multiplier. It is also worth noting that both of these Sky Lights have a colour of 0, 0, 255 (RGB - aka 100% Blue, a bit like the sunlight but Blue instead of Green), because we are generating all lights together and the sky light uses the blue channel in the light map texture.

Finally its time to setup our "Point Lights", which are basically man made lights from lamp posts etc. I'm not planning to have a "night layer" for this map which is the main place this type of light really comes in, other than also for deep dark caves etc, but for the purpose of this tutorial I'm going to put in a few. For the main example I'm going to make a big Omni light in the Lighthouse by first going to the object creation button in the top right, clicking light icon, then clicking on Omni button and placing it in the Lighthouse, then I'm going to turn on shadows, give it the same type of Shadows your using for your Sun Light (In my case, "Adv. Ray Traced"), give it a Multiplier of 1 and a light colour of 255, 0, 0 (RGB - aka 100% Red), give it a decay type of Inverse Square and starting at 100 (10m), and giving it a Far Attenuation starting at 200 (20m) and ending at 1000 (100m) and leaving everything else on default. The last bunch of settings can be tweaked quite a bit depending on how powerful the light is and how far your want the light to travel etc. Getting it right will take a bit of trial and error and to get it right you can do a quick render of your viewport in max and/or do Test LM Renders which I'll get into later in this tutorial.

I'm also going to apply my Lighting Template for the Carrier that I've done for other maps since that takes me only a few seconds to apply and here are the settings of the three type of lights used on it, which are two types of "Spot Light" and one type of "Omni Light", which are all instances of each other so changing the settings on one will change the settings on all the other instances (which is what you should also be doing for your lighting) and if you want to use this Carrier Light Template on your map you can download it here and just align it to the Bridge, note however this is setup for HMS Invincible and if used on the USS Essex there will be a few differences:

It is worth noting that you can setup templates of lights for a type of static, like for example a bunch of lights for each light bulb in a building, then setting each instance of that static to use that light template but this is pretty tricky so if someone really wants to know how to do this and can't work it out for themselves let me know and I might look into adding it into this tutorial at a later date.

Testing your Light & Lightmap Settings
Spoiler for Testing your Light & Lightmap Settings:
Before you go any further we should do some test lightmaps on some of our statics to ensure that everything is working as it should be and the settings are good.

First thing to do is unhide your Overgrowth Layer/Objects and if they don't have the leaf material applied to them its best to do that now, or at the very latest just before you render them. Its worth noting you can alternatively Freeze the layer which will have the same affect as removing its material and increasing FPS.

Generally you want to pick a few large buildings with interiors etc and also some objects that trees will be casting shadows on, and some objects with point lights. Also if there are any objects your unsure about if you have set their lightmap size correctly you should include them in this test render. Just select the LOD0 of each of these objects.

Then go to BF2 > BF2 Lightmapping and first we need to set folders for the tools to save our lightmaps in. First set a folder for your temp files, which is what the lightmaps generated by max will be saved into, I would recommend making a folder called "Temp" inside the same folder as your Lightmapping scene, and then do the same for Output with making another "Output" folder for that:

Once that is done and with your test objects selected, hit the "Render Selected Objects" button and it should render your selected objects

Once your lightmaps have finished rendering you will have a bunch of .tga files for each object lod you have generated:

Now its time to convert them to .dds so that BF2 can read them. Browse to your "\Autodesk\3ds Max 9\Scripts\bf2" folder and in there you will find a "~convert.bat". Open up that file with a text editor and in it you should see this code:
@echo off
"E:\Program Files (x86)\Autodesk\3ds Max 9\scripts\bf2\bin\extern\nvdxt.exe" -file "F:\My Documents\3dsmax\scenes\Project Reality\Statics\Afghan Compound Buildings v3\LM_Tests\Renders\Temp\*.tga" -dxt1a -outdir "F:\My Documents\3dsmax\scenes\Project Reality\Statics\Afghan Compound Buildings v3\LM_Tests\Renders\Output"
Its now a matter of just changing these paths to match the files on your computer, with the first one just changing it to where you have 3DsMax9 and the PR:BF2 Max Tools installed, then for the second one ending in "\Temp\*.tga", changing that to your map's Lightmaps Temp folder you crated above, and then finally changing the last path ending in "\Output" to the location of your maps Lightmaps output folder you created above (you can make your output folder your levels /lightmaps/objects/ folder but I would advise against this since you may overwrite some lightmaps you may have wished not to and far safer to do it manually). Mine ends up looking like this:
@echo off
"E:\Program Files (x86)\Autodesk\3ds Max 9\scripts\bf2\bin\extern\nvdxt.exe" -file "F:\My Documents\3dsmax\scenes\Project Reality\LightMaps\Jamaica\Temp\*.tga" -dxt1a -outdir "F:\My Documents\3dsmax\scenes\Project Reality\LightMaps\Jamaica\Output"
After you have done that run the .bat script and a little cmd.exe window should pop up, showing you which files its currently converting. This may take some time if you've got a lot of files to convert. Once that has finished browse to your maps Lightmaps Output folder you set above and in there you should now see a bunch of .dds images, one for each lod of each static:

Copy all of these into your "\pr_edit\levels\*YOUR MAP*\Lightmaps\Objects" folder and load up your map with the BF2 Editor and you should now see your lightmaps in your map

Here are the results of my test lightmaps:
Spoiler for LM Testing Results:

It is also important to look at the textures themselves as they can tell you a lot:

And each of the colour channels (Green for Sun, Blue for Sky, Red for Point) since they can show you much more clearly what each channel is doing, like noting in the top of the first image which is the Sky of the big building with the trees on its patio thing, that you can see on the top left of the texture, which is its roof, that there is a shadow around that little extra roof bit on top, which you can hardly see ingame but the subconscious dose notice this kinda thing if its not there

There have been two main changes I've made from this testing. The first was to increase the lightmap texture size of the citybuilding_3a/b from "128 64 32 16" to "256 128 64 32" since its shadows had quite a few errors etc, and to also increase the multiplier of the Lighthouse's Omni Light to 2 from 1 since it wasn't quite powerful enough.

Once you are happy with your light settings and you have tested any changes you have made then you can begin to lightmap your objects fully

Full Object Lightmaps
Spoiler for Full Object Lightmaps:
First of all if you can, I would recommend you do your full lightmaps in a later version of max than Max9, ideally a 64bit version too, so you have the fastest and most stable rendering you can get. To do this you just need to install the PR:BF2 3DsMax9 Tools to the newer version of max you wish to lightmap with, and while the importing, exporting and a bunch of other scripts wont work for later versions, the lightmap generation scripts should work fine and have been tested on 3DsMax 2010 and 2012, but should hopefully work on later versions too. It is advised that you backup your Max scene and save a separate version of your lightmap scene to be loaded by the newer version since once the scene is saved with the newer version, it can't be re-opened by the older version.

I would then recommend you restart your computer and when it starts up close down all unnecessary programs you don't need to free up as much of your CPU and RAM as possible since even having something like Skype running in the background will use up some CPU and RAM and will ultimately take longer for your lightmaps to generate as a result.

Once restarted and your system is optimized for LMing, start up the version of max your going to use for LMing and then like in the Test Lightmaps section, go to BF2 > Bf2 Lightmapping, but instead of hitting the "Render Selected Objects" button you will want to press the "Render All Lightmaps" button. But before you do this you should check that the "Light Pass" dropdown box is blank (which means all lights pass, the other options are sun, sky or point light passes separately as done in the past), Specific LOD is set to All and if you want to keep/skip any previously generated lightmaps you can check the "Resume" button which will check if the objects lod its about to generate has a lightmap already (In your Temp Folder), and if it dose, skip it and move onto the next object/lod. If your system crashes for w/e reason 1/2 way though lightmapping this tool can be a life saver. Also ensure your tempt dir is correct and your Lightmap Size File is loaded. Once you've confirmed all the settings are good, render away

In all it took me under 7hrs to render the 200 objects in my map at around 2mins / object with "Adv. Ray Traced" Shadows. I can't be sure how long it actually took because I was asleep during this time and time "Total Time Taken" bugged out as it normally dose after rendering lots of objects and said it took something like -50hrs

And here are the results of my Object LMing, note the terrain is still Medium Editor LMs:
Spoiler for Object LMing Results:

There are a few small errors here and there and some of the leaf shadows would have been a lot better if done with Ray Traced shadows and some are a little buggy but overall they are very good lightmaps and much better than what the editor would have produced and in a hell of a lot less time too

Finally don't forget to Generate your Lightmap Atlases otherwise you wont see your lightmaps ingame. Also watch the output window when its checking for obsolete lightmaps since the BF2 Editor script for getting rid of them doesn't actually work and you should delete them manually if it finds any, then regenerate them again without them in

Terrain Sun & Sky Lightmaps
Spoiler for Terrain Sun & Sky Lightmaps:
Its now time to setup the terrain for its Sun and Sky Lightmaps. Note that the Red channel isn't used for point light on the terrain and its used for water transparency instead which we will do later sepratly.

First load your map back up in 3DsMax9 and turn off (or altenrativly delete) all your point lights if you have any as otherwise they will conflict with the water depth lighting channel.
Note: If you wish to have Man Made (Point) Lighting on your terrain then the best way to go about it is to turn them Blue/Green and have them in your Sky/Sun Light Channel BUT, doing them this way means you can't turn them off in day map layers and they will use the same light colour/intensity as your Sky/Sun light.

Next thing we need to do is create your "Sea Water Level" so that shadows cast on your water are cast on the sea water surface and not on the sea bed.
Select your Terrain mesh (_TERRAIN) and add a "Vol. Select" Modifier to it. Switch the "Stack Selection Level" to "Vertex" and "Selection Method" to "Replace" and check "Invert". This means that any verts outside of this Volume Selection box will now be selected, which by default, is nothing since the box is created to the very limits of your object.

Expand the modifier, selecting Gizmo and switching to "Offset Mode Transform Type-in" with the Move Tool Selected, offset the Volume Selection Box by the Depth of Your Sea Water of your map. My Map has a Sea Water Level of 5m so I need to offset my Vol. Selection Box by 50 Units (since 10 Units = 1m)

Turn on Percentage Snapping and Open up the "Grid and Snap Settings" Window (Right click on the snapping button to open it or go to Customise > Grid and Snap Settings...) and in the Options Tab set the Percent box to 100%. Then add an Edit Poly Modifier to your terrain and go into Vertex Selection Mode and all the verts selected by the Vol. Select modifier should now be selected for you in this new Edit Poly Modifier. Switch to the Scale Tool and with Percentage Snapping still enabled, select the Z Axis and scale it down to 0%, which will make all the verts in your selection totally flat.

Finally switch to the Move tool and in "Absolute Mode Transform Type-In" set the Z amount for your verts to that of your sea water level, which in my case is 5m, 50 Units:

Now if you look at your terrain where your sea water should be closely it should be all flat and at the level your sea water is ingame:

And if we turn off the Edit Poly Modifier we still have our Sea Bed which we will need later (and if you plan on re-LMing any objects since you don't want your sea water level to cast a shadow on your objects)

Now with your Terrain selected hit the "0" key on your keyboard to bring up the "Render to Texture" window (or alternatively go to Render > Render to Texture...). At the top you will see a little "Output" box under the "General Settings" Rollout and next to Path hit the "..." button, then browse to your Lightmap scene folder and make a new "Terrain" Folder and select it.

Next scroll down to the "Output" Rollout and hit the "Add..." Button, then add a "LightingMap" Element. By default it should be created as a .tga, which is what we want:

Next you need to change the Element's Width and Height settings. This depends on the size of your map, and/or how much detail you want on your terrain's lightmap. Generally speaking however a normal map has a terrain lightmap ratio of 2px / meter and these are the normal With and Height Settings you should use for the following sizes of map:
1km x 1km: 2048 x 2048 (16 512x512 Patches)
2km x 2km: 4096 x 4096 (64 512x512 Patches)
4km x 4km: 8192 x 8192 (64 1024x1024 Patches)
Since I'm working on a 4km by 4km map, I'm going to be using a 8192 Width and 8192 Height:

Now we just need to unhide any objects we want to cast shadows on our terrain. You should still have all your LOD0 Static Meshes unhidden but if not, unhide them (by searching for "*=0" in unhide by name as before) and unhide your Overgrowth layer/group and make sure it has the correct leaf material applied to it etc. Then once all that is done and your Sun and Sky lights are the only ones active, save your scene back it up, and save a separate scene to be loaded in a later version of 3DsMax if your using one (pretty much a requirement for an 8192 or above render). Then restart your PC, optimize it for lightmapping like you did before for your final object lightmaps and render away by clicking the "Render" button in the bottom left of the "Render to Texture" Window.
Small little tip for better render preview window, is to turn off your diffuse texture for your terrain material as it will only conflict with the render preview, but will not affect the final saved LM.

I Lightmapped my Sun and Sky Terrain Lightmaps in 2hrs and 7mins with Adv. Ray Traced Shadows and once your done you should have something like this:

Terrain Sea Water Depth/Transparency Lightmap
Spoiler for Terrain Sea Water Depth/Transparency Lightmap:
As mentioned above the Red Channel in the Terrain Lightmap is used to control the water transparency depending on the depth of the water, unlike statics where the Red Channel is used for Point Lighting. This is a pretty quick thing to generate since there is no shadowing required.

First load your lightmapping scene back up in 3DsMax9 and then Download and Merge this "_WaterLight" into your scene the same way you did for your Sky Lights:

This is a "Target Direct" Light, like your Sun Light, but its placed in the centre of your map and points directly downwards. By default the light is at 0,0,50 X,Y,Z and you should change the Z Axis value, ie, the highet this light is placed at to be the same level as your sea water level, which in my case is 5m, aka 50 units which it is already (Ignore that I have the light switched off, forgot to turn it on, the one in the template above is on by default)

This Light is already setup not to cast any shadows and to case the correct red light etc. The only change you may want to make is the "Near Attenuation" settings which basically controls the start and end of the transparency, with the end being when the water is totally Opaque, ie, once the water is very deep. When the terrain is lightmapped with the BF2 Editor the water becomes opaque at around 3.5m, which is what the "End" setting in the "Near Attenuation" is set to currently. If however you want your sea water to be more transparent increase this value and if you want it to be less, decrease this value. Since my map is a sunny tropical map with crystal blue water and with some coral reefs around the island, I want my water to be pretty transparent so I'm going to increase my "Near Attenuation" "End" Value to 45 units (4.5m and again, ignore that the light is turned off in the pics below).

Next turn off all other lights in your map. Your map will turn black from there being no lighting and if you want to see your map again, right click on "Perspective" in the top left of your viewport and select "Configure...", then in the "Rendering Method" tab check "Default Lighting" and hit ok and your map will be back to normal again:

Lastly select your "_TERRAIN" and turn off the Edit Poly and Vol.Select modifiers by clicking on the lightbulb icons to the left of both of these modifiers until they become grey and you should see your sea bed restored from the flat water surface they applied for the sun and sky lighting:

Now we just need to render this water light, hit "0" to bring up the Render to Texture window and MAKE SURE YOU CHANGE THE NAME OF THE TEXTURE as the last thing you want to do is overwrite your Sun and Sky Terrain Lightmap, which you should probably back up before generating the water lightmap just encase too. Other than the "Output File Name's", Name, the render to texture settings are all the same as before and you can probably render this fine in 3DsMax9 since its easy to process, unless its an 8192x8192 texture then you will need to do it in a later, 64bit version of max since Max9 wont have enough memory to save the texture. Its worth noting that your overgrowth should be hidden and you may also want to hide your staticobjects too to speed things up a little but having them in view otherwise should not affect the render since the water light isn't casting any shadows.

Combining & Splitting your Terrain Lightmap
Spoiler for Combining & Splitting your Terrain Lightmap:
Now that you have generated all your Sun, Sky and Water Lightmaps of your terrain the first thing to do is to combine them. Open up both of your "Sun & Sky" and your "Water" Terrain Lightmaps in Photoshop. Your Terrain Water Lightmap should be just Red and Black and should look something like this:

In your Terrain Water Lightmap, go into the Channels tab, select the Red Channel, in selection mode select the entire canvas (Ctrl+A) and copy it (Ctrl+C).

Switch to your Sun and Sky Terrain Lightmap and then switch to its red channel, which should be totally blank, and paste the Red Channel you copied from your Terrain's Water Lightmap into that lightmap:

If you now switch back to the RGB channels your lightmap should now look like this:

Save (As) your Lightmap, I would advise under a different name, something like "_TERRAINLightingMap_Combined.tga" and make sure you save it as a 24bit .TGA

Now that you've got your Combined Terrain Lightmap sorted with all Sun, Sky and Water Lighting in it, its time to split it up into lots of little .dds images so that the game can use them. First download this "SplitTgaToMultipleDDS" Tool/Script kindly made by [R-DEV]AncientMan for this tutorial and install it on your computer by extracting the folder inside the .zip to anywhere on your computer:
Note: You may also need to download and install Visual C++ Redistributable Packages in order for the script to work.

Once you have done that copy your Combined Terrain Lightmap (_TERRAINLightingMap_Combined.tga) into the tools "input" folder.

Now this Tool/Script by default is setup for 2km x 2km and 4km x 4km Maps, which use a 8 x 8 (64) Patch Setup and if your working with a 1km (or smaller) map you will need to change the settings for this script since a 1km x 1km map only uses a 4 x 4 (16) patch setup.
ONLY IF YOU ARE WORKING WITH A 1km OR SMALLER MAP, open up the "SplitTgaToMultipleDds.bat" script with a text editor such as notepad or notepad++ and change the "set num_x=8" and "set num_y=8" to "set num_x=4" and "set num_y=4" and then it will split the image into only the 16 patches used by a 1km by 1km map. If your working on a map smaller than a 1km map, like a 512m x 512m map, then I believe it only uses a 2 x 2 (4) patch setup but you would have to look inside your map files to determine that for sure.

Once you have put your Combined Terrain Lightmap in the input folder and ensured the "SplitTgaToMultipleDds.bat" script is setup as you need, run that .bat script and a cmd window should pop up telling you its splitting your .tga image into lots of little .dds images and once its finished if you look in the output folder, there should now be a sub folder with the same name as the .tga image you put into the input folder and in it should be all your terrain lightmap patches, note it says there is 64 total items in this folder which is what I want:

Finally its just a matter of copying all these patches over into your "\mods\pr_edit\levels\*YOUR MAP*\Lightmaps" folder and overwriting all the old patch lightmaps in there.

And here are the results of my 3DsMax Terrain Lightmap in the Editor (note the transparent water dose not work in the editor, only ingame):
Spoiler for 3DsMax Terrain Lightmap Results:

Optimizing "Flat" Lightmaps
Spoiler for Optimizing "Flat" Lightmaps:
If you have a map with a lot of Sea Water like mine your bond to have a bunch of "Flat" Lightmaps, which are basically lightmaps of a flat sea and nothing else on them like this for example:

Having a 683kb texture of just flat white is quite a waste, especially when you have multiple ones all adding up together which in my case I have a total of 46 blank patches, currently using a total memory of 30.6mb, on nothing... To state the obvious wasted file space isn't just about the maps/mods download size, while yes that is a small factor, its mainly about the Players RAM usage. All of these textures need to be loaded into the players RAM and for starters, there is a limit on how much a player can load inot his RAM since BF2 is a 32bit game, but on top of that having to process these large textures, even if they are blank, slows down FPS and overall simply just isn't good for performance, where instead we can seriously optimize them without any ill affects since they are simply just blank images.

First to find out which patches are used and are not used the simplest way is to overlay a little patch grid over our terrain lightmap. First take your complied terrain lightmap and resave it as a .psd under the name of something like "_TERRAINLightingMap_Patches.psd". If your working with a 4km map and your terrain lightmap is at 8192x8192 you should resize it down to 4096x4096. Next go to Image > Image Rotation > Flip Canvas Vertical to put your lightmap up in the same way as the game reads it and the patches are in order. Then download this terrain_patch_grid.png image (Right Click, Save As), open it up with Photoshop and duplicate it over your "_TERRAINLightingMap_Patches.psd" image and you should end up with something like this:

If your working with a 1km map and have a terrain lightmap size of 2048x2048 this patch should duplicate over your image correctly too, with its 4x4 (16) Patch Setup:

Now you can clearly see what goes in each patch and as you can see, a lot of my patches are just flat white images like the one I showed you above. Note down which patches are blank, in my case its easier to note down the ones which are used, which are:
tx02x03, tx02x04, tx03x03, tx03x04, tx03x06, tx03x07, tx04x02, tx04x03, tx04x04, tx04x07, tx05x03, tx05x04, tx05x07, tx06x00, tx06x03, tx06x07, tx07x00, tx07x07
Note that even thou "tx05x04" and "tx06x03", along with some others are hardly used and being mostly blank, can't be optimized since they are still somewhat used:

Some however like "tx06x02" which have tiny little specs of water transparency difference since they have some little hills under the water (in hindsight I should have probably totally removed them, since they are just small islands in r/l which where part of the DEM data but are not above the surface of the water ingame after downsizing the DEMs scale to fit on the ingame map, but oh well), I'm going to optimize since it isn't worth the tiny little difference in water transparency for them, which in their case is probably going to look odd if I keep them anyways:

Once you have noted down all the files you want to Optimize / don't want to Optimize, close all images in Photoshop and then open up all the images you want to optimize:

Next click on the "Actions" Tab (Windows > Actions if you can't see it) and click on the little "Create new set", folder icon in the bottom and call the new set something like "Resie". Then create the little "Create new Action" Icon and call it something like "8x8 DDS DXT1" and hit the Record button and then anything you do from here in Photoshop will be recoded in this action until you hit the stop recording button so don't do anything other than what I say

First go to Image > Image Size... and change the Pixel Dimensions to 8 x 8 px. Next go to File > Save and Save the Image as a "DXT1 RGB 4bpp | no alpha" DDS Image with "Generate MIP Maps" and make sure "All" is selected in the drop down box next to it, then hit Save. Then go to File > Close and finally hit the "Stop Recording" button to stop the action from recoding your actions.

Now if you open up the image you just optimized/resized in NVIDA WTV you should now see its a 8x8 DXT1 DDS Image with 4 mips total and a total memory usage of 0.1kb:

Now if you select another opened image you want to optimize, select the header of your action (8x8 DDX DXT1 Action) and hit play, it should now automatically resize this image, save it with the same DDS settings and close it. Ensure you open up the image in WTV after its done to check it is all good:

Once you've confirmed your Action is all good its time to apply this Action to all opened files automatically, go to File > Automate > Batch... and in the "Play" Section make sure the correct set and action are selected, and for Source have it set to "Opened Files" (making sure of course you don't have any other files opened in photoshop you don't want to resize and are not .dds images) then hit Ok and it will apply this action to all opened files.

Now the same images that where using up a total of 30.6mb are now using only 8.26kb and are doing exactly the same job, but are far easier for the client to process and takes up only a tiny bit of RAM!

Rhino is offline
Last edited by Rhino; 2020-05-17 at 17:59..
Reply With Quote
Old 2015-09-16, 12:45   #2
PR:BF2 Lead Designer
Supporting Member
PR Server License Administrator

Mineral's Avatar
Default Re: Advanced 3DsMax Lightmapping

For those who have read the tutorial or have done it know that setting up the reference meshes for vegetation and other objects is a lot of work. Therefore me and [R-DEV]Rhino have combined our work so far on making these for multiple maps so you have a head start. This includes the following over 114 already setup meshes:

Now when opening the max-scene with these reference meshes you will have to link the wizard to find all missing external textures. The window will look like this:

Use the Browse button and in the next window the Add button to locate all missing textures files. Browse to your pr_edit location and find the specified folders and it will be able to relocate all those files.

Mineral is offline
Last edited by [R-DEV]Mineral; 2017-07-15 at 12:14..
Reply With Quote
Old 2015-11-20, 18:09   #3
Default Re: Advanced 3DsMax Lightmapping

Thanks Rhino great tutorial It worked out for me really good and looks great ingame.

potatochan is offline Reply With Quote
Old 2016-02-13, 20:05   #4
PR:BF2 Developer

Outlawz7's Avatar
Default Re: Advanced 3DsMax Lightmapping

Before importing the static objects, replace all code copies of statics with their originals (no ladder versions of static with ladders, nondestroyable versions of destroyables) otherwise 3ds Max will lightmap the "wrong" object ie house_double_01_nl won't be recognized by editor/game as there is no staticmesh named that, just a config file that references it.

After importing your lightmap sizes file into Google spreadsheet, it may help to fill the cells with a color before appending the master lightmap sizes, so it's easier to discern.

Outlawz7 is offline Reply With Quote
Old 2016-03-31, 00:02   #5

Rabbit's Avatar
Default Re: Advanced 3DsMax Lightmapping

Can you add a section about renaming destructables to show lightmaps.
Rabbit is offline Reply With Quote
Old 2016-12-09, 18:13   #6
PR:BF2 Lead Designer
Supporting Member
PR Server License Administrator

Mineral's Avatar
Default Re: Advanced 3DsMax Lightmapping

Updated second post with new reference set.

Mineral is offline Reply With Quote
Old 2017-05-13, 22:08   #7
[R-DEV]​X1 Spriggan
PR:BF2 Developer

X1 Spriggan's Avatar
Default Re: Advanced 3DsMax Lightmapping

I'm trying to follow this tutorial but my 3ds Max seems to get bogged down after I apply the optimize modifier and finally runs of memory when I convert to Editable Poly and apply the UVW mod.

EDIT: I had to reduce the polys through a different method. There were nearly 1million quads on my terrain in 3dsmax.

[17:21] Falkun: im making spaghetti
[17:21] Falkun: lal
[17:22] Falkun: i'll put some in an envelope for you
X1 Spriggan is offline
Last edited by [R-CON]X1 Spriggan; 2017-05-15 at 04:55..
Reply With Quote
Old 2017-06-24, 15:18   #8
Project Reality Beta Tester
PR Server License Administrator

ALADE3N's Avatar
Default Re: Advanced 3DsMax Lightmapping

does this just apply on 3ds max 9 or any newer version too?

ALADE3N is offline Reply With Quote
Old 2017-06-24, 16:06   #9
PR:BF2 Lead Designer
Supporting Member
PR Server License Administrator

Mineral's Avatar

You will need 9 to load in all objects. That the most important part. The rendering itself can be done in 2012 (haven't tried other versions personally )

Mineral is offline Reply With Quote
Old 2017-06-24, 20:26   #10
Project Reality Beta Tester
PR Server License Administrator

ALADE3N's Avatar
Default Re: Advanced 3DsMax Lightmapping

Originally Posted by [R-DEV]Mineral View Post
You will need 9 to load in all objects. That the most important part. The rendering itself can be done in 2012 (haven't tried other versions personally )
so sad i don't have max 9 , and my pc rn is so slow to render lightmaps on editor
so i guess i'll scratch my hopes up in lightmapping my map xD

ALADE3N is offline Reply With Quote

3dsmax, advanced, lightmapping
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT. The time now is 11:58.