https://playground.babylonjs.com/indexStable.html#MK6IZ7#1
Hi there,
if you use usePercentageCloserFiltering (Shadowgenerator) it will break Android and only Android (iOS, Safari, Chrome desktop works fine).
BJS - [10:25:40]: Unable to compile effect:
BJS - [10:25:40]: 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, normalMatrix, lightmapMatrix, refractionMatrix, diffuseLeftColor, diffuseRightColor, opacityParts, reflectionLeftColor, reflectionRightColor, emissiveLeftColor, emissiveRightColor, refractionLeftColor, refractionRightColor, vReflectionPosition, vReflectionSize, logarithmicDepthConstant, vTangentSpaceParams, alphaCutOff, vLightData0, vLightDiffuse0, vLightSpecular0, vLightDirection0, vLightGround0, lightMatrix0, shadowsInfo0, depthValues0, diffuseSampler, ambientSampler, opacitySampler, reflectionCubeSampler, reflection2DSampler, emissiveSampler, specularSampler, bumpSampler, lightmapSampler, refractionCubeSampler, refraction2DSampler, shadowSampler0, depthSampler0
t._ErrorEnabled @ babylon.js:4
BJS - [10:25:40]: Attributes: position, normal
BJS - [10:25:40]: Vertex shader: default
1 #version 300 es
2 #define WEBGL2
3 #define DIFFUSEDIRECTUV 0
4 #define AMBIENTDIRECTUV 0
5 #define OPACITYDIRECTUV 0
6 #define EMISSIVEDIRECTUV 0
7 #define SPECULARDIRECTUV 0
8 #define BUMPDIRECTUV 0
9 #define SPECULARTERM
10 #define NORMAL
11 #define NUM_BONE_INFLUENCERS 0
12 #define BonesPerMesh 0
13 #define LIGHTMAPDIRECTUV 0
14 #define SHADOWFLOAT
15 #define NUM_MORPH_INFLUENCERS 0
16 #define VIGNETTEBLENDMODEMULTIPLY
17 #define SAMPLER3DGREENDEPTH
18 #define SAMPLER3DBGRMAP
19 #define LIGHT0
20 #define DIRLIGHT0
21 #define SHADOW0
22 #define SHADOWPCF0
23 #define SHADOWS
24
25 #define SHADER_NAME vertex:default
26 precision highp float;
27 layout(std140,column_major) uniform;
28 uniform Material
29 {
30 vec4 diffuseLeftColor;
31 vec4 diffuseRightColor;
32 vec4 opacityParts;
33 vec4 reflectionLeftColor;
34 vec4 reflectionRightColor;
35 vec4 refractionLeftColor;
36 vec4 refractionRightColor;
37 vec4 emissiveLeftColor;
38 vec4 emissiveRightColor;
39 vec2 vDiffuseInfos;
40 vec2 vAmbientInfos;
41 vec2 vOpacityInfos;
42 vec2 vReflectionInfos;
43 vec3 vReflectionPosition;
44 vec3 vReflectionSize;
45 vec2 vEmissiveInfos;
46 vec2 vLightmapInfos;
47 vec2 vSpecularInfos;
48 vec3 vBumpInfos;
49 mat4 diffuseMatrix;
50 mat4 ambientMatrix;
51 mat4 opacityMatrix;
52 mat4 reflectionMatrix;
53 mat4 emissiveMatrix;
54 mat4 lightmapMatrix;
55 mat4 specularMatrix;
56 mat4 bumpMatrix;
57 vec4 vTangentSpaceParams;
58 mat4 refractionMatrix;
59 vec4 vRefractionInfos;
60 vec4 vSpecularColor;
61 vec3 vEmissiveColor;
62 vec4 vDiffuseColor;
63 float pointSize;
64 };
65 uniform Scene {
66 mat4 viewProjection;
67 mat4 view;
68 };
69
70 #define CUSTOM_VERTEX_BEGIN
71 in vec3 position;
72 #ifdef NORMAL
73 in vec3 normal;
74 #endif
75 #ifdef TANGENT
76 in vec4 tangent;
77 #endif
78 #ifdef UV1
79 in vec2 uv;
80 #endif
81 #ifdef UV2
82 in vec2 uv2;
83 #endif
84 #ifdef VERTEXCOLOR
85 in vec4 color;
86 #endif
87 const float PI=3.1415926535897932384626433832795;
88 const float LinearEncodePowerApprox=2.2;
89 const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
90 const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
91 mat3 transposeMat3(mat3 inMatrix) {
92 vec3 i0=inMatrix[0];
93 vec3 i1=inMatrix[1];
94 vec3 i2=inMatrix[2];
95 mat3 outMatrix=mat3(
96 vec3(i0.x,i1.x,i2.x),
97 vec3(i0.y,i1.y,i2.y),
98 vec3(i0.z,i1.z,i2.z)
99 );
100 return outMatrix;
101 }
102
103 mat3 inverseMat3(mat3 inMatrix) {
104 float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
105 float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
106 float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
107 float b01=a22*a11-a12*a21;
108 float b11=-a22*a10+a12*a20;
109 float b21=a21*a10-a11*a20;
110 float det=a00*b01+a01*b11+a02*b21;
111 return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
112 b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
113 b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
114 }
115 float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
116 {
117 float mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));
118 return mix(value,1.0,mask);
119 }
120 vec3 applyEaseInOut(vec3 x){
121 return x*x*(3.0-2.0*x);
122 }
123 vec3 toLinearSpace(vec3 color)
124 {
125 return pow(color,vec3(LinearEncodePowerApprox));
126 }
127 vec3 toGammaSpace(vec3 color)
128 {
129 return pow(color,vec3(GammaEncodePowerApprox));
130 }
131 float square(float value)
132 {
133 return value*value;
134 }
135 float getLuminance(vec3 color)
136 {
137 return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
138 }
139
140 float getRand(vec2 seed) {
141 return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
142 }
143 float dither(vec2 seed,float varianceAmount) {
144 float rand=getRand(seed);
145 float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
146 return dither;
147 }
148 #if NUM_BONE_INFLUENCERS>0
149 uniform mat4 mBones[BonesPerMesh];
150 in vec4 matricesIndices;
151 in vec4 matricesWeights;
152 #if NUM_BONE_INFLUENCERS>4
153 in vec4 matricesIndicesExtra;
154 in vec4 matricesWeightsExtra;
155 #endif
156 #endif
157
158 #ifdef INSTANCES
159 in vec4 world0;
160 in vec4 world1;
161 in vec4 world2;
162 in vec4 world3;
163 #else
164 uniform mat4 world;
165 #endif
166 #ifdef MAINUV1
167 out vec2 vMainUV1;
168 #endif
169 #ifdef MAINUV2
170 out vec2 vMainUV2;
171 #endif
172 #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
173 out vec2 vDiffuseUV;
174 #endif
175 #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
176 out vec2 vAmbientUV;
177 #endif
178 #if defined(OPACITY) && OPACITYDIRECTUV == 0
179 out vec2 vOpacityUV;
180 #endif
181 #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
182 out vec2 vEmissiveUV;
183 #endif
184 #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
185 out vec2 vLightmapUV;
186 #endif
187 #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
188 out vec2 vSpecularUV;
189 #endif
190 #if defined(BUMP) && BUMPDIRECTUV == 0
191 out vec2 vBumpUV;
192 #endif
193
194 out vec3 vPositionW;
195 #ifdef NORMAL
196 out vec3 vNormalW;
197 #endif
198 #ifdef VERTEXCOLOR
199 out vec4 vColor;
200 #endif
201 #if defined(BUMP) || defined(PARALLAX)
202 #if defined(TANGENT) && defined(NORMAL)
203 out mat3 vTBN;
204 #endif
205 #endif
206
207 #ifdef CLIPPLANE
208 uniform vec4 vClipPlane;
209 out float fClipDistance;
210 #endif
211 #ifdef FOG
212 out vec3 vFogDistance;
213 #endif
214 #ifdef LIGHT0
215 uniform Light0
216 {
217 vec4 vLightData;
218 vec4 vLightDiffuse;
219 vec3 vLightSpecular;
220 #ifdef SPOTLIGHT0
221 vec4 vLightDirection;
222 #endif
223 #ifdef HEMILIGHT0
224 vec3 vLightGround;
225 #endif
226 vec4 shadowsInfo;
227 vec2 depthValues;
228 } light0;
229 #ifdef PROJECTEDLIGHTTEXTURE0
230 uniform mat4 textureProjectionMatrix0;
231 uniform sampler2D projectionLightSampler0;
232 #endif
233 #ifdef SHADOW0
234 #if defined(SHADOWCUBE0)
235 uniform samplerCube shadowSampler0;
236 #else
237 out vec4 vPositionFromLight0;
238 out float vDepthMetric0;
239 #if defined(SHADOWPCSS0)
240 uniform highp sampler2DShadow shadowSampler0;
241 uniform highp sampler2D depthSampler0;
242 #elif defined(SHADOWPCF0)
243 uniform highp sampler2DShadow shadowSampler0;
244 #else
245 uniform sampler2D shadowSampler0;
246 #endif
247 uniform mat4 lightMatrix0;
248 #endif
249 #endif
250 #endif
251 #ifdef LIGHT1
252 uniform Light1
253 {
254 vec4 vLightData;
255 vec4 vLightDiffuse;
256 vec3 vLightSpecular;
257 #ifdef SPOTLIGHT1
258 vec4 vLightDirection;
259 #endif
260 #ifdef HEMILIGHT1
261 vec3 vLightGround;
262 #endif
263 vec4 shadowsInfo;
264 vec2 depthValues;
265 } light1;
266 #ifdef PROJECTEDLIGHTTEXTURE1
267 uniform mat4 textureProjectionMatrix1;
268 uniform sampler2D projectionLightSampler1;
269 #endif
270 #ifdef SHADOW1
271 #if defined(SHADOWCUBE1)
272 uniform samplerCube shadowSampler1;
273 #else
274 out vec4 vPositionFromLight1;
275 out float vDepthMetric1;
276 #if defined(SHADOWPCSS1)
277 uniform highp sampler2DShadow shadowSampler1;
278 uniform highp sampler2D depthSampler1;
279 #elif defined(SHADOWPCF1)
280 uniform highp sampler2DShadow shadowSampler1;
281 #else
282 uniform sampler2D shadowSampler1;
283 #endif
284 uniform mat4 lightMatrix1;
285 #endif
286 #endif
287 #endif
288 #ifdef LIGHT2
289 uniform Light2
290 {
291 vec4 vLightData;
292 vec4 vLightDiffuse;
293 vec3 vLightSpecular;
294 #ifdef SPOTLIGHT2
295 vec4 vLightDirection;
296 #endif
297 #ifdef HEMILIGHT2
298 vec3 vLightGround;
299 #endif
300 vec4 shadowsInfo;
301 vec2 depthValues;
302 } light2;
303 #ifdef PROJECTEDLIGHTTEXTURE2
304 uniform mat4 textureProjectionMatrix2;
305 uniform sampler2D projectionLightSampler2;
306 #endif
307 #ifdef SHADOW2
308 #if defined(SHADOWCUBE2)
309 uniform samplerCube shadowSampler2;
310 #else
311 out vec4 vPositionFromLight2;
312 out float vDepthMetric2;
313 #if defined(SHADOWPCSS2)
314 uniform highp sampler2DShadow shadowSampler2;
315 uniform highp sampler2D depthSampler2;
316 #elif defined(SHADOWPCF2)
317 uniform highp sampler2DShadow shadowSampler2;
318 #else
319 uniform sampler2D shadowSampler2;
320 #endif
321 uniform mat4 lightMatrix2;
322 #endif
323 #endif
324 #endif
325 #ifdef LIGHT3
326 uniform Light3
327 {
328 vec4 vLightData;
329 vec4 vLightDiffuse;
330 vec3 vLightSpecular;
331 #ifdef SPOTLIGHT3
332 vec4 vLightDirection;
333 #endif
334 #ifdef HEMILIGHT3
335 vec3 vLightGround;
336 #endif
337 vec4 shadowsInfo;
338 vec2 depthValues;
339 } light3;
340 #ifdef PROJECTEDLIGHTTEXTURE3
341 uniform mat4 textureProjectionMatrix3;
342 uniform sampler2D projectionLightSampler3;
343 #endif
344 #ifdef SHADOW3
345 #if defined(SHADOWCUBE3)
346 uniform samplerCube shadowSampler3;
347 #else
348 out vec4 vPositionFromLight3;
349 out float vDepthMetric3;
350 #if defined(SHADOWPCSS3)
351 uniform highp sampler2DShadow shadowSampler3;
352 uniform highp sampler2D depthSampler3;
353 #elif defined(SHADOWPCF3)
354 uniform highp sampler2DShadow shadowSampler3;
355 #else
356 uniform sampler2D shadowSampler3;
357 #endif
358 uniform mat4 lightMatrix3;
359 #endif
360 #endif
361 #endif
362
363 #ifdef MORPHTARGETS
364 uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
365 #endif
366
367 #ifdef REFLECTIONMAP_SKYBOX
368 out vec3 vPositionUVW;
369 #endif
370 #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
371 out vec3 vDirectionW;
372 #endif
373 #ifdef LOGARITHMICDEPTH
374 uniform float logarithmicDepthConstant;
375 out float vFragmentDepth;
376 #endif
377 #define CUSTOM_VERTEX_DEFINITIONS
378 void main(void) {
379 #define CUSTOM_VERTEX_MAIN_BEGIN
380 vec3 positionUpdated=position;
381 #ifdef NORMAL
382 vec3 normalUpdated=normal;
383 #endif
384 #ifdef TANGENT
385 vec4 tangentUpdated=tangent;
386 #endif
387
388 #ifdef REFLECTIONMAP_SKYBOX
389 vPositionUVW=positionUpdated;
390 #endif
391 #define CUSTOM_VERTEX_UPDATE_POSITION
392 #define CUSTOM_VERTEX_UPDATE_NORMAL
393 #ifdef INSTANCES
394 mat4 finalWorld=mat4(world0,world1,world2,world3);
395 #else
396 mat4 finalWorld=world;
397 #endif
398 #if NUM_BONE_INFLUENCERS>0
399 mat4 influence;
400 influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
401 #if NUM_BONE_INFLUENCERS>1
402 influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
403 #endif
404 #if NUM_BONE_INFLUENCERS>2
405 influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
406 #endif
407 #if NUM_BONE_INFLUENCERS>3
408 influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
409 #endif
410 #if NUM_BONE_INFLUENCERS>4
411 influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
412 #endif
413 #if NUM_BONE_INFLUENCERS>5
414 influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
415 #endif
416 #if NUM_BONE_INFLUENCERS>6
417 influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
418 #endif
419 #if NUM_BONE_INFLUENCERS>7
420 influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
421 #endif
422 finalWorld=finalWorld*influence;
423 #endif
424 gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
425 vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
426 vPositionW=vec3(worldPos);
427 #ifdef NORMAL
428 mat3 normalWorld=mat3(finalWorld);
429 #ifdef NONUNIFORMSCALING
430 normalWorld=transposeMat3(inverseMat3(normalWorld));
431 #endif
432 vNormalW=normalize(normalWorld*normalUpdated);
433 #endif
434 #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
435 vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
436 #endif
437
438 #ifndef UV1
439 vec2 uv=vec2(0.,0.);
440 #endif
441 #ifndef UV2
442 vec2 uv2=vec2(0.,0.);
443 #endif
444 #ifdef MAINUV1
445 vMainUV1=uv;
446 #endif
447 #ifdef MAINUV2
448 vMainUV2=uv2;
449 #endif
450 #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
451 if (vDiffuseInfos.x == 0.)
452 {
453 vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));
454 }
455 else
456 {
457 vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
458 }
459 #endif
460 #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
461 if (vAmbientInfos.x == 0.)
462 {
463 vAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));
464 }
465 else
466 {
467 vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));
468 }
469 #endif
470 #if defined(OPACITY) && OPACITYDIRECTUV == 0
471 if (vOpacityInfos.x == 0.)
472 {
473 vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));
474 }
475 else
476 {
477 vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
478 }
479 #endif
480 #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
481 if (vEmissiveInfos.x == 0.)
482 {
483 vEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));
484 }
485 else
486 {
487 vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
488 }
489 #endif
490 #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
491 if (vLightmapInfos.x == 0.)
492 {
493 vLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));
494 }
495 else
496 {
497 vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));
498 }
499 #endif
500 #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
501 if (vSpecularInfos.x == 0.)
502 {
503 vSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));
504 }
505 else
506 {
507 vSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));
508 }
509 #endif
510 #if defined(BUMP) && BUMPDIRECTUV == 0
511 if (vBumpInfos.x == 0.)
512 {
513 vBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));
514 }
515 else
516 {
517 vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
518 }
519 #endif
520 #if defined(BUMP) || defined(PARALLAX)
521 #if defined(TANGENT) && defined(NORMAL)
522 vec3 tbnNormal=normalize(normalUpdated);
523 vec3 tbnTangent=normalize(tangentUpdated.xyz);
524 vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;
525 vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
526 #endif
527 #endif
528 #ifdef CLIPPLANE
529 fClipDistance=dot(worldPos,vClipPlane);
530 #endif
531 #ifdef FOG
532 vFogDistance=(view*worldPos).xyz;
533 #endif
534 #ifdef SHADOWS
535 #if defined(SHADOW0) && !defined(SHADOWCUBE0)
536 vPositionFromLight0=lightMatrix0*worldPos;
537 vDepthMetric0=((vPositionFromLight0.z+light0.depthValues.x)/(light0.depthValues.y));
538 #endif
539 #endif
540 #ifdef SHADOWS
541 #if defined(SHADOW1) && !defined(SHADOWCUBE1)
542 vPositionFromLight1=lightMatrix1*worldPos;
543 vDepthMetric1=((vPositionFromLight1.z+light1.depthValues.x)/(light1.depthValues.y));
544 #endif
545 #endif
546 #ifdef SHADOWS
547 #if defined(SHADOW2) && !defined(SHADOWCUBE2)
548 vPositionFromLight2=lightMatrix2*worldPos;
549 vDepthMetric2=((vPositionFromLight2.z+light2.depthValues.x)/(light2.depthValues.y));
550 #endif
551 #endif
552 #ifdef SHADOWS
553 #if defined(SHADOW3) && !defined(SHADOWCUBE3)
554 vPositionFromLight3=lightMatrix3*worldPos;
555 vDepthMetric3=((vPositionFromLight3.z+light3.depthValues.x)/(light3.depthValues.y));
556 #endif
557 #endif
558
559 #ifdef VERTEXCOLOR
560
561 vColor=color;
562 #endif
563 #ifdef POINTSIZE
564 gl_PointSize=pointSize;
565 #endif
566 #ifdef LOGARITHMICDEPTH
567 vFragmentDepth=1.0+gl_Position.w;
568 gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
569 #endif
570 #define CUSTOM_VERTEX_MAIN_END
571 }
572
kind reagards