aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/app_settings/skinned_avatar_nobump.vp
blob: 1874e542d767ab9f41501077f04a24954708a608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
!!ARBvp1.0
# Vertex Program for lit, skinned avatars

# Parameters
PARAM mat[45]		= { program.env[0..44] };
PARAM proj[4]		= { state.matrix.projection };		
PARAM modelAmbient	= state.lightmodel.ambient;
PARAM materialDiffuse = state.material.diffuse;
PARAM lightDir0     = state.light[0].position;
PARAM diffuseCol0   = state.light[0].diffuse;
PARAM lightDir1     = state.light[1].position;
PARAM diffuseCol1   = state.light[1].diffuse;
PARAM lightPos2     = state.light[2].position;
PARAM diffuseCol2   = state.light[2].diffuse;
PARAM lightPos3     = state.light[3].position;
PARAM diffuseCol3   = state.light[3].diffuse;

# Per vertex inputs
ATTRIB iPos			= vertex.position;
ATTRIB iNormal      = vertex.normal;
ATTRIB iTex0		= vertex.texcoord[0];
ATTRIB iWeight		= vertex.attrib[1];

# Temporaries
TEMP blendMat;
TEMP blendPos;		# skinned vertex pos
TEMP dots;			# dot product for lighting calculations
TEMP blendNorm;	# skinned normal
TEMP colorAcc;		# color accumulator
TEMP lightDir;


ALIAS scaledWeight	= colorAcc;
ALIAS divisor		= blendMat;		# divisor for normalization process

ADDRESS address;

# Outputs
OUTPUT oPos			= result.position;			#position
OUTPUT oCol0		= result.color;				#primary color
OUTPUT oTex0		= result.texcoord[0];		#texture coordinate set 0
OUTPUT oFog			= result.fogcoord;			#output fog coord

#fix input blending weight
ARL address.x, iWeight.x;
FRC scaledWeight.x, iWeight;

#Output position and normal
MUL dots, mat[address.x + 1], {1,1,1,1};
SUB blendMat, dots, mat[address.x + 0];
MAD blendMat, scaledWeight.x, blendMat, mat[address.x + 0];
DP4 blendPos.x, blendMat, iPos;
DP3 blendNorm.x, blendMat, iNormal;

MUL dots, mat[address.x + 16], {1,1,1,1};
SUB blendMat, dots, mat[address.x + 15];
MAD blendMat, scaledWeight.x, blendMat, mat[address.x + 15];
DP4 blendPos.y, blendMat, iPos;
DP3 blendNorm.y, blendMat, iNormal;


MUL dots, mat[address.x + 31], {1,1,1,1};
SUB blendMat, dots, mat[address.x + 30];
MAD blendMat, scaledWeight.x, blendMat, mat[address.x + 30];
DP4 blendPos.z, blendMat, iPos;
DP3 blendNorm.z, blendMat, iNormal;
MOV blendPos.w, {0, 0, 0, 1};

#renormalize normal
#add "backlighting" effect
ADD blendNorm, blendNorm, {0, 0, -0.2, 0};
DP3 divisor.w, blendNorm, blendNorm;
RSQ divisor.xyz, divisor.w;
MUL blendNorm.xyz, blendNorm, divisor;


#Projection
DP4 oPos.x, proj[0], blendPos;
DP4 oPos.y, proj[1], blendPos;
DP4 oPos.z, proj[2], blendPos;
DP4 oPos.w, proj[3], blendPos;


#Light 0
DP3 colorAcc.xyz, blendNorm, lightDir0;
MAD colorAcc.xyz, colorAcc, {0.55, 0.55, 0.55, 0.55}, {0.3, 0.3, 0.3, 0.3};
MAX colorAcc, colorAcc, {0, 0, 0, 0};

# Accumulate color contributions.
MAD colorAcc.xyz, colorAcc.x, diffuseCol0, modelAmbient;
MOV colorAcc.w, {0, 0, 0, 1.0};

#Light 1
DP3 dots.x, blendNorm, lightDir1;

#Light 2
SUB lightDir, lightPos2, blendPos;
DP3 divisor.w, lightDir, lightDir;
RSQ divisor.xyz, divisor.w;
MUL lightDir.xyz, lightDir, divisor;

DP3 dots.y, blendNorm, lightDir;

#Light 3
SUB lightDir, lightPos3, blendPos;
DP3 divisor.w, lightDir, lightDir;
RSQ divisor.xyz, divisor.w;
MUL lightDir.xyz, lightDir, divisor;

DP3 dots.z, blendNorm, lightDir;

#Apply lights
MAD dots, dots, {0.55, 0.55, 0.55, 0.55}, {0.3, 0.3, 0.3, 0.3};
MAX dots, dots, {0, 0, 0, 0};
MAD colorAcc.xyz, dots.x, diffuseCol1, colorAcc;
MAD colorAcc.xyz, dots.y, diffuseCol2, colorAcc;
MAD colorAcc.xyz, dots.z, diffuseCol3, colorAcc;

#Output color
MUL oCol0, materialDiffuse, colorAcc;

#Output tex coordinate
MOV oTex0, iTex0;

#Output fog
MOV oFog.x, blendPos.z;

END