Rendering

From wowdev
Jump to: navigation, search

This page contains general information about functions, logic, and data used in the various rendering code paths of the World of Warcraft game client.

Rendering Resources

Information specific to model formats and other rendering code paths can be found at the links below:

Model Rendering

More information about rendering specific model formats used by World of Warcraft can be found at the following pages:

Other Rendering

More information about other logic, systems, or techniques involved in rendering in World of Warcraft can be found at the following pages:

Vertex Buffers

EGxVertexBufferFormat

EGxVertexBufferFormat Attribute Count Size (per Vertex) Attribute Names / Order
GxVBF_P 1 0x0C position
GxVBF_PN 2 0x18 position, normal
GxVBF_PNC 3 0x1C position, normal, color
GxVBF_PNT 3 0x20 position, normal, tc
GxVBF_PNCT 4 0x24 position, normal, color, tc
GxVBF_PNT2 4 0x28 position, normal, tc[2]
GxVBF_PNCT2 5 0x2C position, normal, color, tc[2]
GxVBF_PC 2 0x10 position, color
GxVBF_PCT 3 0x18 position, color, tc
GxVBF_PCT2 4 0x20 position, color, tc[2]
GxVBF_PT 2 0x14 position, tc
GxVBF_PT2 3 0x1C position, tc[2]
GxVBF_PBNT2 6 0x30 position, blendWeight, blendIndices, normal, tc[2]
GxVBF_PNC2T2 6 0x30 position, normal, color[2], tc[2]

EGxVertexAttrib

EGxVertexAttrib Size
GxVA_Position 0x0C
GxVA_BlendWeight 0x04
GxVA_BlendIndices 0x04
GxVA_Normal 0x0C
GxVA_Color0 0x04
GxVA_Color1 0x04
GxVA_TexCoord0 0x08
GxVA_TexCoord1 0x08

Pixel Blending

When drawing geometry (batches, meshes, etc) into a framebuffer, the interaction between the pixels of the incoming geometry and the pixels already present in the framebuffer is controlled by something called blending.

In World of Warcraft, blending states are predefined, and are referenced by the EGxBlend enum.

Note that pixel blending is separate from texture blending. Texture blending controls how multiple textures for the same geometry are blended together, prior to the geometry being drawn into the framebuffer. In other words, texture blending happens before pixel blending. It has its own section on this page.

EGxBlend

The table below is up to date with all blending modes present in the 7.1.0.22996 retail client. Not all blending modes are used, particularly in older clients.

Wrath of the Lich King and Cataclysm do not use separate alpha blending. Legion does use separate alpha blending. It's currently unknown if Mists of Pandaria or Warlords of Draenor use separate alpha blending.

GxBlend_BlendAdd was added at some point after Cataclysm.

Blend function enums are for OpenGL, but each has a Direct3D equivalent. Most pairings should be obvious, except: in Direct3D, CONSTANT_ALPHA is BLEND_FACTOR and ONE_MINUS_CONSTANT_ALPHA is INV_BLEND_FACTOR. See this gist for code that converts OpenGL constants to Direct3D (excerpt from Chrome).

Idx EGxBlend Blending Enabled? Src Color Dest Color Src Alpha Dest Alpha
0 GxBlend_Opaque No GL_ONE GL_ZERO GL_ONE GL_ZERO
1 GxBlend_AlphaKey No GL_ONE GL_ZERO GL_ONE GL_ZERO
2 GxBlend_Alpha Yes GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
3 GxBlend_Add Yes GL_SRC_ALPHA GL_ONE GL_ZERO GL_ONE
4 GxBlend_Mod Yes GL_DST_COLOR GL_ZERO GL_DST_ALPHA GL_ZERO
5 GxBlend_Mod2x Yes GL_DST_COLOR GL_SRC_COLOR GL_DST_ALPHA GL_SRC_ALPHA
6 GxBlend_ModAdd Yes GL_DST_COLOR GL_ONE GL_DST_ALPHA GL_ONE
7 GxBlend_InvSrcAlphaAdd Yes GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA GL_ONE
8 GxBlend_InvSrcAlphaOpaque Yes GL_ONE_MINUS_SRC_ALPHA GL_ZERO GL_ONE_MINUS_SRC_ALPHA GL_ZERO
9 GxBlend_SrcAlphaOpaque Yes GL_SRC_ALPHA GL_ZERO GL_SRC_ALPHA GL_ZERO
10 GxBlend_NoAlphaAdd Yes GL_ONE GL_ONE GL_ZERO GL_ONE
11 GxBlend_ConstantAlpha Yes GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA
12 GxBlend_Screen Yes GL_ONE_MINUS_DST_COLOR GL_ONE GL_ONE GL_ZERO
13 GxBlend_BlendAdd Yes GL_ONE GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA

Table Credits: Deamon, for unearthing blending mode names and laying out the original table; relaxok, for checking D3D state at runtime; schlumpf, for the initial reversing work; fallenoak, for mapping Deamon's table to OpenGL enums and verifying values across several expansion clients.

Texture Blending

Texture blending controls how multiple textures are combined prior to being drawn to the framebuffer.

EGxTexBlend

Idx EGxTexBlend ColorOp AlphaOp
0 GxTexBlend_Opaque GxTexOp_Mod GxTexOp_PassThru
1 GxTexBlend_Mod GxTexOp_Mod GxTexOp_Mod
2 GxTexBlend_Decal GxTexOp_Decal GxTexOp_PassThru
3 GxTexBlend_Add GxTexOp_Add GxTexOp_Add
4 GxTexBlend_Mod2x GxTexOp_Mod2x GxTexOp_Mod2x
5 GxTexBlend_Fade GxTexOp_Fade GxTexOp_PassThru
6 GxTexBlend_Mod2xNA GxTexOp_Mod2x GxTexOp_PassThru
7 GxTexBlend_AddNA GxTexOp_Add GxTexOp_PassThru

EGxTexOp

Idx EGxTexOp Op Scale Arg0 Arg1 Arg2
0 GxTexOp_Mod GL_MODULATE 1.0f GL_PREVIOUS GL_TEXTURE GL_CONSTANT
1 GxTexOp_Mod2x GL_MODULATE 2.0f GL_PREVIOUS GL_TEXTURE GL_CONSTANT
2 GxTexOp_Add GL_ADD 1.0f GL_PREVIOUS GL_TEXTURE GL_CONSTANT
3 GxTexOp_PassThru GL_REPLACE 1.0f GL_PREVIOUS GL_TEXTURE GL_CONSTANT
4 GxTexOp_Decal GL_INTERPOLATE 1.0f GL_PREVIOUS GL_TEXTURE GL_TEXTURE
5 GxTexOp_Fade GL_INTERPOLATE 1.0f GL_TEXTURE GL_PREVIOUS GL_TEXTURE

ColorOp FFP State

When rendering is done using the fixed function pipeline code path, the following calls are made to set the texture blending color op:

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, op);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE,   scale);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, arg0);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, arg1);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, arg2);

AlphaOp FFP State

When rendering is done using the fixed function pipeline code path, the following calls are made to set the texture blending alpha op:

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, op);
glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE,   scale);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, arg0);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, arg1);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, arg2);

Texture Formats

Over the years, the client has used a plethora of texture formats for various rendering features. Formats are defined by the EGxTexFormat enum. Earlier clients support fewer texture formats than later clients.

EGxTexFormat

EGxTexFormat Oldest Known Support
GxTex_Unknown 0.5.3.3368
GxTex_Abgr8888 ?
GxTex_Argb8888 0.5.3.3368
GxTex_Argb4444 0.5.3.3368
GxTex_Argb1555 0.5.3.3368
GxTex_Rgb565 0.5.3.3368
GxTex_Dxt1 0.5.3.3368
GxTex_Dxt3 0.5.3.3368
GxTex_Dxt5 0.5.3.3368
GxTex_Uv88 ?
GxTex_Gr1616F ?
GxTex_R32F ?
GxTex_D24X8 ?

Texture Targets

EGxTexTarget

Idx EGxTexTarget OpenGL
0 GxTex_2d GL_TEXTURE_2D
1 GxTex_CubeMap GL_TEXTURE_CUBE_MAP
2 GxTex_Rectangle GL_TEXTURE_RECTANGLE
3 GxTex_NonPow2?? GL_TEXTURE_2D
4 GxTex_Volume GL_TEXTURE_3D
5 GxTex_Internal?? GL_ZERO

Fog

ViewSettings::s_fogInfo

There are 4 types of fog defined in ViewSettings::s_fogInfo

  • 0: Unk (maybe: exterior above water fog)
  • 1: Unk (maybe: interior above water fog)
  • 2: Exterior underwater fog
  • 3: Interior underwater fog

Liquid

Liquid::s_waterDetail

Liquid rendering quality. From http://wow.gamepedia.com/Console_variables#Graphics:

  • 0: Old water
  • 1: Screen space reflection
  • 2: Dynamic reflection