Jump to content
Official BF Editor Forums
Sign in to follow this  

Bf2 Lightmapping In 3ds Max Tutorial.

Recommended Posts

Merry chrictmas. edited for notepad copying.

Lightmaping for battlefield 2 in 3ds max by Darren Mac Donald (D-Ran(sdp)).

First of all, you will need to have the bf2 3ds max tools installed.

I will be trying to take this step by step assuming that the person reading this knows little

to nothing about 3ds max and it’s functions, however if I manage to miss something or am unclear

about something, let me know and I’ll attempt to correct the issue.

The first step will be to extract your mods objects_client.rar and objects_server.rar into

your mods base dirrectory (though you really only need what’s in the staticmesh sub-dirrectory).

Do the same for the stock bf2 objects_client.rar and objects_server.rar in the mods/bf2

dirrectory. When this is done, it should look like this (1).


Next, open up 3ds max and make sure your units setup is right or your objects won’t import

in the correct places. First, go to the tab labled “costomize” and scroll down to

“units setup” (2). This will bring up the units setup utility (3). Select “generic units” (3*)

then click the “system units setup” button (3*) and make sure it looks just like this (3*).

Now hit ok.



Now click on the bf2 tab. scroll down to the bf2 lightmaping as seen below (4) wich will

bring up the bf2 lightmapping tool (5)



Next you will select the “load staticobjects.con” button (5*) and brouse to your levels

staticobjects.con file. Now you wait abit while your level loads. It may take a few minutes

depending on your computers speed and the amount of objects in your map.

Now after your map

loads, it’s going to make the framerate extreamly slow in max. This is mainly because of the

fact that when it imports the map, it inports it with all of the lods and it’s desplaying them

all at the same time. Fortunatly, you only need to select and display the first lod in each

object to render these lightmaps, so what we’re going to do is to hide all the inconsiquential

objects and only display the first lod in each object. now you COULD go throught the whole map

and hide everything but the main lods, but that would take forever and there is a quicker way.

First you need to assign a temp output folder (a temp folder on your desktop will do fine) by

clicking here (5*).

Next you’ll need to select any objects main lod by opening up the select by list utility (6*)

and selecting your main lod as so (6*) then hit select (6*). Next, go to the “display”

sidebar (6*) and click on “hide unselected” (6*).


Now re-open the bf2 lightmaping utility and hit the “save/update” button (5*) (I’ll get into

why you did this at the end, but it’s important you do it before anything further). Save this

anywhere as a text file called anything you want (say, “lighting file a”).

Now open up the default lightmap size box (5*) and select any size at all. Next hit the

“apply lightmap settings” button (5*). This button will apply the size you selected to all meshes

for lightmaps. Now with the one unhidden object selected, hit the “render selected objects”

button (5*), then hit esc to stop it. You’ll now find that all your objects are visible, but

only the main lods so the framerate is now managable. Note that every time you hit the “render

lightmaps” button, it will automatically unhide all the main lods for the generation of shadows.

Now that we have your map all on screen with (hopefully) a managable framerate, we’re ready

to start seting up the

lighting. First, you will need to import your main sun by hiting the

“load sun” button in the bf2 lightmaping utility (5*) and brouseing to you maps sky.con file.

This will load in a sunlight in the scene, but we’ll need to edit it. Now select the new

sunlight and go to the modify tab (7*).


Now make sure the on button for shadows is clicked (7*) and open up the dropbox (7*) and

select “raycast shadows”.

Now set the intensity (7*) to what you desire (I set it to 0.8 with

good results).You can also edit the light color here, but I have yet to play with that and don’t

know how it will work as of this tut. Now scroll down to the “shadows paramiters” tab and open

it up. Here you can adjust the shadow color (8*) and density (8*). I leave the color as black

and go with a density of 0.65, but you can play and see how you like it.


Now that we’ve setup our main sunlight for shadows, we’re going to setup an ambient light to

keep the rear faces of meshes from being black. We’ll first do this by selecting the main

sunlight and right clicking on it and select “clone”. Make sure you have clone as a copy

selected, not as an instance (I’ll explain this later). Now you need to select the cloned

sunlight and go to the modify tab again (7*). Now scroll down to the “advanced effects” tab and

click the box labeled “ambient only” (8*). Next, scroll back up to the light intensity (7*) and

set it to 0.2-0.3 depending on you taste. Now that we’ve setup the maps sunlight, we’re going to

add some lightsources that come from objects in the map such as streetlights, lamps, ext. To do

this, go to the “create” tab (9*) and select the “lighting” tab (9*). Now select the “omni light”

(9*) and click on the map to place it. Now for placement porposes, I sudgest that you hide all

objects except the ones that are intended to have lightsources coming from them.


Now for placement, what you want to do is once again select your new omni light and right

click on it and select “clone” but this time we want to select “clone as instance”. The

difference here is that when you clone as an instance, any change you make in the light

intensity, shadow color, ext of one omni light will be applyed to all the lights that were cloned

as an instance. Now start cloneing and placeing them whereever you want an aditional light source.

Now if you desire a cirtain light intensity from one type of objects and a different intensity,

ext on a different type of object then it would be a good idea to make a second omni light and

clone that as an instance for the second object type. Do this for all the different types of

objects you have the need a lightsource. Now we need to setup the lighting for these omni lights

so select one omni light for an objects and once again setup the raycast shadows (7*) and (7*),

as well as the shadow parramiters (8*) and (8*). However this time,

We’re goint to set the light intensity (7*) between 0.2 and 0.4, makeing sure that the

“ambient only” button (8*) is unchecked. The big difference here is that with these lights, we’re

going to click the dropdown box under decay (10*) and select “inverse square”. Select the “show”

box (10*) and you’ll see a green sphere appear around the light (10*). Now adjust the size of

this sphere by changeing the distance (10*o). There is no right distance to put here, it’s all

about your taste. just remember that this sphere represents when the lights starts to decay, not

where the decay ends. Now you’ll want to do this for each type of light you created for each

different object.


Now that we’ve setup the lighting for our map, we’ll setup the lightmap sizes. Remember that

file we saved at the

begining (we called it “lightmap file a”)? we’re now going to open that

up in notepad. It should look like this (11).


This is the list of the objects in your map, the lods they have and what each lod has in

lightmap size. What you need to do is replace each “undefined” with a standard dds size

(32,64,128,256,512,1024 and 2048) Noteing each “undefined” represents one lod (the cot shown (12*)

has only one lod, ergo it has only one “undefined”). Also note that you generally make the first

lod the largest size and each following lod half the size as the previous (12*). Now that you’ve

replaced each “undefined” with a nuber representing that lods lightmap size, you want to save the

file and close it, then go back to the bf2 lightmaping utility and hit the “lightmaipe size file”

button (5*) and select the “lightmap file a” file you just edited. now hit the “apply lightmap

settings” button again (5*). Now you are ready to generate your lightmaps. You can click on only

one objects at a time and hit the “render selected objects” (5*) to generate them one by one to

test your light settings out or generate them in groups or you can just


hit the “render all lightmaps” button (5*) and go to sleep, cause it’ll be awhile. Once this

is all over, just select and output dirrectory (5*) and brouse to your maps lightmaps/objects

folder and then hit the “convert temp files” button (5*) and let it do it’s job. That’s it, now

just open your map in the editor and generate the atlas files and you’re done.

I hope this

tutorial has been helpfull and will aid you all in creating much more realistic looking maps and

environments. Enjoy.


I hope this aids people in makeing much more detailed lightmaps with multiple inner lights.

Btw, useing this methode, you will not need those peskey 700 mb samples files.

Edited by D-Ran*sdp*

Share this post

Link to post
Share on other sites

Also keep in mind that while you don't need the samples files, you DO need to still generate lightmap samples files when you export coustom objects as the max lightmapping utility reads the lightmapping uv coordonates from the exported mesh, it doesn't make them up.

Here is an example of what this can do, this is a staircase in a ship I made. If I was to do my lightmaps in the editor, this would all be black as there are no windows leading this far inside.


Edited by D-Ran*sdp*

Share this post

Link to post
Share on other sites

Yes but this tut is how to do them in 3ds so you get better results, as show in the pics, also this way you dont need the lightmap samples.

Share this post

Link to post
Share on other sites

Very nice tutorial :D But why the heck did you insert this huge text pictures ? Any chance to resize them to a smaller version ? :P . Any Notebook user will be very thankful for that , hehehe.

Share this post

Link to post
Share on other sites

Has anyone had a problem converting their temp files? The error I get is in the dos window, it says something like ["Program" is not recognized as an external command]???


I ended up locating the batch file that the Lightmap Rendering tool creates, it is located here:

C:\Program Files\Autodesk\3dsMax8\Scripts\bf2\~convert.bat

Running this file directly works just fine.... Trying to run it from the utilities gui in max doesn't. What gives? At least I got them to convert.

Edited by showNOmercy

Share this post

Link to post
Share on other sites

Hey, thanks for editing your tutorial to be more readable :D

We will not add each and every tutorial to the sticky 'Most useful tutorials' as this would confuse the beginners. This above sticky is mostly meant for starters and only contains the most basic stuff. As your tutorial is for the advanced user, just lets keep it here. If you like you can copy it to the Wiki.

Share this post

Link to post
Share on other sites

Great stuff, got everything working in max as per your tut, apart from the converting targas to dxt's like shownomercy mentioned, but that was solved with the manual bat running thing.

Only thing I couldn't get working was a Mental Ray ambient occlusion pass for the skylighting, & also tried vray & that didnt work either. I could get the standard max lighttracer skylight working, but that's really slow in comparison.

Any idea how to get AO or vray skylight working?

Share this post

Link to post
Share on other sites

Well, the way I do it is just to take the skylight that the lightmaping tool imports and clone it as a copy, then click on the "ambient only" checkbox as seen in page 8 with the red arrow. then lower it's intensity down to like 0.2-0.3. If this isn't working for you, then you may have a part of your copy of max that's abit defunct. I might sudgest reinstalling. BTW, I run on max 7, though I know this would all be there in 6 as well. if nothing else, you could add a regular (omni) light on the opposite side of the map as your shadow light but uncheck the "shadows on" box. then lower it's intensity abit and adjust the main sunlights shadow color and intensity to add rear lighting. I hope this helped you.

Share this post

Link to post
Share on other sites

When i say 'skylight' i mean a GI-looking ambient dome light. You're essentially just making a flat ambient light (same as making the colour in the environment>ambient swatch to something other than black), & i want a skylight with those GI domelight shadows.

If you try & recreate what the editor does & make a bunch of standard shadowmapped spotlights in a dome around your scene, it looks crap because you're covering a whole scene (1-2km) & even large shadowmap sizes dont have the detail required.

So, you need to go with a raytraced solution. Max's Lighttracer skylight works for this purpose, but is a lot slower than mentalray AO or Vray skylight, so I want to try & get those working instead...

Share this post

Link to post
Share on other sites

a slightly off-topic question...

when you generate lightmaps in the editor, you notice a variable next to the setting you choose. Low is 0.25, Medium is 0.5, and High is 2.0. Is there a way to manually generate lightmaps with a variable other than these (like Medium-High 1.0, for instance) in the editor (or out, via a .bat file)?

Share this post

Link to post
Share on other sites

To be honest, I'm not mapping so I haven't ran lightmaps in BF2. But when I was mapping, I used to run my lightmaps through batches in photoshop to give them a heavy tweaking. You can do blur/levels then brightness/contrast and really enhance them and make them appear to be of higher quality. That way you can generate them at lower quality levels and still actually use them. But you still have to generate them in the first place. Doing that with the terrain and object lightmaps is pretty much the only way I know of getting the exact look that you want whether that's brighter sunlight or lighter/darker shadows or them being sharper or more blurry or whatever.

Share this post

Link to post
Share on other sites

On a sidenote: Everybody interested in this method should copy the tutorial including the pictures to the local machine, as photobucket is not a reliable image host for a longer time.

Share this post

Link to post
Share on other sites

ok got a question on this ..

is bf2_sunlight a dynamic light?

i have kinda isolated the bf2_sunlight from my scene by just putting my 1 sided indoor statics inside a cube while rendering.

so i only used some omni and the bf2_sunlight copy as ambient light.

however, with this method no bumbmap nor specular is displayed.

only way to see them is when a dynamic light is near, what kinda sux in that case ..


any idea on how i could get all those textures to work properly? ( with normals and specular effect displayed )

thx in advance

Share this post

Link to post
Share on other sites
icon13.gif Question. When generating lightmaps, if I generate lightmaps using the editor to make sure everything looks good, am I able to still generate lightmaps using 3ds max? and if I make lights(i.e. for street lights) and other light in the editor can I import those light sources and there attributes into 3ds max or should I make those other lights in 3ds max only.

Share this post

Link to post
Share on other sites
1, yes.

2, no you use the lightsources in max.

thanks! one thing though, do I take my level that I genereated lightmaps for and then just bring it into 3dsmax? or is there another step before.

Share this post

Link to post
Share on other sites

OK, it's been awhile since I've looked in this thread I did. Since then, I've learned abit more and I want to make a small amendment here. first of all, in my first post, I told you all to generate the lightmaps in max useing the "sky" setting with the shadows on one light and the ambient on the other with variouse omni lights around. this was slightly incorrect. in fact, the end result is a dds that has rgb. the red is the point lightmap setting (harly ever used) the green is the sun setting (where the shadows are) and the blue is the sky setting (used for ambient lighting across the static). when I sayed use the sky setting, this is still better than the lightmaping in bf2 editor as this generates the shadows in the ambient blue channel, but still lights up the rear side with the ambient blue channel whereas the bf2 editor only renders the shadows in the green shadow channel and leaves the blue channel black. this is why the rear sides and interiors and basically every part of an editor made shadow is almost totally black. While you can edit the way the editor handles ambient lighting, it really doesn't let you totally control both independeantly. this is why when you lower the shadows to see the rear (at little) you also lighten up the shadows you want to see.

the key here is to break this up into two steps. the first step is to render with a shadow sunlight and any omni lights you may want also set for shadows. Do not use an ambient light in this pass, just use shadow light and edit the shadow color and density as you see fit. Now render this pass useing the sun setting (this will make the green, shadow channel for the final dds.) keep in mind that you really should render any building that you use omni lights in seperatly from the other buildings as the lights in a building you are not rendering will still slow down the process, even if the light doesn't reach it.

Sten two will be to change the lightmap setting to sky. now turn off ALL shadow lights (shadowing sunlight and all omni lights) and turn on the ambient sunlight. now adjust the intensity to your likeing and render everything at once. don't worry, this render pass is VERY fast. This will render the all over ambient missing in the editor generation. Above all, MAKE SURE YOU RENDER THE SHADOWS AS SUN AND THE AMBIENT AS SKY. It's very easy to forget to change it and accidentally overwright your sun file with your intended sky files. now when you hit the convert temporary files button, it will combine the sun files (green, ambient channel) and the sky files (blue,ambient channel) into one gourgous dds.

Now while you CAN do your lightmaps in the editor, let me first show you this. the first set of pics is done in the editor, the second with a shadow sunlight set to 0.8 intensity for the sun pass and an ambient light generation of 0.7 for the sky pass.







And with a shadow light set to a 0.2 intensity for the sun pass and an ambient set to 0.5 plus two omni lights set to 0.5 intensity with shadows in the sun pass wel get a very nice night time setting.





I hope this helps out abit.

P.S. If you lightmap something in the editor, then lightmap the same object in max, you will overwright the editor generated ones.

Double P.S. The screen above are all of the final res, the one done in the editor took me 15 minutes to lightmap the one building and two sidewalks in the final 2.0 and the others took me about 8 minute for the light max one and 10 minutes for the night time max ones. I also used area shadow in the sunlights as they go far faster than raytraced and honestly dont look any worse than raytraced.

Edited by D-Ran*sdp*

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this