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