]> git.lizzy.rs Git - irrlicht.git/blob - media/d3d9.vsh
Merging r6194 from trunk to ogl-es branch.
[irrlicht.git] / media / d3d9.vsh
1 ; part of the Irrlicht Engine Shader example.\r
2 ; This Direct3D9 vertex shader will be loaded by the engine.\r
3 ; Please note that these example shaders don't do anything really useful. \r
4 ; They only demonstrate that shaders can be used in Irrlicht.\r
5 \r
6 vs.1.1\r
7 \r
8 dcl_position v0;    ; declare position\r
9 dcl_normal v1;      ; declare normal\r
10 dcl_color v2;       ; declare color\r
11 dcl_texcoord0 v3;   ; declare texture coordinate\r
12 \r
13 ; transpose and transform position to clip space \r
14 mul r0, v0.x, c4      \r
15 mad r0, v0.y, c5, r0   \r
16 mad r0, v0.z, c6, r0   \r
17 add oPos, c7, r0       \r
18 \r
19 ; transform normal \r
20 dp3 r1.x, v1, c0  \r
21 dp3 r1.y, v1, c1  \r
22 dp3 r1.z, v1, c2  \r
23 \r
24 ; renormalize normal \r
25 dp3 r1.w, r1, r1  \r
26 rsq r1.w, r1.w    \r
27 mul r1, r1, r1.w  \r
28 \r
29 ; calculate light vector \r
30 m4x4 r6, v0, c10      ; vertex into world position\r
31 add r2, c8, -r6       ; vtxpos - lightpos\r
32 \r
33 ; normalize light vector \r
34 dp3 r2.w, r2, r2  \r
35 rsq r2.w, r2.w    \r
36 mul r2, r2, r2.w  \r
37 \r
38 ; calculate light color \r
39 dp3 r3, r1, r2       ; dp3 with negative light vector \r
40 lit r5, r3           ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y\r
41 mul oD0, r5.y, c9    ; ouput diffuse color \r
42 mov oT0, v3          ; store texture coordinates