diff options
author | Kruti Shah | 2012-07-17 12:40:00 -0700 |
---|---|---|
committer | Kruti Shah | 2012-07-17 12:40:00 -0700 |
commit | bf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch) | |
tree | 2156d9920ea1b7db49ed6460545fea7cda121bae /assets/shaders/ub_vshader.glsl | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | b4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff) | |
download | ninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz |
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'assets/shaders/ub_vshader.glsl')
-rwxr-xr-x | assets/shaders/ub_vshader.glsl | 255 |
1 files changed, 128 insertions, 127 deletions
diff --git a/assets/shaders/ub_vshader.glsl b/assets/shaders/ub_vshader.glsl index a559d844..4e2667a1 100755 --- a/assets/shaders/ub_vshader.glsl +++ b/assets/shaders/ub_vshader.glsl | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -44,65 +45,65 @@ uniform vec3 u_eye; | |||
44 | 45 | ||
45 | // attributes | 46 | // attributes |
46 | #if defined( MATERIAL ) | 47 | #if defined( MATERIAL ) |
47 | uniform vec4 u_ambientColor; | 48 | uniform vec4 u_ambientColor; |
48 | uniform vec4 u_diffuseColor; | 49 | uniform vec4 u_diffuseColor; |
49 | uniform vec4 u_specularColor; | 50 | uniform vec4 u_specularColor; |
50 | uniform float u_specularPower; | 51 | uniform float u_specularPower; |
51 | #endif | 52 | #endif |
52 | 53 | ||
53 | #if defined( LIGHTING ) | 54 | #if defined( LIGHTING ) |
54 | varying vec3 v_normal; | 55 | varying vec3 v_normal; |
55 | #if defined( LIGHT_0 ) | 56 | #if defined( LIGHT_0 ) |
56 | uniform int u_light0Type; | 57 | uniform int u_light0Type; |
57 | uniform vec3 u_light0Pos; | 58 | uniform vec3 u_light0Pos; |
58 | uniform vec3 u_light0Dir; | 59 | uniform vec3 u_light0Dir; |
59 | uniform vec3 u_light0Atten; | 60 | uniform vec3 u_light0Atten; |
60 | uniform vec2 u_light0Spot; | 61 | uniform vec2 u_light0Spot; |
61 | uniform vec4 u_light0Color; | 62 | uniform vec4 u_light0Color; |
62 | uniform vec4 u_light0Specular; | 63 | uniform vec4 u_light0Specular; |
63 | varying vec3 v_light0Dir; | 64 | varying vec3 v_light0Dir; |
64 | varying vec3 v_light0SpotDir; | 65 | varying vec3 v_light0SpotDir; |
65 | #endif | 66 | #endif |
66 | 67 | ||
67 | #if defined( LIGHT_1 ) | 68 | #if defined( LIGHT_1 ) |
68 | uniform int u_light1Type; | 69 | uniform int u_light1Type; |
69 | uniform vec3 u_light1Pos; | 70 | uniform vec3 u_light1Pos; |
70 | uniform vec3 u_light1Dir; | 71 | uniform vec3 u_light1Dir; |
71 | uniform vec3 u_light1Atten; | 72 | uniform vec3 u_light1Atten; |
72 | uniform vec2 u_light1Spot; | 73 | uniform vec2 u_light1Spot; |
73 | uniform vec3 u_light1Color; | 74 | uniform vec3 u_light1Color; |
74 | uniform vec4 u_light1Specular; | 75 | uniform vec4 u_light1Specular; |
75 | varying vec3 v_light1Dir; | 76 | varying vec3 v_light1Dir; |
76 | varying vec3 v_light1SpotDir; | 77 | varying vec3 v_light1SpotDir; |
77 | #endif | 78 | #endif |
78 | 79 | ||
79 | #if defined( LIGHT_2 ) | 80 | #if defined( LIGHT_2 ) |
80 | uniform int u_light2Type; // 0 - dir, 1 - point, 2 - spot | 81 | uniform int u_light2Type; // 0 - dir, 1 - point, 2 - spot |
81 | uniform vec3 u_light2Pos; | 82 | uniform vec3 u_light2Pos; |
82 | uniform vec3 u_light2Dir; | 83 | uniform vec3 u_light2Dir; |
83 | uniform vec3 u_light2Atten; | 84 | uniform vec3 u_light2Atten; |
84 | uniform vec2 u_light2Spot; // 0 - spot light cutoff angle, 1 - spot light exponent | 85 | uniform vec2 u_light2Spot; // 0 - spot light cutoff angle, 1 - spot light exponent |
85 | uniform vec3 u_light2Color; | 86 | uniform vec3 u_light2Color; |
86 | uniform vec4 u_light2Specular; | 87 | uniform vec4 u_light2Specular; |
87 | varying vec3 v_light2Dir; | 88 | varying vec3 v_light2Dir; |
88 | varying vec3 v_light2SpotDir; | 89 | varying vec3 v_light2SpotDir; |
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | #if defined( LIGHT_3 ) | 92 | #if defined( LIGHT_3 ) |
92 | uniform int u_light3Type; | 93 | uniform int u_light3Type; |
93 | uniform vec3 u_light3Pos; | 94 | uniform vec3 u_light3Pos; |
94 | uniform vec3 u_light3Dir; | 95 | uniform vec3 u_light3Dir; |
95 | uniform vec3 u_light3Atten; | 96 | uniform vec3 u_light3Atten; |
96 | uniform vec2 u_light3Spot; | 97 | uniform vec2 u_light3Spot; |
97 | uniform vec3 u_light3Color; | 98 | uniform vec3 u_light3Color; |
98 | uniform vec4 u_light3Specular; | 99 | uniform vec4 u_light3Specular; |
99 | varying vec3 v_light3Dir; | 100 | varying vec3 v_light3Dir; |
100 | varying vec3 v_light3SpotDir; | 101 | varying vec3 v_light3SpotDir; |
101 | #endif | 102 | #endif |
102 | #endif | 103 | #endif |
103 | 104 | ||
104 | #if defined( ENVIRONMENT_MAP ) | 105 | #if defined( ENVIRONMENT_MAP ) |
105 | uniform float u_envReflection; | 106 | uniform float u_envReflection; |
106 | #endif | 107 | #endif |
107 | 108 | ||
108 | varying vec3 v_mvPos; | 109 | varying vec3 v_mvPos; |
@@ -111,76 +112,76 @@ varying vec2 v_texcoord; | |||
111 | 112 | ||
112 | #if defined( PC ) | 113 | #if defined( PC ) |
113 | void main() { | 114 | void main() { |
114 | // position normals and vert | 115 | // position normals and vert |
115 | v_mvPos = ( u_mvMatrix * vec4( a_pos, 1.0 ) ).xyz; | 116 | v_mvPos = ( u_mvMatrix * vec4( a_pos, 1.0 ) ).xyz; |
116 | 117 | ||
117 | v_texcoord = (u_uvMatrix * vec4(a_texcoord, 0, 1.0)).xy; | 118 | v_texcoord = (u_uvMatrix * vec4(a_texcoord, 0, 1.0)).xy; |
118 | #if ( defined( LIGHTING ) || defined( ENVIRONMENT_MAP ) ) | 119 | #if ( defined( LIGHTING ) || defined( ENVIRONMENT_MAP ) ) |
119 | v_normal = ( u_normalMatrix * vec4( a_normal, 0.0 ) ).xyz; | 120 | v_normal = ( u_normalMatrix * vec4( a_normal, 0.0 ) ).xyz; |
120 | #endif | 121 | #endif |
121 | 122 | ||
122 | #if defined( LIGHTING ) | 123 | #if defined( LIGHTING ) |
123 | v_eyeDir = vec3(-u_viewMatrix[3][0], -u_viewMatrix[3][1], -u_viewMatrix[3][2]); | 124 | v_eyeDir = vec3(-u_viewMatrix[3][0], -u_viewMatrix[3][1], -u_viewMatrix[3][2]); |
124 | #if defined( LIGHT_0 ) | 125 | #if defined( LIGHT_0 ) |
125 | { | 126 | { |
126 | vec3 lpos = ( u_viewMatrix * vec4( u_light0Pos, 1.0 ) ).xyz; | 127 | vec3 lpos = ( u_viewMatrix * vec4( u_light0Pos, 1.0 ) ).xyz; |
127 | 128 | ||
128 | #if ( LIGHT_0 == 0 ) | 129 | #if ( LIGHT_0 == 0 ) |
129 | v_light0Dir = ( u_viewMatrix * vec4( -u_light0Dir, 0.0 ) ).xyz; | 130 | v_light0Dir = ( u_viewMatrix * vec4( -u_light0Dir, 0.0 ) ).xyz; |
130 | #else | 131 | #else |
131 | v_light0Dir = lpos - v_mvPos; | 132 | v_light0Dir = lpos - v_mvPos; |
132 | #if ( LIGHT_0 == 2 ) | 133 | #if ( LIGHT_0 == 2 ) |
133 | v_light0SpotDir = (u_viewMatrix * vec4( -u_light0Dir, 0.0 )).xyz; | 134 | v_light0SpotDir = (u_viewMatrix * vec4( -u_light0Dir, 0.0 )).xyz; |
134 | #endif // ( LIGHT_0 == 2 ) | 135 | #endif // ( LIGHT_0 == 2 ) |
135 | #endif // ( LIGHT_0 == 0 ) | 136 | #endif // ( LIGHT_0 == 0 ) |
136 | } | 137 | } |
137 | #endif // defined( LIGHT_0 ) | 138 | #endif // defined( LIGHT_0 ) |
138 | #if defined( LIGHT_1 ) | 139 | #if defined( LIGHT_1 ) |
139 | { | 140 | { |
140 | vec3 lpos = ( u_viewMatrix * vec4( u_light1Pos, 1.0 ) ).xyz; | 141 | vec3 lpos = ( u_viewMatrix * vec4( u_light1Pos, 1.0 ) ).xyz; |
141 | 142 | ||
142 | #if ( LIGHT_1 == 0 ) | 143 | #if ( LIGHT_1 == 0 ) |
143 | v_light1Dir = ( u_viewMatrix * vec4( -u_light1Dir, 0.0 ) ).xyz; | 144 | v_light1Dir = ( u_viewMatrix * vec4( -u_light1Dir, 0.0 ) ).xyz; |
144 | #else | 145 | #else |
145 | v_light1Dir = lpos - v_mvPos; | 146 | v_light1Dir = lpos - v_mvPos; |
146 | #if ( LIGHT_1 == 2 ) | 147 | #if ( LIGHT_1 == 2 ) |
147 | v_light1SpotDir = (u_viewMatrix * vec4( -u_light1Dir, 0.0 )).xyz; | 148 | v_light1SpotDir = (u_viewMatrix * vec4( -u_light1Dir, 0.0 )).xyz; |
148 | #endif // ( LIGHT_1 == 2 ) | 149 | #endif // ( LIGHT_1 == 2 ) |
149 | #endif // ( LIGHT_1 == 0 ) | 150 | #endif // ( LIGHT_1 == 0 ) |
150 | } | 151 | } |
151 | #endif // defined( LIGHT_1 ) | 152 | #endif // defined( LIGHT_1 ) |
152 | #if defined( LIGHT_2 ) | 153 | #if defined( LIGHT_2 ) |
153 | { | 154 | { |
154 | vec3 lpos = ( u_viewMatrix * vec4( u_light2Pos, 1.0 ) ).xyz; | 155 | vec3 lpos = ( u_viewMatrix * vec4( u_light2Pos, 1.0 ) ).xyz; |
155 | 156 | ||
156 | #if ( LIGHT_2 == 0 ) | 157 | #if ( LIGHT_2 == 0 ) |