Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
trs:fundamentals [2017/11/17 12:17]
stohrendorf
trs:fundamentals [2019/08/09 07:50] (current)
stohrendorf [32-bit Texture Tile]
Line 103: Line 103:
 ==== Textures ==== ==== Textures ====
  
-//​Textured//​ surfaces map textures ​(bitmapped images) ​from the texture ​tiles (textiles) to each point on the mesh surface. This is done using conventional UV mapping, which is specified in “Object Textures” below; each object texture specifies a mapping from a set of vertices to locations in the textile, and these texture vertices are associated with position vertices specified here. Each textile is a 256x256 pixels ​wide area.+//​Textured//​ surfaces map textures from the texture ​atlases ​(textiles) to each point on the mesh surface. This is done using conventional UV mapping, which is specified in “Object Textures” below; each object texture specifies a mapping from a set of vertices to locations in an atlas, and these texture vertices are associated with position vertices specified here. Each atlas has size of 256x256 pixels.
  
-The 16-bit ​textile ​array, which contains [[fundamentals#​tr_textile16|[tr_textile16]]] structures, specifies colours using 16-bit ​ARGB, where the highest bit (''​%%0x8000%%''​) is a crude alpha channel (really just simple transparency — //​0 = transparent//,​ //= opaque//). The next bits (''​%%0x7C00%%''​) specify the red channel, the next bits (''​%%0x03E0%%''​) specify the green channel, and the last bits (''​%%0x001F%%''​) specify the blue channel, each on a scale from 0..31.+The 16-bit ​atlas array, which contains [[fundamentals#​tr_image16|[tr_image16]]] structures, specifies colours using 16-bit 1-5-5-ARGB encoding.
  
 {{:​icons:​tr1.png?​nolink|TR1 only}}{{:​icons:​tr2.png?​nolink|TR2 only}}{{:​icons:​tr3.png?​nolink|TR3 only}} If, for some reason, 16-bit textures are turned off, all colours and textures use an 8-bit palette that is stored in the level file. This palette consists of a 256-element array of [[fundamentals#​tr_colour|[tr_colour]]] structures, each designating some colour; textures and other elements that need to reference a colour specify an index (0..255) into the ''​%%Palette[]%%''​ array. There is also a 16-bit palette, which is used for identifying colours of solid polygons. The 16-bit palette contains up to 256 four-byte entries; the first three bytes are a [[fundamentals#​tr_colour|[tr_colour]]],​ while the last byte is ignored (set to 0). {{:​icons:​tr1.png?​nolink|TR1 only}}{{:​icons:​tr2.png?​nolink|TR2 only}}{{:​icons:​tr3.png?​nolink|TR3 only}} If, for some reason, 16-bit textures are turned off, all colours and textures use an 8-bit palette that is stored in the level file. This palette consists of a 256-element array of [[fundamentals#​tr_colour|[tr_colour]]] structures, each designating some colour; textures and other elements that need to reference a colour specify an index (0..255) into the ''​%%Palette[]%%''​ array. There is also a 16-bit palette, which is used for identifying colours of solid polygons. The 16-bit palette contains up to 256 four-byte entries; the first three bytes are a [[fundamentals#​tr_colour|[tr_colour]]],​ while the last byte is ignored (set to 0).
  
-{{:​icons:​tr4.png?​nolink|TR4 only}}{{:​icons:​tr5.png?​nolink|TR5 only}} The 32-bit ​textile ​array, which contains [[fundamentals#​tr4_textile32|[tr4_textile32]]] structures, specifies colours using 32-bit ARGB, where the highest byte (A) is unused. The next bytes specify (in this order) the red / green / blue channels. The 16-bit and 32-bit ​textile ​arrays depict the same graphics data, but of course the 32-bit array has a better colour resolution. It’s the one used if you select a 32-bit A8R8G8B8 texture format in the setup menu from TR4 and TR5.+{{:​icons:​tr4.png?​nolink|TR4 only}}{{:​icons:​tr5.png?​nolink|TR5 only}} The 32-bit ​texture atlas array, which contains [[fundamentals#​tr4_image32|[tr4_image32]]] structures, specifies colours using 32-bit ARGB, where the alpha channel ​is unused. The 16-bit and 32-bit ​texture atlas arrays depict the same graphics data, but of course the 32-bit array has a better colour resolution. It’s the one used if you select a 32-bit A8R8G8B8 texture format in the setup menu from TR4 and TR5.
  
 ==== Meshes and Sprites ==== ==== Meshes and Sprites ====
Line 299: Line 299:
 {{anchor:​tr_textile8}} {{anchor:​tr_textile8}}
 <code cpp> <code cpp>
-struct ​tr_textile8 ​   // 65536 bytes+struct ​tr_image8 ​   // 65536 bytes
 { {
-    uint8_t ​Tile[256 * 256];+    uint8_t ​pixels[256 * 256];
 }; };
 </​code>​ </​code>​
 ==== 16-bit Texture Tile ==== ==== 16-bit Texture Tile ====
  
-Each ''​%%uint16_t%%''​ represents a pixel whose colour is of the form ARGBMSB-to-LSB:+Each ''​%%uint16_t%%''​ represents a pixel, ​encoded as 1-5-5-5 ARGB.
  
-1-bit transparency (''​%%0%%''​ = transparent,​ ''​%%1%%''​ = opaque) (''​%%0x8000%%''​)\\ +{{anchor:tr_image16}}
-5-bit red channel (''​%%0x7C00%%''​)\\ +
-5-bit green channel (''​%%0x03E0%%''​)\\ +
-5-bit blue channel (''​%%0x001F%%''​) +
- +
-{{anchor:tr_textile16}}+
 <code cpp> <code cpp>
-struct ​tr_textile16 ​   // 131072 bytes+struct ​tr_image16 ​   // 131072 bytes
 { {
-    uint16_t ​Tile[256 * 256];+    uint16_t ​pixels[256 * 256];
 }; };
 </​code>​ </​code>​
 ==== 32-bit Texture Tile ==== ==== 32-bit Texture Tile ====
  
-Each ''​%%uint32_t%%''​ represents a pixel whose colour is of the form ARGB, (A = most significant byte), each component being one byte.+Each ''​%%uint32_t%%''​ represents a pixel encoded in ARGB8.
  
 {{anchor:​tr4_textile32}} {{anchor:​tr4_textile32}}
 <code cpp> <code cpp>
-struct ​tr4_textile32 ​   // 262144 bytes+struct ​tr4_image32 ​   // 262144 bytes
 { {
-    uint32_t ​Tile[256 * 256];+    uint32_t ​pixels[256 * 256];
 }; };
 </​code>​ </​code>​
  
trs/fundamentals.1510917428.txt.gz · Last modified: 2017/11/17 12:17 by stohrendorf
Back to top
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0