Jump to content

[HOWTO] Guide to New Lightmapping Features


Generalcamo

Recommended Posts

Originally Posted by Jonwil, ported to the new RenHelp by Generalcamo, with additional information added.

 

Firstly, a bug has been identified in the vertex solve code related to meshes with bump mapping such as water. With the fixes provided by 4.0, you no longer need to hide water meshes before you run "compute vertex solve".

Secondly, another bug was identified whereby meshes that have no vertex colors and have an opacity of less than 1 set in their material settings would be treated as though the opacity was set to 1. This has been fixed

The most well known example where the opacity bug can be seen is with the glass in the nod airstrip tower. With the new fixes, you will no longer need to hide any of the glass on the stock renegade buildings (including the air tower and the hand of nod) before you run "compute vertex solve".

Thirdly, 4.0 adds a new feature to the vertex solve code that lets you completely disable vertex solve on a particular mesh. This is intended for meshes where the vertex solve still screws up even with the above 2 features as well as for vertexes that contain pre-calculated lighting baked into the w3d file. (such as lightmap textures) To use it, you select the mesh in 3DS MAX and open the "Properties" dialog. Then you click on the "User Defined" tab. In that box you type "Prelit=true" (without the quotes). This will cause the vertex solve code to completly ignore this mesh (i.e. its essentially same as hiding the mesh before you vertex solve) The process is similar in Gmax/RenX.

 

NOTE: If you are using the Prelit=true feature on a mesh that is part of anything other than terrain, ALL the meshes in that w3d file need to be Prelit=true otherwise it will screw up when you run the vertex solve.

 

Before we go into some of the deeper and more complicated stuff, here is some information about w3d you might need to know:

1.Buildings have a prefix set in the building definition

2.Meshes that contain the building prefix followed by the ^ character are exterior meshes for that building

3.Meshes that contain the building preset followed by the # character are interior meshes for that building

4.Buildings can also have lights associated with them. Lights will match the building if the name of the light (which is taken from the .wlt file, see below) matches with the mesh prefix of the building.

5.Lights in renegade can come from 2 places, they can be directly placed into leveledit or they can be placed via a .wlt file

6.Every light in renegade has a "group ID" and a name.

7.A .wlt file is a file that is associated with a terrain .w3d file and contains one or more groups of lights.

8.When a .wlt file is loaded into leveledit, the lights are given names matching the .wlt filename.

9.The first group of lights in the .wlt file are given a "group ID" of 0, the second group is given a "group ID" of 1 and so on.

10.When a building is initialized, it creates 4 lists (actually 5 if you count the building aggregates but that doesn't matter for this discussion) and fills them with the appropriate data. The InteriorMeshes list contains all the interior meshes for the building. The ExteriorMeshes list contains all the exterior meshes for the building. The PowerOffLights list contains all the lights with a name that matches the building and a "Group ID" of 1. The PowerOnLights list contains all the lights with a name that matches the building and a "Group ID" of 0.

10.Meshes can have "Alternate materials" associated with them. This is basically a second set of material data stored in the .w3d file. (this second set of data may contain textures, shader settings, material settings, texture coordinates etc)

11.When a building is destroyed, the alternate materials on both the interior and exterior meshes are enabled. When a building goes low power, the alternate materials on the interior meshes are enabled.

14.When a building is destroyed or goes low power, all the lights in the PowerOnLights list are disabled and all the lights in the PowerOffLights list are enabled.

 

 

With these fixes, we have also identified how to make Alternate materials and alternate lighting work. The alternate material feature will only work properly on terrain and will only work on meshes that are prelit (i.e. those that have "Prelit=true" set)

The alternate lighting feature will only work properly if the meshes being lit all have Prelit=true set. Meshes which do not have Prelit=true (and therefore get lighting from the vertex solve) will probably not look correct when the lights switch to the "power off/dead" set of lights.

To use the alternate lighting feature you do the following: (there may be other ways to generate .wlt files, I am only describing the way I know to do it)

1.Load leveledit and create a blank map

2.Place the building interior terrain for the building you want to add lights to at 0,0,0 (i.e. so that 0,0,0 in the building terrain is at 0,0,0 in the level)

3.Create any light presets you like and place them anywhere in the level (but presumably they will be inside the building). These will be the "normal" lights

4.Choose Lighting-Export... from the menu. Save the lights as e.g. normal.wlt (the name doesn't matter, I am using normal.wlt for this example)

5.You can (if you like) save this level with the placed lights in it for later further work if you like (you dont need to though)

6.Delete all your "normal" lights

7.Place your "dead" lights (which will also be used when there is low power)

8.Choose Lighting-Export... from the menu. Save the lights as e.g. dead.wlt (the name doesn't matter, I am using dead.wlt for this example)

9.You can (if you like) save this level with the placed lights in it for later further work if you like (you dont need to though)

10.Put wltmake.exe, memorymanager.dll, normal.wlt and dead.wlt in a folder. Open a command prompt and go to this folder.

11.Run wltmake out.wlt normal.wlt dead.wlt. Instead of out.wlt in that command, use the name of your building interior mesh but with a .wlt extension (so if the building is mabar_int.w3d, the wlt file would be mabar_int.wlt)

12.Copy the new output wlt file into your always.dat file or whatever (somewhere LE and the game can find it)

13.Edit the preset for your building interior terrain and set m_LightFilename to the name of your new .wlt file

14.Repeat steps #1 to #13 for all the buildings that need special lights

15.Once that is complete, open up each map that contains the newly-lit buildings.

16.Delete any instances of the building interior meshes (or of any terrain that proxies them in) and re-insert them into the level so that the lights get pulled in.

17.Save and re-export the map.

18.Enjoy your new lighting (hopefully)

To use the alternate materials feature you do the following:

1.Take your mesh in max or gmax and apply the "normal/alive" materials (including any light maps you may have created)

2.Export this to a w3d file (lets call it normal.w3d for this example)

3.Edit the mesh and apply the "dead" materials (including any light maps you may have created)

4.Export this to another w3d file (lets call it dead.w3d for this example)

5.Put both w3d files, memorymanager.dll, altmat.exe and w3dlib.dll in a folder. Open a command prompt and go to this folder.

6.Run altmat out.w3d normal.w3d dead.w3d replacing out.w3d with the name of the output mesh you want (i.e. the name that matches the building you are working with)

7.Place the new w3d file in a place that leveledit and the game will find it.

8.Export your maps as normal

9.Load the game and enjoy your new materials

The things you can change between normal and dead materials are:

Vertex colors

Texture coordinates

All the values on the Vertex Material tab

All the values on the Shader tab

All the values on the Texture tab EXCEPT for the "Stage 0 Texture" and "Stage 1 Texture" checkboxes

Changing anything else (including geometry or pass counts) will not work and may lead to crashes (in altmat or in the game).

Remember that you can't rename a w3d file so make sure you use the correct output filename.

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.