Talk:M2
Finished for Build 8820 now. Post changes here first! And please pay attention to the style when you add something.. --schlumpf_ 00:53, 23 August 2008 (CEST)
Deleted Blocks
Block D
- nD records of (int16, int16) starting at ofsD
Maybe a lookup table for animations? Since the numbers happen to be in fixed positions. The first short seems to increase with the position for models with all animations (like characters), the second seems to be flags or a modifier? Or something.
Contain indices into the texture animations list, or -1 meaning a static texture.
Render Flags
Please forgive any ignorance I show here as I'm not a professional programmer. I'm just trying to help improve Wow Model Viewer, which has very few staff left and these pages have been invaluable for understanding it :) I just wanted to mention something that confused me and I'm not sure if it needs correcting...
The Render Flags section of this page has two different tables for blend modes, with no mention of what the difference is. Is one out of date? The settings they recommend are different for a few modes, but they agree on others. I also tried them out in WMV and found that blend mode 1 is not working right with the settings from the tables (sections are appearing completely invisible when they shouldn't be) so maybe it's out of date in both, or there's something I'm not understanding. Perhaps it's meant to be used in conjunction with GL_ALPHA_TEST or glAlphaFunc() or something.
Thanks for all your work here! :)
- Wain
- the second table was created by relax by tracing directx stuff in the MoP client, the first one was later created by schlumpf based on reverse engineering the WoD beta client. The first table assumes alpha test to be the same, the second one lists them separate. there might be errors in both, tbh. feel free to fix them if you find them, or come to quakenet#modcraft to discuss them. :) --Schlumpf (talk) 16:47, 14 October 2015 (UTC)
- Aha! Thanks very much :) I'll experiment with the modes more and see what I can find.
-- Wain
Particle Emitters
I'm not yet sure what to do with the new parameters: MultiTexParamX (2 values), and MultiTexParam0 and MultiTexParam1 (each two pairs of x and y values).
Below I've included values for a sample of models that use multitextured particles, along with some other parameters from the same particle emitter structure. You'll note that some of the texture tile rotation values are also unusual, as they are expected to be -1, 0 or 1.
Only particles that have multitexturing flagged are included, as the rest always seem to have zero for these parameters.
Blend | Emitter | Texture | MultitexParamX | MultitexParam0 | MultitexParam1 | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | Type | Tile Rotat | [0] | [1] | [0].x | [0].y | [1].x | [1].y | [0].x | [0].y | [1].x | [1].y |
moosemount.m2 | ||||||||||||
7 | 2 | 7 | 0.1875 | 0.09375 | 0.0234375 | 0.0234375 | -0.0136719 | -0.0136719 | 0.00585938 | 0.00585938 | 0.00585938 | 0.00585938 |
2 | 2 | 4 | 0.5 | 0.6875 | 0 | 0.138438 | 0 | 0.138438 | 0.0488281 | 0.0488281 | 0.0234375 | 0.0234375 |
2 | 1 | 4 | 0.5 | 0.6875 | 0 | 0.0996094 | 0 | 0.0488281 | 0.00976562 | 0.00976562 | 0.00390625 | 0.00390625 |
saber2mount.m2 | ||||||||||||
4 | 1 | 0 | 0.78125 | 1 | 0 | 0.0996094 | 0 | 0 | 0 | 0 | 0 | 0.0996094 |
4 | 1 | 0 | 0.375 | 0.28125 | 0 | 0.0996094 | 0 | 0 | 0 | 0 | 0 | 0.0996094 |
ironhordeclefthoof.m2 | ||||||||||||
7 | 1 | 1 | 0.25 | 0.4375 | 0 | 0.298828 | 0 | 0.199219 | 0.0585938 | 0.0585938 | 0.0488281 | 0.0488281 |
ironhordeelekk.m2 | ||||||||||||
7 | 1 | 1 | 0.25 | 0.4375 | 0 | 0.298828 | 0 | 0.199219 | 0.0585938 | 0.0585938 | 0.0488281 | 0.0488281 |
ironhordewolf.m2 | ||||||||||||
2 | 1 | 0 | 0.09375 | 0.1875 | 0.0292969 | 0.0292969 | -0.0292969 | 0.0292969 | 0.00390625 | 0.00390625 | 0.00390625 | 0.00390625 |
7 | 1 | 1 | 0.25 | 0.4375 | 0 | 0.298828 | 0 | 0.199219 | 0.0585938 | 0.0585938 | 0.0488281 | 0.0488281 |
archimonde3.m2 | ||||||||||||
7 | 1 | 5 | 0.5 | 0.25 | 0 | 0.199219 | 0 | 0.199219 | 0 | 0.138438 | 0 | 0.138438 |
voidcaller_v2.m2 | ||||||||||||
2 | 2 | -3 | 1 | 1.375 | 0 | -0.199219 | 0 | -0.298828 | 0.0996094 | 0.0234375 | 0.138438 | 0.0488281 |
2 | 2 | -1 | 0.5 | 0.6875 | 0 | 0.0488281 | 0 | 0.0742188 | 0.0234375 | 0.0234375 | 0.00390625 | 0.00390625 |
7 | 2 | 2 | 1 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
7 | 2 | 0 | 0.5 | 0.1875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
7 | 1 | 0 | 0.5 | 0.1875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
lavahorse.m2 | ||||||||||||
7 | 1 | 5 | 0.5 | 0.25 | 0 | 0.199219 | 0 | 0.199219 | 0 | 0.138438 | 0 | 0.138438 |
4 | 1 | 0 | 0.25 | 0.5 | 0 | 0.00976562 | 0 | 0.0195312 | 0.00195312 | 0.00195312 | 0.00195312 | 0.00195312 |
corehound2.m2 | ||||||||||||
7 | 1 | 0 | 0.25 | 0.4375 | 0 | 0.298828 | 0 | 0.199219 | 0 | 0.0488281 | 0 | 0.0488281 |
4 | 1 | 0 | 0.25 | 0.5 | 0 | 0.00976562 | 0 | 0.0195312 | 0.00195312 | 0.00195312 | 0.00195312 | 0.00195312 |
dreadravenwarbirdfel.m2 | ||||||||||||
4 | 1 | 0 | 0.25 | 0.5 | 0 | 0.00976562 | 0 | 0.0195312 | 0.00195312 | 0.00195312 | 0.00195312 | 0.00195312 |
7 | 1 | 0 | 0.25 | 0.4375 | 0 | 0.298828 | 0 | 0.199219 | 0 | 0.0488281 | 0 | 0.0488281 |
dreadravenwarbirdsun.m2 | ||||||||||||
4 | 1 | 0 | 0.25 | 0.5 | 0 | 0.00976562 | 0 | 0.0195312 | 0.00195312 | 0.00195312 | 0.00195312 | 0.00195312 |
7 | 1 | 0 | 0.25 | 0.4375 | 0 | 0.298828 | 0 | 0.199219 | 0 | 0.0488281 | 0 | 0.0488281 |
-- Wain (talk) 14:57, 4 November 2015 (UTC)
Note that all the above MultitexParamX values are exact fractions of 32 (0.4375 = 14/32, etc.). This seems to be a complicated way of storing info that could be just represented as a simple uint8. -- Wain (talk) 03:15, 4 February 2016 (UTC)
Blend values
Those arrays were retrieved from client
char* blendModes[14] = { "Blend_Opaque", //0 "Blend_AlphaKey", //1 "Blend_Alpha", //2 "Blend_Add", //3 "Blend_Mod", //4 "Blend_Mod2x", //5 "Blend_ModAdd", //6 "Blend_InvSrcAlphaAdd", //7 "Blend_InvSrcAlphaOpaque", //8 "Blend_SrcAlphaOpaque", //9 "Blend_NoAlphaAdd", //10 "Blend_ConstantAlpha", //11 "Blend_Screen", //12 "Blend_BlendAdd" //13 } uint64 sourceRGBBlendFactorEnum[14] = { 1, //0 1, //1 4, //2 4, //3 6, //4 6, //5 6, //6 5, //7 5, //8 4, //9 1, //10 0x0B, //11 7, //12 1 //13 } uint64 destRGBBlendFactorEnum[14] = { 0, //0 0, //1 5, //2 1, //3 0, //4 2, //5 1, //6 1, //7 0, //8 0, //9 1, //10 0x0C, //11 1, //12 5 //13 } uint64 sourceAlphaBlendFactorEnum[14] = { 1, //0 1, //1 1, //2 0, //3 8, //4 8, //5 8, //6 5, //7 5, //8 4, //9 0, //10 0x0D, //11 1, //12 1 //13 } uint64 destAlphaBlendFactorEnum[14] = { 0, //0 0, //1 5, //2 1, //3 0, //4 4, //5 1, //6 1, //7 0, //8 0, //9 1, //10 0x0E, //11 0, //12 5 //13 }
I think the lower 5 bits of GxBlendStateDesc(where this comes from) is index into this array. So based on info from notes in https://wowdev.wiki/M2/WotLK#Render_flags the blend modes are mapped this way:
0 - Blend_Opaque(0), 1 - Blend_AlphaKey(1), 2 - Blend_Alpha(2), 3 - Blend_NoAlphaAdd(10), 4 - Blend_Add(3) 5 - Blend_Mod(4) 6 - Blend_Mod2x(5) 7 - Blend_BlendAdd(13)
I this assumption, it's a matter of correlation between numbers and blend modes
blendMode | RenderFlag blend | Src Color | Dest Color | Src Alpha | Dest Alpha | |
---|---|---|---|---|---|---|
0 | Blend_Opaque | 0 | 1 | 0 | 1 | 0 |
1 | Blend_AlphaKey | 1 | 1 | 0 | 1 | 0 |
2 | Blend_Alpha | 2 | 4 | 5 | 1 | 5 |
3 | Blend_Add | 4 | 4 | 1 | 0 | 1 |
4 | Blend_Mod | 5 | 6 | 0 | 8 | 0 |
5 | Blend_Mod2x | 6 | 6 | 2 | 8 | 4 |
6 | Blend_ModAdd | -1 | 6 | 1 | 8 | 1 |
7 | Blend_InvSrcAlphaAdd | -1 | 5 | 1 | 5 | 1 |
8 | Blend_InvSrcAlphaOpaque | -1 | 5 | 0 | 5 | 0 |
9 | Blend_SrcAlphaOpaque | -1 | 4 | 0 | 4 | 0 |
10 | Blend_NoAlphaAdd | 3 | 1 | 1 | 0 | 1 |
11 | Blend_ConstantAlpha | -1 | 11 | 12 | 13 | 14 |
12 | Blend_Screen | -1 | 7 | 1 | 1 | 0 |
13 | Blend_BlendAdd | 7 | 1 | 5 | 1 | 5 |
Based on info from article my current guess for values in this table is:
- define GL_ZERO 0
- define GL_ONE 1
- define GL_SRC_COLOR 2
- define GL_ONE_MINUS_SRC_COLOR 3
- define GL_SRC_ALPHA 4
- define GL_ONE_MINUS_SRC_ALPHA 5
- define GL_DST_ALPHA 6
- define GL_ONE_MINUS_DST_ALPHA 7
- define GL_DST_COLOR 8
- define GL_ONE_MINUS_DST_COLOR 9
- define GL_SRC_ALPHA_SATURATE 10
- define GL_CONSTANT_COLOR 11
- define GL_ONE_MINUS_CONSTANT_COLOR 12
- define GL_CONSTANT_ALPHA 13
- define GL_ONE_MINUS_CONSTANT_ALPHA 14
blendMode | RenderFlag blend | Src Color | Dest Color | Src Alpha | Dest Alpha | |
---|---|---|---|---|---|---|
0 | Blend_Opaque | 0 | GL_ONE | GL_ZERO | GL_ONE | GL_ZERO |
1 | Blend_AlphaKey | 1 | GL_ONE | GL_ZERO | GL_ONE | GL_ZERO |
2 | Blend_Alpha | 2 | GL_SRC_ALPHA | GL_ONE_MINUS_SRC_ALPHA | GL_ONE | GL_ONE_MINUS_SRC_ALPHA |
3 | Blend_Add | 4 | GL_SRC_ALPHA | GL_ONE | GL_ZERO | GL_ONE |
4 | Blend_Mod | 5 | GL_DST_ALPHA | GL_ZERO | GL_DST_COLOR | GL_ZERO |
5 | Blend_Mod2x | 6 | GL_DST_ALPHA | GL_SRC_COLOR | GL_DST_COLOR | GL_SRC_ALPHA |
6 | Blend_ModAdd | -1 | GL_DST_ALPHA | GL_ONE | GL_DST_COLOR | GL_ONE |
7 | Blend_InvSrcAlphaAdd | -1 | GL_ONE_MINUS_SRC_ALPHA | GL_ONE | GL_ONE_MINUS_SRC_ALPHA | GL_ONE |
8 | Blend_InvSrcAlphaOpaque | -1 | GL_ONE_MINUS_SRC_ALPHA | GL_ZERO | GL_ONE_MINUS_SRC_ALPHA | GL_ZERO |
9 | Blend_SrcAlphaOpaque | -1 | GL_SRC_ALPHA | GL_ZERO | GL_SRC_ALPHA | GL_ZERO |
10 | Blend_NoAlphaAdd | 3 | GL_ONE | GL_ONE | GL_ZERO | GL_ONE |
11 | Blend_ConstantAlpha | -1 | GL_CONSTANT_COLOR | GL_ONE_MINUS_CONSTANT_COLOR | GL_CONSTANT_ALPHA | GL_ONE_MINUS_CONSTANT_ALPHA |
12 | Blend_Screen | -1 | GL_ONE_MINUS_DST_ALPHA | GL_ONE | GL_ONE | GL_ZERO |
13 | Blend_BlendAdd | 7 | GL_ONE | GL_ONE_MINUS_SRC_ALPHA | GL_ONE | GL_ONE_MINUS_SRC_ALPHA |
(updated using fallenoak's findings)