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