OSDN Git Service

Set optimal mime types and executable settings.
[mikumikustudio/MikuMikuStudio.git] / src / jmetest / data / images / bump_parallax.fp
1 !!ARBfp1.0\r
2 \r
3 PARAM light0color = state.light[0].diffuse;\r
4 PARAM light1color = state.light[1].diffuse;\r
5 PARAM ambient = state.lightmodel.ambient;\r
6 \r
7 TEMP eyevects;\r
8 TEMP rgb, normal, height, temp, bump, total;\r
9 TEMP light0tsvec, light1tsvec;\r
10 TEMP newtexcoord;\r
11 \r
12 # normalize tangent space eye vector\r
13 DP3 temp, fragment.texcoord[3], fragment.texcoord[3];\r
14 RSQ temp, temp.x;\r
15 MUL eyevects, fragment.texcoord[3], temp;\r
16 \r
17 # calculate offset and new texture coordinate\r
18 TEX height, fragment.texcoord[0], texture[2], 2D;\r
19 MAD height, height, 0.04, -0.02;  # scale and bias\r
20 MAD newtexcoord, height, eyevects, fragment.texcoord[0];\r
21 \r
22 # get texture data\r
23 TEX rgb, newtexcoord, texture[0], 2D;\r
24 TEX normal, newtexcoord, texture[1], 2D;\r
25 \r
26 # remove scale and bias from the normal map\r
27 MAD normal, normal, 2.0, -1.0;\r
28 \r
29 # normalize the normal map\r
30 DP3 temp, normal, normal;\r
31 RSQ temp, temp.r;\r
32 MUL normal, normal, temp;\r
33 \r
34 # normalize the light0 vector\r
35 DP3 temp, fragment.texcoord[1], fragment.texcoord[1];\r
36 RSQ temp, temp.x;\r
37 MUL light0tsvec, fragment.texcoord[1], temp;\r
38 \r
39 # normal dot lightdir\r
40 DP3 bump, normal, light0tsvec;\r
41 \r
42 # add light0 color\r
43 MUL_SAT total, bump, light0color;\r
44 \r
45 # normalize the light1 vector\r
46 DP3 temp, fragment.texcoord[2], fragment.texcoord[2];\r
47 RSQ temp, temp.x;\r
48 MUL light1tsvec, fragment.texcoord[2], temp;\r
49 \r
50 # normal dot lightdir\r
51 DP3 bump, normal, light1tsvec;\r
52 \r
53 # add light1 color\r
54 MUL_SAT bump, bump, light1color;\r
55 ADD_SAT total, total, bump;\r
56 \r
57 # add ambient lighting\r
58 ADD_SAT total, total, ambient;\r
59 \r
60 # multiply by regular texture map color\r
61 MUL_SAT result.color, rgb, total;\r
62 \r
63 END\r