M2/Rendering: Difference between revisions

From wowdev
Jump to navigation Jump to search
mNo edit summary
Line 56: Line 56:
| DST_COLOR
| DST_COLOR
| ZERO
| ZERO
| 8
| DST_ALPHA
| ZERO
| ZERO
|-
|-
Line 64: Line 64:
| DST_COLOR
| DST_COLOR
| SRC_COLOR
| SRC_COLOR
| 8
| DST_ALPHA
| SRC_ALPHA
| SRC_ALPHA
|-
|-
Line 72: Line 72:
| DST_COLOR
| DST_COLOR
| ONE
| ONE
| 8
| DST_ALPHA
| ONE
| ONE
|-
|-

Revision as of 21:52, 27 November 2016

WIP

Blending Modes

Wrath of the Lich King and Cataclysm do not use separate alpha blending. Later expansion clients likely do use separate alpha blending.

Blend_BlendAdd was added after Cataclysm.

Values for functions match OpenGL, but each has a D3D equivalent.

blendStateIdx Mode Blending Enabled Src Color Dest Color Src Alpha Dest Alpha
0 Blend_Opaque Disabled ONE ZERO ONE ZERO
1 Blend_AlphaKey Disabled ONE ZERO ONE ZERO
2 Blend_Alpha Enabled SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE ONE_MINUS_SRC_ALPHA
3 Blend_Add Enabled SRC_ALPHA ONE ZERO ONE
4 Blend_Mod Enabled DST_COLOR ZERO DST_ALPHA ZERO
5 Blend_Mod2x Enabled DST_COLOR SRC_COLOR DST_ALPHA SRC_ALPHA
6 Blend_ModAdd Enabled DST_COLOR ONE DST_ALPHA ONE
7 Blend_InvSrcAlphaAdd Enabled ONE_MINUS_SRC_ALPHA ONE ONE_MINUS_SRC_ALPHA ONE
8 Blend_InvSrcAlphaOpaque Enabled ONE_MINUS_SRC_ALPHA ZERO ONE_MINUS_SRC_ALPHA ZERO
9 Blend_SrcAlphaOpaque Enabled SRC_ALPHA ZERO SRC_ALPHA ZERO
10 Blend_NoAlphaAdd Enabled ONE ONE ZERO ONE
11 Blend_ConstantAlpha Enabled CONSTANT_ALPHA ONE_MINUS_CONSTANT_ALPHA 13 14
12 Blend_Screen Enabled ONE_MINUS_DST_COLOR ONE ONE ZERO
13 Blend_BlendAdd Enabled ONE ONE_MINUS_SRC_ALPHA ONE ONE_MINUS_SRC_ALPHA

Credits: Deamon, for unearthing blending mode names and laying out the table; relaxok, for checking D3D state at runtime; schlumpf, for all the initial reversing work; fallenoak, for mapping Deamon's table to OpenGL enums.

Fog Modes

Because blending modes adjust how color is applied during a draw call, fog color often has to be modified accordingly. The client maps blending modes to fog modes using s_fogModeList.

Additionally, M2Material flag 0x02 causes fog mode 0 (disabled) to always be selected, regardless of blending mode.

The following fog modes were taken from Mists of Pandaria (build 15662).

Fog Mode Action Blending Modes
0 Disable fog logic in shader -
1 ? possibly: use fog color without changes ? Blend_Opaque, Blend_AlphaKey, Blend_Alpha
2 Override fog color to 0x000000 (black) Blend_Add, possibly: Blend_NoAlphaAdd
3 Override fog color to 0xFFFFFF (white) Blend_Mod
4 Override fog color to 0x808080 (half white) Blend_Mod2x
5 ? submerged camera related ? -
6 ? liquid plane related ? -

Lighting Modes

Similar to fog modes above, blending modes also impact lighting. The client maps blending modes to lighting modes using s_shadedList.

Additionally, M2Material flag 0x01 always causes lighting mode 0 (disabled) to be selected.

The following lighting modes were taken from Mists of Pandaria (build 15662).

Lighting Mode Action Blending Modes
0 Disable lighting logic in shader Blend_Mod, Blend_Mod2x
1 Enable lighting logic in shader Blend_Opaque, Blend_AlphaKey, Blend_Alpha, Blend_Add, possibly: Blend_NoAlphaAdd