Difference between revisions of "Lights (Metroid Prime)"

From Retro Modding Wiki
Jump to: navigation, search
(Format: Adding new info, marking stuff that isn't 100% certain as unknown because I suspect some of it is likely wrong)
Line 6: Line 6:
  
 
==Format==
 
==Format==
The header for the light section is extremely simple and consists of the magic, <code>0xBABEDEAD</code>, followed by two arrays of lights, preceded by their count.
+
 
 +
The header for the light section is extremely simple and consists of the magic value <code>0xBABEDEAD</code>. It's then followed by two arrays of lights, each preceded by a light count.
 +
 
 
===Light===
 
===Light===
Lights are a 0x41 byte long struct and consists of the following:
+
 
 +
Each light is a 0x41-byte struct that consists of the following data:
 +
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Offset
 
! Offset
 
! Type
 
! Type
 
! Description
 
! Description
 +
! Notes
 
|-
 
|-
 
| 0x0
 
| 0x0
 
| long
 
| long
 
| '''Light Type'''
 
| '''Light Type'''
 +
|
 
|-
 
|-
 
| 0x4
 
| 0x4
 
| float3
 
| float3
 
| '''Light Color'''
 
| '''Light Color'''
 +
|
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| float3
 
| float3
 
| '''Position'''
 
| '''Position'''
 +
|
 
|-
 
|-
 
| 0x1C
 
| 0x1C
 
| float3
 
| float3
 
| '''Direction'''
 
| '''Direction'''
 +
|
 
|-
 
|-
 
| 0x28
 
| 0x28
 
| float
 
| float
| '''Reference Distance'''
+
| {{unknown|'''Unknown'''}}
 +
| Used as a color multiplier for local ambient, and used to calculate attenuation for spot/custom.
 
|-
 
|-
 
| 0x2C
 
| 0x2C
 
| float
 
| float
| '''Spot Cutoff
+
| '''Spot Cutoff'''
 +
|
 
|-
 
|-
 
| 0x30
 
| 0x30
 
| float
 
| float
| {{unknown|Unknown}}
+
| {{unknown|'''Unknown'''}}
 +
|
 
|-
 
|-
 
| 0x34
 
| 0x34
 
| byte
 
| byte
 
| '''Quadratic Cutoff'''
 
| '''Quadratic Cutoff'''
 +
|
 
|-
 
|-
 
| 0x35
 
| 0x35
 
| float
 
| float
| '''Light Factor
+
| '''Light Factor'''
 +
|
 
|-
 
|-
 
| 0x39
 
| 0x39
 
| long
 
| long
| '''Distance Cutoff (bool)'''
+
| {{unknown|'''Unknown'''}}
 +
| Modifies how attenuation is calculated. Possible values range from 0-2.
 
|-
 
|-
 
| 0x3D
 
| 0x3D
 
| float
 
| float
| {{unknown|Unknown}}
+
| {{unknown|'''Unknown'''}}
 +
|
 
|-
 
|-
 
| 0x41
 
| 0x41
| colspan=2 {{unknown|End of light}}
+
| colspan=3 {{unknown|End of light}}
 
|}
 
|}
 +
 +
=== Light Types ===
 +
 +
The first value in each light is a type value. These are the possible values:
 +
 +
{| class="wikitable"
 +
! Type
 +
! Name
 +
|-
 +
| 0x0
 +
| Local Ambient
 +
|-
 +
| 0x1
 +
| Directional
 +
|-
 +
| 0x3
 +
| Spot
 +
|-
 +
| Other
 +
| Custom
 +
|}
 +
 +
The game doesn't actually track separate light types internally; rather, each light type is a preset that only draws from a couple of the possible parameters. The Custom type is not a preset, and allows further control over how the light is set up. Custom lights are commonly found under type 0x2, acting as point/omni lights.
  
 
[[Category:File Formats]]
 
[[Category:File Formats]]

Revision as of 02:18, 9 March 2015

The Lights section in Metroid Prime areas defines several different types of lights: spot, point, directional, and custom. The exact behavior for each type of light is not entirely known, however they all use the same struct. The only difference is how they're utilized by the engine.


Morphball wire.png This file format needs a lot of research
Need to research meaning behind remaining unknowns


Format

The header for the light section is extremely simple and consists of the magic value 0xBABEDEAD. It's then followed by two arrays of lights, each preceded by a light count.

Light

Each light is a 0x41-byte struct that consists of the following data:

Offset Type Description Notes
0x0 long Light Type
0x4 float3 Light Color
0x10 float3 Position
0x1C float3 Direction
0x28 float Unknown Used as a color multiplier for local ambient, and used to calculate attenuation for spot/custom.
0x2C float Spot Cutoff
0x30 float Unknown
0x34 byte Quadratic Cutoff
0x35 float Light Factor
0x39 long Unknown Modifies how attenuation is calculated. Possible values range from 0-2.
0x3D float Unknown
0x41 End of light

Light Types

The first value in each light is a type value. These are the possible values:

Type Name
0x0 Local Ambient
0x1 Directional
0x3 Spot
Other Custom

The game doesn't actually track separate light types internally; rather, each light type is a preset that only draws from a couple of the possible parameters. The Custom type is not a preset, and allows further control over how the light is set up. Custom lights are commonly found under type 0x2, acting as point/omni lights.