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