Skip to content

Doc_Halo1_DirectionalLightmaps

Noah Sherwin edited this page Feb 9, 2023 · 6 revisions

Directional Lightmaps

Welcome to this tutorial on creating directional lightmaps for Halo Custom Edition using OpenSauce.

To follow this tutorial you will need:

  • Halo CE v1.10 installed
  • The Halo Editing Kit installed
  • OpenSauce 4.0.0 installed with the OS HEK and OpenSauceIDE features included
  • 3ds MAX
  • OpenCOLLADA for 3ds MAX

What are directional lightmaps

Directional lightmaps (or Radiosity Normal Maps) are a technique developed by Valve for the source engine which allows a static lighting setup to use normal maps.

In Halo, the lightmaps you are used to contain lighting data that is accumulated using the surface normal of the BSP, and because the lightmap only contains data from a single direction normal maps cannot be applied.

Directional lightmaps on the other hand uses 3 sets of lightmaps, with each lightmap accumulating lighting data from a different direction. These 3 lightmaps represent a rough approximation of the light in a hemisphere around each texel, which can then be sampled using a normal map to create normal mapped static lighting.

Comparison

To create these lightmaps you will need to use an external lighting method using 3ds MAX or Maya. This tutorial does this using 3ds MAX.

Exporting your models

In OpenSauce 4.0.0 onward, OpenSauceIDE contains a new model extraction tool which exports your models to the COLLADA format.

First we need to export our BSP.

  1. Open OpenSauceIDE
  2. Open the model extractor tool under the Tools menu.
  3. Set your tags and data directories.
  4. Change the model type to scenario_structure_bsp.
  5. Set the extension you are using for your bitmaps.
  6. Tick overwrite files.
  7. Tick render mesh and lightmap sizes.
  8. Set the lightmap multiplier to the size you want you lightmaps to be multiplied by (or leave it at 1).
  9. Select Add Job and choose the BSP to export.

NOTE: The model exporter does NOT export bitmaps. You will need to export those yourself using another program.

Comparison

Next we need to export our scenario. This will export all of the GBX models that are used in the scenario and will create COLLADA files that instantiate those models.

  1. Open OpenSauceIDE
  2. Open the model extractor tool under the Tools menu.
  3. Set your tags and data directories.
  4. Change the model type to scenario.
  5. Check all of the Extraction flags.
  6. Select Add Job and choose your scenario.
  7. Wait for all jobs to be completed.

Comparison

3ds MAX

Plugin setup

When you installed the OS HEK a MAXScripts director was added to your Halo CE directory. Inside that folder is the RenderLightmaps script that you will be using to create your directional lightmaps.

  1. Start 3ds MAX.
  2. Run the RenderLightmaps.ms script via the MaxScript menu.
  3. Right click your top UI bar and select Customize.
  4. Change the category to Render.
  5. Find "Render Lightmaps" in the list and click-drag it to your top UI bar.

This should now persist between sessions.

3ds MAX UI Customize

Model Import

To import your models you will need to have the latest version of OpenCOLLADA installed. This is because the build in COLLADA plugin is ass and barely works.

  1. Go to File -> Import and change the "Files of type" to "OpenCOLLADA (*.DAE)"
  2. Navigate to your scenario tag's relative location in your data directory.
  3. Import your BSP.
  4. Repeat for the scenario-scenery.dae, scenario-device_controls.dae, and such.

You will now have all of your model's imported.

NOTE: Because we are using COLLADA we can now have the lightmap UV's in channel 2 of the BSP meshes. So you will only import one set of BSP meshes.

To clean up the imported shaders (do a quick render and the textures will be washed out):

  1. Go to the hammer tab at the right hand side and select MAXScript.
  2. Run the MaterialFixer.ms script.
  3. Select "Material Fix" in the drop down menu.
  4. Select everything in your scene and press "Fix Materials".

Lightmap rendering

Add lighting to your scene as you see fit. Once finished you can render your lightmaps.

3ds MAX Lighting

  1. Using "Select by Name", select your BSP meshes in order from 0 to whatever, ignoring the transparent meshes object with -1 as it's index.

3ds MAX Selected Meshes

  1. Open the Lightmap Renderer (the button added to your UI previously).

3ds MAX Lightmap Renderer

  1. Select Setup Objects. This will add render to texture elements to your meshes for baking the lighting data.
  2. Select Import Bitmap Sizes and choose the lmsz file created for your BSP. This will set up the target texture size for each mesh.
  3. Modify padding and bitmaps sizes as you see fit.
  4. Select a directory to save your lightmap plates to (for instance a "lightmaps" folder in your scenario's data directory).
  5. Select a directory to save your raw lightmap's to (for instance a "lightmaps\raw" folder in your scenario's data directory).
  6. Select Render.

NOTE: Lightmap plates are bitmaps that have all of the individual lightmaps added to them in the correct order with a 1px blue border around them.

Tag Setup

You now have your BSP's lightmap plates. The lightmaps in them may look a bit odd but that is intentional as the 3 component lightmaps had their normals skewed to accumulate light from a different direction.

Because the lightmap plates are set up with 1px of blue between all of the lightmaps you can just run them through tools bitmaps command to create your lightmap tags. You may want to open each tag and change the usage to "light map" and the format for each bitmap to "r5g6g5" (which required a re-run in tool) but it isn't critical.

The last steps to add the lightmaps to your map are as follows:

  1. Open your scenario in OS Guerilla.
  2. Add a BSP Modifier entry for the relevant BSP
  3. Add a Lightmap Set
  4. Point the lightmap tag references to the relevant bitmaps.

Guerilla Scenario

  1. Save and compile your map using build-cache-file-ex.
  2. Play your map!

Complete

Clone this wiki locally