diff options
Diffstat (limited to 'assets/shaders/ub_vshader.glsl')
-rwxr-xr-x | assets/shaders/ub_vshader.glsl | 232 |
1 files changed, 116 insertions, 116 deletions
diff --git a/assets/shaders/ub_vshader.glsl b/assets/shaders/ub_vshader.glsl index a559d844..43c7c9fc 100755 --- a/assets/shaders/ub_vshader.glsl +++ b/assets/shaders/ub_vshader.glsl | |||
@@ -44,65 +44,65 @@ uniform vec3 u_eye; | |||
44 | 44 | ||
45 | // attributes | 45 | // attributes |
46 | #if defined( MATERIAL ) | 46 | #if defined( MATERIAL ) |
47 | uniform vec4 u_ambientColor; | 47 | uniform vec4 u_ambientColor; |
48 | uniform vec4 u_diffuseColor; | 48 | uniform vec4 u_diffuseColor; |
49 | uniform vec4 u_specularColor; | 49 | uniform vec4 u_specularColor; |
50 | uniform float u_specularPower; | 50 | uniform float u_specularPower; |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #if defined( LIGHTING ) | 53 | #if defined( LIGHTING ) |
54 | varying vec3 v_normal; | 54 | varying vec3 v_normal; |
55 | #if defined( LIGHT_0 ) | 55 | #if defined( LIGHT_0 ) |
56 | uniform int u_light0Type; | 56 | uniform int u_light0Type; |
57 | uniform vec3 u_light0Pos; | 57 | uniform vec3 u_light0Pos; |
58 | uniform vec3 u_light0Dir; | 58 | uniform vec3 u_light0Dir; |
59 | uniform vec3 u_light0Atten; | 59 | uniform vec3 u_light0Atten; |
60 | uniform vec2 u_light0Spot; | 60 | uniform vec2 u_light0Spot; |
61 | uniform vec4 u_light0Color; | 61 | uniform vec4 u_light0Color; |
62 | uniform vec4 u_light0Specular; | 62 | uniform vec4 u_light0Specular; |
63 | varying vec3 v_light0Dir; | 63 | varying vec3 v_light0Dir; |
64 | varying vec3 v_light0SpotDir; | 64 | varying vec3 v_light0SpotDir; |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #if defined( LIGHT_1 ) | 67 | #if defined( LIGHT_1 ) |
68 | uniform int u_light1Type; | 68 | uniform int u_light1Type; |
69 | uniform vec3 u_light1Pos; | 69 | uniform vec3 u_light1Pos; |
70 | uniform vec3 u_light1Dir; | 70 | uniform vec3 u_light1Dir; |
71 | uniform vec3 u_light1Atten; | 71 | uniform vec3 u_light1Atten; |
72 | uniform vec2 u_light1Spot; | 72 | uniform vec2 u_light1Spot; |
73 | uniform vec3 u_light1Color; | 73 | uniform vec3 u_light1Color; |
74 | uniform vec4 u_light1Specular; | 74 | uniform vec4 u_light1Specular; |
75 | varying vec3 v_light1Dir; | 75 | varying vec3 v_light1Dir; |
76 | varying vec3 v_light1SpotDir; | 76 | varying vec3 v_light1SpotDir; |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #if defined( LIGHT_2 ) | 79 | #if defined( LIGHT_2 ) |
80 | uniform int u_light2Type; // 0 - dir, 1 - point, 2 - spot | 80 | uniform int u_light2Type; // 0 - dir, 1 - point, 2 - spot |
81 | uniform vec3 u_light2Pos; | 81 | uniform vec3 u_light2Pos; |
82 | uniform vec3 u_light2Dir; | 82 | uniform vec3 u_light2Dir; |
83 | uniform vec3 u_light2Atten; | 83 | uniform vec3 u_light2Atten; |
84 | uniform vec2 u_light2Spot; // 0 - spot light cutoff angle, 1 - spot light exponent | 84 | uniform vec2 u_light2Spot; // 0 - spot light cutoff angle, 1 - spot light exponent |
85 | uniform vec3 u_light2Color; | 85 | uniform vec3 u_light2Color; |
86 | uniform vec4 u_light2Specular; | 86 | uniform vec4 u_light2Specular; |
87 | varying vec3 v_light2Dir; | 87 | varying vec3 v_light2Dir; |
88 | varying vec3 v_light2SpotDir; | 88 | varying vec3 v_light2SpotDir; |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | #if defined( LIGHT_3 ) | 91 | #if defined( LIGHT_3 ) |
92 | uniform int u_light3Type; | 92 | uniform int u_light3Type; |
93 | uniform vec3 u_light3Pos; | 93 | uniform vec3 u_light3Pos; |
94 | uniform vec3 u_light3Dir; | 94 | uniform vec3 u_light3Dir; |
95 | uniform vec3 u_light3Atten; | 95 | uniform vec3 u_light3Atten; |
96 | uniform vec2 u_light3Spot; | 96 | uniform vec2 u_light3Spot; |
97 | uniform vec3 u_light3Color; | 97 | uniform vec3 u_light3Color; |
98 | uniform vec4 u_light3Specular; | 98 | uniform vec4 u_light3Specular; |
99 | varying vec3 v_light3Dir; | 99 | varying vec3 v_light3Dir; |
100 | varying vec3 v_light3SpotDir; | 100 | varying vec3 v_light3SpotDir; |
101 | #endif | 101 | #endif |
102 | #endif | 102 | #endif |
103 | 103 | ||
104 | #if defined( ENVIRONMENT_MAP ) | 104 | #if defined( ENVIRONMENT_MAP ) |
105 | uniform float u_envReflection; | 105 | uniform float u_envReflection; |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | varying vec3 v_mvPos; | 108 | varying vec3 v_mvPos; |
@@ -111,76 +111,76 @@ varying vec2 v_texcoord; | |||
111 | 111 | ||
112 | #if defined( PC ) | 112 | #if defined( PC ) |
113 | void main() { | 113 | void main() { |
114 | // position normals and vert | 114 | // position normals and vert |
115 | v_mvPos = ( u_mvMatrix * vec4( a_pos, 1.0 ) ).xyz; | 115 | v_mvPos = ( u_mvMatrix * vec4( a_pos, 1.0 ) ).xyz; |
116 | 116 | ||
117 | v_texcoord = (u_uvMatrix * vec4(a_texcoord, 0, 1.0)).xy; | 117 | v_texcoord = (u_uvMatrix * vec4(a_texcoord, 0, 1.0)).xy; |
118 | #if ( defined( LIGHTING ) || defined( ENVIRONMENT_MAP ) ) | 118 | #if ( defined( LIGHTING ) || defined( ENVIRONMENT_MAP ) ) |
119 | v_normal = ( u_normalMatrix * vec4( a_normal, 0.0 ) ).xyz; | 119 | v_normal = ( u_normalMatrix * vec4( a_normal, 0.0 ) ).xyz; |
120 | #endif | 120 | #endif |
121 | 121 | ||
122 | #if defined( LIGHTING ) | 122 | #if defined( LIGHTING ) |
123 | v_eyeDir = vec3(-u_viewMatrix[3][0], -u_viewMatrix[3][1], -u_viewMatrix[3][2]); | 123 | v_eyeDir = vec3(-u_viewMatrix[3][0], -u_viewMatrix[3][1], -u_viewMatrix[3][2]); |
124 | #if defined( LIGHT_0 ) | 124 | #if defined( LIGHT_0 ) |
125 | { | 125 | { |
126 | vec3 lpos = ( u_viewMatrix * vec4( u_light0Pos, 1.0 ) ).xyz; | 126 | vec3 lpos = ( u_viewMatrix * vec4( u_light0Pos, 1.0 ) ).xyz; |
127 | 127 | ||
128 | #if ( LIGHT_0 == 0 ) | 128 | #if ( LIGHT_0 == 0 ) |
129 | v_light0Dir = ( u_viewMatrix * vec4( -u_light0Dir, 0.0 ) ).xyz; | 129 | v_light0Dir = ( u_viewMatrix * vec4( -u_light0Dir, 0.0 ) ).xyz; |
130 | #else | 130 | #else |
131 | v_light0Dir = lpos - v_mvPos; | 131 | v_light0Dir = lpos - v_mvPos; |
132 | #if ( LIGHT_0 == 2 ) | 132 | #if ( LIGHT_0 == 2 ) |
133 | v_light0SpotDir = (u_viewMatrix * vec4( -u_light0Dir, 0.0 )).xyz; | 133 | v_light0SpotDir = (u_viewMatrix * vec4( -u_light0Dir, 0.0 )).xyz; |
134 | #endif // ( LIGHT_0 == 2 ) | 134 | #endif // ( LIGHT_0 == 2 ) |
135 | #endif // ( LIGHT_0 == 0 ) | 135 | #endif // ( LIGHT_0 == 0 ) |
136 | } | 136 | } |
137 | #endif // defined( LIGHT_0 ) | 137 | #endif // defined( LIGHT_0 ) |
138 | #if defined( LIGHT_1 ) | 138 | #if defined( LIGHT_1 ) |
139 | { | 139 | { |
140 | vec3 lpos = ( u_viewMatrix * vec4( u_light1Pos, 1.0 ) ).xyz; | 140 | vec3 lpos = ( u_viewMatrix * vec4( u_light1Pos, 1.0 ) ).xyz; |
141 | 141 | ||
142 | #if ( LIGHT_1 == 0 ) | 142 | #if ( LIGHT_1 == 0 ) |
143 | v_light1Dir = ( u_viewMatrix * vec4( -u_light1Dir, 0.0 ) ).xyz; | 143 | v_light1Dir = ( u_viewMatrix * vec4( -u_light1Dir, 0.0 ) ).xyz; |
144 | #else | 144 | #else |
145 | v_light1Dir = lpos - v_mvPos; | 145 | v_light1Dir = lpos - v_mvPos; |
146 | #if ( LIGHT_1 == 2 ) | 146 | #if ( LIGHT_1 == 2 ) |
147 | v_light1SpotDir = (u_viewMatrix * vec4( -u_light1Dir, 0.0 )).xyz; | 147 | v_light1SpotDir = (u_viewMatrix * vec4( -u_light1Dir, 0.0 )).xyz; |
148 | #endif // ( LIGHT_1 == 2 ) | 148 | #endif // ( LIGHT_1 == 2 ) |
149 | #endif // ( LIGHT_1 == 0 ) | 149 | #endif // ( LIGHT_1 == 0 ) |
150 | } | 150 | } |
151 | #endif // defined( LIGHT_1 ) | 151 | #endif // defined( LIGHT_1 ) |
152 | #if defined( LIGHT_2 ) | 152 | #if defined( LIGHT_2 ) |
153 | { | 153 | { |
154 | vec3 lpos = ( u_viewMatrix * vec4( u_light2Pos, 1.0 ) ).xyz; | 154 | vec3 lpos = ( u_viewMatrix * vec4( u_light2Pos, 1.0 ) ).xyz; |
155 | 155 | ||
156 | #if ( LIGHT_2 == 0 ) | 156 | #if ( LIGHT_2 == 0 ) |
157 | v_light2Dir = ( u_viewMatrix * vec4( -u_light2Dir, 0.0 ) ).xyz; | 157 | v_light2Dir = ( u_viewMatrix * vec4( -u_light2Dir, 0.0 ) ).xyz; |
158 | #else | 158 | #else |
159 | v_light2Dir = lpos - v_mvPos; | 159 | v_light2Dir = lpos - v_mvPos; |
160 | #if ( LIGHT_2 == 2 ) | 160 | #if ( LIGHT_2 == 2 ) |
161 | v_light2SpotDir = (u_viewMatrix * vec4( -u_light2Dir, 0.0 )).xyz; | 161 | v_light2SpotDir = (u_viewMatrix * vec4( -u_light2Dir, 0.0 )).xyz; |
162 | #endif // ( LIGHT_2 == 2 ) | 162 | #endif // ( LIGHT_2 == 2 ) |
163 | #endif // ( LIGHT_2 == 0 ) | 163 | #endif // ( LIGHT_2 == 0 ) |
164 | } | 164 | } |
165 | #endif // defined( LIGHT_2 ) | 165 | #endif // defined( LIGHT_2 ) |
166 | #if defined( LIGHT_3 ) | 166 | #if defined( LIGHT_3 ) |
167 | { | 167 | { |
168 | vec3 lpos = ( u_viewMatrix * vec4( u_light3Pos, 1.0 ) ).xyz; | 168 | vec3 lpos = ( u_viewMatrix * vec4( u_light3Pos, 1.0 ) ).xyz; |
169 | 169 | ||
170 | #if ( LIGHT_3 == 0 ) | 170 | #if ( LIGHT_3 == 0 ) |
171 | v_light3Dir = ( u_viewMatrix * vec4( -u_light3Dir, 0.0 ) ).xyz; | 171 | v_light3Dir = ( u_viewMatrix * vec4( -u_light3Dir, 0.0 ) ).xyz; |
172 | #else | 172 | #else |
173 | v_light3Dir = lpos - v_mvPos; | 173 | v_light3Dir = lpos - v_mvPos; |
174 | #if ( LIGHT_3 == 2 ) | 174 | #if ( LIGHT_3 == 2 ) |
175 | v_light3SpotDir = (u_viewMatrix * vec4( -u_light3Dir, 0.0 )).xyz; | 175 | v_light3SpotDir = (u_viewMatrix * vec4( -u_light3Dir, 0.0 )).xyz; |
176 | #endif // ( LIGHT_3 == 2 ) | 176 | #endif // ( LIGHT_3 == 2 ) |
177 | #endif // ( LIGHT_3 == 0 ) | 177 | #endif // ( LIGHT_3 == 0 ) |
178 | } | 178 | } |
179 | #endif // defined( LIGHT_3 ) | 179 | #endif // defined( LIGHT_3 ) |
180 | #endif // defined( LIGHTING ) | 180 | #endif // defined( LIGHTING ) |
181 | 181 | ||
182 | // pass along the geo | 182 | // pass along the geo |
183 | gl_Position = u_projMatrix * vec4(v_mvPos, 1.0); | 183 | gl_Position = u_projMatrix * vec4(v_mvPos, 1.0); |
184 | } | 184 | } |
185 | #endif | 185 | #endif |
186 |