OBD talk:TXMP: Difference between revisions

From OniGalore
Jump to navigation Jump to search
No edit summary
Line 294: Line 294:


[[User:Paradox-01|Paradox-01]] 19:40, 17 July 2008 (CEST)
[[User:Paradox-01|Paradox-01]] 19:40, 17 July 2008 (CEST)
05 = 04 + 01
50 = 40 + 10
All flag values are powers of 2 and they can be combined by addition. For example if you want to disable both U and V wrapping you need to use 0x04 + 0x08 = 0x0C.
[[User:Neo|Neo]]


===0x90===
===0x90===

Revision as of 17:46, 17 July 2008

Complete and accurate knowledge on the TXMP format is badly needed.
For one thing, incomplete/inaccurate knowledge may be a reason why repacking (with OUP) fails.
Also, import and export lack a few features (alpha, env maps) and may get colors slightly wrong.
Basically, the incomplete/inaccurate information is related to the three bytes below, and to the associated RAW/SEP formats.
One not-too-comfortable aspect is that apparently contradictory settings for the 3 bytes are somehow interpreted by Oni.
geyser 21:09, 3 February 2007 (CET)


MIP mapping (MIP stands for "multum in parvo")
A texture mapping technique that uses multiple texture maps, or MIP maps. Each MIP map is half the size of the first one, providing several texture maps for various levels of depth.
Alpha blending
In computer graphics, the combining of the alpha channel with other layers in an image in order to show translucency.
The alpha channel is an additional eight bits used with each pixel in a 32-bit graphics system that can represent 256 levels of translucency.
(here, the base color depth is 16 bits; and there are only 4 bits for the alpha channel, so only 16 levels of transparency. geyser)


Bitsets or indices

Store type (0x90)
probably an index
MIP mapping (0x88)
not sure
maybe they are not only MIP mapping options
(in that case almost certainly a set of flags)
Color depth (0x89)
It's not just the color depth
(actually, quite little to do with color depth)
so almost certainly a bitset.

MIP mapping (0x88)

Bitset

0x01
This one "just" turns mip mapping on and off.
For uncompressed pictures, resampling is trivial. ==> They are "pre-resampled". It's not done at runtime.
what about compressed ones.
0x02
unknown
0x04
Disable wrapping for the U coordinate of the texture.
Enabled for skyboxes, animations and pretty much anything else that does not need texture wrapping.
0x08
Disable wrapping for the V coordinate of the texture. See above.
0x10
This one is enabled for env-mapped textures and env maps themselves.
Also enabled for skyboxes?
0x20
used a runtime (marks if a texture name has been allocate for this TXMP or not)
0x40
unknown - animation related
0x80
unknown - animation related, only used by an "electric arc" texture, could mean to play frames of the animation in random order
Anything else?
There aren't so many values: 0, 1, 17, 28. It's hard to decide against an ID.
A bitset does make some sense because both 1 and 17 use MIP mapping...
Well, IMO they're bitsets. I fixed that a long time ago. Ssg 10:59, 13 February 2007 (CET)
You "fixed that" where? I can't see it detailed on OS... geyser 04:05, 6 March 2007 (CET)
Here? Ssg 12:19, 6 March 2007 (CET)
Not that it matters now, but IIRC you had not uploaded that update as of 2007/02/13... geyser 13:41, 6 March 2007 (CET)

Color depth

Actually, the colors are parsed according to the store type.
This one only sets the depth for miscellaneous extras (alpha, env map, etc)
0x01
Used when again?
0x02
Reads the high byte as env map (0x00 is "little", 0xFF is "much")
Sometimes used in conjunction with 5x5x5 textures, i.e. if it really
reads the whole byte, the 3 lower bits will be garbage. Not sure...
0x04
Reads the high byte as alpha (0x00 is transparent, 0xFF is opaque)
0x08
Used when again?
0x10
On if there are 16 bits per uncompressed pixel (color depth etc may vary) ==> no changes ==> Oni reads it directly from the raw file
It appears to me that this bit means that the byte order of texture raw data must be swaped, it does not have anything to do with the number of bits which is encoded in the texture format anyway. Neo
0x20
On if there are 32 bits per uncompressed pixel (color depth etc may vary) (or may they?)
IIRC, that bit is never used in Oni. If you use it, Oni chrashes.
This one appears to be used only at runtime to mark if the texture has been loaded or not (loading basically means to convert the offset to texture data in the raw file to a memory address, that's why Oni crashes if you set this bit, it thinks that the texture is already loaded and it uses the file offset as a memory pointer which is not valid) Neo
0x40
Looks like TXAN looping ON/OFF. Somebody please check somehow ^^
0x80
16 bit blue (?) - only SHIELD use it

The first two bits of the next bitset are used too:

0x01
16 bit alpha (?) - only INVIS use it
0x02
16 bit red (?) - only DAODAN_SHIELD use it Ssg 11:06, 13 February 2007 (CET)

Store type

Data per pixel, uncompressed unless mentioned otherwise

0
(4,4,4) RGB, 4 bits extra (interpreted as alpha or env map blending), equivalent to GL_RGBA4 OpenGL image format
1
(5,5,5) RGB and 1 bit extra, the extra bit is simply ignored, equivalent to GL_RGB5 OpenGL image format
2
(5,5,5) RGB, 1 bit extra (interpreted as alpha or env map blending), equivalent to GL_RGB5_A1 OpenGL image format
8
(8,8,8) RGB, 8 bits extra that are ignored, equivalent to GL_RGB OpenGL image format
9
compressed (four times) (algorithm detailed elsewhere), equivalent to GL_COMPRESSED_RGB_S3TC_DXT1_EXT OpenGL compressed image format
Anything else?
No. Uups... I mean, yes.
The "mac exe" contains the following stuff in the image section (image.c or somthing like that):
rgb555, rgb565, rgba5551, argb1555, argb4444, rgba4444, rgba8888, s3, compressed, i8, i1, i4a4
(r=red, g=green, b=blue, a=alpha, i=intensity; see http://www.cg.tuwien.ac.at/~wimmer/view3dx/TEXUS.html too)




Reloaded

Woohoo, nice clean list for accurate knowledge! Over here!!!

0x88

Bitset (rather large: 18 bits at least) bytes are listed in Little Endian

0x 01 00 00 00

MIP mapping enabled (generations stored in RAW/SEP, used at runtime)
Q: Anything special about MIP mapping of DXT1-compressed pixels?
A: Not really, only the fact that a DXT1-compressed texture must be at least 4x4 pixels in size unlike an uncompressed image that goes down to 1x1 for mipmaps. Neo

0x 02 00 00 00

Q: (sorry) ever used? effect? ^^ geyser
A: There is no texture in any level that uses it. If it is of any use that's only at runtime. Neo

0x 04 00 00 00

U wrapping disabled

0x 08 00 00 00

V wrapping disabled

0x 10 00 00 00

Enabled for env-mapped textures and env maps themselves.
Q: Also enabled for skyboxes? Exact effect? geyser
A: Reseting this bit does not appear to have any effect on env maps or skyboxes and I can't find any trace of its use. Besides it's strange that it is enabled for completly unrelated textures (envmaps and skybox). It seems to be of no use to the game engine. Neo

0x 20 00 00 00

used a runtime (marks if a texture name has been allocated for this TXMP or not) Neo
Q: same question as below for 0x00200000: does the whole bitset get copied "elsewhere" at runtime? geyser
A: See below Neo

0x 40 00 00 00

unknown - animation related Neo
Q: (sorry) exact effect? ^^ geyser
A: Play animation back to back - frames 0 to n then n-1 to 0 Neo

0x 80 00 00 00

Play animation in random order, only used by an "electric arc" texture Neo
With random frame time Alloc

0x 00 01 00 00

Q: Ever used? Effect? ^^ geyser
A: Animation related again, seems to change the time reference for animation. I've seen it used by w1_case texture in level0 which makes sense because you don't want to see 10 falling bullet cases playing the same animation frame. Neo

0x 00 02 00 00

Reads the high byte as env map (0x00 is "little", 0xFF is "much")
Q: Sometimes used in conjunction with store type 1 or 2. 5x5x5 color, 1 bit extra, i.e., if it really reads the whole high byte, the 3 lower bits are garbage then?
A: Not sure about what "lower 3 bits" are you talking about. Probably you are asking if for a GL_RGBA4 texture all the 4 bits of the alpha channel are used. Yes, they are used. For env maps the alpha channel is sort of a "how much reflective is the surface" so it can be more or less reflective. Neo

0x 00 04 00 00

Reads the high byte as alpha (0x00 is transparent, 0xFF is opaque)
Q: Same as above: what if the store type is 1 or 2?
A: The above explanation sounds strange. Most of the textures that use it are GL_RGB5 so there is no alpha channel. However, all the textures (most of them are animations) that use it have a black bakground which becomes transparent at runtime. Neo

0x 00 08 00 00

Q: Ever used? Effect? ^^ geyser
A: There is no texture in any level that uses it. If it is of any use that's only at runtime. Neo
More exactly this changes the alpha blending mode for the texture that uses it. Normally transparency is calculates using the formula
TextureColor * TextureAlpha + ExistingScreenColor * (1 - TextureAlpha)
but when this bit is set blending is done using another formula
TexureColor * TextureAlpha + ExistingScreenColor
The obvious effect of this is that black becomes transparent because adding 0 results in the same color (but note that black is not a special "transparency" color). Most of the textures where this is used don't even have an alpha channel and TextureAlpha is considered to be 1 in those cases so it just adds the TextureColor to the ExistingScreenColor. If you don't realised it already, this is used to make "light sources" like explosions and glares.

0x 00 10 00 00

On if there are 16 bits per uncompressed pixel (color depth etc may vary) ==> no changes ==> Oni reads it directly from the raw file Ssg 11:06, 13 February 2007 (CET)
It appears to me that this bit means that the byte order of texture raw data must be swapped, it does not have anything to do with the number of bits which is encoded in the texture format anyway. Neo
Q: Whom is the swapped data relevant to, then? "Texture format" = "store type"? "Number of bits" = RGB color depth = "store type"? geyser
A: The data from raw file is byte swapped. This is independent of texture format (= store type) which also includes the number of bits used. Neo

0x 00 20 00 00

IIRC, that bit is never used in Oni. If you use it, Oni chrashes. Ssg 11:06, 13 February 2007 (CET)
This one appears to be used only at runtime to mark if the texture has been loaded or not (loading basically means to convert the offset to texture data in the raw file to a memory address, that's why Oni crashes if you set this bit, it thinks that the texture is already loaded and it uses the file offset as a memory pointer which is not valid) Neo
Q: Neo, are you saying Oni writes to the memory-mapped DAT-part of every loaded TXMP? Or is that particular bitset copied "elsewhere"? geyser
A: Yes, it writes to this bitset and in many other places of the DAT file. Links to files are replaced with pointers, offset in the raw data file are replaced with pointers, bitsets are written, "dead" fields or fields that are always 0 and appear to be unused are written to. Neo

0x 00 40 00 00

Looks like TXAN looping ON/OFF. Somebody please check somehow ^^ geyser
Q: (sorry) did anybody "please check somehow"? ^^ geyser

0x 00 80 00 00

16 bit blue (?) - only SHIELD uses it Ssg 11:06, 13 February 2007 (CET)
Q: ??? geyser

0x 00 00 01 00

16 bit alpha (?) - only INVIS uses it Ssg 11:06, 13 February 2007 (CET)
Q: ??? geyser

0x 00 00 02 00

16 bit red (?) - only DAODAN_SHIELD uses it Ssg 11:06, 13 February 2007 (CET)
Q: ??? geyser
To the last 3 entries: F.e. the SHIELD in ONI is blue. If you disable the "blue bit" and enable the "red bit" you'll get a red shield. If you disable the "blue bit" and enable no other "colour bit", you'll get a white shield, because IIRC, the hex data of the texture is fully FFFF. Ssg 12:35, 6 March 2007 (CET)
Neo, what say you? Ssg: thanks a lot, but... no "green" bit? geyser 13:44, 6 March 2007 (CET)
A: I haven't looked at this but from your story it seems correct. I can add that Open GL has 4 texture formats GL_RED, GL_GREEN, GL_BLUE and GL_ALPHA which can be used to implement the above behavior. Neo
Update. I've tried those last three for Konoko's asspelvis (GL_RGB5). The effect is interesting.
The RGB colors of the basic texture are retained, but they are blended with a randomly moving pattern.
Pattern varies smoothly in both space and time, and is apparently multiplied by the RGB data, with different weights for the 3 channels.
  • "blue bit" favors the blue channel (but the others are still there)
  • "red bit" favors the red channel (but the others are still there)
  • "alpha bit" just makes the whole color much darker (i.e., the phase cloak is actually "black")
In other words, the "INVIS" bit has nothing to do with alpha; rather it's a "black bit"
(transparence of various cloaks/shields is dynamic/hardcoded anyway)
Those 3 work the same for GL_RGB5 (pelvis), GL_RGBA4 (chest, head) and GL_RGB5_A1 (shoulders).
The alpha/envmap channel (if any) seems irrelevant (note that SHIELD, INVIS and DAODAN_SHIELD have no alpha)
I assume those bits don't affect the way the RGBA data is read from the RAW/SEP.
All 3 "effects" seem to be ignored for environment/skybox/object texturing: tried with several available store types.
They correspond to hard-coded eye candy, specially designed for shields, phase cloaks and boss shields.
Overlaid with regular textures, they create funky/spooky blue, black or red colorization, respectively.
We could thus call them AO-bit, KURO-bit and AKA-bit, respectively. ^^
geyser 02:33, 7 March 2007 (CET)
These bits have no effect on the texture itself but the colors of the 3D model to which the texture is applied. Each point gets a color based on current time and some coefficients for each color component. For example for invisibility green has 0.15, blue has 0.3 and red 0. Neo

0x88, a few more flags

50 00 - ? 05 00 - ? 09 00 - ? 0C 00 - ? 0D 00 - ? 00 50 - ? 00 05 - ?


05 14 - contrail4444, gradient, laser_contrail, w11_contrail, w12_contrail

09 10 - barab_swave_tex, blast_ring1_texture, blast_ring2_texture, bomb_swave_tex, w11_granade_tex, blast1_tex

09 14 - glow01_tex

0C 10 - Oni_startup_0 .. 5, fail01_0 .. fail03_5, splashscreen_0 .. 5, options_0 .. 5, oni_kanji_0 .. 5 (level 0), level01_win_1 .. 5 (level1), .. (should be the same)

0D 10 - ROTORBLADES (with TXAN link), WH_DCTRBND (no TXAN link), barab_shock (no TXAN link), shadow1 (no TXAN link), target01 .. target9C (no TXAN link), toxic_bubble_tex, wind02, wind03

0D 11 - (all with TXAN link) bomb_smoke, roach

0D 14 - arrow (with TXAN link), bomb_wind (no TXAN link), cloud01 (with TXAN link), bomb_flash (no TXAN link), bomb_flotsam (no TXAN link), count1, count2, count3 (no TXAN link, shown before bomber guy explodes), glowtex_ammo _cell hypo _invis _lsi shield (no TXAN link), h2h_ball (no TXAN link), h2h_haymaker (no TXAN link), h2h_konflash (no TXAN link), h2h_point (no TXAN link), h2h_shockwave (no TXAN link), h2h_steak (no TXAN link), lensflare01 (no TXAN link), lensflare02 (no TXAN link), lensflare02a, lensflare02b .. lensflare11f (no TXAN link), ripple (with TXAN link), scanman (no TXAN link), skull (no TXAN link), stratus (no TXAN link), toxic_bubble2 (no TXAN link), toxic_gas (no TXAN link), toxic_ripple (no TXAN link), toxic_splash (no TXAN link), toxic_wave (no TXAN link), w1_flash2 (no TXAN link), w1_flash3 (no TXAN link), w1_glow (no TXAN link), w1_glow_ammo (no TXAN link), w2_flash2 (no TXAN link), w2_flash3 (no TXAN link), w2_glow (no TXAN link), w2_glow_ammo (no TXAN link), w3_flash2 (no TXAN link), w3_flash3 (with TXAN link), w3_glow (no TXAN link), w3_glow_ammo (no TXAN link), w4_flash (no TXAN link), w4_glow (no TXAN link), w4_glow_ammo (no TXAN link), w4_spark1 (no TXAN link), w5_glow (no TXAN link), w5_glow_ammo (no TXAN link), w6_glow (no TXAN link), w6_glow_ammo (no TXAN link), w7_glow (no TXAN link), w7_glow_ammo (no TXAN link), w8_glow (no TXAN link), w8_glow_ammo (no TXAN link), w9_aura (no TXAN link), w9_flare (no TXAN link), w9_glow (no TXAN link), w9_glow_ammo

0D 15 - (all with TXAN link) bomb_fire1, bomb_fire2

0D 51 - (all with TXAN link) h2h_dust, splat, wind01

0D 54 - (all with TXAN link) debris, steam1

0D 55 - (all with TXAN link) cumulous, hit, readout, scan, toxic_sludge, w1_flash1, w2_flash1

11 51 - glass_shard (with TXAN link)

1C 10 - afternoon _back _front _left _right _top, crap_back _front _left _right _top, night_back _front _left _right _top, sunset_back _front _left _right _top

1D 10 - PROP (with TXAN link), cloudflash (no TXAN link), glass_bit (no TXAN link), point (no TXAN link), raindrop (no TXAN link), ripple1 (no TXAN link), smoke (no TXAN link), snow (no TXAN link), steam2 (no TXAN link), w1_smoke (no TXAN link), w2_smoke (no TXAN link), w3_flash1 (no TXAN link), w3_smoke (no TXAN link), w4_smoke1 (no TXAN link), w6_smoke1 (no TXAN link), w9_dust (no TXAN link), w9_smoke (no TXAN link), w9_smoke1 (no TXAN link)

1D 11 - (all with TXAN link) env_gas5, smoke1, xp1tex

1D 14 - lensflare01_tex (no TXAN link), lensflare02_tex (no TXAN link)

1D 51 - env_steam (with TXAN link)

4D 14 - (all with TXAN link) fireball, w5_fireball

4D 15 - (all with TXAN link) fire10, fire11, fire12, fire13, fire5, fire7, fire8, fire9

51 51 - (all with TXAN link) w1_case (11 11 mode for folling files), w2_case (11 11 mode for following files)

5D 10 - w5_smoke (with TXAN link)

5D 11 - smoke3 (with TXAN link)

89 15 - elec_tex (with TXAN link) (blue elec + black background)


random tests on w1_case (51 51 in original file)

31 31 - like B1B1/A1A1 but slower

51 01 - bullet keeps rotating left-right right-left left-right and so on when on ground

61 61 - white squares sometimes appears

71 71 - no change

91 91 - keeps rotating

A1 A1 - keeps rotating, after one cycle while squares appear, then new rotation with normal case

B1 B1 - keeps rotating, after one cycle while squares appear, then new rotation with normal case

C1 C1 - no rotating, sometime a green case appears

D1 D1 - no change

E1 E1 - white squares sometimes appears

F1 F1 - white squares sometimes appears


Huh? What's this??

Neo

When you open OUP, dat editor and choose for example "contrail4444" then you will see "05" at offset 0x88. But that flag isn't explained here. Same "50" and so on. All the listed files have one or more unknown flag at offset 0x88. The question is what does they stand for. -- Or do I have overlooked their meaning??

Paradox-01 19:40, 17 July 2008 (CEST)

05 = 04 + 01 50 = 40 + 10

All flag values are powers of 2 and they can be combined by addition. For example if you want to disable both U and V wrapping you need to use 0x04 + 0x08 = 0x0C.

Neo

0x90

Integer ID. Defines the RGB color depth of texels (is that correct? geyser)

0
(4,4,4) RGB, 4 bits extra (interpreted as alpha or env map blending)
equivalent to GL_RGBA4 OpenGL image format Neo
Q: Does the interpretation of the high bits depend on the 0x88 settings? geyser
A: Yes, for env maps it really means how much reflective is the surface instead of transparency. Neo
1
(5,5,5) RGB and 1 bit extra
the extra bit is simply ignored, equivalent to GL_RGB5 OpenGL image format Neo
Q: Is the extra bit always ignored, regardless of the 0x88 settings? geyser
A: Yes, if it's RGB5 then it's RGB5, no alpha. Neo
2
(5,5,5) RGB, 1 bit extra (interpreted as alpha or env map blending)
equivalent to GL_RGB5_A1 OpenGL image format Neo
Q: Does the interpretation of the high bits depend on the 0x88 settings? geyser
A: Same as for 0 store type. Neo
8
(8,8,8) RGB, 8 bits extra
extra bits are ignored, equivalent to GL_RGB OpenGL image format Neo
Q: (sorry) are the extra bit always ignored, regardless of the 0x88 settings? geyser
A: Again, if it's RGB then it's RGB and not RGBA. If I remember correctly only skyboxes have this format and they don't have/need alpha anyway. If you need an RGBA format try store type 7, with some luck it will work. Neo
9
compressed (four times) (algorithm detailed elsewhere)
equivalent to GL_COMPRESSED_RGB_S3TC_DXT1_EXT OpenGL compressed image format Neo
(note: ARB stands for Architecture Review Board, not Alpha Red Blue ^^ geyser)
Q: Aha, "dxt1". Any more ideas looking at THESE? geyser
A: gl_disable_dxt1 probably decompresses the texture before passing it to Open GL. On the current videocards DXT1 is always supported and hopefully correctly implemented but when Oni was created things weren't necesarily as today. The 3 options are similar probably, either needed because of videocard/driver issues or maybe simply for debugging and testing. Neo
Anything else?
Q: (sorry) nothing else, ever ever? ^^ geyser