Skip to content

WIP Wrath Shading

fallenoak edited this page Sep 20, 2016 · 1 revision

Vertex Shaders

MapObj*

Vertex Attributes

vertex.attrib[0]        // position
vertex.attrib[3]        // normal
vertex.attrib[4]        // color0 (afaict, mocv)
vertex.attrib[5]        // color1 (?)
vertex.attrib[6]        // texcoord0
vertex.attrib[7]        // texcoord1

Program Locals

program.local[2]        // ? projectionMatrix[0]
program.local[3]        // ? projectionMatrix[1]
program.local[4]        // ? projectionMatrix[2]
program.local[5]        // ? projectionMatrix[3]

program.local[10]       // ? ambient.rgb (weirdly seems to be lacking values)
program.local[11]       // ? diffuse.rgb (weirdly seems to be lacking values)
program.local[12]       // lightDir.xyz

program.local[17]       // ???
program.local[18]       // ???
program.local[26]       // ???
program.local[27]       // ???
program.local[28]       // ???
program.local[29]       // ???
program.local[30]       // ???

program.local[31]       // modelViewMatrix[0]
program.local[32]       // modelViewMatrix[1]
program.local[33]       // modelViewMatrix[2]

MapObjDiffuse_T1

Permutation 0

!!ARBvp1.0

OPTION NV_vertex_program3;

PARAM c[34] = {
  { 1, 0 },
  program.local[1..33]
};

TEMP R0;
TEMP R1;
TEMP RC, HC;

BB1:
DP4     R1.x, vertex.attrib[0], c[33];
DP4     R0.x, vertex.attrib[0], c[31];
DP4     R0.y, vertex.attrib[0], c[32];
MOV     R0.w, c[0].x;
MOV     R0.z, R1.x;
DP4     result.position.w, R0, c[5];
DP4     result.position.z, R0, c[4];
DP4     result.position.y, R0, c[3];
DP4     result.position.x, R0, c[2];
MAD     R0.x, R1, c[30], c[30].y;
MAX     R0.x, R0, c[0].y;
MOV     result.color, vertex.attrib[4];
MOV     result.texcoord[0].zw, c[0].xyyx;
MOV     result.texcoord[0].xy, vertex.attrib[6];
POW_SAT result.fogcoord.x, R0.x, c[30].z;

END

Permutation 1

!!ARBvp1.0

OPTION NV_vertex_program3;

PARAM c[34] = {
  { 1, 0 },
  program.local[1..33]
};

TEMP R0;
TEMP R1;
TEMP RC, HC;

BB1:

// Obtain model-view normal

DP3     R0.x, vertex.attrib[3], c[31];                  // R0.x = dot(normal.xyz, c[31]);
DP3     R0.y, vertex.attrib[3], c[32];                  // R0.y = dot(normal.xyz, c[32]);
DP3     R0.z, vertex.attrib[3], c[33];                  // R0.z = dot(normal.xyz, c[33]);
DP3     R0.w, R0, R0;                                   // R0.w = dot(R0.xyz, R0.xyz);
RSQ     R0.w, R0.w;                                     // R0.w = inversesqrt(R0.w);
MUL     R1.xyz, R0.w, R0;                               // R1.xyz = R0.w * R0.xyz;

// Obtain lighting
// vec4 finalLight = vec4(saturate((vertexColor.rgb * light.rgb) + c[29].rgb), saturate(vertexColor.a));

DP3_SAT R1.x, R1, -c[12];                               // R1.x = saturate(dot(normal.xyz * -lightDir.xyz));
MUL     R1.xyz, R1.x, c[11];                            // R1.rgb = R1.x * diffuse.rgb;
ADD_SAT R1.xyz, c[10], R1;                              // R1.rgb = saturate(R1.rgb + ambient.rgb);
MAD_SAT result.color.xyz, vertex.attrib[4], R1, c[29];  // result.color.rgb = saturate((vertexColor.rgb * R1.rgb) + c[29].rgb);
MOV_SAT result.color.w, vertex.attrib[4];               // result.color.a = vertexColor.a;

// Obtain model-view position
// vec4 mvPosition = vec4(vertex.attrib[0] * modelViewMatrix, 1.0);

DP4     R0.x, vertex.attrib[0], c[31];
DP4     R0.y, vertex.attrib[0], c[32];
DP4     R1.w, vertex.attrib[0], c[33];
MOV     R0.z, R1.w;
MOV     R0.w, c[0].x;                                   // R0.w = 1.0;

// Obtain projected position
// result.position.xyzw = projectionMatrix * mvPosition;

DP4     result.position.x, R0, c[2];
DP4     result.position.y, R0, c[3];
DP4     result.position.z, R0, c[4];
DP4     result.position.w, R0, c[5];

// Obtain texture coordinate (t1)

MOV     result.texcoord[0].zw, c[0].xyyx;               // result.texcoord[0].zw = vec2(0.0, 1.0);
MOV     result.texcoord[0].xy, vertex.attrib[6];        // result.texcoord[0].xy = texcoords[0].xy;

// Something about fog

MAD     R0.x, R1.w, c[30], c[30].y;                     // R0.x = R1.w * c[30].w + c[30].y;
MAX     R0.x, R0, c[0].y;                               // R0.x = max(R0.x, 0.0);
POW_SAT result.fogcoord.x, R0.x, c[30].z;               // result.fogcoord.x = saturate(pow(R0.x, c[30].z));

END

Pixel Shaders

MapObj*

Program Locals

program.local[1]      // ???
program.local[2]      // ???

MapObjDiffuse

Permutation 0

!!ARBfp1.0

OPTION ARB_fog_linear;

PARAM c[1] = {
  { 2 }
};

TEMP R0;

TEX R0, fragment.texcoord[0], texture[0], 2D;       // R0 = texture2D(texture[0], fragment.texcoord[0]);
MUL R0, fragment.color.primary, R0;                 // R0 = fragment.color.primary * R0;
MOV result.color.w, R0;                             // result.color.a = R0.a;
MUL result.color.xyz, R0, c[0].x;                   // result.color.rgb = R0.rgb * 2.0;

END

Permutation Unk

!!ARBfp1.0

OPTION ARB_fog_linear;

PARAM c[3] = {
  { 2 },
  program.local[1..2]
};

TEMP R0;

TEX R0, fragment.texcoord[0], texture[0], 2D;       // R0 = texture2D(texture[0], fragment.texcoord[0]);
MUL R0.w, fragment.color.primary, R0;               // R0.a = fragment.color.primary.a * R0.a;
MOV result.color.w, R0;                             // result.color.a = R0.a;
MUL R0.xyz, fragment.color.primary, R0;             // R0.rgb = fragment.color.primary.rgb * R0.rgb;
SLT R0.w, R0, c[2];                                 // R0.a = R0.a < c[2].w ? 1.0 : 0.0;
KIL -R0.w;                                          // if (-R0.a < 0.0) { discard; }
MUL result.color.xyz, R0, c[0].x;                   // result.color.rgb = R0.rgb * 2.0;

END

MapObjOpaque

Permutation 0

!!ARBfp1.0

OPTION ARB_fog_linear;

PARAM c[1] = {
  { 2 }
};

TEMP R0;

TEX R0.xyz, fragment.texcoord[0], texture[0], 2D;
MUL R0.xyz, fragment.color.primary, R0;
MUL result.color.xyz, R0, c[0].x;
MOV result.color.w, fragment.color.primary;

END

Permutation Unk

!!ARBfp1.0

OPTION ARB_fog_linear;

PARAM c[3] = {
  { 2 },
  program.local[1..2]
};

TEMP R0;

TEX R0.xyz, fragment.texcoord[0], texture[0], 2D;   // R0.rgb = sample2D(texture[0], fragment.texcoord[0]).rgb;
SLT R0.w, fragment.color.primary, c[2];             // R0.a = fragment.color.primary.a < c[2].w ? 1.0 : 0.0;
KIL -R0.w;                                          // if (-R0.a < 0.0) { discard; }
MUL R0.xyz, fragment.color.primary, R0;             // R0.rgb = fragment.color.rgb * R0.rgb;
MUL result.color.xyz, R0, c[0].x;                   // result.color.rgb = R0.rgb * 2.0;
MOV result.color.w, fragment.color.primary;         // result.color.a = fragment.color.primary.a;

END

D3D9 WMO Shaders

Registers

c2 // fog color (rgba)

Logic

Permutation ?

ps_3_0

def c0, 2, 0, 0, 0              // vec4(2.0, 0.0, 0.0, 0.0)

dcl_color    v0                 // vertexColor
dcl_texcoord v1.xy              // coordinates[0]
dcl_fog      v2.x               // fogFactor
dcl_2d       s0                 // textures[0]

texld  r0, v1, s0               // vec4 sampled = texture2d(textures[0], coordinates[0]);
mul    oC0.w, r0.w, v0.w        // result.a = sampled.a * vertexColor.a;
mul    r0.xyz, r0, v0           // sampled.rgb = sampled.rgb * vertexColor.rgb;
mov    r1.xyz, c2               // vec4 r1.rgb = fogColor.rgb;
mad    r0.xyz, r0, c0.x, -r1    // sampled.rgb = (sampled.rgb * 2.0) + -fogColor.rgb;
mad    oC0.xyz, v2.x, r0, c2    // result.rgb = (fogFactor * sampled.rgb) + fogColor.rgb;

Miscellaneous

  • Default exterior vertex color going in to the vertex shader appears to be 0.5, 0.5, 0.5. Because the pixel shader multiplies the modulated color by 2.0, the 0.5 effectively causes no change. Note that the default might only be the case for batch type C vertices, since some Northrend buildings seem to actually use vertex colors on exterior vertices.