Skip to content

TBC Shading

fallenoak edited this page Sep 10, 2016 · 7 revisions

Vertex Shaders

MapObjDiffuse

Permutation 2

!!ARBvp1.0

PARAM c1 = { 0, 1, 0, 0 };
PARAM c0 = { 0, 1, 2, 0 };

TEMP R0;

ATTRIB v19 = vertex.color;
ATTRIB v24 = vertex.texcoord[0];
ATTRIB v7 = vertex.attrib[7];
ATTRIB v17 = vertex.weight;
ATTRIB v18 = vertex.normal;
ATTRIB v16 = vertex.position;

PARAM c6[4] = { program.local[6..9] };
PARAM c2[4] = { program.local[2..5] };
PARAM c31[3] = { program.local[31..33] };

MOV result.color.front.primary, v19;
MOV result.color.front.secondary, c0.x;
MOV result.fogcoord.x, c0.x;
DP4 R0.x, c31[0], v16;
DP4 R0.y, c31[1], v16;
DP4 R0.z, c31[2], v16;
MOV R0.w, c0.y;
DP4 result.position.x, c2[0], R0;
DP4 result.position.y, c2[1], R0;
DP4 result.position.z, c2[2], R0;
DP4 result.position.w, c2[3], R0;
DP4 result.texcoord[0].x, c6[0], v24;
DP4 result.texcoord[0].y, c6[1], v24;
MOV result.texcoord[0].zw, c1.xyxy;
END

# permutation:2 -DBONE_INFLUENCES=0 -DLIGHTS=0 -DLIGHT_ENABLE=0 -DSPEC_ENABLE=0 -DVERTEX_COLOR_ENABLE=1 -DFOG_ENABLE=0

Permutation 10

!!ARBvp1.0

PARAM c1 = { 0, 1, 0, 0 };
PARAM c0 = { 0, 1, 2, 0 };

TEMP R0;

ATTRIB v19 = vertex.color;
ATTRIB v24 = vertex.texcoord[0];
ATTRIB v7 = vertex.attrib[7];
ATTRIB v17 = vertex.weight;
ATTRIB v18 = vertex.normal;
ATTRIB v16 = vertex.position;

PARAM c6[4] = { program.local[6..9] };
PARAM c28[2] = { program.local[28..29] };
PARAM c11 = program.local[11];
PARAM c10 = program.local[10];
PARAM c12 = program.local[12];
PARAM c2[4] = { program.local[2..5] };
PARAM c31[3] = { program.local[31..33] };

MOV result.color.front.secondary, c0.x;
MOV result.fogcoord.x, c0.x;
DP4 R0.x, c31[0], v16;
DP4 R0.y, c31[1], v16;
DP4 R0.z, c31[2], v16;
MOV R0.w, c0.y;
DP4 result.position.x, c2[0], R0;
DP4 result.position.y, c2[1], R0;
DP4 result.position.z, c2[2], R0;
DP4 result.position.w, c2[3], R0;
DP3 R0.y, c31[0].xyzx, v18.xyzx;
DP3 R0.z, c31[1].xyzx, v18.xyzx;
DP3 R0.w, c31[2].xyzx, v18.xyzx;
DP3 R0.x, R0.yzwy, R0.yzwy;
RSQ R0.x, R0.x;
MUL R0.xyz, R0.x, R0.yzwy;

DP3 R0.x, -c12.xyzx, R0.xyzx;                      # R0.x    = dot(-lightDir, normal);
MIN R0.x, c0.y, R0.x;                              # R0.x    = min(R0.x, 1);
MAX R0.w, c0.x, R0.x;                              # R0.w    = saturate(dot(-lightDir, normal));

MOV R0.xyz, c10;                                   # R0.xyz  = diffuse.rgb;
MAD R0.xyz, R0.w, R0.xyzx, c11.xyzx;               # R0.xyz  = (R0.w * diffuse.rgb) + ambient.rgb;
MOV R0.w, c0.y;                                    # R0.w    = 1.0;
MAD result.color.front.primary, v19, R0, c28[1];   # primary = (vertex.color * R0) + c28[1];

DP4 result.texcoord[0].x, c6[0], v24;
DP4 result.texcoord[0].y, c6[1], v24;
MOV result.texcoord[0].zw, c1.xyxy;

END

# permutation:10 -DBONE_INFLUENCES=0 -DLIGHTS=0 -DLIGHT_ENABLE=1 -DSPEC_ENABLE=0 -DVERTEX_COLOR_ENABLE=1 -DFOG_ENABLE=0

Pixel Shaders

MapObjOpaque

Permutation 0

!!ARBfp1.0

TEMP R0;

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

END

Permutation 1

!!ARBfp1.0

TEMP R0;
TEMP R1;

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

END

Ideas

  • fragment.color.primary: lighting (both mocv and sun light)
  • fragment.color.secondary: specular term (only seems to be set when LIGHT_ENABLED and SPEC_ENABLED are set in the vertex shader
main() {
  vec4 sampled0 = texture(textures[0], coordinates[0]);

  vec4 result;

  result.rgb = vertexColor.rgb * sampled0.rgb + (light.rgb * vertexColor.a);
  result.a = vertexColor.a;
}
Clone this wiki locally