Skip to content

Wrath Blending

fallenoak edited this page Nov 24, 2016 · 29 revisions

Blending States

When blending is enabled, Wrath of the Lich King always uses FUNC_ADD for the blending equation.

Note that Wrath of the Lich King does not use separate blending functions for alpha blending. Later client expansions do appear to make use of separate alpha blending, though.

State Name Src Dest Comment
0 Blend_Opaque ONE ZERO Blending disabled
1 Blend_AlphaKey ONE ZERO Blending disabled
2 Blend_Alpha SRC_ALPHA ONE_MINUS_SRC_ALPHA Standard blending func
3 Blend_Add SRC_ALPHA ONE Additive blending func
4 Blend_Mod DST_COLOR ZERO Modulative blending func
5 Blend_Mod2x DST_COLOR SRC_COLOR 2x modulative blending func
6 Blend_ModAdd DST_COLOR ONE Modulative + additive
7 Blend_InvSrcAlphaAdd ONE_MINUS_SRC_ALPHA ONE

M2 Blending Modes

M2Material defines a blendingMode, but the blendingMode isn't a direct lookup in the blending states table.

For M2s without header flag 0x08 set, the M2Material blendingMode is looked up in a default mapping table:

Default Mapping Table

On-Disk Blending Mode Value State State Name Example
0 0 Blend_Opaque WORLD\EXPANSION01\DOODADS\GENERIC\DRAENEI\LAMPPOSTS\DR_LAMPPOST_01.m2
1 1 Blend_AlphaKey World\GENERIC\NIGHTELF\PASSIVE DOODADS\LAMPS\KalidarStreetLamp02.m2
2 2 Blend_Alpha WORLD\EXPANSION01\DOODADS\GENERIC\DRAENEI\LAMPPOSTS\DR_LAMPPOST_01.m2
3 ? ? ?
4 3 Blend_Add World\GENERIC\NIGHTELF\PASSIVE DOODADS\LAMPS\KalidarStreetLamp02.m2
5 4 Blend_Mod WORLD\EXPANSION01\DOODADS\THEEXODAR\PASSIVEDOODADS\LIGHT_SCONCES\EXODAR_SCONCE_MAGENTA.M2
6 5 Blend_Mod2x World\GENERIC\GNOME\PASSIVE DOODADS\GNOMEMACHINE\GnomeSubwayGlass.m2

M2 Fog Modes

Typically, fog modes are selected based on the blending mode (see below).

Fog Mode Action
0 Disable fog logic in the shader
1 ? no override ?
2 Override fog color to 0x000000 (black)
3 Override fog color to 0xFFFFFF (white)
4 Override fog color to 0x808080 (half white)
5 ? related to submerged camera ?
6 ? related to liquid plane ?

Selecting M2 Fog Mode

Because blending modes change how color is applied, fog color needs to be taken into account for more interesting blending modes.

If M2Material flag 0x02 is set, fog mode 0 (ie disabled) is always selected.

If M2Material flag 0x02 is not set, the client maps blending modes to fog modes with the s_fogModeList table.

On-Disk Blending Mode Value State State Name Fog Mode
0 0 Blend_Opaque 1 *
1 1 Blend_AlphaKey 1 *
2 2 Blend_Alpha 1 *
3 ? ? ? (2?) *
4 3 Blend_Add 2
5 4 Blend_Mod 3
6 5 Blend_Mod2x 4

* indicates theory, not tested

M2 Lighting Modes

Typically, lighting modes are selected based on the blending mode (see below).

Lighting Mode Action
0 Disable global lighting logic in the shader (does not impact emissive term)
1 Enable global lighting logic in the shader

Selecting M2 Lighting Mode

If M2Material flag 0x01 is set, lighting mode 0 (ie disabled) is always selected.

If M2Material flag 0x01 is not set, the client maps blending modes to lighting modes using the s_shadedList table.

The client appears to forcibly disable directional lighting logic in the shader for Blend_Mod and Blend_Mod2x, but keeps directional lighting enabled for all other blending modes.

On-Disk Blending Mode Value State State Name Lighting Mode
0 0 Blend_Opaque 1 *
1 1 Blend_AlphaKey 1 *
2 2 Blend_Alpha 1 *
3 ? ? 1 *
4 3 Blend_Add 1 *
5 4 Blend_Mod 0
6 5 Blend_Mod2x 0 *

* indicates theory, not tested

  • Confirmed 5 to 0 mapping using EXODAR_SCONCE_MAGENTA.M2. Material idx 1 has an on-disk blending mode value of 5 and material flags of 0x10. Given the material flags, it would be expected to have global lighting logic enabled in the shader. It does not, which is explained by the table above.