Lights (Metroid Prime): Difference between revisions

Jump to navigation Jump to search
no edit summary
>Aruki
>Aruki
No edit summary
Line 1: Line 1:
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.
The '''lights''' section in Metroid Prime areas defines several different types of lights: local ambient, directional, spot, and custom. Every light type has the same structure in the file; however, different types are utilized in different ways by the engine.


{{research|moderate|Need to research meaning behind remaining unknowns}}
{{research|moderate|Need to research meaning behind remaining unknowns}}
Line 11: Line 11:
===Light===
===Light===


Each light is a 0x41-byte struct that consists of the following data:
Each light is a 0x41-byte struct. Note that the same structure is used for every light type, but not every value is used by every type; in fact, some of them aren't used by any of them.


{| class="wikitable"
{| class="wikitable"
Line 98: Line 98:
| Custom
| Custom
|}
|}
Note that although the game supports point lights, those can't be set through the MREA files; custom lights are used for omnidirectional lights.
== Light Functionality ==
=== Local Ambient ===
Ambient lights represent the brightness/color of an area in the absence of any regular lights. There's typically one of these per area; it's not known how they interact if there's more than one. For ambient lights, the color is not used directly; it's multiplied by the Multiplier value and then clamped between 0 and 1, and the result is used as the ambient color.
=== Directional ===
Directional lights are lights that have a constant direction for every vertex in the scene. Since GX doesn't have any built-in functions for handling directional lights, the way the game implements this is by taking the light's direction, inverting it, and then multiplying it by 1048576; the result is used as the light's position.
=== Spot ===
Spot lights shine in a specific direction from a specific position. Distance attenuation is calculated the same way as with custom lights. For angular attenuation, this is calculated using the spot cutoff parameter. The cutoff value from the file is halved and converted from degrees to radians, and the cosine of the result is calculated. Then the angular attenuation coefficients are calculated as:
<pre>(0.0, -CosCutoff / (1.0 - CosCutoff), 1.0 / (1.0 - CosCutoff))</pre>
=== Custom ===
While the other light types only use a couple of the value to generate lights out of what's essentially a preset setup, custom lights allow for much greater control and customization of the light properties. They're commonly used to represent omnidirectional lights; as such they're by far the most common light type in the game. For attenuation, angular attenuation is set to (1.0, 0.0, 0.0). Distance attenuation is calculated differently depending on the falloff type.
Each falloff type will set one distance attenuation coefficient, with the other two set to 0. For each type:
* 0: '''Constant''': Coefficient A is set to <code>2.0 / Multiplier</code>
* 1: '''Linear''': Coefficient B is set to <code>250 / Multiplier</code>
* 2: '''Quadratic''': Coefficient C is set to <code>25000 / Multiplier</code>


[[Category:File Formats]]
[[Category:File Formats]]
Anonymous user

Navigation menu