Jump to content

Guide to new Lighting Features in scripts 4.x


GeneralCamo

Recommended Posts

Author: Jonwil, Generalcamo

Skill level: 5

 

 

Light solve improvements

-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.

 

 

Buildings and lights

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

  • Buildings have a prefix set in the building definition
  • Meshes that contain the building prefix followed by the ^ character are exterior meshes for that building
  • Meshes that contain the building preset followed by the # character are interior meshes for that building
  • 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.
  • Lights in Renegade can come from 2 places, they can be directly placed into leveledit or they can be placed via a .wlt file
  • Every light in renegade has a "group ID" and a name.
  • A .wlt file is a file that is associated with a terrain .w3d file and contains one or more groups of lights.
  • When a .wlt file is loaded into leveledit, the lights are given names matching the .wlt filename.
  • 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.
  • 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.
  • 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)
  • 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.
  • 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.

 

 

Using alternate lighting

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)

Don't forget: you can always also use animated Tiles to hide/show different parts or versions of your buildings.

Note: Lights will only be affected up to 50 meters from the building controller, so for large buildings try to center the building controller for best results.

 

 

Using alternate materials

To use the alternate materials feature you do the following:

  • Take your mesh in max or gmax and apply the "normal/alive" materials (including any light maps you may have created)
  • Export this to a w3d file (lets call it normal.w3d for this example)
  • Edit the mesh and apply the "dead" materials (including any light maps you may have created)
  • Export this to another w3d file (lets call it dead.w3d for this example)
  • Put both w3d files, memorymanager.dll, altmat.exe and w3dlib.dll in a folder. Open a command prompt and go to this folder.
  • 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)
  • Place the new w3d file in a place that leveledit and the game will find it.
  • Export your maps as normal
  • 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

  • 1 year later...

Quick headsup, but the Prelit=true flag does not work equally well on non-tile presets. If you flag a 3DS object with it and set it up as for example a simple object in LevelEdit, the vertex solve still affects it somehow, darkening it.

 

Noticed this while doing battle with a specific map mechanic for Siege. It caused me to use tiles instead (and since these were animated objects, exporting as terrain wasn't an option).

Edited by Raap
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...