Sonic Adventure lighting guide


The Dreamcast version of Sonic Adventure has a lighting system (referred to internally as “LANTERN”) that uses 256-color palettes. Lighting information for each level is stored in a pair of files: the PL file (PL*.BIN) contains the palettes, and the SL file (SL*.bin) contains light direction and additional lighting information for models that don't use palette lighting. The Lantern Engine mod for Sonic Adventure DX PC is a reimplementation of this system for the PC port of SADX.

Brightness indices

The LANTERN lighting system gives each vertex in the scene a “brightness index”, which is used to select a color in a palette to apply to the vertex. Brightness index calculation is influenced by vertex normals and light direction. If we visualized brightness indices (from white being maximum brightness to black being completely unlit), it would look something like this:

Note that the sky is edited out from the above image to help visibility. The skybox ignores lighting so its textures are used as-is.

Diffuse and specular lighting

LANTERN palettes are always applied in pairs to create diffuse and specular lighting. Diffuse color is the color that is calculated by multiplying the texture's color with the color in the diffuse palette. It works like the "Multiply" blending mode in Photoshop. Specular color is additive, so it works like the "Add" blending mode. Making the diffuse color brighter makes the result closer to the original texture's color. Making the specular color brighter adds to the brightness of the resulting color directly, so white diffuse + black specular is effectively the same as not applying any lighting at all, and white specular would make the vertex completely white regardless of the texture and diffuse color.

Here are some examples that may help understand how those different blending modes work:

Diffuse color Specular color Resulting color
White Black Fullbright texture
White White White (texture invisible)
Black Black Black (texture invisible)
Black White White (texture invisible)

Diffuse lighting is used to give the entire area/model some "base" color, while specular lighting is used to add gloss. Here are examples of different palettes used on Sonic's model (the top palette is diffuse, the bottom one is specular):

Palette selection

The PL file can store up to 8 pairs of diffuse/specular palettes. Here is an example of a palette list from the Chaos 6 boss fight, which uses more palettes than other stages:

(Diffuse 1, Diffuse 3 and palette pairs 6-7 do not seem to be used in the original game)

There are several variables the game relies on to select which palettes to apply to a specific model:

1. Light type

This is a variable set in code before rendering the model. Light type determines which diffuse palette is used by the model. Light type affects the entire model/object, including any child or sibling models. The following light types are known at this point:

The majority of models in the game outside cutscenes use the level/object light type. These are the palettes you see on level pieces and objects.

Character/NPC models and models used in cutscenes generally use the character/event light type, although there are some exceptions. For example, Amy's Warrior Feather and some parts of Gamma's body that are rendered as separate models (such as the laser scope) use the level/object light type outside cutscenes. The gameplay models in Sky Chase use the level/object light type despite being character-related; however, models involving the Tornado in cutscenes use the character light type. It happens the other way around as well: some non-character objects that would normally be using level/object palettes (floating meteors near the end of Twinkle Park Act 1) set the character light type so they also get character lighting, but this is uncommon.

Special light type is only used by a few models in the game. Diffuse 4 and Specular 5 are used by Chaos 2, Chaos 6 and Perfect Chaos. Diffuse 4/Specular 4 and Diffuse 5/Specular 5 are also used by the transition effect in Mystic Ruins Past when the Emerald Altar is on fire. The above palettes blend between each other to create the burning fire effect.

2. Material flags

Material flags affect specular palette selection:

Note that only the first mesh's material in the model affects specular palette selection, and all other meshes follow it regardless of whether they have "ignore specular" or not. Specular palette selection is consistent within a single model, but if the model has child or sibling models those are processed separately unlike the light type. So it is possible to have a model (e.g. Tails) that has child models with a different specular palette (Tails' shoes). They would still use the same diffuse palette, however, as they would have the same light type as the parent model.

Sometimes the game forcibly adds or removes the "ignore specular flag" on some models or sets the a specific light type, in which case you would need to change/disable the code doing that, or use Lantern API to register those models' materials for arbitrary palette selection.

3. White diffuse

This may have been unintentional, but if a mesh in a model has a material with the "ignore lighting" flag, the remaining meshes after it may get the fullbright diffuse palette (as if they were ignoring lighting), but keep the specular palette. The Lantern Engine mod does not do this by default, although Dreamcast Conversion level mods have this implemented manually in the API for better accuracy against the original game.

4. Palette blending

There are cases when the game blends between different palettes for some special effects:

Here is a simple example of palette selection based on Emerald Coast. Color-coded specular palettes are used to tell which light type is being used by the model:

Palette file selection

The game loads PL/SL files using a naming scheme that roughly matches the game's internal level list. The first number/letter after "PL_" is the level ID, the number after that is usually act number, but there are some exceptions. Here is a list of PL files and stages that load them:

Action Stages

PL_10B.BIN - Emerald Coast (all acts), Egg Carrier Outside when the Egg Carrier has sunk
PL_20B.BIN - Windy Valley Act 1
PL_21B.BIN - Windy Valley Act 2
PL_22B.BIN - Windy Valley Act 3
PL_30B.BIN - Twinkle Park Act 1
PL_31B.BIN - Twinkle Park Act 2
PL_32B.BIN - Twinkle Park Act 3
PL_40B.BIN - Speed Highway Act 1
PL_41B.BIN - Speed Highway Act 2
PL_42B.BIN - Speed Highway Act 3
PL_50B.BIN - Red Mountain Act 1
PL_51B.BIN - Red Mountain Act 2
PL_52B.BIN - Red Mountain Act 3 (Knuckles)
PL_60B.BIN - Character select screen, Sky Deck normal (Acts 1-2), Sky Deck Act 3
PL_61B.BIN - Sky Deck dark (Acts 1-2)
PL_70B.BIN - Lost World Act 1
PL_71B.BIN - Lost World Acts 2-3
PL_80B.BIN - Ice Cap Act 1
PL_81B.BIN - Ice Cap Act 2
PL_82B.BIN - Ice Cap Act 3
PL_83B.BIN - Ice Cap Act 4 (Big)
PL_90B.BIN - Casinopolis Act 1
PL_91B.BIN - Casinopolis Act 2 (Sewers)
PL_92B.BIN - Casinopolis Act 3 (Sonic pinball)
PL_93B.BIN - Casinopolis Act 4 (NiGHTS pinball)
PL_A0B.BIN - Final Egg Act 1
PL_A1B.BIN - Final Egg Act 2
PL_A2B.BIN - Final Egg Act 3 (Sonic/Gamma)
PL_C0B.BIN - Hot Shelter Act 1
PL_C1B.BIN - Hot Shelter Act 2
PL_C2B.BIN - Hot Shelter Act 3 (Gamma)

PL_F0B.BIN - Chaos 0
PL_G0B.BIN - Chaos 2
PL_H0B.BIN - Chaos 4
PL_I0B.BIN - Chaos 6
PL_J0B.BIN - Perfect Chaos (first 3 hits)
PL_J1B.BIN - Perfect Chaos 2nd phase
PL_K0B.BIN - Egg Hornet
PL_M0B.BIN - Egg Viper
PL_N0B.BIN - Zero
PL_O0B.BIN - E-101 Beta
PL_P0B.BIN - E-101R

Adventure Fields
PL_Q1B.BIN - Station Square Evening (All acts)
PL_Q3B.BIN - Egg Walker, Station Square Night (All acts)
PL_Q4B.BIN - Station Square Day (All acts)
PL_T0B.BIN - Egg Carrier Outside (before the Egg Carrier sinks)
PL_T2B.BIN - Egg Carrier Private Room
PL_T3B.BIN - Egg Carrier Captain's Room
PL_T5B.BIN - Egg Carrier Pool
PL_W0B.BIN - Egg Carrier Ammunition Room
PL_W1B.BIN - Egg Carrier Bridge
PL_W2B.BIN - Egg Carrier Hedgehog Hammer Room
PL_W3B.BIN - Egg Carrier Prison
PL_W4B.BIN - Egg Carrier Reservoir Room
PL_W5B.BIN - Egg Carrier Chao Garden transporter
PL_X0B.BIN - Mystic Ruins Day (Acts 1-3)
PL_X1B.BIN - Mystic Ruins Evening (Acts 1-3)
PL_X2B.BIN - Mystic Ruins Night (Acts 1-3)
PL_X3B.BIN - Mystic Ruins Eggman's Base
PL_Y0B.BIN - Past Act 1 (Echidna City)
PL_Y1B.BIN - Past Act 2 (Emerald Altar)
PL_Y2B.BIN - Past Act 3 (Emerald Altar on fire)

PL_Z0B.BIN - Twinkle Circuit
PL1A0B.BIN - Sky Chase Act 1
PL1B0B.BIN - Sky Chase Act 2
PL1C0B.BIN - Sand Hill

PL1D0B.BIN - Station Square Chao Garden
PL1E0B.BIN - Egg Carrier Chao Garden
PL1F0B.BIN - Mystic Ruins Chao Garden Day
PL1F1B.BIN - Mystic Ruins Chao Garden Evening (unused in the original game, used in SADX Lantern Engine)
PL1F2B.BIN - Mystic Ruins Chao Garden Night (unused in the original game, used in SADX Lantern Engine)
PL1G0B.BIN - Chao Stadium
PL1G1B.BIN - Chao Race

The following files are present on the disk, but not used by the game:
PL_9MB.BIN - An alternative version of the Casinopolis sewers palette that is never applied, but it was originally supposed to be used by an object called MUD. The object would change Sonic's specular palette to make it less shiny.
PL_MRD.BIN - Possibly alternative Mystic Ruins Day palette
PL_MRE.BIN - Possibly alternative Mystic Ruins Evening palette
PL_MRN.BIN - Possibly alternative Mystic Ruins Night palette
PL_T1B.BIN - Egg Carrier related, might have been used in the early transformation cutscene
PL_T4B.BIN - Egg Carrier related, posibly the lighting used for some endgame credits images
PL1D1B.BIN - Possibly Station Square Chao Garden Night
PL1E1B.BIN - Egg Carrier Chao Garden Evening
PL1E2B.BIN - Egg Carrier Chao Garden Night

Lighting data for non-palettized models (SL Light)

SL files use the same naming scheme as the PL files. They contain additional lighting information, which is currently being researched here. SL files have the following confirmed information:

Several models in the original game use the SL light system, and PL files have no effect on them. The following models are known SL objects:

The "SL lights" configured for the above objects use the same light direction as the palette lights. Both diffuse and specular lights are the same color. PL Tool provides a visualization of this lighting data, but it is only a rough estimate because SL Lights do not use palettes, and because "SL objects" have an additional set of lights that is configured outside the SL file.

Note: the "ignore specular" material flag disables the specular SL light for the mesh that has it.

The SL lighting system is currently not implemented in the Lantern Engine mod.

Additional light data for non-palettized models

In addition to the above, non-palettized models have another set of lights mixed with the SL lights. These additional lights appear to vary between stages, and their data has not been found in SA1 yet. The additional lights consist of a diffuse light (with an ambient value that brings up the overall brightness of the light) and a specular light, both of which use a fixed light direction that is independent of the default light direction and the data in the SL file. This type of lighting is currently not implemented in the Lantern Engine mod. As the data for these lights is likely located in 1ST_READ.BIN or level binaries, PL Tool cannot edit them.