Created
June 30, 2017 22:00
-
-
Save jasonayre/3f5aea25c5e09540f9e00f426211d808 to your computer and use it in GitHub Desktop.
babylon bumpTexture error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.js:108436 BJS - [15:29:04]: Unable to compile effect:t._ErrorEnabled @ client.js:108436Effect._prepareEffect @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadFragmentShader @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadVertexShader @ client.js:108446Effect @ client.js:108446n.createEffect @ client.js:108438r.isReadyForSubMesh @ client.js:108449r.render @ client.js:108445t.render @ client.js:108446t.renderUnsorted @ client.js:108442t.render @ client.js:108441t.render @ client.js:108441r._renderForCamera @ client.js:108443r._processSubCameras @ client.js:108443r.render @ client.js:108443(anonymous function) @ client.js:134916n._renderLoop @ client.js:108437 | |
client.js:108436 BJS - [15:29:04]: Uniforms: world, view, viewProjection, vEyePosition, vLightsType, vAmbientColor, vDiffuseColor, vSpecularColor, vEmissiveColor, vFogInfos, vFogColor, pointSize, vDiffuseInfos, vAmbientInfos, vOpacityInfos, vReflectionInfos, vEmissiveInfos, vSpecularInfos, vBumpInfos, vLightmapInfos, vRefractionInfos, mBones, vClipPlane, diffuseMatrix, ambientMatrix, opacityMatrix, reflectionMatrix, emissiveMatrix, specularMatrix, bumpMatrix, lightmapMatrix, refractionMatrix, depthValues, diffuseLeftColor, diffuseRightColor, opacityParts, reflectionLeftColor, reflectionRightColor, emissiveLeftColor, emissiveRightColor, refractionLeftColor, refractionRightColor, logarithmicDepthConstant, vLightData0, vLightDiffuse0, vLightSpecular0, vLightDirection0, vLightGround0, lightMatrix0, shadowsInfo0, vLightData1, vLightDiffuse1, vLightSpecular1, vLightDirection1, vLightGround1, lightMatrix1, shadowsInfo1, diffuseSampler, ambientSampler, opacitySampler, reflectionCubeSampler, reflection2DSampler, emissiveSampler, specularSampler, bumpSampler, lightmapSampler, refractionCubeSampler, refraction2DSampler, shadowSampler0, shadowSampler1t._ErrorEnabled @ client.js:108436Effect._prepareEffect @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadFragmentShader @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadVertexShader @ client.js:108446Effect @ client.js:108446n.createEffect @ client.js:108438r.isReadyForSubMesh @ client.js:108449r.render @ client.js:108445t.render @ client.js:108446t.renderUnsorted @ client.js:108442t.render @ client.js:108441t.render @ client.js:108441r._renderForCamera @ client.js:108443r._processSubCameras @ client.js:108443r.render @ client.js:108443(anonymous function) @ client.js:134916n._renderLoop @ client.js:108437 | |
client.js:108436 BJS - [15:29:04]: Attributes: position, normal, uvt._ErrorEnabled @ client.js:108436Effect._prepareEffect @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadFragmentShader @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadVertexShader @ client.js:108446Effect @ client.js:108446n.createEffect @ client.js:108438r.isReadyForSubMesh @ client.js:108449r.render @ client.js:108445t.render @ client.js:108446t.renderUnsorted @ client.js:108442t.render @ client.js:108441t.render @ client.js:108441r._renderForCamera @ client.js:108443r._processSubCameras @ client.js:108443r.render @ client.js:108443(anonymous function) @ client.js:134916n._renderLoop @ client.js:108437 | |
client.js:108436 BJS - [15:29:04]: Vertex shader: default | |
1 #define DIFFUSE | |
2 #define BUMP | |
3 #define SPECULARTERM | |
4 #define NORMAL | |
5 #define UV1 | |
6 #define NUM_BONE_INFLUENCERS 0 | |
7 #define BonesPerMesh 0 | |
8 #define NUM_MORPH_INFLUENCERS 0 | |
9 #define LIGHT0 | |
10 #define HEMILIGHT0 | |
11 #define LIGHT1 | |
12 #define HEMILIGHT1 | |
13 | |
14 precision highp float; | |
15 | |
16 uniform mat4 viewProjection; | |
17 uniform mat4 view; | |
18 #ifdef DIFFUSE | |
19 uniform mat4 diffuseMatrix; | |
20 uniform vec2 vDiffuseInfos; | |
21 #endif | |
22 #ifdef AMBIENT | |
23 uniform mat4 ambientMatrix; | |
24 uniform vec2 vAmbientInfos; | |
25 #endif | |
26 #ifdef OPACITY | |
27 uniform mat4 opacityMatrix; | |
28 uniform vec2 vOpacityInfos; | |
29 #endif | |
30 #ifdef EMISSIVE | |
31 uniform vec2 vEmissiveInfos; | |
32 uniform mat4 emissiveMatrix; | |
33 #endif | |
34 #ifdef LIGHTMAP | |
35 uniform vec2 vLightmapInfos; | |
36 uniform mat4 lightmapMatrix; | |
37 #endif | |
38 #if defined(SPECULAR) && defined(SPECULARTERM) | |
39 uniform vec2 vSpecularInfos; | |
40 uniform mat4 specularMatrix; | |
41 #endif | |
42 #ifdef BUMP | |
43 uniform vec3 vBumpInfos; | |
44 uniform mat4 bumpMatrix; | |
45 #endif | |
46 #ifdef POINTSIZE | |
47 uniform float pointSize; | |
48 #endif | |
49 | |
50 | |
51 attribute vec3 position; | |
52 #ifdef NORMAL | |
53 attribute vec3 normal; | |
54 #endif | |
55 #ifdef TANGENT | |
56 attribute vec4 tangent; | |
57 #endif | |
58 #ifdef UV1 | |
59 attribute vec2 uv; | |
60 #endif | |
61 #ifdef UV2 | |
62 attribute vec2 uv2; | |
63 #endif | |
64 #ifdef VERTEXCOLOR | |
65 attribute vec4 color; | |
66 #endif | |
67 #if NUM_BONE_INFLUENCERS>0 | |
68 uniform mat4 mBones[BonesPerMesh]; | |
69 attribute vec4 matricesIndices; | |
70 attribute vec4 matricesWeights; | |
71 #if NUM_BONE_INFLUENCERS>4 | |
72 attribute vec4 matricesIndicesExtra; | |
73 attribute vec4 matricesWeightsExtra; | |
74 #endif | |
75 #endif | |
76 | |
77 #ifdef INSTANCES | |
78 attribute vec4 world0; | |
79 attribute vec4 world1; | |
80 attribute vec4 world2; | |
81 attribute vec4 world3; | |
82 #else | |
83 uniform mat4 world; | |
84 #endif | |
85 #ifdef DIFFUSE | |
86 varying vec2 vDiffuseUV; | |
87 #endif | |
88 #ifdef AMBIENT | |
89 varying vec2 vAmbientUV; | |
90 #endif | |
91 #ifdef OPACITY | |
92 varying vec2 vOpacityUV; | |
93 #endif | |
94 #ifdef EMISSIVE | |
95 varying vec2 vEmissiveUV; | |
96 #endif | |
97 #ifdef LIGHTMAP | |
98 varying vec2 vLightmapUV; | |
99 #endif | |
100 #if defined(SPECULAR) && defined(SPECULARTERM) | |
101 varying vec2 vSpecularUV; | |
102 #endif | |
103 #ifdef BUMP | |
104 varying vec2 vBumpUV; | |
105 #endif | |
106 | |
107 varying vec3 vPositionW; | |
108 #ifdef NORMAL | |
109 varying vec3 vNormalW; | |
110 #endif | |
111 #ifdef VERTEXCOLOR | |
112 varying vec4 vColor; | |
113 #endif | |
114 #if defined(BUMP) || defined(PARALLAX) | |
115 #if defined(TANGENT) && defined(NORMAL) | |
116 varying mat3 vTBN; | |
117 #endif | |
118 #endif | |
119 | |
120 #ifdef CLIPPLANE | |
121 uniform vec4 vClipPlane; | |
122 varying float fClipDistance; | |
123 #endif | |
124 #ifdef FOG | |
125 varying vec3 vFogDistance; | |
126 #endif | |
127 #ifdef SHADOWS | |
128 #if defined(SPOTLIGHT0) || defined(DIRLIGHT0) | |
129 uniform mat4 lightMatrix0; | |
130 varying vec4 vPositionFromLight0; | |
131 #endif | |
132 #endif | |
133 | |
134 #ifdef SHADOWS | |
135 #if defined(SPOTLIGHT1) || defined(DIRLIGHT1) | |
136 uniform mat4 lightMatrix1; | |
137 varying vec4 vPositionFromLight1; | |
138 #endif | |
139 #endif | |
140 | |
141 #ifdef SHADOWS | |
142 #if defined(SPOTLIGHT2) || defined(DIRLIGHT2) | |
143 uniform mat4 lightMatrix2; | |
144 varying vec4 vPositionFromLight2; | |
145 #endif | |
146 #endif | |
147 | |
148 #ifdef SHADOWS | |
149 #if defined(SPOTLIGHT3) || defined(DIRLIGHT3) | |
150 uniform mat4 lightMatrix3; | |
151 varying vec4 vPositionFromLight3; | |
152 #endif | |
153 #endif | |
154 | |
155 | |
156 #ifdef MORPHTARGETS | |
157 uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS]; | |
158 #endif | |
159 | |
160 #ifdef REFLECTIONMAP_SKYBOX | |
161 varying vec3 vPositionUVW; | |
162 #endif | |
163 #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) | |
164 varying vec3 vDirectionW; | |
165 #endif | |
166 #ifdef LOGARITHMICDEPTH | |
167 uniform float logarithmicDepthConstant; | |
168 varying float vFragmentDepth; | |
169 #endif | |
170 void main(void) { | |
171 vec3 positionUpdated=position; | |
172 #ifdef NORMAL | |
173 vec3 normalUpdated=normal; | |
174 #endif | |
175 #ifdef TANGENT | |
176 vec4 tangentUpdated=tangent; | |
177 #endif | |
178 | |
179 #ifdef REFLECTIONMAP_SKYBOX | |
180 vPositionUVW=positionUpdated; | |
181 #endif | |
182 #ifdef INSTANCES | |
183 mat4 finalWorld=mat4(world0,world1,world2,world3); | |
184 #else | |
185 mat4 finalWorld=world; | |
186 #endif | |
187 #if NUM_BONE_INFLUENCERS>0 | |
188 mat4 influence; | |
189 influence=mBones[int(matricesIndices[0])]*matricesWeights[0]; | |
190 #if NUM_BONE_INFLUENCERS>1 | |
191 influence+=mBones[int(matricesIndices[1])]*matricesWeights[1]; | |
192 #endif | |
193 #if NUM_BONE_INFLUENCERS>2 | |
194 influence+=mBones[int(matricesIndices[2])]*matricesWeights[2]; | |
195 #endif | |
196 #if NUM_BONE_INFLUENCERS>3 | |
197 influence+=mBones[int(matricesIndices[3])]*matricesWeights[3]; | |
198 #endif | |
199 #if NUM_BONE_INFLUENCERS>4 | |
200 influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; | |
201 #endif | |
202 #if NUM_BONE_INFLUENCERS>5 | |
203 influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; | |
204 #endif | |
205 #if NUM_BONE_INFLUENCERS>6 | |
206 influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; | |
207 #endif | |
208 #if NUM_BONE_INFLUENCERS>7 | |
209 influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; | |
210 #endif | |
211 finalWorld=finalWorld*influence; | |
212 #endif | |
213 gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); | |
214 vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); | |
215 vPositionW=vec3(worldPos); | |
216 #ifdef NORMAL | |
217 vNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0))); | |
218 #endif | |
219 #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) | |
220 vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); | |
221 #endif | |
222 | |
223 #ifndef UV1 | |
224 vec2 uv=vec2(0.,0.); | |
225 #endif | |
226 #ifndef UV2 | |
227 vec2 uv2=vec2(0.,0.); | |
228 #endif | |
229 #ifdef DIFFUSE | |
230 if (vDiffuseInfos.x == 0.) | |
231 { | |
232 vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0)); | |
233 } | |
234 else | |
235 { | |
236 vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); | |
237 } | |
238 #endif | |
239 #ifdef AMBIENT | |
240 if (vAmbientInfos.x == 0.) | |
241 { | |
242 vAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0)); | |
243 } | |
244 else | |
245 { | |
246 vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0)); | |
247 } | |
248 #endif | |
249 #ifdef OPACITY | |
250 if (vOpacityInfos.x == 0.) | |
251 { | |
252 vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0)); | |
253 } | |
254 else | |
255 { | |
256 vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0)); | |
257 } | |
258 #endif | |
259 #ifdef EMISSIVE | |
260 if (vEmissiveInfos.x == 0.) | |
261 { | |
262 vEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0)); | |
263 } | |
264 else | |
265 { | |
266 vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0)); | |
267 } | |
268 #endif | |
269 #ifdef LIGHTMAP | |
270 if (vLightmapInfos.x == 0.) | |
271 { | |
272 vLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0)); | |
273 } | |
274 else | |
275 { | |
276 vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0)); | |
277 } | |
278 #endif | |
279 #if defined(SPECULAR) && defined(SPECULARTERM) | |
280 if (vSpecularInfos.x == 0.) | |
281 { | |
282 vSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0)); | |
283 } | |
284 else | |
285 { | |
286 vSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0)); | |
287 } | |
288 #endif | |
289 #ifdef BUMP | |
290 if (vBumpInfos.x == 0.) | |
291 { | |
292 vBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0)); | |
293 } | |
294 else | |
295 { | |
296 vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0)); | |
297 } | |
298 #endif | |
299 #if defined(BUMP) || defined(PARALLAX) | |
300 #if defined(TANGENT) && defined(NORMAL) | |
301 vec3 normalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0))); | |
302 vec3 tangentW=normalize(vec3(finalWorld*vec4(tangentUpdated.xyz,0.0))); | |
303 vec3 bitangentW=cross(normalW,tangentW)*tangentUpdated.w; | |
304 vTBN=mat3(tangentW,bitangentW,normalW); | |
305 #endif | |
306 #endif | |
307 #ifdef CLIPPLANE | |
308 fClipDistance=dot(worldPos,vClipPlane); | |
309 #endif | |
310 #ifdef FOG | |
311 vFogDistance=(view*worldPos).xyz; | |
312 #endif | |
313 #ifdef SHADOWS | |
314 #if defined(SPOTLIGHT0) || defined(DIRLIGHT0) | |
315 vPositionFromLight0=lightMatrix0*worldPos; | |
316 #endif | |
317 #endif | |
318 #ifdef SHADOWS | |
319 #if defined(SPOTLIGHT1) || defined(DIRLIGHT1) | |
320 vPositionFromLight1=lightMatrix1*worldPos; | |
321 #endif | |
322 #endif | |
323 #ifdef SHADOWS | |
324 #if defined(SPOTLIGHT2) || defined(DIRLIGHT2) | |
325 vPositionFromLight2=lightMatrix2*worldPos; | |
326 #endif | |
327 #endif | |
328 #ifdef SHADOWS | |
329 #if defined(SPOTLIGHT3) || defined(DIRLIGHT3) | |
330 vPositionFromLight3=lightMatrix3*worldPos; | |
331 #endif | |
332 #endif | |
333 | |
334 #ifdef VERTEXCOLOR | |
335 | |
336 vColor=color; | |
337 #endif | |
338 #ifdef POINTSIZE | |
339 gl_PointSize=pointSize; | |
340 #endif | |
341 #ifdef LOGARITHMICDEPTH | |
342 vFragmentDepth=1.0+gl_Position.w; | |
343 gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant; | |
344 #endif | |
345 }t._ErrorEnabled @ client.js:108436Effect._dumpShadersSource @ client.js:108446Effect._prepareEffect @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadFragmentShader @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadVertexShader @ client.js:108446Effect @ client.js:108446n.createEffect @ client.js:108438r.isReadyForSubMesh @ client.js:108449r.render @ client.js:108445t.render @ client.js:108446t.renderUnsorted @ client.js:108442t.render @ client.js:108441t.render @ client.js:108441r._renderForCamera @ client.js:108443r._processSubCameras @ client.js:108443r.render @ client.js:108443(anonymous function) @ client.js:134916n._renderLoop @ client.js:108437 | |
client.js:108436 BJS - [15:29:04]: Fragment shader: default | |
1 #define DIFFUSE | |
2 #define BUMP | |
3 #define SPECULARTERM | |
4 #define NORMAL | |
5 #define UV1 | |
6 #define NUM_BONE_INFLUENCERS 0 | |
7 #define BonesPerMesh 0 | |
8 #define NUM_MORPH_INFLUENCERS 0 | |
9 #define LIGHT0 | |
10 #define HEMILIGHT0 | |
11 #define LIGHT1 | |
12 #define HEMILIGHT1 | |
13 | |
14 precision highp float; | |
15 uniform vec4 vDiffuseColor; | |
16 #ifdef SPECULARTERM | |
17 uniform vec4 vSpecularColor; | |
18 #endif | |
19 uniform vec3 vEmissiveColor; | |
20 | |
21 #ifdef DIFFUSE | |
22 uniform vec2 vDiffuseInfos; | |
23 #endif | |
24 #ifdef AMBIENT | |
25 uniform vec2 vAmbientInfos; | |
26 #endif | |
27 #ifdef OPACITY | |
28 uniform vec2 vOpacityInfos; | |
29 #endif | |
30 #ifdef EMISSIVE | |
31 uniform vec2 vEmissiveInfos; | |
32 #endif | |
33 #ifdef LIGHTMAP | |
34 uniform vec2 vLightmapInfos; | |
35 #endif | |
36 #ifdef BUMP | |
37 uniform vec3 vBumpInfos; | |
38 #endif | |
39 #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) | |
40 uniform mat4 view; | |
41 #endif | |
42 #ifdef REFRACTION | |
43 uniform vec4 vRefractionInfos; | |
44 #ifndef REFRACTIONMAP_3D | |
45 uniform mat4 refractionMatrix; | |
46 #endif | |
47 #ifdef REFRACTIONFRESNEL | |
48 uniform vec4 refractionLeftColor; | |
49 uniform vec4 refractionRightColor; | |
50 #endif | |
51 #endif | |
52 #if defined(SPECULAR) && defined(SPECULARTERM) | |
53 uniform vec2 vSpecularInfos; | |
54 #endif | |
55 #ifdef DIFFUSEFRESNEL | |
56 uniform vec4 diffuseLeftColor; | |
57 uniform vec4 diffuseRightColor; | |
58 #endif | |
59 #ifdef OPACITYFRESNEL | |
60 uniform vec4 opacityParts; | |
61 #endif | |
62 #ifdef EMISSIVEFRESNEL | |
63 uniform vec4 emissiveLeftColor; | |
64 uniform vec4 emissiveRightColor; | |
65 #endif | |
66 | |
67 #ifdef REFLECTION | |
68 uniform vec2 vReflectionInfos; | |
69 #ifdef REFLECTIONMAP_SKYBOX | |
70 #else | |
71 #if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) | |
72 uniform mat4 reflectionMatrix; | |
73 #endif | |
74 #endif | |
75 #ifdef REFLECTIONFRESNEL | |
76 uniform vec4 reflectionLeftColor; | |
77 uniform vec4 reflectionRightColor; | |
78 #endif | |
79 #endif | |
80 #ifdef BUMP | |
81 #extension GL_OES_standard_derivatives : enable | |
82 #endif | |
83 #ifdef LOGARITHMICDEPTH | |
84 #extension GL_EXT_frag_depth : enable | |
85 #endif | |
86 | |
87 #define RECIPROCAL_PI2 0.15915494 | |
88 uniform vec3 vEyePosition; | |
89 uniform vec3 vAmbientColor; | |
90 | |
91 varying vec3 vPositionW; | |
92 #ifdef NORMAL | |
93 varying vec3 vNormalW; | |
94 #endif | |
95 #ifdef VERTEXCOLOR | |
96 varying vec4 vColor; | |
97 #endif | |
98 | |
99 mat3 transposeMat3(mat3 inMatrix) { | |
100 vec3 i0=inMatrix[0]; | |
101 vec3 i1=inMatrix[1]; | |
102 vec3 i2=inMatrix[2]; | |
103 mat3 outMatrix=mat3( | |
104 vec3(i0.x,i1.x,i2.x), | |
105 vec3(i0.y,i1.y,i2.y), | |
106 vec3(i0.z,i1.z,i2.z) | |
107 ); | |
108 return outMatrix; | |
109 } | |
110 | |
111 #ifdef LIGHT0 | |
112 uniform vec4 vLightData0; | |
113 uniform vec4 vLightDiffuse0; | |
114 #ifdef SPECULARTERM | |
115 uniform vec3 vLightSpecular0; | |
116 #else | |
117 vec3 vLightSpecular0=vec3(0.); | |
118 #endif | |
119 #ifdef SHADOW0 | |
120 #if defined(SPOTLIGHT0) || defined(DIRLIGHT0) | |
121 varying vec4 vPositionFromLight0; | |
122 uniform sampler2D shadowSampler0; | |
123 #else | |
124 uniform samplerCube shadowSampler0; | |
125 #endif | |
126 uniform vec3 shadowsInfo0; | |
127 #endif | |
128 #ifdef SPOTLIGHT0 | |
129 uniform vec4 vLightDirection0; | |
130 #endif | |
131 #ifdef HEMILIGHT0 | |
132 uniform vec3 vLightGround0; | |
133 #endif | |
134 #endif | |
135 #ifdef LIGHT1 | |
136 uniform vec4 vLightData1; | |
137 uniform vec4 vLightDiffuse1; | |
138 #ifdef SPECULARTERM | |
139 uniform vec3 vLightSpecular1; | |
140 #else | |
141 vec3 vLightSpecular1=vec3(0.); | |
142 #endif | |
143 #ifdef SHADOW1 | |
144 #if defined(SPOTLIGHT1) || defined(DIRLIGHT1) | |
145 varying vec4 vPositionFromLight1; | |
146 uniform sampler2D shadowSampler1; | |
147 #else | |
148 uniform samplerCube shadowSampler1; | |
149 #endif | |
150 uniform vec3 shadowsInfo1; | |
151 #endif | |
152 #ifdef SPOTLIGHT1 | |
153 uniform vec4 vLightDirection1; | |
154 #endif | |
155 #ifdef HEMILIGHT1 | |
156 uniform vec3 vLightGround1; | |
157 #endif | |
158 #endif | |
159 #ifdef LIGHT2 | |
160 uniform vec4 vLightData2; | |
161 uniform vec4 vLightDiffuse2; | |
162 #ifdef SPECULARTERM | |
163 uniform vec3 vLightSpecular2; | |
164 #else | |
165 vec3 vLightSpecular2=vec3(0.); | |
166 #endif | |
167 #ifdef SHADOW2 | |
168 #if defined(SPOTLIGHT2) || defined(DIRLIGHT2) | |
169 varying vec4 vPositionFromLight2; | |
170 uniform sampler2D shadowSampler2; | |
171 #else | |
172 uniform samplerCube shadowSampler2; | |
173 #endif | |
174 uniform vec3 shadowsInfo2; | |
175 #endif | |
176 #ifdef SPOTLIGHT2 | |
177 uniform vec4 vLightDirection2; | |
178 #endif | |
179 #ifdef HEMILIGHT2 | |
180 uniform vec3 vLightGround2; | |
181 #endif | |
182 #endif | |
183 #ifdef LIGHT3 | |
184 uniform vec4 vLightData3; | |
185 uniform vec4 vLightDiffuse3; | |
186 #ifdef SPECULARTERM | |
187 uniform vec3 vLightSpecular3; | |
188 #else | |
189 vec3 vLightSpecular3=vec3(0.); | |
190 #endif | |
191 #ifdef SHADOW3 | |
192 #if defined(SPOTLIGHT3) || defined(DIRLIGHT3) | |
193 varying vec4 vPositionFromLight3; | |
194 uniform sampler2D shadowSampler3; | |
195 #else | |
196 uniform samplerCube shadowSampler3; | |
197 #endif | |
198 uniform vec3 shadowsInfo3; | |
199 #endif | |
200 #ifdef SPOTLIGHT3 | |
201 uniform vec4 vLightDirection3; | |
202 #endif | |
203 #ifdef HEMILIGHT3 | |
204 uniform vec3 vLightGround3; | |
205 #endif | |
206 #endif | |
207 | |
208 | |
209 struct lightingInfo | |
210 { | |
211 vec3 diffuse; | |
212 #ifdef SPECULARTERM | |
213 vec3 specular; | |
214 #endif | |
215 #ifdef NDOTL | |
216 float ndl; | |
217 #endif | |
218 }; | |
219 lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) { | |
220 lightingInfo result; | |
221 vec3 lightVectorW; | |
222 float attenuation=1.0; | |
223 if (lightData.w == 0.) | |
224 { | |
225 vec3 direction=lightData.xyz-vPositionW; | |
226 attenuation=max(0.,1.0-length(direction)/range); | |
227 lightVectorW=normalize(direction); | |
228 } | |
229 else | |
230 { | |
231 lightVectorW=normalize(-lightData.xyz); | |
232 } | |
233 | |
234 float ndl=max(0.,dot(vNormal,lightVectorW)); | |
235 #ifdef NDOTL | |
236 result.ndl=ndl; | |
237 #endif | |
238 result.diffuse=ndl*diffuseColor*attenuation; | |
239 #ifdef SPECULARTERM | |
240 | |
241 vec3 angleW=normalize(viewDirectionW+lightVectorW); | |
242 float specComp=max(0.,dot(vNormal,angleW)); | |
243 specComp=pow(specComp,max(1.,glossiness)); | |
244 result.specular=specComp*specularColor*attenuation; | |
245 #endif | |
246 return result; | |
247 } | |
248 lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) { | |
249 lightingInfo result; | |
250 vec3 direction=lightData.xyz-vPositionW; | |
251 vec3 lightVectorW=normalize(direction); | |
252 float attenuation=max(0.,1.0-length(direction)/range); | |
253 | |
254 float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW)); | |
255 if (cosAngle>=lightDirection.w) | |
256 { | |
257 cosAngle=max(0.,pow(cosAngle,lightData.w)); | |
258 attenuation*=cosAngle; | |
259 | |
260 float ndl=max(0.,dot(vNormal,lightVectorW)); | |
261 #ifdef NDOTL | |
262 result.ndl=ndl; | |
263 #endif | |
264 result.diffuse=ndl*diffuseColor*attenuation; | |
265 #ifdef SPECULARTERM | |
266 | |
267 vec3 angleW=normalize(viewDirectionW+lightVectorW); | |
268 float specComp=max(0.,dot(vNormal,angleW)); | |
269 specComp=pow(specComp,max(1.,glossiness)); | |
270 result.specular=specComp*specularColor*attenuation; | |
271 #endif | |
272 return result; | |
273 } | |
274 result.diffuse=vec3(0.); | |
275 #ifdef SPECULARTERM | |
276 result.specular=vec3(0.); | |
277 #endif | |
278 #ifdef NDOTL | |
279 result.ndl=0.; | |
280 #endif | |
281 return result; | |
282 } | |
283 lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) { | |
284 lightingInfo result; | |
285 | |
286 float ndl=dot(vNormal,lightData.xyz)*0.5+0.5; | |
287 #ifdef NDOTL | |
288 result.ndl=ndl; | |
289 #endif | |
290 result.diffuse=mix(groundColor,diffuseColor,ndl); | |
291 #ifdef SPECULARTERM | |
292 | |
293 vec3 angleW=normalize(viewDirectionW+lightData.xyz); | |
294 float specComp=max(0.,dot(vNormal,angleW)); | |
295 specComp=pow(specComp,max(1.,glossiness)); | |
296 result.specular=specComp*specularColor; | |
297 #endif | |
298 return result; | |
299 } | |
300 | |
301 #ifdef SHADOWS | |
302 #ifndef SHADOWFULLFLOAT | |
303 float unpack(vec4 color) | |
304 { | |
305 const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0); | |
306 return dot(color,bit_shift); | |
307 } | |
308 #endif | |
309 uniform vec2 depthValues; | |
310 float computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness) | |
311 { | |
312 vec3 directionToLight=vPositionW-lightPosition; | |
313 float depth=length(directionToLight); | |
314 depth=(depth-depthValues.x)/(depthValues.y-depthValues.x); | |
315 depth=clamp(depth,0.,1.0); | |
316 directionToLight=normalize(directionToLight); | |
317 directionToLight.y=-directionToLight.y; | |
318 #ifndef SHADOWFULLFLOAT | |
319 float shadow=unpack(textureCube(shadowSampler,directionToLight)); | |
320 #else | |
321 float shadow=textureCube(shadowSampler,directionToLight).x; | |
322 #endif | |
323 if (depth>shadow) | |
324 { | |
325 return darkness; | |
326 } | |
327 return 1.0; | |
328 } | |
329 float computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness) | |
330 { | |
331 vec3 directionToLight=vPositionW-lightPosition; | |
332 float depth=length(directionToLight); | |
333 depth=(depth-depthValues.x)/(depthValues.y-depthValues.x); | |
334 depth=clamp(depth,0.,1.0); | |
335 directionToLight=normalize(directionToLight); | |
336 directionToLight.y=-directionToLight.y; | |
337 float visibility=1.; | |
338 vec3 poissonDisk[4]; | |
339 poissonDisk[0]=vec3(-1.0,1.0,-1.0); | |
340 poissonDisk[1]=vec3(1.0,-1.0,-1.0); | |
341 poissonDisk[2]=vec3(-1.0,-1.0,-1.0); | |
342 poissonDisk[3]=vec3(1.0,-1.0,1.0); | |
343 | |
344 #ifndef SHADOWFULLFLOAT | |
345 if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25; | |
346 if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25; | |
347 if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25; | |
348 if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25; | |
349 #else | |
350 if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25; | |
351 if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25; | |
352 if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25; | |
353 if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25; | |
354 #endif | |
355 return min(1.0,visibility+darkness); | |
356 } | |
357 float computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale) | |
358 { | |
359 vec3 directionToLight=vPositionW-lightPosition; | |
360 float depth=length(directionToLight); | |
361 depth=(depth-depthValues.x)/(depthValues.y-depthValues.x); | |
362 float shadowPixelDepth=clamp(depth,0.,1.0); | |
363 directionToLight=normalize(directionToLight); | |
364 directionToLight.y=-directionToLight.y; | |
365 #ifndef SHADOWFULLFLOAT | |
366 float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight)); | |
367 #else | |
368 float shadowMapSample=textureCube(shadowSampler,directionToLight).x; | |
369 #endif | |
370 float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample-darkness,0.,1.); | |
371 return esm; | |
372 } | |
373 float computeShadow(vec4 vPositionFromLight,sampler2D shadowSampler,float darkness) | |
374 { | |
375 vec3 depth=vPositionFromLight.xyz/vPositionFromLight.w; | |
376 depth=0.5*depth+vec3(0.5); | |
377 vec2 uv=depth.xy; | |
378 if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) | |
379 { | |
380 return 1.0; | |
381 } | |
382 #ifndef SHADOWFULLFLOAT | |
383 float shadow=unpack(texture2D(shadowSampler,uv)); | |
384 #else | |
385 float shadow=texture2D(shadowSampler,uv).x; | |
386 #endif | |
387 if (depth.z>shadow) | |
388 { | |
389 return darkness; | |
390 } | |
391 return 1.; | |
392 } | |
393 float computeShadowWithPCF(vec4 vPositionFromLight,sampler2D shadowSampler,float mapSize,float darkness) | |
394 { | |
395 vec3 depth=vPositionFromLight.xyz/vPositionFromLight.w; | |
396 depth=0.5*depth+vec3(0.5); | |
397 vec2 uv=depth.xy; | |
398 if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) | |
399 { | |
400 return 1.0; | |
401 } | |
402 float visibility=1.; | |
403 vec2 poissonDisk[4]; | |
404 poissonDisk[0]=vec2(-0.94201624,-0.39906216); | |
405 poissonDisk[1]=vec2(0.94558609,-0.76890725); | |
406 poissonDisk[2]=vec2(-0.094184101,-0.92938870); | |
407 poissonDisk[3]=vec2(0.34495938,0.29387760); | |
408 | |
409 #ifndef SHADOWFULLFLOAT | |
410 if (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<depth.z) visibility-=0.25; | |
411 if (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<depth.z) visibility-=0.25; | |
412 if (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<depth.z) visibility-=0.25; | |
413 if (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<depth.z) visibility-=0.25; | |
414 #else | |
415 if (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<depth.z) visibility-=0.25; | |
416 if (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<depth.z) visibility-=0.25; | |
417 if (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<depth.z) visibility-=0.25; | |
418 if (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<depth.z) visibility-=0.25; | |
419 #endif | |
420 return min(1.0,visibility+darkness); | |
421 } | |
422 float computeShadowWithESM(vec4 vPositionFromLight,sampler2D shadowSampler,float darkness,float depthScale) | |
423 { | |
424 vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; | |
425 vec3 depth=0.5*clipSpace+vec3(0.5); | |
426 vec2 uv=depth.xy; | |
427 float shadowPixelDepth=depth.z; | |
428 if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) | |
429 { | |
430 return 1.0; | |
431 } | |
432 #ifndef SHADOWFULLFLOAT | |
433 float shadowMapSample=unpack(texture2D(shadowSampler,uv)); | |
434 #else | |
435 float shadowMapSample=texture2D(shadowSampler,uv).x; | |
436 #endif | |
437 float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample-darkness,0.,1.); | |
438 | |
439 | |
440 | |
441 | |
442 | |
443 return esm; | |
444 } | |
445 #endif | |
446 | |
447 #ifdef DIFFUSE | |
448 varying vec2 vDiffuseUV; | |
449 uniform sampler2D diffuseSampler; | |
450 #endif | |
451 #ifdef AMBIENT | |
452 varying vec2 vAmbientUV; | |
453 uniform sampler2D ambientSampler; | |
454 #endif | |
455 #ifdef OPACITY | |
456 varying vec2 vOpacityUV; | |
457 uniform sampler2D opacitySampler; | |
458 #endif | |
459 #ifdef EMISSIVE | |
460 varying vec2 vEmissiveUV; | |
461 uniform sampler2D emissiveSampler; | |
462 #endif | |
463 #ifdef LIGHTMAP | |
464 varying vec2 vLightmapUV; | |
465 uniform sampler2D lightmapSampler; | |
466 #endif | |
467 #ifdef REFRACTION | |
468 #ifdef REFRACTIONMAP_3D | |
469 uniform samplerCube refractionCubeSampler; | |
470 #else | |
471 uniform sampler2D refraction2DSampler; | |
472 #endif | |
473 #endif | |
474 #if defined(SPECULAR) && defined(SPECULARTERM) | |
475 varying vec2 vSpecularUV; | |
476 uniform sampler2D specularSampler; | |
477 #endif | |
478 | |
479 #ifdef FRESNEL | |
480 float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power) | |
481 { | |
482 float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power); | |
483 return clamp(fresnelTerm,0.,1.); | |
484 } | |
485 #endif | |
486 | |
487 #ifdef REFLECTION | |
488 #ifdef REFLECTIONMAP_3D | |
489 uniform samplerCube reflectionCubeSampler; | |
490 #else | |
491 uniform sampler2D reflection2DSampler; | |
492 #endif | |
493 #ifdef REFLECTIONMAP_SKYBOX | |
494 varying vec3 vPositionUVW; | |
495 #else | |
496 #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) | |
497 varying vec3 vDirectionW; | |
498 #endif | |
499 #endif | |
500 vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal) | |
501 { | |
502 #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) | |
503 vec3 direction=normalize(vDirectionW); | |
504 float t=clamp(direction.y*-0.5+0.5,0.,1.0); | |
505 float s=atan(direction.z,direction.x)*RECIPROCAL_PI2+0.5; | |
506 #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED | |
507 return vec3(1.0-s,t,0); | |
508 #else | |
509 return vec3(s,t,0); | |
510 #endif | |
511 #endif | |
512 #ifdef REFLECTIONMAP_EQUIRECTANGULAR | |
513 vec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition); | |
514 vec3 r=reflect(cameraToVertex,worldNormal); | |
515 float t=clamp(r.y*-0.5+0.5,0.,1.0); | |
516 float s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5; | |
517 return vec3(s,t,0); | |
518 #endif | |
519 #ifdef REFLECTIONMAP_SPHERICAL | |
520 vec3 viewDir=normalize(vec3(view*worldPos)); | |
521 vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0))); | |
522 vec3 r=reflect(viewDir,viewNormal); | |
523 r.z=r.z-1.0; | |
524 float m=2.0*length(r); | |
525 return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0); | |
526 #endif | |
527 #ifdef REFLECTIONMAP_PLANAR | |
528 vec3 viewDir=worldPos.xyz-vEyePosition; | |
529 vec3 coords=normalize(reflect(viewDir,worldNormal)); | |
530 return vec3(reflectionMatrix*vec4(coords,1)); | |
531 #endif | |
532 #ifdef REFLECTIONMAP_CUBIC | |
533 vec3 viewDir=worldPos.xyz-vEyePosition; | |
534 vec3 coords=reflect(viewDir,worldNormal); | |
535 #ifdef INVERTCUBICMAP | |
536 coords.y=1.0-coords.y; | |
537 #endif | |
538 return vec3(reflectionMatrix*vec4(coords,0)); | |
539 #endif | |
540 #ifdef REFLECTIONMAP_PROJECTION | |
541 return vec3(reflectionMatrix*(view*worldPos)); | |
542 #endif | |
543 #ifdef REFLECTIONMAP_SKYBOX | |
544 return vPositionUVW; | |
545 #endif | |
546 #ifdef REFLECTIONMAP_EXPLICIT | |
547 return vec3(0,0,0); | |
548 #endif | |
549 } | |
550 #endif | |
551 #ifdef CAMERACOLORGRADING | |
552 uniform sampler2D cameraColorGrading2DSampler; | |
553 uniform vec4 vCameraColorGradingInfos; | |
554 uniform vec4 vCameraColorGradingScaleOffset; | |
555 vec4 colorGrades(vec4 color) | |
556 { | |
557 | |
558 float sliceContinuous=color.z*vCameraColorGradingInfos.z; | |
559 float sliceInteger=floor(sliceContinuous); | |
560 | |
561 | |
562 float sliceFraction=sliceContinuous-sliceInteger; | |
563 | |
564 vec2 sliceUV=color.xy*vCameraColorGradingScaleOffset.xy+vCameraColorGradingScaleOffset.zw; | |
565 | |
566 | |
567 sliceUV.x+=sliceInteger*vCameraColorGradingInfos.w; | |
568 vec4 slice0Color=texture2D(cameraColorGrading2DSampler,sliceUV); | |
569 sliceUV.x+=vCameraColorGradingInfos.w; | |
570 vec4 slice1Color=texture2D(cameraColorGrading2DSampler,sliceUV); | |
571 vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction); | |
572 color.rgb=mix(color.rgb,result,vCameraColorGradingInfos.x); | |
573 return color; | |
574 } | |
575 #endif | |
576 #ifdef CAMERACOLORCURVES | |
577 uniform vec4 vCameraColorCurveNeutral; | |
578 uniform vec4 vCameraColorCurvePositive; | |
579 uniform vec4 vCameraColorCurveNegative; | |
580 const vec3 HDTVRec709_RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722); | |
581 vec3 applyColorCurves(vec3 original) { | |
582 vec3 result=original; | |
583 | |
584 | |
585 | |
586 float luma=dot(result.rgb,HDTVRec709_RGBLuminanceCoefficients); | |
587 vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0,0.0),vec2(1.0,1.0)); | |
588 vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative; | |
589 result.rgb*=colorCurve.rgb; | |
590 result.rgb=mix(vec3(luma,luma,luma),result.rgb,colorCurve.a); | |
591 return result; | |
592 } | |
593 #endif | |
594 #ifdef BUMP | |
595 varying vec2 vBumpUV; | |
596 uniform sampler2D bumpSampler; | |
597 #if defined(TANGENT) && defined(NORMAL) | |
598 varying mat3 vTBN; | |
599 #endif | |
600 | |
601 mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv) | |
602 { | |
603 | |
604 uv=gl_FrontFacing ? uv : -uv; | |
605 | |
606 vec3 dp1=dFdx(p); | |
607 vec3 dp2=dFdy(p); | |
608 vec2 duv1=dFdx(uv); | |
609 vec2 duv2=dFdy(uv); | |
610 | |
611 vec3 dp2perp=cross(dp2,normal); | |
612 vec3 dp1perp=cross(normal,dp1); | |
613 vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x; | |
614 vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y; | |
615 #ifdef USERIGHTHANDEDSYSTEM | |
616 binormal=-binormal; | |
617 #endif | |
618 | |
619 float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal))); | |
620 return mat3(tangent*invmax,binormal*invmax,normal); | |
621 } | |
622 vec3 perturbNormal(mat3 cotangentFrame,vec2 uv) | |
623 { | |
624 vec3 map=texture2D(bumpSampler,uv).xyz; | |
625 #ifdef INVERTNORMALMAPX | |
626 map.x=1.0-map.x; | |
627 #endif | |
628 #ifdef INVERTNORMALMAPY | |
629 map.y=1.0-map.y; | |
630 #endif | |
631 map=map*255./127.-128./127.; | |
632 return normalize(cotangentFrame*map); | |
633 } | |
634 #ifdef PARALLAX | |
635 const float minSamples=4.; | |
636 const float maxSamples=15.; | |
637 const int iMaxSamples=15; | |
638 | |
639 vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) { | |
640 float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z; | |
641 parallaxLimit*=parallaxScale; | |
642 vec2 vOffsetDir=normalize(vViewDirCoT.xy); | |
643 vec2 vMaxOffset=vOffsetDir*parallaxLimit; | |
644 float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples)); | |
645 float stepSize=1.0/numSamples; | |
646 | |
647 float currRayHeight=1.0; | |
648 vec2 vCurrOffset=vec2(0,0); | |
649 vec2 vLastOffset=vec2(0,0); | |
650 float lastSampledHeight=1.0; | |
651 float currSampledHeight=1.0; | |
652 for (int i=0; i<iMaxSamples; i++) | |
653 { | |
654 currSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w; | |
655 | |
656 if (currSampledHeight>currRayHeight) | |
657 { | |
658 float delta1=currSampledHeight-currRayHeight; | |
659 float delta2=(currRayHeight+stepSize)-lastSampledHeight; | |
660 float ratio=delta1/(delta1+delta2); | |
661 vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset; | |
662 | |
663 break; | |
664 } | |
665 else | |
666 { | |
667 currRayHeight-=stepSize; | |
668 vLastOffset=vCurrOffset; | |
669 vCurrOffset+=stepSize*vMaxOffset; | |
670 lastSampledHeight=currSampledHeight; | |
671 } | |
672 } | |
673 return vCurrOffset; | |
674 } | |
675 vec2 parallaxOffset(vec3 viewDir,float heightScale) | |
676 { | |
677 | |
678 float height=texture2D(bumpSampler,vBumpUV).w; | |
679 vec2 texCoordOffset=heightScale*viewDir.xy*height; | |
680 return -texCoordOffset; | |
681 } | |
682 #endif | |
683 #endif | |
684 #ifdef CLIPPLANE | |
685 varying float fClipDistance; | |
686 #endif | |
687 #ifdef LOGARITHMICDEPTH | |
688 uniform float logarithmicDepthConstant; | |
689 varying float vFragmentDepth; | |
690 #endif | |
691 #ifdef FOG | |
692 #define FOGMODE_NONE 0. | |
693 #define FOGMODE_EXP 1. | |
694 #define FOGMODE_EXP2 2. | |
695 #define FOGMODE_LINEAR 3. | |
696 #define E 2.71828 | |
697 uniform vec4 vFogInfos; | |
698 uniform vec3 vFogColor; | |
699 varying vec3 vFogDistance; | |
700 float CalcFogFactor() | |
701 { | |
702 float fogCoeff=1.0; | |
703 float fogStart=vFogInfos.y; | |
704 float fogEnd=vFogInfos.z; | |
705 float fogDensity=vFogInfos.w; | |
706 float fogDistance=length(vFogDistance); | |
707 if (FOGMODE_LINEAR == vFogInfos.x) | |
708 { | |
709 fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart); | |
710 } | |
711 else if (FOGMODE_EXP == vFogInfos.x) | |
712 { | |
713 fogCoeff=1.0/pow(E,fogDistance*fogDensity); | |
714 } | |
715 else if (FOGMODE_EXP2 == vFogInfos.x) | |
716 { | |
717 fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity); | |
718 } | |
719 return clamp(fogCoeff,0.0,1.0); | |
720 } | |
721 #endif | |
722 void main(void) { | |
723 #ifdef CLIPPLANE | |
724 if (fClipDistance>0.0) | |
725 { | |
726 discard; | |
727 } | |
728 #endif | |
729 vec3 viewDirectionW=normalize(vEyePosition-vPositionW); | |
730 | |
731 vec4 baseColor=vec4(1.,1.,1.,1.); | |
732 vec3 diffuseColor=vDiffuseColor.rgb; | |
733 | |
734 float alpha=vDiffuseColor.a; | |
735 | |
736 #ifdef NORMAL | |
737 vec3 normalW=normalize(vNormalW); | |
738 #else | |
739 vec3 normalW=vec3(1.0,1.0,1.0); | |
740 #endif | |
741 vec2 uvOffset=vec2(0.0,0.0); | |
742 #if defined(BUMP) || defined(PARALLAX) | |
743 #if NORMALXYSCALE | |
744 normalW=normalize(normalW*vec3(vBumpInfos.y,vBumpInfos.y,1.0)); | |
745 float normalScale=1.0; | |
746 #else | |
747 float normalScale=vBumpInfos.y; | |
748 #endif | |
749 #if defined(TANGENT) && defined(NORMAL) | |
750 mat3 TBN=vTBN; | |
751 #else | |
752 mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV); | |
753 #endif | |
754 #endif | |
755 #ifdef PARALLAX | |
756 mat3 invTBN=transposeMat3(TBN); | |
757 #ifdef PARALLAXOCCLUSION | |
758 uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z); | |
759 #else | |
760 uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z); | |
761 #endif | |
762 #endif | |
763 #ifdef BUMP | |
764 normalW=perturbNormal(TBN,vBumpUV+uvOffset); | |
765 #endif | |
766 #ifdef TWOSIDEDLIGHTING | |
767 normalW=gl_FrontFacing ? normalW : -normalW; | |
768 #endif | |
769 #ifdef DIFFUSE | |
770 baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset); | |
771 #ifdef ALPHATEST | |
772 if (baseColor.a<0.4) | |
773 discard; | |
774 #endif | |
775 #ifdef ALPHAFROMDIFFUSE | |
776 alpha*=baseColor.a; | |
777 #endif | |
778 baseColor.rgb*=vDiffuseInfos.y; | |
779 #endif | |
780 #ifdef VERTEXCOLOR | |
781 baseColor.rgb*=vColor.rgb; | |
782 #endif | |
783 | |
784 vec3 baseAmbientColor=vec3(1.,1.,1.); | |
785 #ifdef AMBIENT | |
786 baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y; | |
787 #endif | |
788 | |
789 #ifdef SPECULARTERM | |
790 float glossiness=vSpecularColor.a; | |
791 vec3 specularColor=vSpecularColor.rgb; | |
792 #ifdef SPECULAR | |
793 vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset); | |
794 specularColor=specularMapColor.rgb; | |
795 #ifdef GLOSSINESS | |
796 glossiness=glossiness*specularMapColor.a; | |
797 #endif | |
798 #endif | |
799 #else | |
800 float glossiness=0.; | |
801 #endif | |
802 | |
803 vec3 diffuseBase=vec3(0.,0.,0.); | |
804 lightingInfo info; | |
805 #ifdef SPECULARTERM | |
806 vec3 specularBase=vec3(0.,0.,0.); | |
807 #endif | |
808 float shadow=1.; | |
809 #ifdef LIGHTMAP | |
810 vec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y; | |
811 #endif | |
812 #ifdef LIGHT0 | |
813 #if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED0) && defined(LIGHTMAPNOSPECULAR0) | |
814 | |
815 #else | |
816 #ifdef SPOTLIGHT0 | |
817 info=computeSpotLighting(viewDirectionW,normalW,vLightData0,vLightDirection0,vLightDiffuse0.rgb,vLightSpecular0,vLightDiffuse0.a,glossiness); | |
818 #endif | |
819 #ifdef HEMILIGHT0 | |
820 info=computeHemisphericLighting(viewDirectionW,normalW,vLightData0,vLightDiffuse0.rgb,vLightSpecular0,vLightGround0,glossiness); | |
821 #endif | |
822 #if defined(POINTLIGHT0) || defined(DIRLIGHT0) | |
823 info=computeLighting(viewDirectionW,normalW,vLightData0,vLightDiffuse0.rgb,vLightSpecular0,vLightDiffuse0.a,glossiness); | |
824 #endif | |
825 #endif | |
826 #ifdef SHADOW0 | |
827 #ifdef SHADOWESM0 | |
828 #if defined(POINTLIGHT0) | |
829 shadow=computeShadowWithESMCube(vLightData0.xyz,shadowSampler0,shadowsInfo0.x,shadowsInfo0.z); | |
830 #else | |
831 shadow=computeShadowWithESM(vPositionFromLight0,shadowSampler0,shadowsInfo0.x,shadowsInfo0.z); | |
832 #endif | |
833 #else | |
834 #ifdef SHADOWPCF0 | |
835 #if defined(POINTLIGHT0) | |
836 shadow=computeShadowWithPCFCube(vLightData0.xyz,shadowSampler0,shadowsInfo0.y,shadowsInfo0.x); | |
837 #else | |
838 shadow=computeShadowWithPCF(vPositionFromLight0,shadowSampler0,shadowsInfo0.y,shadowsInfo0.x); | |
839 #endif | |
840 #else | |
841 #if defined(POINTLIGHT0) | |
842 shadow=computeShadowCube(vLightData0.xyz,shadowSampler0,shadowsInfo0.x); | |
843 #else | |
844 shadow=computeShadow(vPositionFromLight0,shadowSampler0,shadowsInfo0.x); | |
845 #endif | |
846 #endif | |
847 #endif | |
848 #else | |
849 shadow=1.; | |
850 #endif | |
851 #ifdef CUSTOMUSERLIGHTING | |
852 diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); | |
853 #ifdef SPECULARTERM | |
854 specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); | |
855 #endif | |
856 #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED0) | |
857 diffuseBase+=lightmapColor*shadow; | |
858 #ifdef SPECULARTERM | |
859 #ifndef LIGHTMAPNOSPECULAR0 | |
860 specularBase+=info.specular*shadow*lightmapColor; | |
861 #endif | |
862 #endif | |
863 #else | |
864 diffuseBase+=info.diffuse*shadow; | |
865 #ifdef SPECULARTERM | |
866 specularBase+=info.specular*shadow; | |
867 #endif | |
868 #endif | |
869 #endif | |
870 #ifdef LIGHT1 | |
871 #if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED1) && defined(LIGHTMAPNOSPECULAR1) | |
872 | |
873 #else | |
874 #ifdef SPOTLIGHT1 | |
875 info=computeSpotLighting(viewDirectionW,normalW,vLightData1,vLightDirection1,vLightDiffuse1.rgb,vLightSpecular1,vLightDiffuse1.a,glossiness); | |
876 #endif | |
877 #ifdef HEMILIGHT1 | |
878 info=computeHemisphericLighting(viewDirectionW,normalW,vLightData1,vLightDiffuse1.rgb,vLightSpecular1,vLightGround1,glossiness); | |
879 #endif | |
880 #if defined(POINTLIGHT1) || defined(DIRLIGHT1) | |
881 info=computeLighting(viewDirectionW,normalW,vLightData1,vLightDiffuse1.rgb,vLightSpecular1,vLightDiffuse1.a,glossiness); | |
882 #endif | |
883 #endif | |
884 #ifdef SHADOW1 | |
885 #ifdef SHADOWESM1 | |
886 #if defined(POINTLIGHT1) | |
887 shadow=computeShadowWithESMCube(vLightData1.xyz,shadowSampler1,shadowsInfo1.x,shadowsInfo1.z); | |
888 #else | |
889 shadow=computeShadowWithESM(vPositionFromLight1,shadowSampler1,shadowsInfo1.x,shadowsInfo1.z); | |
890 #endif | |
891 #else | |
892 #ifdef SHADOWPCF1 | |
893 #if defined(POINTLIGHT1) | |
894 shadow=computeShadowWithPCFCube(vLightData1.xyz,shadowSampler1,shadowsInfo1.y,shadowsInfo1.x); | |
895 #else | |
896 shadow=computeShadowWithPCF(vPositionFromLight1,shadowSampler1,shadowsInfo1.y,shadowsInfo1.x); | |
897 #endif | |
898 #else | |
899 #if defined(POINTLIGHT1) | |
900 shadow=computeShadowCube(vLightData1.xyz,shadowSampler1,shadowsInfo1.x); | |
901 #else | |
902 shadow=computeShadow(vPositionFromLight1,shadowSampler1,shadowsInfo1.x); | |
903 #endif | |
904 #endif | |
905 #endif | |
906 #else | |
907 shadow=1.; | |
908 #endif | |
909 #ifdef CUSTOMUSERLIGHTING | |
910 diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); | |
911 #ifdef SPECULARTERM | |
912 specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); | |
913 #endif | |
914 #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED1) | |
915 diffuseBase+=lightmapColor*shadow; | |
916 #ifdef SPECULARTERM | |
917 #ifndef LIGHTMAPNOSPECULAR1 | |
918 specularBase+=info.specular*shadow*lightmapColor; | |
919 #endif | |
920 #endif | |
921 #else | |
922 diffuseBase+=info.diffuse*shadow; | |
923 #ifdef SPECULARTERM | |
924 specularBase+=info.specular*shadow; | |
925 #endif | |
926 #endif | |
927 #endif | |
928 #ifdef LIGHT2 | |
929 #if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED2) && defined(LIGHTMAPNOSPECULAR2) | |
930 | |
931 #else | |
932 #ifdef SPOTLIGHT2 | |
933 info=computeSpotLighting(viewDirectionW,normalW,vLightData2,vLightDirection2,vLightDiffuse2.rgb,vLightSpecular2,vLightDiffuse2.a,glossiness); | |
934 #endif | |
935 #ifdef HEMILIGHT2 | |
936 info=computeHemisphericLighting(viewDirectionW,normalW,vLightData2,vLightDiffuse2.rgb,vLightSpecular2,vLightGround2,glossiness); | |
937 #endif | |
938 #if defined(POINTLIGHT2) || defined(DIRLIGHT2) | |
939 info=computeLighting(viewDirectionW,normalW,vLightData2,vLightDiffuse2.rgb,vLightSpecular2,vLightDiffuse2.a,glossiness); | |
940 #endif | |
941 #endif | |
942 #ifdef SHADOW2 | |
943 #ifdef SHADOWESM2 | |
944 #if defined(POINTLIGHT2) | |
945 shadow=computeShadowWithESMCube(vLightData2.xyz,shadowSampler2,shadowsInfo2.x,shadowsInfo2.z); | |
946 #else | |
947 shadow=computeShadowWithESM(vPositionFromLight2,shadowSampler2,shadowsInfo2.x,shadowsInfo2.z); | |
948 #endif | |
949 #else | |
950 #ifdef SHADOWPCF2 | |
951 #if defined(POINTLIGHT2) | |
952 shadow=computeShadowWithPCFCube(vLightData2.xyz,shadowSampler2,shadowsInfo2.y,shadowsInfo2.x); | |
953 #else | |
954 shadow=computeShadowWithPCF(vPositionFromLight2,shadowSampler2,shadowsInfo2.y,shadowsInfo2.x); | |
955 #endif | |
956 #else | |
957 #if defined(POINTLIGHT2) | |
958 shadow=computeShadowCube(vLightData2.xyz,shadowSampler2,shadowsInfo2.x); | |
959 #else | |
960 shadow=computeShadow(vPositionFromLight2,shadowSampler2,shadowsInfo2.x); | |
961 #endif | |
962 #endif | |
963 #endif | |
964 #else | |
965 shadow=1.; | |
966 #endif | |
967 #ifdef CUSTOMUSERLIGHTING | |
968 diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); | |
969 #ifdef SPECULARTERM | |
970 specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); | |
971 #endif | |
972 #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED2) | |
973 diffuseBase+=lightmapColor*shadow; | |
974 #ifdef SPECULARTERM | |
975 #ifndef LIGHTMAPNOSPECULAR2 | |
976 specularBase+=info.specular*shadow*lightmapColor; | |
977 #endif | |
978 #endif | |
979 #else | |
980 diffuseBase+=info.diffuse*shadow; | |
981 #ifdef SPECULARTERM | |
982 specularBase+=info.specular*shadow; | |
983 #endif | |
984 #endif | |
985 #endif | |
986 #ifdef LIGHT3 | |
987 #if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED3) && defined(LIGHTMAPNOSPECULAR3) | |
988 | |
989 #else | |
990 #ifdef SPOTLIGHT3 | |
991 info=computeSpotLighting(viewDirectionW,normalW,vLightData3,vLightDirection3,vLightDiffuse3.rgb,vLightSpecular3,vLightDiffuse3.a,glossiness); | |
992 #endif | |
993 #ifdef HEMILIGHT3 | |
994 info=computeHemisphericLighting(viewDirectionW,normalW,vLightData3,vLightDiffuse3.rgb,vLightSpecular3,vLightGround3,glossiness); | |
995 #endif | |
996 #if defined(POINTLIGHT3) || defined(DIRLIGHT3) | |
997 info=computeLighting(viewDirectionW,normalW,vLightData3,vLightDiffuse3.rgb,vLightSpecular3,vLightDiffuse3.a,glossiness); | |
998 #endif | |
999 #endif | |
1000 #ifdef SHADOW3 | |
1001 #ifdef SHADOWESM3 | |
1002 #if defined(POINTLIGHT3) | |
1003 shadow=computeShadowWithESMCube(vLightData3.xyz,shadowSampler3,shadowsInfo3.x,shadowsInfo3.z); | |
1004 #else | |
1005 shadow=computeShadowWithESM(vPositionFromLight3,shadowSampler3,shadowsInfo3.x,shadowsInfo3.z); | |
1006 #endif | |
1007 #else | |
1008 #ifdef SHADOWPCF3 | |
1009 #if defined(POINTLIGHT3) | |
1010 shadow=computeShadowWithPCFCube(vLightData3.xyz,shadowSampler3,shadowsInfo3.y,shadowsInfo3.x); | |
1011 #else | |
1012 shadow=computeShadowWithPCF(vPositionFromLight3,shadowSampler3,shadowsInfo3.y,shadowsInfo3.x); | |
1013 #endif | |
1014 #else | |
1015 #if defined(POINTLIGHT3) | |
1016 shadow=computeShadowCube(vLightData3.xyz,shadowSampler3,shadowsInfo3.x); | |
1017 #else | |
1018 shadow=computeShadow(vPositionFromLight3,shadowSampler3,shadowsInfo3.x); | |
1019 #endif | |
1020 #endif | |
1021 #endif | |
1022 #else | |
1023 shadow=1.; | |
1024 #endif | |
1025 #ifdef CUSTOMUSERLIGHTING | |
1026 diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); | |
1027 #ifdef SPECULARTERM | |
1028 specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); | |
1029 #endif | |
1030 #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED3) | |
1031 diffuseBase+=lightmapColor*shadow; | |
1032 #ifdef SPECULARTERM | |
1033 #ifndef LIGHTMAPNOSPECULAR3 | |
1034 specularBase+=info.specular*shadow*lightmapColor; | |
1035 #endif | |
1036 #endif | |
1037 #else | |
1038 diffuseBase+=info.diffuse*shadow; | |
1039 #ifdef SPECULARTERM | |
1040 specularBase+=info.specular*shadow; | |
1041 #endif | |
1042 #endif | |
1043 #endif | |
1044 | |
1045 | |
1046 vec3 refractionColor=vec3(0.,0.,0.); | |
1047 #ifdef REFRACTION | |
1048 vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y)); | |
1049 #ifdef REFRACTIONMAP_3D | |
1050 refractionVector.y=refractionVector.y*vRefractionInfos.w; | |
1051 if (dot(refractionVector,viewDirectionW)<1.0) | |
1052 { | |
1053 refractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x; | |
1054 } | |
1055 #else | |
1056 vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0))); | |
1057 vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z; | |
1058 refractionCoords.y=1.0-refractionCoords.y; | |
1059 refractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x; | |
1060 #endif | |
1061 #endif | |
1062 | |
1063 vec3 reflectionColor=vec3(0.,0.,0.); | |
1064 #ifdef REFLECTION | |
1065 vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW); | |
1066 #ifdef REFLECTIONMAP_3D | |
1067 #ifdef ROUGHNESS | |
1068 float bias=vReflectionInfos.y; | |
1069 #ifdef SPECULARTERM | |
1070 #ifdef SPECULAR | |
1071 #ifdef GLOSSINESS | |
1072 bias*=(1.0-specularMapColor.a); | |
1073 #endif | |
1074 #endif | |
1075 #endif | |
1076 reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x; | |
1077 #else | |
1078 reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x; | |
1079 #endif | |
1080 #else | |
1081 vec2 coords=vReflectionUVW.xy; | |
1082 #ifdef REFLECTIONMAP_PROJECTION | |
1083 coords/=vReflectionUVW.z; | |
1084 #endif | |
1085 coords.y=1.0-coords.y; | |
1086 reflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x; | |
1087 #endif | |
1088 #ifdef REFLECTIONFRESNEL | |
1089 float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a); | |
1090 #ifdef REFLECTIONFRESNELFROMSPECULAR | |
1091 #ifdef SPECULARTERM | |
1092 reflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; | |
1093 #else | |
1094 reflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; | |
1095 #endif | |
1096 #else | |
1097 reflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; | |
1098 #endif | |
1099 #endif | |
1100 #endif | |
1101 #ifdef REFRACTIONFRESNEL | |
1102 float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a); | |
1103 refractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb; | |
1104 #endif | |
1105 #ifdef OPACITY | |
1106 vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset); | |
1107 #ifdef OPACITYRGB | |
1108 opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11); | |
1109 alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y; | |
1110 #else | |
1111 alpha*=opacityMap.a*vOpacityInfos.y; | |
1112 #endif | |
1113 #endif | |
1114 #ifdef VERTEXALPHA | |
1115 alpha*=vColor.a; | |
1116 #endif | |
1117 #ifdef OPACITYFRESNEL | |
1118 float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w); | |
1119 alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y; | |
1120 #endif | |
1121 | |
1122 vec3 emissiveColor=vEmissiveColor; | |
1123 #ifdef EMISSIVE | |
1124 emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y; | |
1125 #endif | |
1126 #ifdef EMISSIVEFRESNEL | |
1127 float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a); | |
1128 emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb; | |
1129 #endif | |
1130 | |
1131 #ifdef DIFFUSEFRESNEL | |
1132 float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a); | |
1133 diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb; | |
1134 #endif | |
1135 | |
1136 #ifdef EMISSIVEASILLUMINATION | |
1137 vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb; | |
1138 #else | |
1139 #ifdef LINKEMISSIVEWITHDIFFUSE | |
1140 vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb; | |
1141 #else | |
1142 vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb; | |
1143 #endif | |
1144 #endif | |
1145 #ifdef SPECULARTERM | |
1146 vec3 finalSpecular=specularBase*specularColor; | |
1147 #ifdef SPECULAROVERALPHA | |
1148 alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.); | |
1149 #endif | |
1150 #else | |
1151 vec3 finalSpecular=vec3(0.0); | |
1152 #endif | |
1153 #ifdef REFLECTIONOVERALPHA | |
1154 alpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.); | |
1155 #endif | |
1156 | |
1157 #ifdef EMISSIVEASILLUMINATION | |
1158 vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha); | |
1159 #else | |
1160 vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha); | |
1161 #endif | |
1162 | |
1163 #ifdef LIGHTMAP | |
1164 #ifndef LIGHTMAPEXCLUDED | |
1165 #ifdef USELIGHTMAPASSHADOWMAP | |
1166 color.rgb*=lightmapColor; | |
1167 #else | |
1168 color.rgb+=lightmapColor; | |
1169 #endif | |
1170 #endif | |
1171 #endif | |
1172 #ifdef LOGARITHMICDEPTH | |
1173 gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5; | |
1174 #endif | |
1175 #ifdef FOG | |
1176 float fog=CalcFogFactor(); | |
1177 color.rgb=fog*color.rgb+(1.0-fog)*vFogColor; | |
1178 #endif | |
1179 #ifdef CAMERACOLORGRADING | |
1180 color=colorGrades(color); | |
1181 #endif | |
1182 #ifdef CAMERACOLORCURVES | |
1183 color.rgb=applyColorCurves(color.rgb); | |
1184 #endif | |
1185 gl_FragColor=color; | |
1186 }t._ErrorEnabled @ client.js:108436Effect._dumpShadersSource @ client.js:108446Effect._prepareEffect @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadFragmentShader @ client.js:108446(anonymous function) @ client.js:108446Effect._processShaderConversion @ client.js:108446(anonymous function) @ client.js:108446Effect._processIncludes @ client.js:108446(anonymous function) @ client.js:108446Effect._loadVertexShader @ client.js:108446Effect @ client.js:108446n.createEffect @ client.js:108438r.isReadyForSubMesh @ client.js:108449r.render @ client.js:108445t.render @ client.js:108446t.renderUnsorted @ client.js:108442t.render @ client.js:108441t.render @ client.js:108441r._renderForCamera @ client.js:108443r._processSubCameras @ client.js:108443r.render @ client.js:108443(anonymous function) @ client.js:134916n._renderLoop @ client.js:108437 | |
client.js:108436 BJS - [15:29:04]: Error: WARNING: 0:81: ' | |
' : extension directive should occur before any non-preprocessor tokens | |
ERROR: 0:743: 'NORMALXYSCALE' : unexpected token after conditional expression | |