diff options
Diffstat (limited to 'linden/indra/newview/app_settings/skinned_avatar.vp')
-rw-r--r-- | linden/indra/newview/app_settings/skinned_avatar.vp | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/linden/indra/newview/app_settings/skinned_avatar.vp b/linden/indra/newview/app_settings/skinned_avatar.vp new file mode 100644 index 0000000..a4adbd5 --- /dev/null +++ b/linden/indra/newview/app_settings/skinned_avatar.vp | |||
@@ -0,0 +1,146 @@ | |||
1 | !!ARBvp1.0 | ||
2 | # Vertex Program for lit, skinned avatars | ||
3 | |||
4 | # Parameters | ||
5 | PARAM mat[45] = { program.env[0..44] }; | ||
6 | PARAM embossScale = program.env[63]; | ||
7 | PARAM proj[4] = { state.matrix.projection }; | ||
8 | PARAM modelAmbient = state.lightmodel.ambient; | ||
9 | PARAM materialDiffuse = state.material.diffuse; | ||
10 | PARAM lightDir0 = state.light[0].position; | ||
11 | PARAM diffuseCol0 = state.light[0].diffuse; | ||
12 | PARAM lightDir1 = state.light[1].position; | ||
13 | PARAM diffuseCol1 = state.light[1].diffuse; | ||
14 | PARAM lightPos2 = state.light[2].position; | ||
15 | PARAM diffuseCol2 = state.light[2].diffuse; | ||
16 | PARAM lightPos3 = state.light[3].position; | ||
17 | PARAM diffuseCol3 = state.light[3].diffuse; | ||
18 | |||
19 | # Per vertex inputs | ||
20 | ATTRIB iPos = vertex.position; | ||
21 | ATTRIB iNormal = vertex.normal; | ||
22 | ATTRIB iTex0 = vertex.texcoord[0]; | ||
23 | ATTRIB iTex1 = vertex.texcoord[1]; | ||
24 | ATTRIB iWeight = vertex.attrib[1]; | ||
25 | ATTRIB iBinormal = vertex.attrib[6]; | ||
26 | |||
27 | # Temporaries | ||
28 | TEMP blendBinorm; # result of skinned binormal | ||
29 | TEMP blendTangent; # result of skinned tangent | ||
30 | TEMP blendMat; | ||
31 | TEMP blendPos; # skinned vertex pos | ||
32 | TEMP dots; # dot product for lighting calculations | ||
33 | TEMP blendNorm; # skinned normal | ||
34 | TEMP colorAcc; # color accumulator | ||
35 | |||
36 | ALIAS scaledWeight = colorAcc; | ||
37 | ALIAS divisor = blendMat; # divisor for normalization process | ||
38 | ALIAS lightDir = blendBinorm; | ||
39 | |||
40 | ADDRESS address; | ||
41 | |||
42 | # Outputs | ||
43 | OUTPUT oPos = result.position; #position | ||
44 | OUTPUT oCol0 = result.color; #primary color | ||
45 | OUTPUT oTex0 = result.texcoord[0]; #texture coordinate set 0 | ||
46 | OUTPUT oTex1 = result.texcoord[1]; #texture coordinate set 1 | ||
47 | OUTPUT oFog = result.fogcoord; #output fog coord | ||
48 | |||
49 | #fix input blending weight | ||
50 | ARL address.x, iWeight.x; | ||
51 | FRC scaledWeight.x, iWeight; | ||
52 | |||
53 | #Output position and normal | ||
54 | MUL dots, mat[address.x + 1], {1,1,1,1}; | ||
55 | SUB blendMat, dots, mat[address.x + 0]; | ||
56 | MAD blendMat, scaledWeight.x, blendMat, mat[address.x + 0]; | ||
57 | DP4 blendPos.x, blendMat, iPos; | ||
58 | DP3 blendNorm.x, blendMat, iNormal; | ||
59 | DP3 blendBinorm.x, blendMat, iBinormal; | ||
60 | |||
61 | MUL dots, mat[address.x + 16], {1,1,1,1}; | ||
62 | SUB blendMat, dots, mat[address.x + 15]; | ||
63 | MAD blendMat, scaledWeight.x, blendMat, mat[address.x + 15]; | ||
64 | DP4 blendPos.y, blendMat, iPos; | ||
65 | DP3 blendNorm.y, blendMat, iNormal; | ||
66 | DP3 blendBinorm.y, blendMat, iBinormal; | ||
67 | |||
68 | MUL dots, mat[address.x + 31], {1,1,1,1}; | ||
69 | SUB blendMat, dots, mat[address.x + 30]; | ||
70 | MAD blendMat, scaledWeight.x, blendMat, mat[address.x + 30]; | ||
71 | DP4 blendPos.z, blendMat, iPos; | ||
72 | DP3 blendNorm.z, blendMat, iNormal; | ||
73 | DP3 blendBinorm.z, blendMat, iBinormal; | ||
74 | MOV blendPos.w, {0, 0, 0, 1}; | ||
75 | |||
76 | #renormalize normal | ||
77 | #add "normal spread" effect | ||
78 | ADD blendNorm, blendNorm, {0, 0, -0.4, 0}; | ||
79 | DP3 divisor.w, blendNorm, blendNorm; | ||
80 | RSQ divisor.xyz, divisor.w; | ||
81 | MUL blendNorm.xyz, blendNorm, divisor; | ||
82 | |||
83 | #renormalize binormal | ||
84 | DP3 divisor.w, blendBinorm, blendBinorm; | ||
85 | RSQ divisor.xyz, divisor.w; | ||
86 | MUL blendBinorm.xyz, blendBinorm, divisor; | ||
87 | |||
88 | #Projection | ||
89 | DP4 oPos.x, proj[0], blendPos; | ||
90 | DP4 oPos.y, proj[1], blendPos; | ||
91 | DP4 oPos.z, proj[2], blendPos; | ||
92 | DP4 oPos.w, proj[3], blendPos; | ||
93 | |||
94 | #tangent = binormal X normal | ||
95 | XPD blendTangent, blendNorm, blendBinorm; | ||
96 | |||
97 | #oTex1 = iTex0 + LLVector2( lightDir0 * tangent, lightDir0 * binormal ); | ||
98 | DP3 blendTangent.x, lightDir0, blendTangent; | ||
99 | DP3 blendTangent.y, lightDir0, blendBinorm; | ||
100 | MAD oTex1, embossScale.x, blendTangent, iTex0; | ||
101 | |||
102 | #Light 0 | ||
103 | DP3 colorAcc.xyz, blendNorm, lightDir0; | ||
104 | MAD colorAcc.xyz, colorAcc, {0.55, 0.55, 0.55, 0.55}, {0.3, 0.3, 0.3, 0.3}; | ||
105 | MAX colorAcc, colorAcc, {0, 0, 0, 0}; | ||
106 | |||
107 | # Accumulate color contributions. | ||
108 | MAD colorAcc.xyz, colorAcc.x, diffuseCol0, modelAmbient; | ||
109 | MOV colorAcc.w, {0, 0, 0, 1.0}; | ||
110 | |||
111 | #Light 1 | ||
112 | DP3 dots.x, blendNorm, lightDir1; | ||
113 | |||
114 | #Light 2 | ||
115 | SUB lightDir, lightPos2, blendPos; | ||
116 | DP3 divisor.w, lightDir, lightDir; | ||
117 | RSQ divisor.xyz, divisor.w; | ||
118 | MUL lightDir.xyz, lightDir, divisor; | ||
119 | |||
120 | DP3 dots.y, blendNorm, lightDir; | ||
121 | |||
122 | #Light 3 | ||
123 | SUB lightDir, lightPos3, blendPos; | ||
124 | DP3 divisor.w, lightDir, lightDir; | ||
125 | RSQ divisor.xyz, divisor.w; | ||
126 | MUL lightDir.xyz, lightDir, divisor; | ||
127 | |||
128 | DP3 dots.z, blendNorm, lightDir; | ||
129 | |||
130 | # Apply Lights | ||
131 | MAD dots, dots, {0.55, 0.55, 0.55, 0.55}, {0.3, 0.3, 0.3, 0.3}; | ||
132 | MAX dots, dots, {0,0,0,0}; | ||
133 | MAD colorAcc.xyz, dots.x, diffuseCol1, colorAcc; | ||
134 | MAD colorAcc.xyz, dots.y, diffuseCol2, colorAcc; | ||
135 | MAD colorAcc.xyz, dots.z, diffuseCol3, colorAcc; | ||
136 | |||
137 | #Output color | ||
138 | MUL oCol0, materialDiffuse, colorAcc; | ||
139 | |||
140 | #Output tex coordinate | ||
141 | MOV oTex0, iTex0; | ||
142 | |||
143 | #Output fog | ||
144 | MOV oFog.x, blendPos.z; | ||
145 | |||
146 | END | ||