diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/media/opengl.vsh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/media/opengl.vsh b/libraries/irrlicht-1.8/media/opengl.vsh new file mode 100644 index 0000000..9cd71bf --- /dev/null +++ b/libraries/irrlicht-1.8/media/opengl.vsh | |||
@@ -0,0 +1,60 @@ | |||
1 | !!ARBvp1.0 | ||
2 | # part of the Irrlicht Engine Shader example. | ||
3 | # Please note that these example shaders don't do anything really useful. | ||
4 | # They only demonstrate that shaders can be used in Irrlicht. | ||
5 | |||
6 | #input | ||
7 | ATTRIB InPos = vertex.position; | ||
8 | ATTRIB InColor = vertex.color; | ||
9 | ATTRIB InNormal = vertex.normal; | ||
10 | ATTRIB InTexCoord = vertex.texcoord; | ||
11 | |||
12 | #output | ||
13 | OUTPUT OutPos = result.position; | ||
14 | OUTPUT OutColor = result.color; | ||
15 | OUTPUT OutTexCoord = result.texcoord; | ||
16 | |||
17 | PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix. | ||
18 | TEMP Temp; | ||
19 | TEMP TempColor; | ||
20 | TEMP TempNormal; | ||
21 | TEMP TempPos; | ||
22 | |||
23 | #transform position to clip space | ||
24 | DP4 Temp.x, MVP[0], InPos; | ||
25 | DP4 Temp.y, MVP[1], InPos; | ||
26 | DP4 Temp.z, MVP[2], InPos; | ||
27 | DP4 Temp.w, MVP[3], InPos; | ||
28 | |||
29 | #transform normal | ||
30 | DP3 TempNormal.x, InNormal.x, program.local[0]; | ||
31 | DP3 TempNormal.y, InNormal.y, program.local[1]; | ||
32 | DP3 TempNormal.z, InNormal.z, program.local[2]; | ||
33 | |||
34 | #renormalize normal | ||
35 | DP3 TempNormal.w, TempNormal, TempNormal; | ||
36 | RSQ TempNormal.w, TempNormal.w; | ||
37 | MUL TempNormal, TempNormal, TempNormal.w; | ||
38 | |||
39 | # calculate light vector | ||
40 | DP4 TempPos.x, InPos, program.local[10]; # vertex into world position | ||
41 | DP4 TempPos.y, InPos, program.local[11]; | ||
42 | DP4 TempPos.z, InPos, program.local[12]; | ||
43 | DP4 TempPos.w, InPos, program.local[13]; | ||
44 | |||
45 | ADD TempPos, program.local[8], -TempPos; # vtxpos - lightpos | ||
46 | |||
47 | # normalize light vector | ||
48 | DP3 TempPos.w, TempPos, TempPos; | ||
49 | RSQ TempPos.w, TempPos.w; | ||
50 | MUL TempPos, TempPos, TempPos.w; | ||
51 | |||
52 | # calculate light color | ||
53 | DP3 TempColor, TempNormal, TempPos; # dp3 with negative light vector | ||
54 | LIT OutColor, TempColor; # clamp to zero if r3 < 0, r5 has diffuce component in r5.y | ||
55 | MUL OutColor, TempColor.y, program.local[9]; # ouput diffuse color | ||
56 | MOV OutColor.w, 1.0; # we want alpha to be always 1 | ||
57 | MOV OutTexCoord, InTexCoord; # store texture coordinate | ||
58 | MOV OutPos, Temp; | ||
59 | |||
60 | END \ No newline at end of file | ||