Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
trs:miscellany [2017/06/04 15:40] – [Palette] zdimensiontrs:miscellany [2020/12/11 18:26] (current) – [Object Textures] typo stohrendorf
Line 1: Line 1:
 +{{indexmenu_n>8}}
 +
 ====== Miscellany ====== ====== Miscellany ======
  
Line 13: Line 15:
   * ''%%0xFF180038%%'' — Tomb Raider 3, Gold, Gold Title level   * ''%%0xFF180038%%'' — Tomb Raider 3, Gold, Gold Title level
   * ''%%0xFF080038%%'' — Tomb Raider 3 (Title level on Normal)   * ''%%0xFF080038%%'' — Tomb Raider 3 (Title level on Normal)
-  * ''%%0xFF180034%%'' — Tomb Raider 3 (''VICT.TR2'' that only contains palette and textiles)+  * ''%%0xFF180034%%'' — Tomb Raider 3 (''VICT.TR2'' that only contains palette and atlases)
   * ''%%0x00345254%%'' (''TR4 '') — Tomb Raider 4 and Tomb Raider 5   * ''%%0x00345254%%'' (''TR4 '') — Tomb Raider 4 and Tomb Raider 5
   * ''%%0x63345254%%'' (''TR4c'') — Tomb Raider 4 (demo versions)   * ''%%0x63345254%%'' (''TR4c'') — Tomb Raider 4 (demo versions)
Line 31: Line 33:
 ===== Palette ===== ===== Palette =====
  
-This consists of 256 [[trs:fundamentals#tr_colour|[tr_colour]]] structs, one for each palette entry. However, the individual colour values range from 0 to 63; they must be multiplied by 4 (or bitshifted by 2 to the left) to get the correct values.+This consists of 256 [[trs:fundamentals#tr_colour|[tr_colour]]] structs, one for each palette entry. However, the individual colour values range from 0 to 63; they must be multiplied by 4 (or bitshifted by 2 to the left) to get the correct values. Palette is used for all 8-bit colour, such as 8-bit textures.
  
-This used for all 8-bit colour, such as 8-bit textures.+{{:icons:tr1.png?nolink|TR1 only}} First entry in palette is treated as //transparent colour// used for textures with alpha testing. In later games, transparent colour was replaced by so-called "magenta transparency"meaning that any pixel with red and blue values at maximum and green value at zero, is treated as completely transparent.
  
 ===== Object Textures ===== ===== Object Textures =====
  
-Object texture (or //texture details// in TRLE terms) keeps detailed information about each texture independently used in game. While it’s not texture image itself (these are kept inside //texture tiles//), it’s rather a reference to particular texture tile zone kept with all other necessary information to display this texture.+An object texture (or //texture details// in TRLE terms) keeps detailed information about each texture independently used in the game. While it’s not texture image itself (these are kept inside //texture atlases//), it’s rather a reference to particular texture in an atlas, kept with all other necessary information to display this texture. 
  
 ==== Object Texture Vertex Structure ==== ==== Object Texture Vertex Structure ====
  
-This sub-structure used by object textures specifies a vertex location in textile coordinates. The Xpixel and Ypixel are the actual coordinates of the vertexs pixel. The Xcoordinate and Ycoordinate values depend on where the other vertices are in the object texture. And if the object texture is used to specify a triangle, then the fourth vertexs values will all be zero.+This sub-structure used by object textures specifies a vertex location in texture tile coordinates. The Xcoordinate and Ycoordinate are the actual coordinates of the vertex's pixel. If the object texture is used to specify a triangle, then the fourth vertex's values will all be zero.
  
 {{anchor:tr_object_texture_vert}} {{anchor:tr_object_texture_vert}}
Line 47: Line 50:
 struct tr_object_texture_vert // 4 bytes struct tr_object_texture_vert // 4 bytes
 { {
-    uint8_t Xcoordinate; // 1 if Xpixel is the low value, 255 if Xpixel is the high value in the object texture +    ufixed16 Xcoordinate; 
-    uint8_t Xpixel; +    ufixed16 Ycoordinate;
-    uint8_t Ycoordinate; // 1 if Ypixel is the low value, 255 if Ypixel is the high value in the object texture +
-    uint8_t Ypixel;+
 }; };
 </code> </code>
 +
 +<note>
 +Actual texture coordinade format was unknown before the end of 2017, when //TE// developer MontyTRC uncovered that used format is similar to fixed-point format used for fractional values in animation structures, yet it uses 2 bytes instead of 4 (i.e. one byte for whole part and another for fractional part). However, since classic TR games built with native tools produced only whole coordinates (e.g. 64x64, 16x32, and so on) and there was no occurence of seeing fractional coordinates in levels, for many years it was believed that //low byte// in each field must always be of specific value (not 0 as expected, but either 1 or 255 which is probably caused by rounding error in Core's native conversion tools).
 +</note>
 {{anchor:tr_object_texture}} {{anchor:tr_object_texture}}
 ==== Object Texture Structure (TR1-3) ==== ==== Object Texture Structure (TR1-3) ====
Line 63: Line 68:
 { {
     uint16_t               Attribute;     uint16_t               Attribute;
-    uint16_t               TileAndFlag;+    uint16_t               AtlasAndFlag;
     tr_object_texture_vert Vertices[4]; // The four corners of the texture     tr_object_texture_vert Vertices[4]; // The four corners of the texture
 }; };
 </code> </code>
-''%%TileAndFlag%%'' is a combined field:+''%%AtlasAndFlag%%'' is a combined field:
  
-  * //Bits 0..14// specify //texture tile// to use. +  * //Bits 0..14// specify the //texture atlas// to use. On PC, the value should be between 0 and 63 (inclusive)
-  * //Bit 15//: if set, it indicates that texture is used on a triangle face.+  * //Bit 15//: {{:icons:tr4.png?nolink|TR4 only}}{{:icons:tr5.png?nolink|TR5 only}} if set, it indicates that the texture is used on a triangle face.
  
 ''%%Attribute%%'' specifies transparency mode (i.e. //blending mode//) used for face with this texture applied. There are several ones available: ''%%Attribute%%'' specifies transparency mode (i.e. //blending mode//) used for face with this texture applied. There are several ones available:
Line 97: Line 102:
 |//Bump mapping turned off//                                    |//Bump mapping turned on//                                       | |//Bump mapping turned off//                                    |//Bump mapping turned on//                                       |
  
-Assignation of bump maps happened inside level editor, where each texture piece could be marked as either //level 1// or //level 2// degree of bump map effect. When level was converted, all texture pieces with bumpmaps were placed into separate texture tiles after all other texture tilesfollowing by the same amount of texture tiles with auto-generated bump maps arranged in the same manner as original texture tilesNumber of bumped texture tiles was kept in separate variable as well (see [[trs:file_formats#level_format_tr4|TR4 Level Format]] section).+Assignment of bump maps happened inside level editor, where each texture piece could be marked as either //level 1// or //level 2// of the bump map effect. When the level was converted, all texture pieces with bumpmaps were placed into separate texture atlases after all other texture atlasesfollowed by the same amount of texture atlases with auto-generated bump maps arranged in the same manner as the original texture atlasesThe number of bump map atlases was kept in separate variable as well (see [[trs:file_formats#level_format_tr4|TR4 Level Format]] section).
  
-So, when engine rendered a face with texture marked as //bumped//, it rendered original texture at first, then it jumped to the texture tile //plus number of bumped texture tiles//, and rendered one more texture pass on this face using texture from resulting texture tile and the same UV coordinates.+So, when the engine rendered a face with texture marked as //bump-mapped//, it rendered the original texture first, then it jumped to the texture atlas //plus the number of bump-mapped texture atlases//, and rendered one more texture pass on this face using the texture from the resulting texture atlas and the same UV coordinates.
  
 {{anchor:tr4_object_texture}} {{anchor:tr4_object_texture}}
Line 106: Line 111:
 { {
     uint16_t               Attribute;     uint16_t               Attribute;
-    uint16_t               TileAndFlag;+    uint16_t               AtlasAndFlag;
     uint16_t               NewFlags;     uint16_t               NewFlags;
  
Line 119: Line 124:
 ''%%NewFlags%%'' is a bit field with flags: ''%%NewFlags%%'' is a bit field with flags:
  
-  * **Bits 0..2** — Mapping correction. It seems that these bits change the way the texture is applied+  * **Bits 0..2** — Mapping correction. This value is used by internal ''AdjustUV'' function which crops the texture in specific way to prevent //border bleeding issue// happening because of texture atlas packingValue meaning depends on texture face type (triangle or quad). For quads, only types ''0'' and ''1'' are actually used (''0'' being normal and ''1'' being mirrored quad texture), while other types (2-7) produce same result as 0. For triangles, all possible values (0-7) are used for each possible right triangle type (including mirrored coordinates): 
-  * **Bits 11..12** — Specifies bump mapping level (see above), so can be either ''%%00 = 0%%'' (no bump mapping), ''%%01 = 1%%'' (level 1) or ''%%10 = 2%%'' (level 2).+ 
 +|{{:illustrations:mapping-correction.png?nolink|illustrations/mapping-correction.png}}| 
 +|//Triangle mapping correction types. Orange shapes indicate normal (non-mirrored) texture coordinates, while blue shapes indicate mirrored ones. Mirrored coordinates mean that they are placed in counterclockwise order.//| 
 + 
 +  * **Bits 9..10** — Specifies bump mapping level (see above), so can be either ''%%00 = 0%%'' (no bump mapping), ''%%01 = 1%%'' (level 1) or ''%%10 = 2%%'' (level 2).
   * **Bit 15** — If set, the texture is for a triangle/quad from a room geometry. If not set, the texture is for a static mesh or model.   * **Bit 15** — If set, the texture is for a triangle/quad from a room geometry. If not set, the texture is for a static mesh or model.
  
Line 225: Line 234:
 ''%%Flags%%'' is an array of bit flags specifying different camera options: ''%%Flags%%'' is an array of bit flags specifying different camera options:
  
-  * **Bit 0** — Make a cut to flyby from Lara camera position. Without it, it’ll pan smoothly. +^ Hex ^ Bit ^ Description ^ 
-  * **Bit 1** — {{:icons:tr4.png?nolink|TR4 only}} Tracks specified entity position (from ''%%Entities[]%%'' array). {{:icons:tr5.png?nolink|TR5 only}} Creates a vignette around the picture, giving impression of "subjective" camera. +^  ''0x0001'' ^  Make a cut to flyby from Lara camera position. Without it, it’ll pan smoothly. | 
-  * **Bit 2** — Infinitely loop sequence. +^  ''0x0002'' {{:icons:tr4.png?nolink|TR4 only}} Tracks specified entity position (from ''%%Entities[]%%'' array). 
-  * **Bit 3** — //Used only with first camera in a sequence:// whole sequence is treated merely as a camera “rails”, and camera itself focuses on Lara, thus creating “tracking” camera. Best example is “tracking” view in ''%%ALEXHUB2.TR4%%'', rooms #23 and #31. +^ ::: ^ ::: | {{:icons:tr5.png?nolink|TR5 only}} Creates a vignette around the picture, giving impression of "subjective" camera. | 
-  * **Bit 4** — {{:icons:tr4.png?nolink|TR4 only}} Camera focuses on Lara’s last head position. {{:icons:tr5.png?nolink|TR5 only}} For TR5, this flag is now used to hide Lara for this camera. +^  ''0x0004'' Infinitely loop sequence. | 
-  * **Bit 5** — Camera continuously focuses on Lara’s head, overriding own angle. +^  ''0x0008'' //Used only with first camera in a sequence:// whole sequence is treated merely as a camera “rails”, and camera itself focuses on Lara, thus creating “tracking” camera. Best example is “tracking” view in ''%%ALEXHUB2.TR4%%'', rooms #23 and #31. | 
-  * **Bit 6** — //Used only with last camera in a sequence:// camera smoothly pans back to Lara camera position. +^  ''0x0010'' {{:icons:tr4.png?nolink|TR4 only}} Camera focuses on Lara’s last head position. 
-  * **Bit 7** — When flyby arrives to this position, cuts to specific camera in same sequence. Next camera number is specified in //Timer// field of this camera. +^ ::: ^ ::: | {{:icons:tr5.png?nolink|TR5 only}} For TR5, this flag is now used to hide Lara for this camera. | 
-  * **Bit 8** — Stops camera movement for a given time (see //Timer// field). +^  ''0x0020'' Camera continuously focuses on Lara’s head, overriding own angle. | 
-  * **Bit 9** — Disables look keypress breakout. +^  ''0x0040'' //Used only with last camera in a sequence:// camera smoothly pans back to Lara camera position. | 
-  * **Bit 10** — Disables all Lara controls //for all next camera points//. Also engages //widescreen bars// to create cinematic feel. +^  ''0x0080'' When flyby arrives to this position, cuts to specific camera in same sequence. Next camera number is specified in //Timer// field of this camera. | 
-  * **Bit 11** — Overrides //Bit 10// controls lock, enabling them back. Widescreen bars remain unaffected. +^  ''0x0100'' Stops camera movement for a given time (see //Timer// field). | 
-  * **Bit 12** — {{:icons:tr5.png?nolink|TR5 only}} Make screen fade-in. +^  ''0x0200'' Disables look keypress breakout. | 
-  * **Bit 13** — {{:icons:tr5.png?nolink|TR5 only}} Make screen fade-out. +^  ''0x0400'' 10 Disables all Lara controls //for all next camera points//. Also engages //widescreen bars// to create cinematic feel. | 
-  * **Bit 14** — Camera can activate //heavy triggers//, just like particular kinds of entities (boulders, pushables, etc.). When camera is moving right above heavy trigger sector, it will be activated. +^  ''0x0800'' 11 Overrides //Bit 10// controls lock, enabling them back. Widescreen bars remain unaffected. | 
-  * **Bit 15** — {{:icons:tr5.png?nolink|TR5 only}} TRLE for TR5 says this flag is used to make camera one-shot, but it’s not true. Actual one-shot flag is placed in extra ''%%uint16_t%%'' field at ''%%0x0100%%'' for flyby camera //TrigAction//.+^  ''0x1000'' 12 {{:icons:tr5.png?nolink|TR5 only}} Make screen fade-in. | 
 +^  ''0x2000'' 13 {{:icons:tr5.png?nolink|TR5 only}} Make screen fade-out. | 
 +^  ''0x4000'' 14 Camera can activate //heavy triggers//, just like particular kinds of entities (boulders, pushables, etc.). When camera is moving right above heavy trigger sector, it will be activated. | 
 +^  ''0x8000'' 15 {{:icons:tr5.png?nolink|TR5 only}} TRLE for TR5 says this flag is used to make camera one-shot, but it’s not true. Actual one-shot flag is placed in extra ''%%uint16_t%%'' field at ''%%0x0100%%'' for flyby camera //TrigAction//|
  
 ===== Cinematic Frames ===== ===== Cinematic Frames =====
Line 301: Line 313:
 But the TR series has a more general solution, one that does not require palettes to have colour ramps. It uses precalculated lighting tables, the ''%%ColourMap%%'' objects. These contain translations of a colour value and a lighting value, listed by palette index. The translation goes as follows: But the TR series has a more general solution, one that does not require palettes to have colour ramps. It uses precalculated lighting tables, the ''%%ColourMap%%'' objects. These contain translations of a colour value and a lighting value, listed by palette index. The translation goes as follows:
  
-''%%n = ColourMap[256 k + i];%%'' +$n = ColourMap[256 \cdot k + i]$
- +
-where ''%%i%%'' is the original palette index, ''%%k%%'' is determined from the lighting value, and ''%%n%%'' is the new palette index. The lighting index ''%%k%%'' varies from 0 to 31, and the corresponding lighting value is, <color red>for TR1</color>, +
- +
-''%%2 - k / 16%%'' +
- +
-and for TR2 and TR3,+
  
-''%%2 - (k + 1) / 16%%''+where $i$ is the original palette index, $k$ is determined from the lighting value, and $n$ is the new palette index. The lighting index $k$ varies from $0$ to $31$, and the corresponding lighting value is $2 - k / 16$ for TR1 and $2 - (k + 1) / 16$ for TR2 and TR3.
  
-This may be associated with the curious fact of the lighting values in the data files increasing in the “wrong” direction in TR1 and TR2, with 0 being full brightness and greater values being darker.+This may be associated with the curious fact of the lighting values in the data files increasing in the “wrong” direction in TR1 and TR2, with $0being full brightness and greater values being darker.
  
 {{anchor:flipeffects}} {{anchor:flipeffects}}
Line 419: Line 425:
   * ''%%LARA_BUBBLES%%'' — When underwater, emit bubble sound (ID #37) and produce bubble particle for Lara. Position of bubble is linked to model’s last mesh (which is headmesh in case of Lara).   * ''%%LARA_BUBBLES%%'' — When underwater, emit bubble sound (ID #37) and produce bubble particle for Lara. Position of bubble is linked to model’s last mesh (which is headmesh in case of Lara).
   * ''%%FINISH_LEVEL%%'' — Same effect as //TrigAction// ''%%0x07%%'' — immediately loads next level. For TR4, (which requires explicit level index to jump), current level index is increased and passed as level index to jump to.   * ''%%FINISH_LEVEL%%'' — Same effect as //TrigAction// ''%%0x07%%'' — immediately loads next level. For TR4, (which requires explicit level index to jump), current level index is increased and passed as level index to jump to.
-  * ''%%FLIP_MAP%%'' — Equal to [[trs:floordata#trigfunc_0x03|TrigAction ''%%0x03%%'']].+  * ''%%FLIP_MAP%%'' — Equal to [[trs:floordata#trigfunc_0x03|TrigAction ]]''[[trs:floordata#trigfunc_0x03|0x03]]''.
   * ''%%ACTIVATE_CAMERA%%'' — If there is a trigger type //Key// (SubFunction ''%%0x03%%'') being queued at the moment, and there are any //Camera// TrigActions (''%%0x01%%'') present in ''%%ActionList%%'', these TrigActions will be forced to activate at a given frame of //keyhole entity// current animation, rather than at the ending frame of it. Works only for //keyhole entities// which have complex activation animations, not single-frame ones. It can be used to change camera POV before keyhole animation is finished.   * ''%%ACTIVATE_CAMERA%%'' — If there is a trigger type //Key// (SubFunction ''%%0x03%%'') being queued at the moment, and there are any //Camera// TrigActions (''%%0x01%%'') present in ''%%ActionList%%'', these TrigActions will be forced to activate at a given frame of //keyhole entity// current animation, rather than at the ending frame of it. Works only for //keyhole entities// which have complex activation animations, not single-frame ones. It can be used to change camera POV before keyhole animation is finished.
   * ''%%ACTIVATE_KEY%%'' — Same as above, but works for //Object// TrigAction. That is, any entities to be activated from ''%%ActionList%%'' will be activated at a given frame of //keyhole entity// current animation, rather than at the ending frame of it. Can be used to activate entities before actual keyhole animation is finished.   * ''%%ACTIVATE_KEY%%'' — Same as above, but works for //Object// TrigAction. That is, any entities to be activated from ''%%ActionList%%'' will be activated at a given frame of //keyhole entity// current animation, rather than at the ending frame of it. Can be used to activate entities before actual keyhole animation is finished.
Line 475: Line 481:
   * ''%%EXPLOSION_FX%%'' — Plays //global// explosion sound (ID #105) and produce full-screen flash graphical FX (TR3-5) or camera shake effect (TR1-2).   * ''%%EXPLOSION_FX%%'' — Plays //global// explosion sound (ID #105) and produce full-screen flash graphical FX (TR3-5) or camera shake effect (TR1-2).
   * ''%%FLOOD_FX%%'' — Plays //global// flooding sound (TR1 — ID #81, TR2 — ID #79, TR3 — ID #163, TR4 — ID #238). Implementation differs from version to version — in TR1 and TR2 looped waterfall sound is used (which is then stopped by an engine after 1 second), while in TR3 and TR4 one-shot sound is engaged.   * ''%%FLOOD_FX%%'' — Plays //global// flooding sound (TR1 — ID #81, TR2 — ID #79, TR3 — ID #163, TR4 — ID #238). Implementation differs from version to version — in TR1 and TR2 looped waterfall sound is used (which is then stopped by an engine after 1 second), while in TR3 and TR4 one-shot sound is engaged.
 +  * ''%%FOOTPRINT_FX%%'' — Plays random footprint sound effect, taking current block's **material index** into consideration. On PlayStation, also applies footprint sprite under left or right Lara foot (target foot is selected based on packed flag which is stored in animcommand argument — [[trs:mesh_construction_animation#animcommand-structure|look here]] for details).
  
  
trs/miscellany.1496590815.txt.gz · Last modified: 2017/06/04 15:40 by zdimension
Back to top
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0