Rendering: Difference between revisions
(Cleaning up header levels) |
|||
Line 1: | Line 1: | ||
This page covers general rendering concerns that are not specific to model formats. | This page covers general rendering concerns that are not specific to model formats. | ||
= Model Specific Rendering = | == Model Specific Rendering == | ||
More information about rendering specific model formats can be found at the following pages: | More information about rendering specific model formats can be found at the following pages: | ||
Line 7: | Line 7: | ||
* [[M2/Rendering|M2 Rendering]] | * [[M2/Rendering|M2 Rendering]] | ||
= Pixel Blending = | == 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. | 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. | ||
Line 15: | Line 15: | ||
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. | 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 == | === 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. | 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. | ||
Line 150: | Line 150: | ||
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. | 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 == | ||
Texture blending controls how multiple textures are combined prior to being drawn to the framebuffer. | Texture blending controls how multiple textures are combined prior to being drawn to the framebuffer. | ||
== EGxTexBlend == | === EGxTexBlend === | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
Line 204: | Line 204: | ||
|} | |} | ||
== EGxTexOp == | === EGxTexOp === | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
Line 265: | Line 265: | ||
|} | |} | ||
=== FFP | === 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: | When rendering is done using the fixed function pipeline code path, the following calls are made to set the texture blending color op: | ||
Line 277: | Line 277: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== FFP | === 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: | When rendering is done using the fixed function pipeline code path, the following calls are made to set the texture blending alpha op: | ||
Line 289: | Line 289: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Screen Effects = | == Screen Effects == | ||
== EffectGlow == | === EffectGlow === | ||
This fullscreen effect controls both the bloom-style glow effect used by the game, and player state driven blur effects like inebriation. | This fullscreen effect controls both the bloom-style glow effect used by the game, and player state driven blur effects like inebriation. | ||
Line 309: | Line 309: | ||
The blurred render targets (<tt>RT 1</tt>, <tt>RT 2</tt>, and <tt>RT 3</tt>) are sized at 1/4 of the width and 1/4 of the height of the original render target (<tt>RT 0</tt>). | The blurred render targets (<tt>RT 1</tt>, <tt>RT 2</tt>, and <tt>RT 3</tt>) are sized at 1/4 of the width and 1/4 of the height of the original render target (<tt>RT 0</tt>). | ||
=== FFXBox4 Shaders (7.x) === | ==== FFXBox4 Shaders (7.x) ==== | ||
This shader implements a simple 2x2 [https://en.wikipedia.org/wiki/Box_blur box blur]. | This shader implements a simple 2x2 [https://en.wikipedia.org/wiki/Box_blur box blur]. | ||
Line 370: | Line 370: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== FFXGauss4 Shaders (7.x) === | ==== FFXGauss4 Shaders (7.x) ==== | ||
This shader implements a 4-tap gaussian blur. It's typically applied by the client in 2 passes (possibly: horizontal, then vertical). | This shader implements a 4-tap gaussian blur. It's typically applied by the client in 2 passes (possibly: horizontal, then vertical). | ||
Line 415: | Line 415: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== FFXGlow Shaders (7.x) === | ==== FFXGlow Shaders (7.x) ==== | ||
'''Vertex Shader''' | '''Vertex Shader''' | ||
Line 466: | Line 466: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== FFXGlow Shaders (3.x) === | ==== FFXGlow Shaders (3.x) ==== | ||
TODO | |||
== ViewSettings::s_fogInfo == | == Fog == | ||
=== ViewSettings::s_fogInfo === | |||
There are 4 types of fog defined in <tt>ViewSettings::s_fogInfo</tt> | There are 4 types of fog defined in <tt>ViewSettings::s_fogInfo</tt> | ||
Line 479: | Line 481: | ||
* <tt>3</tt>: Interior underwater fog | * <tt>3</tt>: Interior underwater fog | ||
= Liquid = | == Liquid == | ||
== Liquid::s_waterDetail == | === Liquid::s_waterDetail === | ||
From http://wow.gamepedia.com/Console_variables#Graphics: | Liquid rendering quality. From http://wow.gamepedia.com/Console_variables#Graphics: | ||
* <tt>0</tt>: Old water | * <tt>0</tt>: Old water | ||
* <tt>1</tt>: Screen space reflection | * <tt>1</tt>: Screen space reflection | ||
* <tt>2</tt>: Dynamic reflection | * <tt>2</tt>: Dynamic reflection |
Revision as of 07:09, 7 March 2017
This page covers general rendering concerns that are not specific to model formats.
Model Specific Rendering
More information about rendering specific model formats can be found at the following pages:
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);
Screen Effects
EffectGlow
This fullscreen effect controls both the bloom-style glow effect used by the game, and player state driven blur effects like inebriation.
To apply the effect, the game creates 4 new render targets:
- RT 0: Already exists, and holds the output of rendering the given world scene
- RT 1: Created by passing RT 0 through the FFXBox4 shader (2x2 box blur)
- RT 2: Created by passing RT 1 through the FFXGauss4 shader (4-tap gaussian blur)
- RT 3: Created by passing RT 2 through the FFXGauss4 shader (second pass)
- RT 4: Created by passing RT 0 and RT 3 through the FFXGlow shader (both targets are sampled)
The blurred render targets (RT 1, RT 2, and RT 3) are sized at 1/4 of the width and 1/4 of the height of the original render target (RT 0).
FFXBox4 Shaders (7.x)
This shader implements a simple 2x2 box blur.
The client appears to precompute the texture coordinates on the CPU.
- PassBox4::box4Offs = { -1.5, -1.5, 0.5, -1.5, 0.5, 0.5, -1.5, 0.5 }
- FFX::SetupGeo_Quad::s_tex = { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0 }
Vertex Shader
The vertex shader used for FFXBox4 is a simple full screen vertex shader, and can be found in FullScreen.bls in the appropriate vertex shader directory.
Pixel Shader
The same source render target (the output of RT 0) is bound 4 times. Each of the 4 coordinate pairs is 'slipped' such that the addition of each sampled color results in the box blur.
The coordinate pairs in in_tc0 through in_tc3 are offset as follows:
- in_tc0: reference
- in_tc1: shifted right vs in_tc0
- in_tc2: shifted up vs in_tc0
- in_tc3: shifted right and up vs in_tc0
#version 420
layout(location = 1) in vec2 in_tc0;
layout(location = 2) in vec2 in_tc1;
layout(location = 3) in vec2 in_tc2;
layout(location = 4) in vec2 in_tc3;
layout(location = 0) out vec4 out_result;
uniform sampler2D pt_texture0;
uniform sampler2D pt_texture1;
uniform sampler2D pt_texture2;
uniform sampler2D pt_texture3;
void main()
{
float blurWeight = 0.25;
vec3 color0 = texture(pt_texture0, in_tc0).rgb;
vec3 color1 = texture(pt_texture1, in_tc1).rgb;
vec3 color2 = texture(pt_texture2, in_tc2).rgb;
vec3 color3 = texture(pt_texture3, in_tc3).rgb;
vec3 finalColor = vec3(0.0);
finalColor += color0 * blurWeight;
finalColor += color1 * blurWeight;
finalColor += color2 * blurWeight;
finalColor += color3 * blurWeight;
out_result = vec4(finalColor.rgb, 1.0);
}
FFXGauss4 Shaders (7.x)
This shader implements a 4-tap gaussian blur. It's typically applied by the client in 2 passes (possibly: horizontal, then vertical).
Pixel Shader
The same source render target is bound 4 times.
#version 420
layout(location = 1) in vec2 in_tc0;
layout(location = 2) in vec2 in_tc1;
layout(location = 3) in vec2 in_tc2;
layout(location = 4) in vec2 in_tc3;
layout(location = 0) out vec4 out_result;
uniform sampler2D pt_texture0;
uniform sampler2D pt_texture1;
uniform sampler2D pt_texture2;
uniform sampler2D pt_texture3;
void main()
{
vec2 blurWeight = vec2(0.125, 0.375);
vec4 color0 = texture(pt_texture1, in_tc0);
vec4 color1 = texture(pt_texture1, in_tc1);
vec4 color2 = texture(pt_texture1, in_tc2);
vec4 color3 = texture(pt_texture1, in_tc3);
vec4 finalColor = vec4(0.0);
finalColor += color0 * blurWeight.x;
finalColor += color1 * blurWeight.y;
finalColor += color2 * blurWeight.y;
finalColor += color3 * blurWeight.x;
out_result = finalColor;
}
FFXGlow Shaders (7.x)
Vertex Shader
The vertex shader used for FFXGlow is a simple full screen vertex shader, and can be found in FullScreen.bls in the appropriate vertex shader directory.
Pixel Shader
- pc_blurAmount.z: controls how much of the final blur output (RT 3) is carried over in the final output; this is used to manage effects like blurring the screen due to inebriation
- pc_blurAmount.w: controls how much bloom-style glow is applied to the screen; this typically is sourced from the LightParams client database: LightParamsRec->m_glow
#version 420
layout(location = 1) in vec2 in_screenCoord;
layout(location = 2) in vec2 in_blurCoord;
layout(location = 0) out vec4 out_result;
layout(std140) uniform ps_cb0
{
vec4 pc_blurAmount;
};
uniform sampler2D pt_screenTex;
uniform sampler2D pt_blurTex;
void main()
{
float blurFactor = pc_blurAmount.z;
float glowFactor = pc_blurAmount.w;
vec4 screenColor = texture(pt_screenTex, in_screenCoord);
vec3 blurColor = texture(pt_blurTex, in_blurCoord).rgb;
// Mix screen and blur color (to handle effects like inebriation)
vec4 finalColor = vec4(mix(screenColor.rgb, blurColor, vec3(blurFactor)), 0.0);
// Calculate the glow color
vec3 glowColor = (blurColor * blurColor) * glowFactor;
// Add the glow color
finalColor.rgb += glowColor;
out_result = vec4(finalColor.rgb, screenColor.a);
}
FFXGlow Shaders (3.x)
TODO
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