Skip to content

Lighting

TheKillerey edited this page Apr 13, 2026 · 1 revision

Lighting

The addon provides three lighting systems: LightGrid (spatial light sampling), Lightmaps (baked textures), and Point Lights (custom feature). All lighting operations are in the Lighting & Baking panel.


LightGrid

The lightgrid is a spatial grid that stores pre-computed light colours at regular intervals. The game samples this grid at runtime for dynamic lighting on characters and effects.

File Format

Binary .dat file, version 3:

Field Type Description
Version uint32 Always 3
Grid Offset uint32 Header size (typically 32)
Width uint32 Grid cells wide
Height uint32 Grid cells tall
Bounds X float32 Physical world size X
Bounds Y float32 Physical world size Y
Light Scale float32 Global intensity multiplier (0.0–10.0)
Fullbright Intensity float32 Ambient light level (0.0–1.0)
Cell Data 24 bytes × (W×H) 6 BGRA colours per cell

Cell Structure

Each cell stores 6 directional colour samples (24 bytes total):

C1 — Directional light sample 1  (4 bytes BGRA)
C2 — Directional light sample 2  (4 bytes BGRA)
C3 — Directional light sample 3  (4 bytes BGRA)
C4 — Directional light sample 4  (4 bytes BGRA)
C5 — Sky/ambient light           (4 bytes BGRA)
C6 — Bounce/environment light    (4 bytes BGRA)

Create LightGrid

  1. Open Lighting & Baking panel.
  2. Set grid dimensions (default: 256×256).
  3. Set bounds in world units (default: 12877.52 — Summoner's Rift size).
  4. Configure light scale and fullbright intensity.
  5. Click Create LightGrid.

Parameters are stored as scene custom properties.

Bake LightGrid

The bake process samples light at every grid cell:

  1. Create a lightgrid (or import an existing one).
  2. Place Blender light objects in the scene (any type: Point, Spot, Sun, Area).
  3. Mark meshes that block light as Occluder (see below).
  4. Mark ground planes to skip as Ignore.
  5. Set sample height (Z offset, default 1.0).
  6. Click Bake LightGrid.

The baker:

  • Iterates every grid cell
  • Casts 6 directional rays from the cell centre
  • Ray-traces to each light, checking for occluder intersections
  • Stores resulting BGRA colours per cell
  • Shows progress: Baking cell 14221 / 65536

Occluder / Ignore Flags

Button Property Effect
Set Occluder lightgrid_occluder = true Mesh casts shadows during bake — rays hitting it block light
Set Ignore lightgrid_occluder = false Mesh is transparent to rays — light passes through

Import / Export

Operation Format Description
Import LightGrid .dat binary Load official map lightgrid
Export LightGrid .dat binary Save baked lightgrid for game

Visualize

Click Visualize LightGrid to render cell colours in the viewport as coloured dots/cubes.

Clear

Click Clear LightGrid to remove all grid data from the scene.

Scene Properties

scene["lightgrid_width"]               # Grid width in cells
scene["lightgrid_height"]              # Grid height in cells
scene["lightgrid_bounds"]              # [X, Y] physical bounds
scene["lightgrid_light_scale"]         # Intensity multiplier
scene["lightgrid_fullbright_intensity"] # Ambient level
scene["lightgrid_cell_count"]          # Total cells
scene["lightgrid_cells_baked"]         # JSON with all cell data (RGBA per C1-C6)
scene["lightgrid_cells_preview"]       # First 100 cells for UI display
scene["lightgrid_baked"]               # Boolean flag
scene["lightgrid_filepath"]            # Source file if imported

Lightmaps (Baked Light Textures)

Lightmaps store pre-computed lighting as texture atlases applied via UV mapping. Every official League map uses lightmaps for static mesh lighting.

Per-Mesh Lightmap Data

Each mesh can have up to 3 light channels:

Channel Use Description
Baked Primary Static pre-baked lighting
Stationary Unused Reserved for custom point lights
Paint Overlay Painted texture data

Each channel stores:

  • Texture path — e.g. ASSETS/Maps/Particles/.../bakedlight_srf_001.dds
  • Scale — UV scale (U, V), typically (1.0, 1.0)
  • Bias — UV offset (U, V), typically (0.0, 0.0)

Lightmap UV Layer

Lightmap UVs are stored in a dedicated UV layer named LightmapUV (mapped to TEXCOORD7 in the mapgeo format).

5-Step Lightmap Workflow

Step 1: Prepare Mesh Values

Click Prepare Lightmap Setup:

  • Auto-populates lightmap_texture path based on mesh name
  • Sets scale to [1.0, 1.0] and bias to [0.0, 0.0]
  • Marks meshes as occluders

Step 2: Create Lightmap UVs

Click Create Lightmap UVs:

  • Creates LightmapUV layer on each mesh
  • Runs smart UV projection (66° angle limit, 3% island margin)
  • Sets as active render UV layer

Step 3: Remove NO_BAKED_LIGHT Macro

Click Remove NO_BAKED_LIGHT:

  • Strips NO_BAKED_LIGHT and NO_BAKED_LIGHTING from material shader macros
  • Required: materials with this macro ignore lightmap data

Step 4: Bake Lightmaps

Click Bake Lightmaps:

  • Switches to Cycles renderer
  • Bakes diffuse lighting (direct + indirect)
  • Uses OpenImageDenoise for clean results
  • Creates image texture per mesh
  • Saves as PNG to export folder

Settings:

Setting Default Description
Resolution 2048×2048 Lightmap texture size
Samples 64 Ray sample count
Margin 2 Padding around UV islands
Selected Only Off Process only selected meshes
Export Folder — Output directory path
Game Path — In-game texture path root

Step 5: Export Lightmaps

Click Export Lightmaps:

  • Writes PNG files to the export folder
  • Updates texture path properties on meshes
  • Files are ready for injection into the game WAD

Manual Lightmap Assignment

Use Assign Lightmap Texture to manually set texture paths and UV parameters on selected meshes. This is useful for restoring lightmap settings or pointing to different textures.


Custom Point Lights

Warning: Point lights are not used in official League maps. A scan of 195 mapgeo files found zero meshes using the stationary_light field. This feature is for custom/modded maps only and requires a modified game client or custom renderer.

Add Point Light

  1. Select one or more mesh objects.
  2. Set light properties:
    • Color (RGB)
    • Intensity (Watts, default 500)
    • Radius (influence radius, default 5.0)
    • Z Offset (height above mesh, default 2.0)
  3. Click Add Point Light.

The addon:

  • Creates a Blender Point Light object
  • Parents it to the mesh
  • Stores properties as mesh custom properties

Mesh Properties

mesh["point_light_enabled"]   # true
mesh["point_light_color"]     # [R, G, B]
mesh["point_light_intensity"] # float (watts)
mesh["point_light_radius"]    # float
mesh["point_light_offset_z"]  # float

Export Point Lights

Click Export Point Lights to write a JSON file:

{
  "version": 1,
  "lights": [
    {
      "mesh": "wall_segment_001",
      "position": [100.0, 50.0, 32.0],
      "color": [1.0, 0.8, 0.6],
      "intensity": 500.0,
      "radius": 5.0
    }
  ]
}

Remove Point Lights

Select meshes → Remove Point Light to delete light objects and clear custom properties.


General Light Management

Panel: Light Manager (in Lighting & Baking)

Manage scene lights as a group:

Operation Description
Create Light Place a new light (Point, Spot, Sun, Area) at 3D cursor
Duplicate Light Copy selected lights
Delete Light Remove selected lights
Select by Type Select all lights of a specific type
Toggle Visibility Show/hide all lights
Export Lights JSON Save all scene lights with properties to JSON
Import Lights JSON Restore lights from a previously exported JSON

Create Light Properties

Property Description
Type POINT / SPOT / SUN / AREA
Name Light name
Power Energy in Watts
Color RGB colour
Radius Influence radius (Point/Spot)
Spot Size Cone angle in radians (Spot)
Spot Blend Soft edge falloff (Spot)
Distance Custom cutoff distance

All addon-created lights are tagged with mapgeo_light = true for easy filtering.


Code Example

LightGrid data structures

from MapgeoAddon.lightgrid_parser import Color, LightGridCell, LightGrid

# Create a colour from BGRA integer
c = Color.from_bgra(0xFF8060FF)  # B=255, G=128, R=96, A=255
print(f"R={c.r:.2f} G={c.g:.2f} B={c.b:.2f} A={c.a:.2f}")

# Build a cell
cell = LightGridCell()
cell.c1 = Color(1.0, 0.9, 0.8, 1.0)  # Warm directional
cell.c2 = Color(0.2, 0.3, 0.5, 1.0)  # Cool fill
cell.c5 = Color(0.6, 0.7, 0.9, 1.0)  # Sky ambient
cell.c6 = Color(0.1, 0.1, 0.1, 1.0)  # Minimal bounce

# Read a lightgrid file
grid = LightGrid.load("path/to/lightgrid.dat")
print(f"Grid: {grid.width}x{grid.height}, {grid.width * grid.height} cells")
print(f"Bounds: {grid.bounds_x:.1f} x {grid.bounds_y:.1f}")
print(f"Light scale: {grid.light_scale}, Fullbright: {grid.fullbright}")

Clone this wiki locally