diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /assets/shaders/test_vshader.glsl | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'assets/shaders/test_vshader.glsl')
-rw-r--r-- | assets/shaders/test_vshader.glsl | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/assets/shaders/test_vshader.glsl b/assets/shaders/test_vshader.glsl new file mode 100644 index 00000000..a02d9720 --- /dev/null +++ b/assets/shaders/test_vshader.glsl | |||
@@ -0,0 +1,82 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | |||
8 | attribute vec3 vert; | ||
9 | attribute vec3 normal; | ||
10 | attribute vec2 texcoord; | ||
11 | |||
12 | // matrix uniforms | ||
13 | uniform mat4 u_mvMatrix; | ||
14 | uniform vec3 u_eye; | ||
15 | uniform mat4 u_normalMatrix; | ||
16 | uniform mat4 u_projMatrix; | ||
17 | uniform mat4 u_worldMatrix; | ||
18 | |||
19 | uniform mat4 u_shadowLightWorld; | ||
20 | uniform mat4 u_shadowBiasMatrix; | ||
21 | uniform mat4 u_vShadowLight; | ||
22 | uniform vec3 u_lightPos; | ||
23 | |||
24 | // varyings | ||
25 | varying vec4 vNormal; // w = texcoord.x | ||
26 | varying vec4 vECPos; // w = texcoord.y | ||
27 | varying vec3 vEyePos; | ||
28 | varying vec4 vShadowCoord; | ||
29 | varying vec2 vEnvTexCoord; | ||
30 | varying float vDiffuseIntensity; | ||
31 | |||
32 | #ifdef PC | ||
33 | void main() | ||
34 | { | ||
35 | vNormal.w = texcoord.x; | ||
36 | vECPos.w = texcoord.y; | ||
37 | vEyePos = u_eye; | ||
38 | |||
39 | // position normals and vert | ||
40 | vECPos.xyz = (u_mvMatrix*vec4(vert, 1.0)).xyz; | ||
41 | vNormal.xyz = (u_normalMatrix*vec4(normal, 0.0)).xyz; | ||
42 | |||
43 | // pass along the geo | ||
44 | gl_Position = u_projMatrix * vec4(vECPos.xyz, 1.0); | ||
45 | |||
46 | mat4 shadowMat = u_shadowBiasMatrix*u_projMatrix*u_vShadowLight*u_worldMatrix; | ||
47 | vShadowCoord = shadowMat * vec4(vert, 1.0); | ||
48 | } | ||
49 | #endif | ||
50 | |||
51 | #ifdef DEVICE | ||
52 | |||
53 | void main() | ||
54 | { | ||
55 | vNormal.w = texcoord.x; | ||
56 | vECPos.w = texcoord.y; | ||
57 | vEyePos = u_eye; | ||
58 | |||
59 | // position normals and vert | ||
60 | vECPos.xyz = (u_mvMatrix*vec4(vert, 1.0)).xyz; | ||
61 | vNormal.xyz = (u_normalMatrix*vec4(normal, 0.0)).xyz; | ||
62 | |||
63 | // pass along the geo | ||
64 | gl_Position = u_projMatrix * vec4(vECPos.xyz, 1.0); | ||
65 | |||
66 | //mat4 shadowMat = u_shadowBiasMatrix*u_projMatrix*u_vShadowLight*u_worldMatrix; | ||
67 | //vShadowCoord = shadowMat * vec4(vert, 1.0); | ||
68 | |||
69 | // normal mapping | ||
70 | vec3 normal = normalize(vNormal.xyz); | ||
71 | |||
72 | // create envmap coordinates | ||
73 | vec3 r = reflect( vec3(vECPos.xyz - u_eye.xyz), normal); | ||
74 | float m = 2.0 * length(r); | ||
75 | vEnvTexCoord = vec2(r.x/m + 0.5, r.y/m + 0.5); | ||
76 | |||
77 | vec3 lightDirection = normalize(u_lightPos - vECPos.xyz); | ||
78 | vDiffuseIntensity = max(0.0, dot(normal, lightDirection)); | ||
79 | |||
80 | } | ||
81 | |||
82 | #endif | ||