[ Updated threads · New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 3
  • 1
  • 2
  • 3
  • »
Forum » Welcome to the [FHSW] Europe Community! » Mapping » [Tutorial] Lightmapping (m)
[Tutorial] Lightmapping (m)
Endless_NamelessDate: Friday, 2013-01-04, 7:05 PM | Message # 1
General
Group: Admins
Messages: 1237
Awards: 38
Reputation: 19
Status: Offline
Original post in spoiler


Tools you need:
a) WinRFA
b) BF1942_r.exe
c) IrfanView to batch convert .tga to .dds (keyboard shortcut B)
d) Samplesmaker 1.0
e) .tga to .dds converter

I packed them together here.

Create these folders in your BF1942 root directory (..\EA GAMES\Battlefield 1942\):
A) bf1942\levels\MAPNAME\
B) ShadowWork\bf1942\levels\MAPNAME\
C) ShadowWork\bf1942\levels\MAPNAME\Textures\
D) standardmesh\

!!! To suppress all game engine related problems if you’re using Win7, I recommend to run all shortcuts with Win98/Me compatibility mode. !!!



Object Lightmapping

1) You need a .samples file of all the objects you want to lightmap on your map (mostly buildings). For each object you have to extract the corresponding .sm file which you find in the mod’s standardmesh.rfa. Since FHSW uses objects from BF1942, FH and FHSW the file can be in either of them as well as the map itself. So the easiest way is to simply extract all three standardmesh.rfa’s in the order BF1942->FH->FHSW, put them into one folder and overwrite everything if asked. You only need the .sm files, you can delete the .rs files.

Now put the samplesmaker.exe and samplesmakerall.bat from d) into the folder you extracted the .sm files. Then go to Start -> Run and enter cmd.exe, choose the drive where your .sm files are stored (or type in cd/ if it already is at the right drive), then type in these two lines:
Code
cd \YOUR FOLDER\
samplesmakerall medium

Then the program should start generating .samples files, ignore any errors that come up. When the program is finished put all .samples in D).

!!! If your map uses custom objects you want to lightmap extract the .sm and, contrary to regular objects, also the .rs files! Create a .samples file of these as well and put all three files (.sm .rs .samples) into D). !!!

!!! If the samplesmaker doesn't create a .samples file (or the resulting shadows are messed up) it usually means that your object doesn't have a correct channel 3 UV map. It's really simple to create it with 3ds max but be aware that you have to replace the old object in the mod's standardmesh.rfa. Here's a quick tutorial on how to do it with 3ds max. !!!

2) Create an ObjectsLightmap.con via notepad in A) with the text below or just take it from another map. The most important lines here are the sun direction, copy/paste it from your map’s SkyAndSun.con (sky.sunLightDirectionVec). Also play around with shadow and light intensity to make it look natural, on a sunny day you want to have strong lights and shadows, if it's cloudy tone these down a bit.

Code
raytracer.init
raytracer.ambientIntensity 0.05
rem *** Can't say for sure what these two do. Modify at your own risk! ***
raytracer.blockSize 16
raytracer.sampleOffset 0.05

rem *** You should never have to change these settings ***
raytracer.OnlyNearest 0
raytracer.shadowsNearCamera -10.0

rem *** This first instance is best left at default settings. ***
rem *** But still update the light direction on this one too! ***
raytracer.light.create
rem **** Should be sun direction ***
raytracer.light.direction 0.826002/0.312193/-0.469316
raytracer.light.selfshadowing 1
raytracer.light.objectShadows 0
raytracer.light.shadowIntensity 1
raytracer.light.intensity 0.35
raytracer.light.softness 1.0
raytracer.light.fov 130
raytracer.light.viewDistance 200

raytracer.light.create
rem **** Should be sun direction ***
raytracer.light.direction 0.826002/0.312193/-0.469316
raytracer.light.selfshadowing 1
raytracer.light.objectShadows 1
rem *** This increases shadow intensity (darkness)***
raytracer.light.shadowIntensity 1
rem *** this increases intensity of light ***
raytracer.light.intensity 0.6
raytracer.light.softness 0.0
rem *** Reduce this to make shadow edges sharper ***
raytracer.light.fov 8
raytracer.light.viewDistance 500

raytracer.addIgnoreObject terrain
raytracer.addIgnoreObject track


3) You don’t want to lightmap every tree or stone because that would take veeery long and also increase the file size of the map too much. So delete all the unwanted .samples files in D). It's a tedious process but you only have to do it once then you're set for all maps to come.

4) Create a shortcut of b) or your BF1942.exe and add the following line to the target
Code
+game FHSW +workingFolder "ShadowWork\" +traceObjectShadows "bf1942\levels\MAPNAME\"


5) Click on the shortcut. Some errors might occur, if they are unrelated to lightmapping (e. g. missing sound files) you can just click retry to ignore them. Depending on the number of objects the lightmapping process may take some time, when it’s finished you should see a new folder called ObjectLightmaps in B).

6) Drag this folder into your map’s root. You also need a Palette.pal file there which you can copy from another map that has Object Lightmaps. This file defines the brightness and fading of your shadows. Because of that it’s best to use a Palette from a map that looks similar to the one you are working on, don’t use a desert Palette on a snow map. You can also create/edit this file by yourself via Photoshop, here’s a very quick tutorial. The Palette.pal really defines the mood one your map and you should play around with it for the best possible result.



Terrain Lightmapping

1) Extract all the textures stored in the folder Textures from your map with the help of a). Batch convert these .dds files to .tga’s via c) and put them into C).

!!! If your map uses custom objects you have to extract the .sm files and put them into D) otherwise these won't cast any shadows on your terrain! !!!

2) Create a TerrainLightmap.con via notepad in A) with the text below or just take it from another map. The most important line here is the sun direction, copy/paste it from your map’s SkyAndSun.con (sky.sunLightDirectionVec).

Code
rem
rem ******** Example of a terrain shadow creation script.
rem

GeometryTemplate.setActive patchGeometry
rem *** 4.0 is 4 pixels per meter.
GeometryTemplate.shadowPrecision 4

raytracer.init
raytracer.ambientIntensity 0.3
raytracer.blockSize 16

rem *** 1 == Trace only the nearest terrain patch.
rem *** 0 == Trace all patches.
raytracer.OnlyNearest 0

rem *** < 0, trace all pixels
rem *** Else, number of meters from moving free camera to trace the shadows. Preview tool.
raytracer.shadowsNearCamera -10.0

raytracer.light.create
rem **** Should be sun direction ***
raytracer.light.direction 0.628000/0.661000/-0.410000
raytracer.light.selfshadowing 1
raytracer.light.objectShadows 1
raytracer.light.shadowIntensity 1
raytracer.light.intensity 1
raytracer.light.fov 2
raytracer.light.viewDistance 500
raytracer.light.softness 0.0

raytracer.light.create
raytracer.light.direction 0/1/0
raytracer.light.selfshadowing 0
raytracer.light.objectShadows 1
raytracer.light.shadowIntensity 0.8
raytracer.light.intensity 0
raytracer.light.fov 45
raytracer.light.viewDistance 20
raytracer.light.softness 0.0


3) Create a shortcut of b) or your BF1942.exe and add the following line to the target
Code
+game FHSW +workingFolder "ShadowWork\" +traceTerrainShadows "bf1942\levels\MAPNAME\" "ShadowWork\bf1942\levels\MAPNAME\textures"


4) Click on the shortcut. Some errors might occur, if they are unrelated to lightmapping (e. g. missing sound files) you can just click retry to ignore them. Depending on the size of the map the lightmapping process may take some time, when it’s finished you should see for each of your textures a new file with the ending _lgt in C). These are your created shadows for the map.

5) Now you have to merge the textures and shadows. For this the first thing you want to do is to put a TerrainPalette.pal into C). Similar to the Palette.pal for object lightmapping you can extract it from an existing map and also edit it with Photoshop. This file really defines the mood one your map and you should play around with it for the best possible result. Then create another shortcut of b) or your BF1942.exe and add the following line to the target
Code
+game FHSW +workingFolder "ShadowWork\" +mergeTerrainShadows "bf1942\levels\MAPNAME\ 1.5 0.4"


6) Again click on the shortcut, the merging should actually take only a few seconds. After it’s done there appears a new folder Merged in C) which contains your merged textures. Now you have to convert these back to .dds files, use e) for this.

7) Put these files into your map’s Textures folder and overwrite your old textures.



Big thanks to:
  • Apache Thunder for his tutorial
  • Senshi for his tutorial
  • Mr_J for his great tip regarding terrain lightmapping.

    My Youtube Channel
    aka eYe.ris
  •  
    slobodanDate: Friday, 2013-01-04, 8:08 PM | Message # 2
    Koń
    Group: Friends
    Messages: 434
    Awards: 53
    Reputation: 22
    Status: Offline
    Great job eYe! I want to try mapmaking but I have problem with editor42.

     
    Endless_NamelessDate: Friday, 2013-01-04, 8:19 PM | Message # 3
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    I never tried mapmaking, as I stated in the OP I created the lightmaps without BC or ED42. I don't even have either of them installed. So I can't help you there sadly. sad

    The map above is Kushira.

    btw. thanks for award. smile


    My Youtube Channel
    aka eYe.ris
     
    Mr_JDate: Sunday, 2013-01-06, 7:35 PM | Message # 4
    Accessory Admin
    Group: Admins
    Messages: 635
    Awards: 22
    Reputation: 13
    Status: Offline
    Are you going to make a client side patch eYe?
     
    Endless_NamelessDate: Sunday, 2013-01-06, 8:06 PM | Message # 5
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    Probably not a patch but I can upload one or two maps if you like.

    My Youtube Channel
    aka eYe.ris
     
    Mr_JDate: Sunday, 2013-01-06, 9:52 PM | Message # 6
    Accessory Admin
    Group: Admins
    Messages: 635
    Awards: 22
    Reputation: 13
    Status: Offline
    As I remember it's nearly automatic job once you get all the common .samples files ready ?
     
    Endless_NamelessDate: Sunday, 2013-01-06, 10:26 PM | Message # 7
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    Basically yes.

    But I have some trouble with terrain lightmapping, the resulting .tga files after the merging are always red.


    My Youtube Channel
    aka eYe.ris
     
    Mr_JDate: Monday, 2013-01-07, 5:53 PM | Message # 8
    Accessory Admin
    Group: Admins
    Messages: 635
    Awards: 22
    Reputation: 13
    Status: Offline
    I think that many players, including me, would be very satisfied with the fix that finally repairs all these japanese maps. Moreover someone whu uses Twitter should let to know FHSW Devs about this thread.

    (Endless_Nameless)
    the resulting .tga files after the merging are always red.

    Sounds like your program bakes the alpha chanell onto the ground texture. What program you use for merging?
     
    Endless_NamelessDate: Monday, 2013-01-07, 7:15 PM | Message # 9
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    I use the method that is described here: http://bfmods.com/viewtopic.php?f=43&t=125

    I object lightmapped Ilomantsi (it's already terrain lightmapped) and it looks pretty cool imo:

    Before:


    After:


    Look at the house with the blue roof, it appears so out of place in the first picture.

    Download: http://www.file-upload.net/downloa....fa.html


    My Youtube Channel
    aka eYe.ris
     
    Mr_JDate: Monday, 2013-01-07, 7:55 PM | Message # 10
    Accessory Admin
    Group: Admins
    Messages: 635
    Awards: 22
    Reputation: 13
    Status: Offline
    (Endless_Nameless)
    I object lightmapped Ilomantsi (it's already terrain lightmapped) and it looks pretty cool imo:


    It does indeed!
     
    akodanaDate: Tuesday, 2013-01-08, 10:16 AM | Message # 11
    Private
    Group: Blocked
    Messages: 12
    Awards: 0
    Reputation: 0
    Status: Offline
    Good work =(

    Me dont know how to make a sky texture in Ed42 :E
     
    Endless_NamelessDate: Tuesday, 2013-01-08, 8:43 PM | Message # 12
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    @Mr_J: In the zipped version of FHSW there is a second objects.rfa in the folder "for modders" or something, could you please upload it for me? I somehow deleted it by accident.

    My Youtube Channel
    aka eYe.ris
     
    Mr_JDate: Tuesday, 2013-01-08, 9:20 PM | Message # 13
    Accessory Admin
    Group: Admins
    Messages: 635
    Awards: 22
    Reputation: 13
    Status: Offline
    Here you are: http://www.file-upload.net/download-7030524/objects.rar.html
     
    Endless_NamelessDate: Tuesday, 2013-01-08, 10:58 PM | Message # 14
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    Thanks, I was hoping it would solve another problem I encountered but it didn't work. Somehow it doesn't want to object lightmap objects from FHSW, only the FH and Vanilla ones.

    €: Okay it's not FHSW related, it seems to be a general problem that some things can't be lightmapped. I can live with that though, since so far that have been mostly small objects like ammo crates.


    My Youtube Channel
    aka eYe.ris
     
    Endless_NamelessDate: Tuesday, 2013-03-05, 7:16 PM | Message # 15
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    Tutorial finished.

    Here's another map, Fall of Singapore, this time with terrain and object lightmaps. Terrain lightmapping took 3 days, luckily I have a second PC.

    DL: http://www.file-upload.net/downloa....fa.html Don't rename it or anything, just put it in ..\Battlefield 1942\Mods\FHSW\Archives\bf1942\levels

    Before:


    After:


    My Youtube Channel
    aka eYe.ris
     
    Stefan1990Date: Tuesday, 2013-03-05, 8:17 PM | Message # 16
    General
    Group: Admins
    Messages: 1428
    Awards: 10
    Reputation: 7
    Status: Offline
    we need a fhsw Lightmap-mappack! smile
     
    crazygameloverDate: Wednesday, 2013-03-06, 2:38 AM | Message # 17
    Colonel
    Group: Trusted
    Messages: 308
    Awards: 13
    Reputation: 5
    Status: Offline
    @Stefan That would take a VERY long time, especially since it took eYe 3 DAYS to edit Fall of Singapore alone. However, if we all work together, it may possible. Good job eYe!
     
    Endless_NamelessDate: Wednesday, 2013-03-06, 2:30 PM | Message # 18
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    My hope is more that the devs do this, if you have everything set up it's such a simple task. You just let the PC do all the work, no creative thinking or anything required. There's really no excuse to not do it.

    Fall of Singapore took so long because it's big and there are so many objects on that map, Suomussalmi was done in roughly two hours.

    Maps without object and/or terrain lightmaps are (afaik):

  • Air Raid Alert Kure
  • Alaska
  • Battle at River Don
  • Battle of Iwo Jima (partially)
  • Fall of Singapore
  • Gazaps
  • Hungary Forest (partially)
  • Ilomantsi
  • Kakazu Ridge
  • Kushira
  • Manchuria
  • Moscow Outskirts
  • Naichi
  • Operation Coronet
  • Kikusui Day2
  • Pakfront
  • Suomussalmi

    My Youtube Channel
    aka eYe.ris
  •  
    Mr_JDate: Thursday, 2013-03-07, 7:35 PM | Message # 19
    Accessory Admin
    Group: Admins
    Messages: 635
    Awards: 22
    Reputation: 13
    Status: Offline
    Oh wow, Singapure looks so glamorous now. I think you must make that 'lightmap pack', there's no excuse to not to
    If you have 4 core processor you could process 4 maps at once, right?

    Quote (Endless_Nameless)
    Maps without object and/or terrain lightmaps are (afaik):

    Air Raid Alert Kure
    Alaska
    Battle at River Don
    Battle of Iwo Jima (partially)
    Fall of Singapore
    Gazaps
    Hungary Forest (partially)
    Ilomantsi
    Kakazu Ridge
    Kushira
    Manchuria
    Moscow Outskirts
    Naichi
    Operation Coronet
    Kikusui Day2
    Pakfront
    Suomussalmi


    + Operation Coronet
     
    Endless_NamelessDate: Friday, 2013-03-15, 4:31 PM | Message # 20
    General
    Group: Admins
    Messages: 1237
    Awards: 38
    Reputation: 19
    Status: Offline
    I'm done with most maps now, 3 or 4 to go. But look at this:

    Air Raid Alert Kure: Expected time to create lightmaps: 37000 minutes (10 days) cry shock


    My Youtube Channel
    aka eYe.ris
     
    Forum » Welcome to the [FHSW] Europe Community! » Mapping » [Tutorial] Lightmapping (m)
    • Page 1 of 3
    • 1
    • 2
    • 3
    • »
    Search: