Difference between revisions of "Textureinformation Crash 2/3"

From Crash Bandicoot Hacking Wiki
Jump to navigation Jump to search
m (Introduction)
(Extended information)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
In Crash 2/3, ''textureinformation'' contains information about a 3D model's UV coordinates, (animated) textures and colorpalettes. This information is stored in 12-byte structures in the 4th item of scenery and modelentries. The textureinformation can also be used by ''<nowiki/>'extended information''', which is stored in the 7th item in sceneryentries or the 5th item in modelentries. Extended information can loop through multiple 12-byte structures to make animated textures, or provide settings for textures with different LOD's (Levels of Detail).
+
In Crash 2/3, ''texture information'' contains information about a 3D model's UV coordinates, (animated) textures and colorpalettes. The ''texture information'' can also be used by ''<nowiki/>'extended information''' . Extended information can loop through multiple 12-byte structures to make animated textures, or provide settings for textures with different LOD's (Levels of Detail).
  
== Textureinformation ==
+
== Texture information ==
The format for the 12-byte structure consists of 3 consequent 32-bit integers and is as follows:
+
Texture information information is stored in 12-byte structures in the 4th item of scenery and model entries. The format for the 12-byte structure consists of 3 consequent 32-bit integers and is as follows:
  
 
'''YYYYYYYY YYYYXXXX BBBBBBBB AAAAAAAA'''
 
'''YYYYYYYY YYYYXXXX BBBBBBBB AAAAAAAA'''
  
'''TTTTTTTT FCC0SSSS DDDDDDDD CCCCCCCC'''
+
'''TTTTTTTT FMM0SSSS DDDDDDDD CCCCCCCC'''
  
 
'''HHHHHHHH GGGGGGGG FFFFFFFF EEEEEEEE'''   
 
'''HHHHHHHH GGGGGGGG FFFFFFFF EEEEEEEE'''   
Line 15: Line 15:
 
'''<u>AAAAAAAA</u>'''
 
'''<u>AAAAAAAA</u>'''
  
for triangle type “AA” and “BB”, mapping point 3 x
+
Model entry: for triangle type “AA” and “BB”, UV point 3 x, for triangle type “CC”, UV point 1 x
  
for triangle type “CC”, mapping point 1 x
+
Scenery entry: UV point 1 x
  
 
'''<u>BBBBBBBB</u>'''
 
'''<u>BBBBBBBB</u>'''
  
for triangle type “AA” and “BB”, mapping point 3 y
+
Model entry: for triangle type “AA” and “BB”, UV point 3 y, for triangle type “CC”, UV point 1 y
  
for triangle type “CC”, mapping point 1 y
+
Scenery entry: UV point 1 y
  
 
<u>XXXX</u>  
 
<u>XXXX</u>  
Line 31: Line 31:
 
'''<u>YYYYYYYYYYYY</u>'''
 
'''<u>YYYYYYYYYYYY</u>'''
  
<nowiki> </nowiki>CLUT-line origin y coordinate
+
CLUT-line origin y coordinate
  
 
The origin [x,y] for the CLUT-line is placed in a 16-bit interpretation of the texturechunk.
 
The origin [x,y] for the CLUT-line is placed in a 16-bit interpretation of the texturechunk.
Line 41: Line 41:
 
'''<u>CCCCCCCC</u>'''
 
'''<u>CCCCCCCC</u>'''
  
 mapping point 2 x
+
 Scenery/model entry: UV point 2 x
  
 
'''<u>DDDDDDDD</u>'''
 
'''<u>DDDDDDDD</u>'''
  
 mapping point 2 y
+
 Scenery/model entry: UV point 2 y
  
 
'''<u>F</u> '''
 
'''<u>F</u> '''
Line 51: Line 51:
 
Flag determined to define a 8 or 4-bit texture. 0 = 4-bit, 1 = 8-bit.
 
Flag determined to define a 8 or 4-bit texture. 0 = 4-bit, 1 = 8-bit.
  
'''<u>CC</u>'''
+
'''<u>MM</u>'''
 
 
<nowiki> </nowiki>Colormode.
 
0 = translucent face
 
1 = additive face
 
2 = subtractive face
 
3 = standard face
 
  
 +
The colormode instructs how the texture should interpret the CLUT-colors (formatted as 'SBBBBBGGGGGRRRRR').
 +
{| class="article-table"
 +
!Colormode
 +
!RGBA if 'S' = 1
 +
!RGBA if 'S' = 0
 +
|-
 +
|0 (translucent face)
 +
|A = 50%
 +
|if [R,G,B] = [0,0,0]  A = 0% else A = 100%
 +
|-
 +
|1 (additive face)
 +
|A = 50%
 +
|if [R,G,B] = [0,0,0]  A = 0% else A = 100%
 +
|-
 +
|2 (subtractive face)
 +
|A = 0%
 +
|if [R,G,B] = [0,0,0]  A = 0% else A = 100%
 +
|-
 +
|3 (standard/opaque face)
 +
|A = 0%
 +
|if [R,G,B] = [0,0,0]  A = 0% else A = 100%
 +
|}
 
'''<u>0</u>'''
 
'''<u>0</u>'''
  
Line 84: Line 100:
 
- 256 x 128
 
- 256 x 128
  
The segment index refers to the origin of the segment. The
+
The segment index refers to the origin of the segment. The UV points work relative from this origin. Note that the values of the UV points are not effected by 8- or 4-bit mode. The x,y values range from
mapping points work relative from this origin. Note that the values of the
 
mapping points are not effected by 8- or 4-bit mode. The x,y values range from
 
 
0 to 255 and are fixed.
 
0 to 255 and are fixed.
  
 
'''<u>TTTTTTTT</u>'''
 
'''<u>TTTTTTTT</u>'''
  
 refers to an offset from 0x0C in the header, for which textureslot to use (0-7 (i.e. 0x0 – 0x40 ) )
+
 Model entry: refers to an offset from 0x0C in the header, for which textureslot to use (0-7 (i.e. 0x0 – 0x40 ) )
 +
 
 +
 Scenery entry: refers to an offset from 0x2C in the header, for which textureslot to use (0-7 (i.e. 0x0 – 0x40 ) )
  
 
'''<u>EEEEEEEE</u>'''
 
'''<u>EEEEEEEE</u>'''
  
for triangle type “AA” and “BB”, mapping point 1 x
+
Model entry: for triangle type “AA” and “BB”, UV point 1 x, for triangle type “CC”, UV point 3 x
  
for triangle type “CC”, mapping point 3 x
+
Scenery/model entry: UV point 3 x
  
 
'''<u>FFFFFFFF</u>'''
 
'''<u>FFFFFFFF</u>'''
  
for triangle type “AA” and “BB”, mapping point 1 y
+
Model entry: for triangle type “AA” and “BB”, UV point 1 y, for triangle type “CC”, UV point  3 y
 
 
for triangle type “CC”, mapping point  3 y
 
  
'''scenery quads only:'''
+
Scenery/model entry: UV point 3 y
  
 
'''<u>GGGGGGGG</u> '''
 
'''<u>GGGGGGGG</u> '''
  
mapping point  4 y
+
Scenery entry: UV point  4 y (applies to quads only)
  
 
'''<u>HHHHHHHH</u> '''
 
'''<u>HHHHHHHH</u> '''
  
mapping point  4 x
+
Scenery entry: UV point  4 x (applies to quads only)
 +
 
 +
== Extended information ==
 +
Extended information is in the 7th item in scenery entries and/or the 5th item in model entries. It is stored as 32-bit integers and can have 2 different formats according to flag 'F':
 +
 
 +
'''F???????? ???????? ?????OOO OOOOOOOO'''
 +
 
 +
<u>'''OOOOOOOOOOO'''</u>
 +
 
 +
Starting offset (in 12-byte structures) in the item for ''texture information''. Keep in mind the first normal texture structure is indexed by 1, not 0, while the first extended texture structure is indexed by 0.
 +
 
 +
=== Texture information with LOD ===
 +
If flag 'F' is set, the extended information will serve as ''texture information'' with 8 customizable LOD-settings according to camera distance, ranging from close (AA) to further away (II).
 +
 
 +
'''1AABBCCDDE EFFGGHH0 00000OOO OOOOOOOO'''
 +
 
 +
'''<u>AA, BB, CC, DD, EE, FF, GG, HH</u>'''
 +
 
 +
LOD-settings. Since each texture has a maximum of 4 LOD's (respectively from hi- to lo-res), each one of these 8 settings can be set from 00 (hi-res) to II (lo-res) in binary.
 +
 
 +
'''<u>000000</u>'''
 +
 
 +
Unused?
 +
 
 +
=== Animated texture information ===
 +
If flag 'F' is not set, the extended information will serve as ''animated'' ''texture information. ''The LOD-distances are standardized. This extended information will define a ''128-frame loop''  ranging from 0 to 127, starting at the ''starting offset''.
 +
 
 +
'''0SSSSSDD DDDDDMMM MMMMLOOO OOOOOOOO'''
 +
 
 +
'''<u>MMMMMMM</u>'''
 +
 
 +
Loopmask. Each frame in the 128-sized loop will be masked by this value. For example, a value of 0x3 would result in a subloop of 4 frames that is repeated 32 times within the 128 frame-sized loop:
 +
{| class="article-table"
 +
!Frame index (bin)
 +
!Loopmask (bin)
 +
!Step/played texture information (bin)
 +
|-
 +
|0000000
 +
|0000011
 +
|Starting offset + 00
 +
|-
 +
|0000001
 +
|0000011
 +
|Starting offset + 01
 +
|-
 +
|0000010
 +
|0000011
 +
|Starting offset + 10
 +
|-
 +
|0000011
 +
|0000011
 +
|Starting offset + 11
 +
|-
 +
|0000100
 +
|0000011
 +
|Starting offset + 00
 +
|-
 +
|0000101
 +
|0000011
 +
|Starting offset + 01
 +
|-
 +
|0000110
 +
|0000011
 +
|Starting offset + 10
 +
|-
 +
|0000111
 +
|0000011
 +
|Starting offset + 11
 +
|-
 +
|.........
 +
|.........
 +
|.........
 +
|-
 +
|.........
 +
|.........
 +
|.........
 +
|-
 +
|1111110
 +
|0000011
 +
|Starting offset + 10
 +
|-
 +
|1111111
 +
|0000011
 +
|Starting offset + 11
 +
|}
 +
There is a great variety of loops to be made with this mechanism.
 +
 
 +
'''<u>DDDDDDD</u>'''
 +
 
 +
Initial delay: The 128-frame texture loop will be offset by this value.
 +
 
 +
'''<u>SSSSS</u>'''
 +
 
 +
Animation speed: Extra frame delay between each animation frame. A value of 0 means the texture animates every [1st] frame, a value of 1 means every 2nd (1 + 1) frame, a value of 2 means every 3rd (1 + 2) frame, etc.
 +
 
 +
'''<u>L</u>'''
 +
 
 +
LOD flag: when set, this flag makes the offset refer to another 32-bit structure inside the 7th item in scenery or the 5th item in models. The eventual texture will be a LOD-type extended texture. This can be used to give a LOD to an animated texture.
 +
[[Category:Crash 2/3]]

Latest revision as of 20:37, 29 December 2019

Introduction

In Crash 2/3, texture information contains information about a 3D model's UV coordinates, (animated) textures and colorpalettes. The texture information can also be used by 'extended information' . Extended information can loop through multiple 12-byte structures to make animated textures, or provide settings for textures with different LOD's (Levels of Detail).

Texture information

Texture information information is stored in 12-byte structures in the 4th item of scenery and model entries. The format for the 12-byte structure consists of 3 consequent 32-bit integers and is as follows:

YYYYYYYY YYYYXXXX BBBBBBBB AAAAAAAA

TTTTTTTT FMM0SSSS DDDDDDDD CCCCCCCC

HHHHHHHH GGGGGGGG FFFFFFFF EEEEEEEE

The contents represent the following:

AAAAAAAA

Model entry: for triangle type “AA” and “BB”, UV point 3 x, for triangle type “CC”, UV point 1 x

Scenery entry: UV point 1 x

BBBBBBBB

Model entry: for triangle type “AA” and “BB”, UV point 3 y, for triangle type “CC”, UV point 1 y

Scenery entry: UV point 1 y

XXXX

CLUT-line origin x coordinate (CLUT: Color LookUp Table, contain the colors for a specific texture)

YYYYYYYYYYYY

CLUT-line origin y coordinate

The origin [x,y] for the CLUT-line is placed in a 16-bit interpretation of the texturechunk.

4-bit textures can have 2^4 = 16 different colors. Therefore the corresponding CLUT-line should always be 16 pixels long (in 16-bit!).

8-bit textures can have 2^8 = 256 different colors. Therefore the corresponding CLUT-line should always be 256 pixels long (in 16-bit!).

CCCCCCCC

 Scenery/model entry: UV point 2 x

DDDDDDDD

 Scenery/model entry: UV point 2 y

F

Flag determined to define a 8 or 4-bit texture. 0 = 4-bit, 1 = 8-bit.

MM

The colormode instructs how the texture should interpret the CLUT-colors (formatted as 'SBBBBBGGGGGRRRRR').

Colormode RGBA if 'S' = 1 RGBA if 'S' = 0
0 (translucent face) A = 50% if [R,G,B] = [0,0,0] A = 0% else A = 100%
1 (additive face) A = 50% if [R,G,B] = [0,0,0] A = 0% else A = 100%
2 (subtractive face) A = 0% if [R,G,B] = [0,0,0] A = 0% else A = 100%
3 (standard/opaque face) A = 0% if [R,G,B] = [0,0,0] A = 0% else A = 100%

0

Unused?

SSSS

Texturechunk segment index (0, 1, 2 or 3)

Each texturechunk in the original Crash games consists out of 4 segments.

The 16-bit size of a texturechunk is 256 x 128

The 8-bit size of a texturechunk is 512 x 128

The 4-bit size of a texturechunk is 1024 x 128

Therefore, the segments in 16-, 8- and 4-bit mode are respectively:

- 64 x 128,

- 128 x 128

- 256 x 128

The segment index refers to the origin of the segment. The UV points work relative from this origin. Note that the values of the UV points are not effected by 8- or 4-bit mode. The x,y values range from 0 to 255 and are fixed.

TTTTTTTT

 Model entry: refers to an offset from 0x0C in the header, for which textureslot to use (0-7 (i.e. 0x0 – 0x40 ) )

 Scenery entry: refers to an offset from 0x2C in the header, for which textureslot to use (0-7 (i.e. 0x0 – 0x40 ) )

EEEEEEEE

Model entry: for triangle type “AA” and “BB”, UV point 1 x, for triangle type “CC”, UV point 3 x

Scenery/model entry: UV point 3 x

FFFFFFFF

Model entry: for triangle type “AA” and “BB”, UV point 1 y, for triangle type “CC”, UV point  3 y

Scenery/model entry: UV point 3 y

GGGGGGGG

Scenery entry: UV point  4 y (applies to quads only)

HHHHHHHH

Scenery entry: UV point  4 x (applies to quads only)

Extended information

Extended information is in the 7th item in scenery entries and/or the 5th item in model entries. It is stored as 32-bit integers and can have 2 different formats according to flag 'F':

F???????? ???????? ?????OOO OOOOOOOO

OOOOOOOOOOO

Starting offset (in 12-byte structures) in the item for texture information. Keep in mind the first normal texture structure is indexed by 1, not 0, while the first extended texture structure is indexed by 0.

Texture information with LOD

If flag 'F' is set, the extended information will serve as texture information with 8 customizable LOD-settings according to camera distance, ranging from close (AA) to further away (II).

1AABBCCDDE EFFGGHH0 00000OOO OOOOOOOO

AA, BB, CC, DD, EE, FF, GG, HH

LOD-settings. Since each texture has a maximum of 4 LOD's (respectively from hi- to lo-res), each one of these 8 settings can be set from 00 (hi-res) to II (lo-res) in binary.

000000

Unused?

Animated texture information

If flag 'F' is not set, the extended information will serve as animated texture information. The LOD-distances are standardized. This extended information will define a 128-frame loop ranging from 0 to 127, starting at the starting offset.

0SSSSSDD DDDDDMMM MMMMLOOO OOOOOOOO

MMMMMMM

Loopmask. Each frame in the 128-sized loop will be masked by this value. For example, a value of 0x3 would result in a subloop of 4 frames that is repeated 32 times within the 128 frame-sized loop:

Frame index (bin) Loopmask (bin) Step/played texture information (bin)
0000000 0000011 Starting offset + 00
0000001 0000011 Starting offset + 01
0000010 0000011 Starting offset + 10
0000011 0000011 Starting offset + 11
0000100 0000011 Starting offset + 00
0000101 0000011 Starting offset + 01
0000110 0000011 Starting offset + 10
0000111 0000011 Starting offset + 11
......... ......... .........
......... ......... .........
1111110 0000011 Starting offset + 10
1111111 0000011 Starting offset + 11

There is a great variety of loops to be made with this mechanism.

DDDDDDD

Initial delay: The 128-frame texture loop will be offset by this value.

SSSSS

Animation speed: Extra frame delay between each animation frame. A value of 0 means the texture animates every [1st] frame, a value of 1 means every 2nd (1 + 1) frame, a value of 2 means every 3rd (1 + 2) frame, etc.

L

LOD flag: when set, this flag makes the offset refer to another 32-bit structure inside the 7th item in scenery or the 5th item in models. The eventual texture will be a LOD-type extended texture. This can be used to give a LOD to an animated texture.