Materials (Metroid Prime): Difference between revisions
→Material Animations
>Aruki (→Mode 4/5: U/V Offset: i'm good at spelling. also extra details added) |
>Aruki |
||
Line 596: | Line 596: | ||
A material can have multiple animations; each animation will generate a separate texture matrix, which can then be used by texgen to transform the texture coordinates accordingly. The structure of the animations themselves is somewhat simple. Each animation has a 32-bit ''mode'' setting, followed by a number of float parameters. The number and usage of these float parameters varies depending on what mode is set. There are 8 possible modes, but only modes 2 through 5 are known. | A material can have multiple animations; each animation will generate a separate texture matrix, which can then be used by texgen to transform the texture coordinates accordingly. The structure of the animations themselves is somewhat simple. Each animation has a 32-bit ''mode'' setting, followed by a number of float parameters. The number and usage of these float parameters varies depending on what mode is set. There are 8 possible modes, but only modes 2 through 5 are known. | ||
For all of the following modes, ''s'' refers to ''the | For all of the following modes, ''s'' refers to ''seconds mod 900''. | ||
==== Mode 0: Inverse ModelView Matrix (No Translation) ==== | |||
This mode is commonly used with vertex normals to simulate reflective surfaces using spheremaps that move with the camera. It takes no parameters, and will generate both a texture matrix and a post-transform matrix. Translation is ignored. | |||
The texture matrix is calculated like this. Note that the multiplication of the view matrix by the model matrix should be modified slightly rather than being a straight multiplication to ignore translation on the model matrix. | |||
<pre>texmtx = inverse(ViewMatrix) * ModelMatrix; | |||
texmtx[0][3] = texmtx[1][3] = texmtx[2][3] = 0;</pre> | |||
The post-transform matrix is a constant value. [1][1] and [1][2] may need to be swapped around for correct playback. | |||
<pre>0.5, 0.0, 0.0, 0.5, | |||
0.0, 0.0, 0.5, 0.5, | |||
0.0, 0.0, 0.0, 1.0</pre> | |||
==== Mode 1: Inverse ModelView Matrix ==== | |||
This mode is nearly identical to mode 0; the only difference is that translation is left as-is. The multiplication of the view matrix by the model matrix actually is a straight multiplication in this mode, and the translation values on the texture matrix aren't set to 0. | |||
==== Mode 2: UV Offset ==== | ==== Mode 2: UV Offset ==== | ||
Line 621: | Line 640: | ||
<pre>float value = step * scale * (offset + s); | <pre>float value = step * scale * (offset + s); | ||
float uv_offset = (float)(short)(float)(numFrames * fmod(value, 1.0f)) * step;</pre> | float uv_offset = (float)(short)(float)(numFrames * fmod(value, 1.0f)) * step;</pre> | ||
==== Mode 6: Model Matrix ==== | |||
This mode is similar to modes 0 and 1 in that it simulates reflective surfaces, but it only takes the model matrix into account, which means camera movement doesn't affect the reflection. It takes no parameters and it generates both a texture matrix and a post-transform matrix. | |||
The texture matrix is simply the model matrix, with the translation values ([0][3], [1][3], and [2][3]) set to 0. The post-transform matrix is set to the following: | |||
<pre>0.5, 0.0, 0.0, ModelMatrix[0][3] * 0.50000001, | |||
0.0, 0.0, 0.5, ModelMatrix[1][3] * 0.50000001, | |||
0.0, 0.0, 0.0, 1.0</pre> | |||
==== Mode 7: Unknown ==== | |||
Mode 7 operates on both the model and view matrices, like modes 0 and 1, and it takes two float parameters. it generates both a texture matrix and a post-transform matrix. It's unknown how this mode works. | |||
[[Category:File Formats]] | [[Category:File Formats]] | ||
[[Category:Metroid Prime]] | [[Category:Metroid Prime]] | ||
[[Category:Metroid Prime 2: Echoes]] | [[Category:Metroid Prime 2: Echoes]] |