@uptimizr/dashboard 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +76 -0
  3. package/out/404.html +1 -0
  4. package/out/__next.__PAGE__.txt +9 -0
  5. package/out/__next._full.txt +20 -0
  6. package/out/__next._head.txt +6 -0
  7. package/out/__next._index.txt +5 -0
  8. package/out/__next._tree.txt +4 -0
  9. package/out/_next/static/93W3szqylNKDg-afLRmVW/_buildManifest.js +11 -0
  10. package/out/_next/static/93W3szqylNKDg-afLRmVW/_clientMiddlewareManifest.js +1 -0
  11. package/out/_next/static/93W3szqylNKDg-afLRmVW/_ssgManifest.js +1 -0
  12. package/out/_next/static/chunks/0-2y-_oomza2l.js +87 -0
  13. package/out/_next/static/chunks/00k_j_r7bv_eb.js +266 -0
  14. package/out/_next/static/chunks/00zdau6mcqeae.js +1 -0
  15. package/out/_next/static/chunks/023axeoslq39i.js +1 -0
  16. package/out/_next/static/chunks/068j6934u8j16.js +1 -0
  17. package/out/_next/static/chunks/0_rf76jneiwal.js +176 -0
  18. package/out/_next/static/chunks/0aznt7717miff.js +1 -0
  19. package/out/_next/static/chunks/0cu-q5q3a7uf3.js +1 -0
  20. package/out/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
  21. package/out/_next/static/chunks/0dm32-jq30tg8.js +1 -0
  22. package/out/_next/static/chunks/0dn0yx0rn6mpf.js +1 -0
  23. package/out/_next/static/chunks/0flc7nppbmsl1.js +3 -0
  24. package/out/_next/static/chunks/0fskcfh9vbhtv.js +1 -0
  25. package/out/_next/static/chunks/0gv7mblzv3dl3.js +87 -0
  26. package/out/_next/static/chunks/0impkpmxx3ttp.js +1 -0
  27. package/out/_next/static/chunks/0jmn7u31w95ly.js +91 -0
  28. package/out/_next/static/chunks/0n8n481szj90g.js +1 -0
  29. package/out/_next/static/chunks/0o6ayai0s01js.js +1 -0
  30. package/out/_next/static/chunks/0rys92_73hdb0.js +22 -0
  31. package/out/_next/static/chunks/0tl_moiyi2txt.js +1 -0
  32. package/out/_next/static/chunks/0tx1j_ghpz7rc.css +3 -0
  33. package/out/_next/static/chunks/0ufbyo1x3qkmo.js +1 -0
  34. package/out/_next/static/chunks/0v82oqyoy9zol.js +1 -0
  35. package/out/_next/static/chunks/0wrm9jr-9bw0e.js +1893 -0
  36. package/out/_next/static/chunks/0wwcfw8i3j_zx.js +1 -0
  37. package/out/_next/static/chunks/0ys9-ozuluawt.js +1 -0
  38. package/out/_next/static/chunks/1-61zh4waha61.js +1 -0
  39. package/out/_next/static/chunks/10r_824wzt8hj.js +1 -0
  40. package/out/_next/static/chunks/112hws17nz665.js +7 -0
  41. package/out/_next/static/chunks/123xxske5c9na.js +1 -0
  42. package/out/_next/static/chunks/13isnf0--pmx1.js +1 -0
  43. package/out/_next/static/chunks/157d9euci08yu.js +1 -0
  44. package/out/_next/static/chunks/15s7425ffrec9.js +3 -0
  45. package/out/_next/static/chunks/163fa70v4mgxj.js +1 -0
  46. package/out/_next/static/chunks/17q0c2h5ui10r.js +4 -0
  47. package/out/_next/static/chunks/18u58lorfahxi.js +4 -0
  48. package/out/_next/static/chunks/1_aahautsz2v_.js +1 -0
  49. package/out/_next/static/chunks/1a9l89j7e6mqu.js +23 -0
  50. package/out/_next/static/chunks/1dsy2ngmfflis.js +123 -0
  51. package/out/_next/static/chunks/1flb8adpj6_2o.js +62 -0
  52. package/out/_next/static/chunks/1lsg-22yob8dx.js +1 -0
  53. package/out/_next/static/chunks/1nj82er7msdto.js +2 -0
  54. package/out/_next/static/chunks/1o1d0p-v1z8ty.js +1 -0
  55. package/out/_next/static/chunks/1pdep2_c530sg.js +1 -0
  56. package/out/_next/static/chunks/1thjncpj7u6pq.js +1 -0
  57. package/out/_next/static/chunks/1vdjn0pkoyypn.js +1 -0
  58. package/out/_next/static/chunks/1yehxf-fmeicg.js +1 -0
  59. package/out/_next/static/chunks/1zvc1tv--w8nn.js +1 -0
  60. package/out/_next/static/chunks/1zx2q-r32thv1.js +4 -0
  61. package/out/_next/static/chunks/2-sjjedfr0kfq.js +1 -0
  62. package/out/_next/static/chunks/21o42k82w4llc.js +1 -0
  63. package/out/_next/static/chunks/25b9x-li-tvk2.js +1 -0
  64. package/out/_next/static/chunks/2712627rfsmwn.js +1 -0
  65. package/out/_next/static/chunks/296w2ke-v5tbm.js +9 -0
  66. package/out/_next/static/chunks/29tfeb6amdkjb.js +23 -0
  67. package/out/_next/static/chunks/2a3spdq-m8drh.js +3 -0
  68. package/out/_next/static/chunks/2aelw3far6rii.js +1 -0
  69. package/out/_next/static/chunks/2aor7m-wbis85.js +1 -0
  70. package/out/_next/static/chunks/2cbmf9m7lqv6k.js +4 -0
  71. package/out/_next/static/chunks/2d09v5u7dfq0q.js +1 -0
  72. package/out/_next/static/chunks/2feca0xcipcyt.js +850 -0
  73. package/out/_next/static/chunks/2fh-_9b6tqhvb.js +1 -0
  74. package/out/_next/static/chunks/2g5gecypj0rqe.js +1 -0
  75. package/out/_next/static/chunks/2kazjq29jeamx.js +1109 -0
  76. package/out/_next/static/chunks/2p2vv6cc9i-3q.js +255 -0
  77. package/out/_next/static/chunks/2szdcpl41-kzv.js +1 -0
  78. package/out/_next/static/chunks/2tws5udjdcmh3.js +1 -0
  79. package/out/_next/static/chunks/2u6shh3oeycm-.js +1 -0
  80. package/out/_next/static/chunks/2unhhuv0arlcv.js +1 -0
  81. package/out/_next/static/chunks/2xwy0-qfho1iz.js +91 -0
  82. package/out/_next/static/chunks/2ycvtdd68gub7.js +1 -0
  83. package/out/_next/static/chunks/2yiy_l8bwiw2_.js +3 -0
  84. package/out/_next/static/chunks/2yph6f7khgqii.js +1 -0
  85. package/out/_next/static/chunks/3-shckrcpvbxu.js +1681 -0
  86. package/out/_next/static/chunks/30fq_t9e2_fv-.js +1 -0
  87. package/out/_next/static/chunks/30yzu213bqtq0.js +5 -0
  88. package/out/_next/static/chunks/310uz81hnnzsu.js +1 -0
  89. package/out/_next/static/chunks/3218lp8l0a5g_.js +1 -0
  90. package/out/_next/static/chunks/35h5n42wxwgzk.js +123 -0
  91. package/out/_next/static/chunks/37vzwr3ciejf1.js +1 -0
  92. package/out/_next/static/chunks/38fhw7fatsyvd.js +3 -0
  93. package/out/_next/static/chunks/3be6s4_kn9q-o.js +1 -0
  94. package/out/_next/static/chunks/3i3gbhccmhu7j.js +210 -0
  95. package/out/_next/static/chunks/3l1dr_qm_x5kp.js +1 -0
  96. package/out/_next/static/chunks/3mqy-84_ul3t2.js +1 -0
  97. package/out/_next/static/chunks/3nz-dh9d7cehk.js +1 -0
  98. package/out/_next/static/chunks/3pufs8g4ui943.js +1 -0
  99. package/out/_next/static/chunks/3sjq_xoi4rbyg.js +31 -0
  100. package/out/_next/static/chunks/3t06schbtqonl.js +1 -0
  101. package/out/_next/static/chunks/3v3-7fio3nw_t.js +1 -0
  102. package/out/_next/static/chunks/3v5ha25nxo43j.js +1 -0
  103. package/out/_next/static/chunks/3yfrsm8lfi6ls.js +22 -0
  104. package/out/_next/static/chunks/3zskk1hxu3-_o.js +1 -0
  105. package/out/_next/static/chunks/turbopack-2ropzf0axp1x9.js +1 -0
  106. package/out/_next/static/media/0c89a48fa5027cee-s.p.2cyn07wtgehh0.woff2 +0 -0
  107. package/out/_next/static/media/13bf9871fe164e7f-s.2f7nqdagzwx2-.woff2 +0 -0
  108. package/out/_next/static/media/28868e710e86be81-s.2eksvhm1z0jwa.woff2 +0 -0
  109. package/out/_next/static/media/32687112bd2dd8db-s.1gepa_7fcx9fm.woff2 +0 -0
  110. package/out/_next/static/media/3fe682a82f50d426-s.0vfdmo25voy_0.woff2 +0 -0
  111. package/out/_next/static/media/70bc3e132a0a741e-s.p.3t6q91iet4nsy.woff2 +0 -0
  112. package/out/_next/static/media/71b036adf157cdcf-s.0bp8oijd_gu96.woff2 +0 -0
  113. package/out/_next/static/media/89b21bb081cb7469-s.1fby2rem9ngyr.woff2 +0 -0
  114. package/out/_next/static/media/cc545e633e20c56d-s.176arc174-8zp.woff2 +0 -0
  115. package/out/_next/static/media/icon.08h29dad3pcxg.svg +4 -0
  116. package/out/_not-found/__next._full.txt +16 -0
  117. package/out/_not-found/__next._head.txt +6 -0
  118. package/out/_not-found/__next._index.txt +5 -0
  119. package/out/_not-found/__next._not-found.__PAGE__.txt +5 -0
  120. package/out/_not-found/__next._not-found.txt +5 -0
  121. package/out/_not-found/__next._tree.txt +2 -0
  122. package/out/_not-found.html +1 -0
  123. package/out/_not-found.txt +16 -0
  124. package/out/api/projects +1 -0
  125. package/out/icon.svg +4 -0
  126. package/out/index.html +1 -0
  127. package/out/index.txt +20 -0
  128. package/out/logo.svg +46 -0
  129. package/package.json +67 -0
  130. package/server/standalone.mjs +182 -0
@@ -0,0 +1,1893 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,40042,e=>{"use strict";var i=e.i(12423);let t="decalFragmentDeclaration",o=`#ifdef DECAL
2
+ uniform vec4 vDecalInfos;
3
+ #endif
4
+ `;i.ShaderStore.IncludesShadersStore[t]||(i.ShaderStore.IncludesShadersStore[t]=o);let r="defaultFragmentDeclaration",a=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;
5
+ #ifdef DIFFUSE
6
+ uniform vec2 vDiffuseInfos;
7
+ #endif
8
+ #ifdef AMBIENT
9
+ uniform vec2 vAmbientInfos;
10
+ #endif
11
+ #ifdef OPACITY
12
+ uniform vec2 vOpacityInfos;
13
+ #endif
14
+ #ifdef EMISSIVE
15
+ uniform vec2 vEmissiveInfos;
16
+ #endif
17
+ #ifdef LIGHTMAP
18
+ uniform vec2 vLightmapInfos;
19
+ #endif
20
+ #ifdef BUMP
21
+ uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
22
+ #endif
23
+ #ifdef ALPHATEST
24
+ uniform float alphaCutOff;
25
+ #endif
26
+ #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)
27
+ uniform mat4 view;
28
+ #endif
29
+ #ifdef REFRACTION
30
+ uniform vec4 vRefractionInfos;
31
+ #ifndef REFRACTIONMAP_3D
32
+ uniform mat4 refractionMatrix;
33
+ #endif
34
+ #ifdef REFRACTIONFRESNEL
35
+ uniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;
36
+ #endif
37
+ #if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
38
+ uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize;
39
+ #endif
40
+ #endif
41
+ #if defined(SPECULAR) && defined(SPECULARTERM)
42
+ uniform vec2 vSpecularInfos;
43
+ #endif
44
+ #ifdef DIFFUSEFRESNEL
45
+ uniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;
46
+ #endif
47
+ #ifdef OPACITYFRESNEL
48
+ uniform vec4 opacityParts;
49
+ #endif
50
+ #ifdef EMISSIVEFRESNEL
51
+ uniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;
52
+ #endif
53
+ #if defined(REFLECTION) || (defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED))
54
+ uniform vec2 vReflectionInfos;
55
+ #if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
56
+ uniform mat4 reflectionMatrix;
57
+ #endif
58
+ #ifndef REFLECTIONMAP_SKYBOX
59
+ #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
60
+ uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
61
+ #endif
62
+ #endif
63
+ #ifdef REFLECTIONFRESNEL
64
+ uniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;
65
+ #endif
66
+ #endif
67
+ #ifdef DETAIL
68
+ uniform vec4 vDetailInfos;
69
+ #endif
70
+ #include<decalFragmentDeclaration>
71
+ #if TEXTURE_REPETITION_MODE>0
72
+ uniform vec4 vTextureRepetitionHexTilingParams;
73
+ #endif
74
+ #define ADDITIONAL_FRAGMENT_DECLARATION
75
+ `;i.ShaderStore.IncludesShadersStore[r]||(i.ShaderStore.IncludesShadersStore[r]=a);var n=e.i(85668),l=e.i(6232),f=e.i(44661);let s="prePassDeclaration",d=`#ifdef PREPASS
76
+ #extension GL_EXT_draw_buffers : require
77
+ layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;
78
+ #ifdef PREPASS_LOCAL_POSITION
79
+ varying highp vec3 vPosition;
80
+ #endif
81
+ #ifdef PREPASS_DEPTH
82
+ varying highp vec3 vViewPos;
83
+ #endif
84
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
85
+ varying highp float vNormViewDepth;
86
+ #endif
87
+ #if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
88
+ varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;
89
+ #endif
90
+ #endif
91
+ `;i.ShaderStore.IncludesShadersStore[s]||(i.ShaderStore.IncludesShadersStore[s]=d);let c="oitDeclaration",v=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
92
+ #extension GL_EXT_draw_buffers : require
93
+ layout(location=0) out vec2 depth;
94
+ layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;
95
+ #define MAX_DEPTH 99999.0
96
+ highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;
97
+ #endif
98
+ `;i.ShaderStore.IncludesShadersStore[c]||(i.ShaderStore.IncludesShadersStore[c]=v);var h=e.i(92692),u=e.i(65296);let p="lightFragmentDeclaration",m=`#ifdef LIGHT{X}
99
+ uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
100
+ #ifdef SPECULARTERM
101
+ uniform vec4 vLightSpecular{X};
102
+ #else
103
+ vec4 vLightSpecular{X}=vec4(0.);
104
+ #endif
105
+ #ifdef SHADOW{X}
106
+ #ifdef SHADOWCSM{X}
107
+ uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
108
+ #if defined(SHADOWPCSS{X})
109
+ uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};
110
+ #elif defined(SHADOWPCF{X})
111
+ uniform highp sampler2DArrayShadow shadowTexture{X};
112
+ #else
113
+ uniform highp sampler2DArray shadowTexture{X};
114
+ #endif
115
+ #ifdef SHADOWCSMDEBUG{X}
116
+ const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
117
+ (
118
+ vec3 ( 1.5,0.0,0.0 ),
119
+ vec3 ( 0.0,1.5,0.0 ),
120
+ vec3 ( 0.0,0.0,5.5 ),
121
+ vec3 ( 1.5,0.0,5.5 ),
122
+ vec3 ( 1.5,1.5,0.0 ),
123
+ vec3 ( 1.0,1.0,1.0 ),
124
+ vec3 ( 0.0,1.0,5.5 ),
125
+ vec3 ( 0.5,3.5,0.75 )
126
+ );vec3 shadowDebug{X};
127
+ #endif
128
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
129
+ int index{X}=-1;
130
+ #else
131
+ int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
132
+ #endif
133
+ float diff{X}=0.;
134
+ #elif defined(SHADOWCUBE{X})
135
+ uniform samplerCube shadowTexture{X};
136
+ #else
137
+ varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
138
+ #if defined(SHADOWPCSS{X})
139
+ uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
140
+ #elif defined(SHADOWPCF{X})
141
+ uniform highp sampler2DShadow shadowTexture{X};
142
+ #else
143
+ uniform sampler2D shadowTexture{X};
144
+ #endif
145
+ uniform mat4 lightMatrix{X};
146
+ #endif
147
+ uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
148
+ #endif
149
+ #ifdef SPOTLIGHT{X}
150
+ uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
151
+ #elif defined(POINTLIGHT{X})
152
+ uniform vec4 vLightFalloff{X};
153
+ #elif defined(HEMILIGHT{X})
154
+ uniform vec3 vLightGround{X};
155
+ #endif
156
+ #ifdef AREALIGHT{X}
157
+ uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X};
158
+ #ifdef RECTAREALIGHTEMISSIONTEXTURE{X}
159
+ uniform sampler2D rectAreaLightEmissionTexture{X};
160
+ #endif
161
+ #endif
162
+ #ifdef IESLIGHTTEXTURE{X}
163
+ uniform sampler2D iesLightTexture{X};
164
+ #endif
165
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
166
+ uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
167
+ #endif
168
+ #ifdef CLUSTLIGHT{X}
169
+ uniform vec2 vSliceData{X};uniform vec2 vSliceRanges{X}[CLUSTLIGHT_SLICES];uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X};
170
+ #endif
171
+ #endif
172
+ `;i.ShaderStore.IncludesShadersStore[p]||(i.ShaderStore.IncludesShadersStore[p]=m);let S="lightUboDeclaration",g=`#ifdef LIGHT{X}
173
+ uniform Light{X}
174
+ {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
175
+ #ifdef SPOTLIGHT{X}
176
+ vec4 vLightDirection;vec4 vLightFalloff;
177
+ #elif defined(POINTLIGHT{X})
178
+ vec4 vLightFalloff;
179
+ #elif defined(HEMILIGHT{X})
180
+ vec3 vLightGround;
181
+ #elif defined(CLUSTLIGHT{X})
182
+ vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES];
183
+ #endif
184
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
185
+ vec4 vLightWidth;vec4 vLightHeight;
186
+ #endif
187
+ vec4 shadowsInfo;vec2 depthValues;} light{X};
188
+ #ifdef IESLIGHTTEXTURE{X}
189
+ uniform sampler2D iesLightTexture{X};
190
+ #endif
191
+ #ifdef RECTAREALIGHTEMISSIONTEXTURE{X}
192
+ uniform sampler2D rectAreaLightEmissionTexture{X};
193
+ #endif
194
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
195
+ uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
196
+ #endif
197
+ #ifdef CLUSTLIGHT{X}
198
+ uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X};
199
+ #endif
200
+ #ifdef SHADOW{X}
201
+ #ifdef SHADOWCSM{X}
202
+ uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
203
+ #if defined(SHADOWPCSS{X})
204
+ uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};
205
+ #elif defined(SHADOWPCF{X})
206
+ uniform highp sampler2DArrayShadow shadowTexture{X};
207
+ #else
208
+ uniform highp sampler2DArray shadowTexture{X};
209
+ #endif
210
+ #ifdef SHADOWCSMDEBUG{X}
211
+ const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
212
+ (
213
+ vec3 ( 1.5,0.0,0.0 ),
214
+ vec3 ( 0.0,1.5,0.0 ),
215
+ vec3 ( 0.0,0.0,5.5 ),
216
+ vec3 ( 1.5,0.0,5.5 ),
217
+ vec3 ( 1.5,1.5,0.0 ),
218
+ vec3 ( 1.0,1.0,1.0 ),
219
+ vec3 ( 0.0,1.0,5.5 ),
220
+ vec3 ( 0.5,3.5,0.75 )
221
+ );vec3 shadowDebug{X};
222
+ #endif
223
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
224
+ int index{X}=-1;
225
+ #else
226
+ int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
227
+ #endif
228
+ float diff{X}=0.;
229
+ #elif defined(SHADOWCUBE{X})
230
+ uniform samplerCube shadowTexture{X};
231
+ #else
232
+ varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
233
+ #if defined(SHADOWPCSS{X})
234
+ uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
235
+ #elif defined(SHADOWPCF{X})
236
+ uniform highp sampler2DShadow shadowTexture{X};
237
+ #else
238
+ uniform sampler2D shadowTexture{X};
239
+ #endif
240
+ uniform mat4 lightMatrix{X};
241
+ #endif
242
+ #endif
243
+ #endif
244
+ `;i.ShaderStore.IncludesShadersStore[S]||(i.ShaderStore.IncludesShadersStore[S]=g);let E="ltcHelperFunctions",C=`vec2 LTCUv( const in vec3 N,const in vec3 V,const in float roughness ) {const float LUTSIZE=64.0;const float LUTSCALE=( LUTSIZE-1.0 )/LUTSIZE;const float LUTBIAS=0.5/LUTSIZE;float dotNV=saturate( dot( N,V ) );vec2 uv=vec2( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;}
245
+ float LTCClippedSphereFormFactor( const in vec3 f ) {float l=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );}
246
+ vec3 LTCEdgeVectorFormFactor( const in vec3 v1,const in vec3 v2 ) {float x=dot( v1,v2 );float y=abs( x );float a=0.8543985+( 0.4965155+0.0145206*y )*y;float b=3.4175940+( 4.1616724+y )*y;float v=a/b;float thetaSintheta=0.0;if( x>0.0 )
247
+ {thetaSintheta=v;}
248
+ else
249
+ {thetaSintheta=0.5*inversesqrt( max( 1.0-x*x,1e-7 ) )-v;}
250
+ return cross( v1,v2 )*thetaSintheta;}
251
+ vec3 LTCEvaluate( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ] ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 );
252
+ mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result );}
253
+ vec3 FetchDiffuseFilteredTexture(sampler2D texLightFiltered,vec3 p1_,vec3 p2_,vec3 p3_,vec3 p4_)
254
+ {vec3 V1=p2_-p1_;vec3 V2=p4_-p1_;vec3 planeOrtho=(cross(V1,V2));float planeAreaSquared=dot(planeOrtho,planeOrtho);float planeDistxPlaneArea=dot(planeOrtho,p1_);vec3 P=planeDistxPlaneArea*planeOrtho/planeAreaSquared-p1_;float dot_V1_V2=dot(V1,V2);float inv_dot_V1_V1=1.0/dot(V1,V1);vec3 V2_=V2-V1*dot_V1_V2*inv_dot_V1_V1;vec2 Puv;Puv.y=dot(V2_,P)/dot(V2_,V2_);Puv.x=dot(V1,P)*inv_dot_V1_V1-dot_V1_V2*inv_dot_V1_V1*Puv.y ;float d=abs(planeDistxPlaneArea)/pow(planeAreaSquared,0.75);float sampleLOD=log(2048.0*d)/log(3.0);vec2 sampleUV=vec2(0.125,0.125)+(vec2(0.75)*Puv);sampleUV.x=1.0-sampleUV.x;return texture2DLodEXT(texLightFiltered,sampleUV,sampleLOD).rgb;}
255
+ vec3 LTCEvaluateWithEmission( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ],const in sampler2D texFilteredMap ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 );
256
+ mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );vec3 textureLight=FetchDiffuseFilteredTexture(texFilteredMap,coords[0],coords[1],coords[2],coords[3]);coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result )*textureLight;}
257
+ struct areaLightData
258
+ {vec3 Diffuse;vec3 Specular;vec4 Fresnel;};
259
+ #define inline
260
+ areaLightData computeAreaLightSpecularDiffuseFresnel(const in sampler2D ltc1,const in sampler2D ltc2,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness)
261
+ {areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight;
262
+ rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight;
263
+ #ifdef SPECULARTERM
264
+ vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3(
265
+ vec3( t1.x,0,t1.y ),
266
+ vec3( 0,1, 0 ),
267
+ vec3( t1.z,0,t1.w )
268
+ );result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords );result.Fresnel=t2;
269
+ #endif
270
+ result.Diffuse=LTCEvaluate( normal,viewDir,position,mat3( 1.0 ),rectCoords );return result;}
271
+ #define inline
272
+ areaLightData computeAreaLightSpecularDiffuseFresnelWithEmission(const in sampler2D ltc1,const in sampler2D ltc2,const in sampler2D texFilteredMap,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness)
273
+ {areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight;
274
+ rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight;
275
+ #ifdef SPECULARTERM
276
+ vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3(
277
+ vec3( t1.x,0,t1.y ),
278
+ vec3( 0,1, 0 ),
279
+ vec3( t1.z,0,t1.w )
280
+ );result.Specular=LTCEvaluateWithEmission( normal,viewDir,position,mInv,rectCoords,texFilteredMap );result.Fresnel=t2;
281
+ #endif
282
+ result.Diffuse=LTCEvaluateWithEmission( normal,viewDir,position,mat3( 1.0 ),rectCoords,texFilteredMap );return result;}`;i.ShaderStore.IncludesShadersStore[E]||(i.ShaderStore.IncludesShadersStore[E]=C);let D="clusteredLightingFunctions",T=`struct ClusteredLight {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;vec4 vLightDirection;vec4 vLightFalloff;};
283
+ #define inline
284
+ ClusteredLight getClusteredLight(sampler2D lightDataTexture,int index) {return ClusteredLight(
285
+ texelFetch(lightDataTexture,ivec2(0,index),0),
286
+ texelFetch(lightDataTexture,ivec2(1,index),0),
287
+ texelFetch(lightDataTexture,ivec2(2,index),0),
288
+ texelFetch(lightDataTexture,ivec2(3,index),0),
289
+ texelFetch(lightDataTexture,ivec2(4,index),0)
290
+ );}
291
+ int getClusteredSliceIndex(vec2 sliceData,float viewDepth) {return int(log(viewDepth)*sliceData.x+sliceData.y);}
292
+ `;i.ShaderStore.IncludesShadersStore[D]||(i.ShaderStore.IncludesShadersStore[D]=T);let L="lightsFragmentFunctions",I=`struct lightingInfo
293
+ {vec3 diffuse;
294
+ #ifdef SPECULARTERM
295
+ vec3 specular;
296
+ #endif
297
+ #ifdef NDOTL
298
+ float ndl;
299
+ #endif
300
+ };lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.)
301
+ {vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
302
+ else
303
+ {lightVectorW=normalize(-lightData.xyz);}
304
+ float ndl=max(0.,dot(vNormal,lightVectorW));
305
+ #ifdef NDOTL
306
+ result.ndl=ndl;
307
+ #endif
308
+ result.diffuse=ndl*diffuseColor*attenuation;
309
+ #ifdef SPECULARTERM
310
+ vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
311
+ #endif
312
+ return result;}
313
+ float getAttenuation(float cosAngle,float exponent) {return max(0.,pow(cosAngle,exponent));}
314
+ float getIESAttenuation(float cosAngle,sampler2D iesLightSampler) {float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;}
315
+ lightingInfo basicSpotLighting(vec3 viewDirectionW,vec3 lightVectorW,vec3 vNormal,float attenuation,vec3 diffuseColor,vec3 specularColor,float glossiness) {lightingInfo result;
316
+ float ndl=max(0.,dot(vNormal,lightVectorW));
317
+ #ifdef NDOTL
318
+ result.ndl=ndl;
319
+ #endif
320
+ result.diffuse=ndl*diffuseColor*attenuation;
321
+ #ifdef SPECULARTERM
322
+ vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
323
+ #endif
324
+ return result;}
325
+ lightingInfo computeIESSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness,sampler2D iesLightSampler) {
326
+ vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float dotProduct=dot(lightDirection.xyz,-lightVectorW);float cosAngle=max(0.,dotProduct);if (cosAngle>=lightDirection.w)
327
+ {
328
+ attenuation*=getIESAttenuation(dotProduct,iesLightSampler);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
329
+ lightingInfo result;result.diffuse=vec3(0.);
330
+ #ifdef SPECULARTERM
331
+ result.specular=vec3(0.);
332
+ #endif
333
+ #ifdef NDOTL
334
+ result.ndl=0.;
335
+ #endif
336
+ return result;}
337
+ lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
338
+ {
339
+ attenuation*=getAttenuation(cosAngle,lightData.w);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
340
+ lightingInfo result;result.diffuse=vec3(0.);
341
+ #ifdef SPECULARTERM
342
+ result.specular=vec3(0.);
343
+ #endif
344
+ #ifdef NDOTL
345
+ result.ndl=0.;
346
+ #endif
347
+ return result;}
348
+ lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;
349
+ #ifdef NDOTL
350
+ result.ndl=ndl;
351
+ #endif
352
+ result.diffuse=mix(groundColor,diffuseColor,ndl);
353
+ #ifdef SPECULARTERM
354
+ vec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
355
+ #endif
356
+ return result;}
357
+ #define inline
358
+ vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;}
359
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
360
+ #include<ltcHelperFunctions>
361
+ uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler;
362
+ #define inline
363
+ lightingInfo computeAreaLighting(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness)
364
+ {lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
365
+ #ifdef SPECULARTERM
366
+ vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
367
+ #endif
368
+ result.diffuse+=diffuseColor*data.Diffuse;return result;}
369
+ lightingInfo computeAreaLightingWithTexture(sampler2D ltc1,sampler2D ltc2,sampler2D emissionTexture,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness)
370
+ {lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc2,emissionTexture,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
371
+ #ifdef SPECULARTERM
372
+ vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
373
+ #endif
374
+ result.diffuse+=diffuseColor*data.Diffuse;return result;}
375
+ #endif
376
+ #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
377
+ #include<clusteredLightingFunctions>
378
+ #define inline
379
+ lightingInfo computeClusteredLighting(
380
+ sampler2D lightDataTexture,
381
+ sampler2D tileMaskTexture,
382
+ vec3 viewDirectionW,
383
+ vec3 vNormal,
384
+ vec4 lightData,
385
+ ivec2 sliceRange,
386
+ float glossiness
387
+ ) {lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);lightingInfo info;if (light.vLightDirection.w<0.0) {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);}
388
+ result.diffuse+=info.diffuse;
389
+ #ifdef SPECULARTERM
390
+ result.specular+=info.specular;
391
+ #endif
392
+ }
393
+ batchOffset+=CLUSTLIGHT_BATCH;}
394
+ return result;}
395
+ #endif
396
+ `;i.ShaderStore.IncludesShadersStore[L]||(i.ShaderStore.IncludesShadersStore[L]=I);let w="shadowsFragmentFunctions",x=`#ifdef SHADOWS
397
+ #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
398
+ #define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
399
+ #else
400
+ #define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
401
+ #endif
402
+ #ifndef SHADOWFLOAT
403
+ float unpack(vec4 color)
404
+ {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);return dot(color,bit_shift);}
405
+ #endif
406
+ float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
407
+ {float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
408
+ #define inline
409
+ float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
410
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
411
+ #ifndef SHADOWFLOAT
412
+ float shadow=unpack(textureCube(shadowSampler,directionToLight));
413
+ #else
414
+ float shadow=textureCube(shadowSampler,directionToLight).x;
415
+ #endif
416
+ return depth>shadow ? darkness : 1.0;}
417
+ #define inline
418
+ float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
419
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0);
420
+ #ifndef SHADOWFLOAT
421
+ if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
422
+ #else
423
+ if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
424
+ #endif
425
+ return min(1.0,visibility+darkness);}
426
+ #define inline
427
+ float computeShadowWithESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
428
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
429
+ #ifndef SHADOWFLOAT
430
+ float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
431
+ #else
432
+ float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
433
+ #endif
434
+ float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
435
+ #define inline
436
+ float computeShadowWithCloseESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
437
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
438
+ #ifndef SHADOWFLOAT
439
+ float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
440
+ #else
441
+ float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
442
+ #endif
443
+ float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
444
+ #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
445
+ #define inline
446
+ float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
447
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);vec3 uvLayer=vec3(uv.x,uv.y,layer);float shadowPixelDepth=clamp(depthMetric,0.,1.0);
448
+ #ifndef SHADOWFLOAT
449
+ float shadow=unpack(texture2D(shadowSampler,uvLayer));
450
+ #else
451
+ float shadow=texture2D(shadowSampler,uvLayer).x;
452
+ #endif
453
+ return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}
454
+ #endif
455
+ #define inline
456
+ float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
457
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
458
+ {return 1.0;}
459
+ else
460
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);
461
+ #ifndef SHADOWFLOAT
462
+ float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
463
+ #else
464
+ float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;
465
+ #endif
466
+ return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}
467
+ #define inline
468
+ float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
469
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
470
+ {return 1.0;}
471
+ else
472
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760);
473
+ #ifndef SHADOWFLOAT
474
+ if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;
475
+ #else
476
+ if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;
477
+ #endif
478
+ return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
479
+ #define inline
480
+ float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
481
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
482
+ {return 1.0;}
483
+ else
484
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);
485
+ #ifndef SHADOWFLOAT
486
+ float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
487
+ #else
488
+ float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
489
+ #endif
490
+ float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
491
+ #define inline
492
+ float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
493
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
494
+ {return 1.0;}
495
+ else
496
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);
497
+ #ifndef SHADOWFLOAT
498
+ float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
499
+ #else
500
+ float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
501
+ #endif
502
+ float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
503
+ #ifdef IS_NDC_HALF_ZRANGE
504
+ #define ZINCLIP clipSpace.z
505
+ #else
506
+ #define ZINCLIP uvDepth.z
507
+ #endif
508
+ #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
509
+ #define SMALLEST_ABOVE_ZERO 1.1754943508e-38
510
+ #define GREATEST_LESS_THAN_ONE 0.99999994
511
+ #define DISABLE_UNIFORMITY_ANALYSIS
512
+ #define inline
513
+ float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
514
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
515
+ #ifdef USE_REVERSE_DEPTHBUFFER
516
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
517
+ #else
518
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
519
+ #endif
520
+ vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
521
+ #define inline
522
+ float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
523
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
524
+ #ifdef USE_REVERSE_DEPTHBUFFER
525
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
526
+ #else
527
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
528
+ #endif
529
+ vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
530
+ uv+=0.5;
531
+ vec2 st=fract(uv);
532
+ vec2 base_uv=floor(uv)-0.5;
533
+ base_uv*=shadowMapSizeAndInverse.y;
534
+ vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
535
+ #define inline
536
+ float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
537
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
538
+ #ifdef USE_REVERSE_DEPTHBUFFER
539
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
540
+ #else
541
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
542
+ #endif
543
+ vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
544
+ uv+=0.5;
545
+ vec2 st=fract(uv);
546
+ vec2 base_uv=floor(uv)-0.5;
547
+ base_uv*=shadowMapSizeAndInverse.y;
548
+ vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
549
+ #define inline
550
+ float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
551
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
552
+ #define inline
553
+ float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
554
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
555
+ uv+=0.5;
556
+ vec2 st=fract(uv);
557
+ vec2 base_uv=floor(uv)-0.5;
558
+ base_uv*=shadowMapSizeAndInverse.y;
559
+ vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
560
+ #define inline
561
+ float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
562
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
563
+ uv+=0.5;
564
+ vec2 st=fract(uv);
565
+ vec2 base_uv=floor(uv)-0.5;
566
+ base_uv*=shadowMapSizeAndInverse.y;
567
+ vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
568
+ const vec3 PoissonSamplers32[64]=vec3[64](
569
+ vec3(0.06407013,0.05409927,0.),
570
+ vec3(0.7366577,0.5789394,0.),
571
+ vec3(-0.6270542,-0.5320278,0.),
572
+ vec3(-0.4096107,0.8411095,0.),
573
+ vec3(0.6849564,-0.4990818,0.),
574
+ vec3(-0.874181,-0.04579735,0.),
575
+ vec3(0.9989998,0.0009880066,0.),
576
+ vec3(-0.004920578,-0.9151649,0.),
577
+ vec3(0.1805763,0.9747483,0.),
578
+ vec3(-0.2138451,0.2635818,0.),
579
+ vec3(0.109845,0.3884785,0.),
580
+ vec3(0.06876755,-0.3581074,0.),
581
+ vec3(0.374073,-0.7661266,0.),
582
+ vec3(0.3079132,-0.1216763,0.),
583
+ vec3(-0.3794335,-0.8271583,0.),
584
+ vec3(-0.203878,-0.07715034,0.),
585
+ vec3(0.5912697,0.1469799,0.),
586
+ vec3(-0.88069,0.3031784,0.),
587
+ vec3(0.5040108,0.8283722,0.),
588
+ vec3(-0.5844124,0.5494877,0.),
589
+ vec3(0.6017799,-0.1726654,0.),
590
+ vec3(-0.5554981,0.1559997,0.),
591
+ vec3(-0.3016369,-0.3900928,0.),
592
+ vec3(-0.5550632,-0.1723762,0.),
593
+ vec3(0.925029,0.2995041,0.),
594
+ vec3(-0.2473137,0.5538505,0.),
595
+ vec3(0.9183037,-0.2862392,0.),
596
+ vec3(0.2469421,0.6718712,0.),
597
+ vec3(0.3916397,-0.4328209,0.),
598
+ vec3(-0.03576927,-0.6220032,0.),
599
+ vec3(-0.04661255,0.7995201,0.),
600
+ vec3(0.4402924,0.3640312,0.),
601
+ vec3(0.),
602
+ vec3(0.),
603
+ vec3(0.),
604
+ vec3(0.),
605
+ vec3(0.),
606
+ vec3(0.),
607
+ vec3(0.),
608
+ vec3(0.),
609
+ vec3(0.),
610
+ vec3(0.),
611
+ vec3(0.),
612
+ vec3(0.),
613
+ vec3(0.),
614
+ vec3(0.),
615
+ vec3(0.),
616
+ vec3(0.),
617
+ vec3(0.),
618
+ vec3(0.),
619
+ vec3(0.),
620
+ vec3(0.),
621
+ vec3(0.),
622
+ vec3(0.),
623
+ vec3(0.),
624
+ vec3(0.),
625
+ vec3(0.),
626
+ vec3(0.),
627
+ vec3(0.),
628
+ vec3(0.),
629
+ vec3(0.),
630
+ vec3(0.),
631
+ vec3(0.),
632
+ vec3(0.)
633
+ );const vec3 PoissonSamplers64[64]=vec3[64](
634
+ vec3(-0.613392,0.617481,0.),
635
+ vec3(0.170019,-0.040254,0.),
636
+ vec3(-0.299417,0.791925,0.),
637
+ vec3(0.645680,0.493210,0.),
638
+ vec3(-0.651784,0.717887,0.),
639
+ vec3(0.421003,0.027070,0.),
640
+ vec3(-0.817194,-0.271096,0.),
641
+ vec3(-0.705374,-0.668203,0.),
642
+ vec3(0.977050,-0.108615,0.),
643
+ vec3(0.063326,0.142369,0.),
644
+ vec3(0.203528,0.214331,0.),
645
+ vec3(-0.667531,0.326090,0.),
646
+ vec3(-0.098422,-0.295755,0.),
647
+ vec3(-0.885922,0.215369,0.),
648
+ vec3(0.566637,0.605213,0.),
649
+ vec3(0.039766,-0.396100,0.),
650
+ vec3(0.751946,0.453352,0.),
651
+ vec3(0.078707,-0.715323,0.),
652
+ vec3(-0.075838,-0.529344,0.),
653
+ vec3(0.724479,-0.580798,0.),
654
+ vec3(0.222999,-0.215125,0.),
655
+ vec3(-0.467574,-0.405438,0.),
656
+ vec3(-0.248268,-0.814753,0.),
657
+ vec3(0.354411,-0.887570,0.),
658
+ vec3(0.175817,0.382366,0.),
659
+ vec3(0.487472,-0.063082,0.),
660
+ vec3(-0.084078,0.898312,0.),
661
+ vec3(0.488876,-0.783441,0.),
662
+ vec3(0.470016,0.217933,0.),
663
+ vec3(-0.696890,-0.549791,0.),
664
+ vec3(-0.149693,0.605762,0.),
665
+ vec3(0.034211,0.979980,0.),
666
+ vec3(0.503098,-0.308878,0.),
667
+ vec3(-0.016205,-0.872921,0.),
668
+ vec3(0.385784,-0.393902,0.),
669
+ vec3(-0.146886,-0.859249,0.),
670
+ vec3(0.643361,0.164098,0.),
671
+ vec3(0.634388,-0.049471,0.),
672
+ vec3(-0.688894,0.007843,0.),
673
+ vec3(0.464034,-0.188818,0.),
674
+ vec3(-0.440840,0.137486,0.),
675
+ vec3(0.364483,0.511704,0.),
676
+ vec3(0.034028,0.325968,0.),
677
+ vec3(0.099094,-0.308023,0.),
678
+ vec3(0.693960,-0.366253,0.),
679
+ vec3(0.678884,-0.204688,0.),
680
+ vec3(0.001801,0.780328,0.),
681
+ vec3(0.145177,-0.898984,0.),
682
+ vec3(0.062655,-0.611866,0.),
683
+ vec3(0.315226,-0.604297,0.),
684
+ vec3(-0.780145,0.486251,0.),
685
+ vec3(-0.371868,0.882138,0.),
686
+ vec3(0.200476,0.494430,0.),
687
+ vec3(-0.494552,-0.711051,0.),
688
+ vec3(0.612476,0.705252,0.),
689
+ vec3(-0.578845,-0.768792,0.),
690
+ vec3(-0.772454,-0.090976,0.),
691
+ vec3(0.504440,0.372295,0.),
692
+ vec3(0.155736,0.065157,0.),
693
+ vec3(0.391522,0.849605,0.),
694
+ vec3(-0.620106,-0.328104,0.),
695
+ vec3(0.789239,-0.419965,0.),
696
+ vec3(-0.545396,0.538133,0.),
697
+ vec3(-0.178564,-0.596057,0.)
698
+ );
699
+ #define inline
700
+ float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
701
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
702
+ #ifdef USE_REVERSE_DEPTHBUFFER
703
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
704
+ #else
705
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
706
+ #endif
707
+ vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
708
+ float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec4 offset=vec4(poissonSamplers[i],0.);offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);}
709
+ shadow/=float(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);if (numBlocker<1.0) {return 1.0;}
710
+ else
711
+ {return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
712
+ #define inline
713
+ float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
714
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
715
+ if (numBlocker<1.0) {return 1.0;}
716
+ else
717
+ {float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec3 offset=poissonSamplers[i];offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);shadow+=TEXTUREFUNC(shadowSampler,uvDepth+offset*filterRadius,0.);}
718
+ shadow/=float(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}}
719
+ #define inline
720
+ float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
721
+ {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
722
+ #define inline
723
+ float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
724
+ {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
725
+ #define inline
726
+ float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
727
+ {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
728
+ #define inline
729
+ float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
730
+ {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
731
+ #define inline
732
+ float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
733
+ {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
734
+ #define inline
735
+ float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
736
+ {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
737
+ #endif
738
+ #endif
739
+ `;i.ShaderStore.IncludesShadersStore[w]||(i.ShaderStore.IncludesShadersStore[w]=x);let A="samplerFragmentDeclaration",P=`#ifdef _DEFINENAME_
740
+ #if _DEFINENAME_DIRECTUV==1
741
+ #define v_VARYINGNAME_UV vMainUV1
742
+ #elif _DEFINENAME_DIRECTUV==2
743
+ #define v_VARYINGNAME_UV vMainUV2
744
+ #elif _DEFINENAME_DIRECTUV==3
745
+ #define v_VARYINGNAME_UV vMainUV3
746
+ #elif _DEFINENAME_DIRECTUV==4
747
+ #define v_VARYINGNAME_UV vMainUV4
748
+ #elif _DEFINENAME_DIRECTUV==5
749
+ #define v_VARYINGNAME_UV vMainUV5
750
+ #elif _DEFINENAME_DIRECTUV==6
751
+ #define v_VARYINGNAME_UV vMainUV6
752
+ #else
753
+ varying vec2 v_VARYINGNAME_UV;
754
+ #endif
755
+ uniform sampler2D _SAMPLERNAME_Sampler;
756
+ #endif
757
+ `;i.ShaderStore.IncludesShadersStore[A]||(i.ShaderStore.IncludesShadersStore[A]=P);let R="fresnelFunction",X=`#ifdef FRESNEL
758
+ float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
759
+ {float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
760
+ #endif
761
+ `;i.ShaderStore.IncludesShadersStore[R]||(i.ShaderStore.IncludesShadersStore[R]=X);let F="reflectionFunction",N=`vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
762
+ {float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0); }
763
+ vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
764
+ {float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(1.0-s,t,0); }
765
+ vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
766
+ {vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);vec3 r=normalize(reflect(cameraToVertex,worldNormal));r=vec3(reflectionMatrix*vec4(r,0));float lon=atan(r.z,r.x);float lat=acos(r.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0);}
767
+ vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
768
+ {vec3 viewDir=normalize(vec3(view*worldPos));vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));vec3 r=reflect(viewDir,viewNormal);r=vec3(reflectionMatrix*vec4(r,0));r.z=r.z-1.0;float m=2.0*length(r);return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);}
769
+ vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
770
+ {vec3 viewDir=worldPos.xyz-eyePosition;vec3 coords=normalize(reflect(viewDir,worldNormal));return vec3(reflectionMatrix*vec4(coords,1));}
771
+ vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
772
+ {vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=vec3(reflectionMatrix*vec4(coords,0));
773
+ #ifdef INVERTCUBICMAP
774
+ coords.y*=-1.0;
775
+ #endif
776
+ return coords;}
777
+ vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
778
+ {vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=vec3(reflectionMatrix*vec4(coords,0));
779
+ #ifdef INVERTCUBICMAP
780
+ coords.y*=-1.0;
781
+ #endif
782
+ return coords;}
783
+ vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
784
+ {return vec3(reflectionMatrix*(view*worldPos));}
785
+ vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
786
+ {return vec3(reflectionMatrix*vec4(positionW,1.));}
787
+ #ifdef REFLECTION
788
+ vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
789
+ {
790
+ #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
791
+ vec3 direction=normalize(vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
792
+ #endif
793
+ #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
794
+ vec3 direction=normalize(vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
795
+ #endif
796
+ #ifdef REFLECTIONMAP_EQUIRECTANGULAR
797
+ return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
798
+ #endif
799
+ #ifdef REFLECTIONMAP_SPHERICAL
800
+ return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
801
+ #endif
802
+ #ifdef REFLECTIONMAP_PLANAR
803
+ return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
804
+ #endif
805
+ #ifdef REFLECTIONMAP_CUBIC
806
+ #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
807
+ return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
808
+ #else
809
+ return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
810
+ #endif
811
+ #endif
812
+ #ifdef REFLECTIONMAP_PROJECTION
813
+ return computeProjectionCoords(worldPos,view,reflectionMatrix);
814
+ #endif
815
+ #ifdef REFLECTIONMAP_SKYBOX
816
+ return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
817
+ #endif
818
+ #ifdef REFLECTIONMAP_EXPLICIT
819
+ return vec3(0,0,0);
820
+ #endif
821
+ }
822
+ #endif
823
+ `;i.ShaderStore.IncludesShadersStore[F]||(i.ShaderStore.IncludesShadersStore[F]=N);let M="imageProcessingDeclaration",_=`#ifdef EXPOSURE
824
+ uniform float exposureLinear;
825
+ #endif
826
+ #ifdef CONTRAST
827
+ uniform float contrast;
828
+ #endif
829
+ #if defined(VIGNETTE) || defined(DITHER)
830
+ uniform vec2 vInverseScreenSize;
831
+ #endif
832
+ #ifdef VIGNETTE
833
+ uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;
834
+ #endif
835
+ #ifdef COLORCURVES
836
+ uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;
837
+ #endif
838
+ #ifdef COLORGRADING
839
+ #ifdef COLORGRADING3D
840
+ uniform highp sampler3D txColorTransform;
841
+ #else
842
+ uniform sampler2D txColorTransform;
843
+ #endif
844
+ uniform vec4 colorTransformSettings;
845
+ #endif
846
+ #ifdef DITHER
847
+ uniform float ditherIntensity;
848
+ #endif
849
+ `;i.ShaderStore.IncludesShadersStore[M]||(i.ShaderStore.IncludesShadersStore[M]=_);let O="imageProcessingFunctions",y=`#if defined(COLORGRADING) && !defined(COLORGRADING3D)
850
+ /**
851
+ * Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.
852
+ * sampler3dSetting.x=textureOffset (0.5/textureSize).
853
+ * sampler3dSetting.y=textureSize.
854
+ */
855
+ #define inline
856
+ vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
857
+ {float sliceSize=2.0*sampler3dSetting.x;
858
+ #ifdef SAMPLER3DGREENDEPTH
859
+ float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
860
+ #else
861
+ float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
862
+ #endif
863
+ float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;
864
+ #ifdef SAMPLER3DGREENDEPTH
865
+ vec2 sliceUV=color.rb;
866
+ #else
867
+ vec2 sliceUV=color.rg;
868
+ #endif
869
+ sliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
870
+ #ifdef SAMPLER3DBGRMAP
871
+ color.rgb=result.rgb;
872
+ #else
873
+ color.rgb=result.bgr;
874
+ #endif
875
+ return color;}
876
+ #endif
877
+ #if TONEMAPPING==3
878
+ const float PBRNeutralStartCompression=0.8-0.04;const float PBRNeutralDesaturation=0.15;vec3 PBRNeutralToneMapping( vec3 color ) {float x=min(color.r,min(color.g,color.b));float offset=x<0.08 ? x-6.25*x*x : 0.04;color-=offset;float peak=max(color.r,max(color.g,color.b));if (peak<PBRNeutralStartCompression) return color;float d=1.-PBRNeutralStartCompression;float newPeak=1.-d*d/(peak+d-PBRNeutralStartCompression);color*=newPeak/peak;float g=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(color,newPeak*vec3(1,1,1),g);}
879
+ #endif
880
+ #if TONEMAPPING==2
881
+ const mat3 ACESInputMat=mat3(
882
+ vec3(0.59719,0.07600,0.02840),
883
+ vec3(0.35458,0.90834,0.13383),
884
+ vec3(0.04823,0.01566,0.83777)
885
+ );const mat3 ACESOutputMat=mat3(
886
+ vec3( 1.60475,-0.10208,-0.00327),
887
+ vec3(-0.53108, 1.10813,-0.07276),
888
+ vec3(-0.07367,-0.00605, 1.07602)
889
+ );vec3 RRTAndODTFit(vec3 v)
890
+ {vec3 a=v*(v+0.0245786)-0.000090537;vec3 b=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
891
+ vec3 ACESFitted(vec3 color)
892
+ {color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;color=saturate(color);return color;}
893
+ #endif
894
+ #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
895
+ vec4 applyImageProcessing(vec4 result) {
896
+ #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
897
+ #ifdef EXPOSURE
898
+ result.rgb*=exposureLinear;
899
+ #endif
900
+ #ifdef VIGNETTE
901
+ vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);float vignetteTerm=dot(vignetteXY1,vignetteXY1);float vignette=pow(vignetteTerm,vignetteSettings2.w);vec3 vignetteColor=vignetteSettings2.rgb;
902
+ #ifdef VIGNETTEBLENDMODEMULTIPLY
903
+ vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);result.rgb*=vignetteColorMultiplier;
904
+ #endif
905
+ #ifdef VIGNETTEBLENDMODEOPAQUE
906
+ result.rgb=mix(vignetteColor,result.rgb,vignette);
907
+ #endif
908
+ #endif
909
+ #if TONEMAPPING==3
910
+ result.rgb=PBRNeutralToneMapping(result.rgb);
911
+ #elif TONEMAPPING==2
912
+ result.rgb=ACESFitted(result.rgb);
913
+ #elif TONEMAPPING==1
914
+ const float tonemappingCalibration=1.590579;result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
915
+ #endif
916
+ result.rgb=toGammaSpace(result.rgb);result.rgb=saturate(result.rgb);
917
+ #ifdef CONTRAST
918
+ vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);if (contrast<1.0) {result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);} else {result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);}
919
+ result.rgb=max(result.rgb,0.);
920
+ #endif
921
+ #ifdef COLORGRADING
922
+ vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
923
+ #ifdef COLORGRADING3D
924
+ vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
925
+ #else
926
+ vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
927
+ #endif
928
+ result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
929
+ #endif
930
+ #ifdef COLORCURVES
931
+ float luma=getLuminance(result.rgb);vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;result.rgb*=colorCurve.rgb;result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
932
+ #endif
933
+ #ifdef DITHER
934
+ float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither));
935
+ #endif
936
+ #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
937
+ return result;}`;i.ShaderStore.IncludesShadersStore[O]||(i.ShaderStore.IncludesShadersStore[O]=y);let b="textureRepetitionFunctions",U=`#if TEXTURE_REPETITION_MODE>0
938
+ vec4 _texRepHash4(vec2 p) {return fract(sin(vec4(
939
+ 1.0+dot(p,vec2(37.0,17.0)),
940
+ 2.0+dot(p,vec2(11.0,47.0)),
941
+ 3.0+dot(p,vec2(41.0,29.0)),
942
+ 4.0+dot(p,vec2(23.0,31.0))
943
+ ))*103.0);}
944
+ #endif
945
+ #if TEXTURE_REPETITION_MODE==1
946
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {float k=texture2D(samp,0.005*uv).x;float index=k*8.0;float f=fract(index);float i=floor(index+0.5);float ib=floor(index);f=min(f,1.0-f)*2.0;vec2 offa=sin(vec2(3.0,7.0)*i);vec2 offb=sin(vec2(3.0,7.0)*ib);vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);vec4 cola=textureGrad(samp,uv+0.3*offa,dx,dy);vec4 colb=textureGrad(samp,uv+0.3*offb,dx,dy);float colSum=cola.x+cola.y+cola.z-colb.x-colb.y-colb.z;return mix(cola,colb,smoothstep(0.2,0.8,f-0.1*colSum));}
947
+ #elif TEXTURE_REPETITION_MODE==2
948
+ #ifndef TEXTURE_REPETITION_M_PI
949
+ #define TEXTURE_REPETITION_M_PI 3.14159265358979
950
+ #endif
951
+ vec2 _texRepHexHash(vec2 p) {vec2 r=mat2(127.1,269.5,311.7,183.3)*p;return fract(sin(r)*43758.5453);}
952
+ void _texRepTriangleGrid(
953
+ out float w1,out float w2,out float w3,
954
+ out ivec2 vertex1,out ivec2 vertex2,out ivec2 vertex3,
955
+ vec2 st
956
+ ) {st*=2.0*sqrt(3.0);mat2 gridToSkewedGrid=mat2(1.0,0.0,-0.57735027,1.15470054);vec2 skewedCoord=gridToSkewedGrid*st;ivec2 baseId=ivec2(floor(skewedCoord));vec3 temp=vec3(fract(skewedCoord),0.0);temp.z=1.0-temp.x-temp.y;float s=step(0.0,-temp.z);float s2=2.0*s-1.0;w1=-temp.z*s2;w2=s-temp.y*s2;w3=s-temp.x*s2;vertex1=baseId+ivec2(int(s),int(s));vertex2=baseId+ivec2(int(s),int(1.0-s));vertex3=baseId+ivec2(int(1.0-s),int(s));}
957
+ vec2 _texRepMakeCenST(ivec2 Vertex) {mat2 invSkewMat=mat2(1.0,0.0,0.5,1.0/1.15470054);return (invSkewMat*vec2(Vertex))/(2.0*sqrt(3.0));}
958
+ mat2 _texRepLoadRot2x2(ivec2 idx,float rotStr) {float angle=float(abs(idx.x*idx.y)+abs(idx.x+idx.y))+TEXTURE_REPETITION_M_PI;angle=mod(angle,2.0*TEXTURE_REPETITION_M_PI);if (angle<0.0) angle+=2.0*TEXTURE_REPETITION_M_PI;if (angle>TEXTURE_REPETITION_M_PI) angle-=TEXTURE_REPETITION_M_PI;angle*=rotStr;float cs=cos(angle);float si=sin(angle);return mat2(cs,si,-si,cs);}
959
+ vec3 _texRepGain3(vec3 x,float r) {float k=log(1.0-r)/log(0.5);vec3 s=2.0*step(0.5,x);vec3 m=2.0*(1.0-s);vec3 res=0.5*s+0.25*m*pow(max(vec3(0.0),s+x*m),vec3(k));return res/(res.x+res.y+res.z);}
960
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {float rotStrength=vTextureRepetitionHexTilingParams.x;float fallOffContrast=vTextureRepetitionHexTilingParams.y;float expVal=vTextureRepetitionHexTilingParams.z;float r=vTextureRepetitionHexTilingParams.w;vec2 dSTdx=dFdx(uv);vec2 dSTdy=dFdy(uv);float w1,w2,w3;ivec2 vertex1,vertex2,vertex3;_texRepTriangleGrid(w1,w2,w3,vertex1,vertex2,vertex3,uv);mat2 rot1=_texRepLoadRot2x2(vertex1,rotStrength);mat2 rot2=_texRepLoadRot2x2(vertex2,rotStrength);mat2 rot3=_texRepLoadRot2x2(vertex3,rotStrength);vec2 cen1=_texRepMakeCenST(vertex1);vec2 cen2=_texRepMakeCenST(vertex2);vec2 cen3=_texRepMakeCenST(vertex3);vec2 st1=(uv-cen1)*rot1+cen1+_texRepHexHash(vec2(vertex1));vec2 st2=(uv-cen2)*rot2+cen2+_texRepHexHash(vec2(vertex2));vec2 st3=(uv-cen3)*rot3+cen3+_texRepHexHash(vec2(vertex3));vec4 c1=textureGrad(samp,st1,dSTdx*rot1,dSTdy*rot1);vec4 c2=textureGrad(samp,st2,dSTdx*rot2,dSTdy*rot2);vec4 c3=textureGrad(samp,st3,dSTdx*rot3,dSTdy*rot3);vec3 Lw=vec3(0.299,0.587,0.114);vec3 Dw=vec3(dot(c1.rgb,Lw),dot(c2.rgb,Lw),dot(c3.rgb,Lw));Dw=mix(vec3(1.0),Dw,fallOffContrast);vec3 W=Dw*pow(vec3(w1,w2,w3),vec3(expVal));W/=(W.x+W.y+W.z);if (r != 0.5) {W=_texRepGain3(W,r);}
961
+ return W.x*c1+W.y*c2+W.z*c3;}
962
+ #elif TEXTURE_REPETITION_MODE==3
963
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {vec2 iuv=floor(uv);vec2 fuv=fract(uv);vec4 ofa=_texRepHash4(iuv+vec2(0.0,0.0));vec4 ofb=_texRepHash4(iuv+vec2(1.0,0.0));vec4 ofc=_texRepHash4(iuv+vec2(0.0,1.0));vec4 ofd=_texRepHash4(iuv+vec2(1.0,1.0));vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);ofa.zw=sign(ofa.zw-0.5);ofb.zw=sign(ofb.zw-0.5);ofc.zw=sign(ofc.zw-0.5);ofd.zw=sign(ofd.zw-0.5);vec2 uva=uv*ofa.zw+ofa.xy; vec2 ddxa=dx*ofa.zw; vec2 ddya=dy*ofa.zw;vec2 uvb=uv*ofb.zw+ofb.xy; vec2 ddxb=dx*ofb.zw; vec2 ddyb=dy*ofb.zw;vec2 uvc=uv*ofc.zw+ofc.xy; vec2 ddxc=dx*ofc.zw; vec2 ddyc=dy*ofc.zw;vec2 uvd=uv*ofd.zw+ofd.xy; vec2 ddxd=dx*ofd.zw; vec2 ddyd=dy*ofd.zw;vec2 b=smoothstep(0.25,0.75,fuv);return mix(
964
+ mix(textureGrad(samp,uva,ddxa,ddya),textureGrad(samp,uvb,ddxb,ddyb),b.x),
965
+ mix(textureGrad(samp,uvc,ddxc,ddyc),textureGrad(samp,uvd,ddxd,ddyd),b.x),
966
+ b.y
967
+ );}
968
+ #elif TEXTURE_REPETITION_MODE==4
969
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {vec2 p=floor(uv);vec2 f=fract(uv);vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);vec4 va=vec4(0.0);float wt=0.0;float w2=0.0;for (int j=-1; j<=1; j++) {for (int i=-1; i<=1; i++) {vec2 g=vec2(float(i),float(j));vec4 o=_texRepHash4(p+g);vec2 r=g-f+o.xy;float d=dot(r,r);float w=exp(-5.0*d);vec4 c=textureGrad(samp,uv+o.zw,dx,dy);va+=w*c;wt+=w;w2+=w*w;}}
970
+ float mean=0.3;vec4 res=mean+(va-wt*mean)/sqrt(w2);return mix(va/wt,res,0.4);}
971
+ #endif
972
+ #if TEXTURE_REPETITION_MODE>0
973
+ #define TEXRD(s,uv) _texRepSample(s,uv)
974
+ #else
975
+ #define TEXRD(s,uv) texture2D(s,uv)
976
+ #endif
977
+ #define TEXRD_DEFINED
978
+ `;i.ShaderStore.IncludesShadersStore[b]||(i.ShaderStore.IncludesShadersStore[b]=U);let W="bumpFragmentMainFunctions",H=`#ifndef TEXRD_DEFINED
979
+ #define TEXRD(s,uv) texture2D(s,uv)
980
+ #define TEXRD_DEFINED
981
+ #endif
982
+ #if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
983
+ #if defined(TANGENT) && defined(NORMAL)
984
+ varying mat3 vTBN;
985
+ #endif
986
+ #ifdef OBJECTSPACE_NORMALMAP
987
+ uniform mat4 normalMatrix;
988
+ #if defined(WEBGL2) || defined(WEBGPU)
989
+ mat4 toNormalMatrix(mat4 wMatrix)
990
+ {mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;}
991
+ #else
992
+ mat4 toNormalMatrix(mat4 m)
993
+ {float
994
+ a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],
995
+ a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],
996
+ a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],
997
+ a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],
998
+ b00=a00*a11-a01*a10,
999
+ b01=a00*a12-a02*a10,
1000
+ b02=a00*a13-a03*a10,
1001
+ b03=a01*a12-a02*a11,
1002
+ b04=a01*a13-a03*a11,
1003
+ b05=a02*a13-a03*a12,
1004
+ b06=a20*a31-a21*a30,
1005
+ b07=a20*a32-a22*a30,
1006
+ b08=a20*a33-a23*a30,
1007
+ b09=a21*a32-a22*a31,
1008
+ b10=a21*a33-a23*a31,
1009
+ b11=a22*a33-a23*a32,
1010
+ det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(
1011
+ a11*b11-a12*b10+a13*b09,
1012
+ a02*b10-a01*b11-a03*b09,
1013
+ a31*b05-a32*b04+a33*b03,
1014
+ a22*b04-a21*b05-a23*b03,
1015
+ a12*b08-a10*b11-a13*b07,
1016
+ a00*b11-a02*b08+a03*b07,
1017
+ a32*b02-a30*b05-a33*b01,
1018
+ a20*b05-a22*b02+a23*b01,
1019
+ a10*b10-a11*b08+a13*b06,
1020
+ a01*b08-a00*b10-a03*b06,
1021
+ a30*b04-a31*b02+a33*b00,
1022
+ a21*b02-a20*b04-a23*b00,
1023
+ a11*b07-a10*b09-a12*b06,
1024
+ a00*b09-a01*b07+a02*b06,
1025
+ a31*b01-a30*b03-a32*b00,
1026
+ a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
1027
+ mi[0][1],mi[1][1],mi[2][1],mi[3][1],
1028
+ mi[0][2],mi[1][2],mi[2][2],mi[3][2],
1029
+ mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
1030
+ #endif
1031
+ #endif
1032
+ vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
1033
+ {
1034
+ #ifdef NORMALXYSCALE
1035
+ normal=normalize(normal*vec3(scale,scale,1.0));
1036
+ #endif
1037
+ return normalize(cotangentFrame*normal);}
1038
+ vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
1039
+ {return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
1040
+ mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
1041
+ {vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);}
1042
+ #endif
1043
+ `;i.ShaderStore.IncludesShadersStore[W]||(i.ShaderStore.IncludesShadersStore[W]=H);let z="bumpFragmentFunctions",V=`#if defined(BUMP)
1044
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
1045
+ #endif
1046
+ #if defined(DETAIL)
1047
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
1048
+ #endif
1049
+ #if defined(BUMP) && defined(PARALLAX)
1050
+ const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++)
1051
+ {currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;if (!keepWorking)
1052
+ {}
1053
+ else if (currSampledHeight>currRayHeight)
1054
+ {float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
1055
+ else
1056
+ {currRayHeight-=stepSize;vLastOffset=vCurrOffset;
1057
+ #ifdef PARALLAX_RHS
1058
+ vCurrOffset-=stepSize*vMaxOffset;
1059
+ #else
1060
+ vCurrOffset+=stepSize*vMaxOffset;
1061
+ #endif
1062
+ lastSampledHeight=currSampledHeight;}}
1063
+ return vCurrOffset;}
1064
+ vec2 parallaxOffset(vec3 viewDir,float heightScale)
1065
+ {float height=texture2D(bumpSampler,vBumpUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;
1066
+ #ifdef PARALLAX_RHS
1067
+ return texCoordOffset;
1068
+ #else
1069
+ return -texCoordOffset;
1070
+ #endif
1071
+ }
1072
+ #endif
1073
+ `;i.ShaderStore.IncludesShadersStore[z]||(i.ShaderStore.IncludesShadersStore[z]=V);var G=e.i(29981),B=e.i(97226),k=e.i(56770),Y=e.i(69838);let Z="bumpFragment",q=`vec2 uvOffset=vec2(0.0,0.0);
1074
+ #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
1075
+ #ifdef NORMALXYSCALE
1076
+ float normalScale=1.0;
1077
+ #elif defined(BUMP)
1078
+ float normalScale=vBumpInfos.y;
1079
+ #else
1080
+ float normalScale=1.0;
1081
+ #endif
1082
+ #if defined(TANGENT) && defined(NORMAL)
1083
+ mat3 TBN=vTBN;
1084
+ #elif defined(BUMP)
1085
+ vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
1086
+ #else
1087
+ vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
1088
+ #endif
1089
+ #elif defined(ANISOTROPIC)
1090
+ #if defined(TANGENT) && defined(NORMAL)
1091
+ mat3 TBN=vTBN;
1092
+ #else
1093
+ vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
1094
+ #endif
1095
+ #endif
1096
+ #ifdef PARALLAX
1097
+ mat3 invTBN=transposeMat3(TBN);
1098
+ #ifdef PARALLAXOCCLUSION
1099
+ uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
1100
+ #else
1101
+ uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
1102
+ #endif
1103
+ #endif
1104
+ #ifdef DETAIL
1105
+ vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
1106
+ #endif
1107
+ #ifdef BUMP
1108
+ #ifdef OBJECTSPACE_NORMALMAP
1109
+ #define CUSTOM_FRAGMENT_BUMP_FRAGMENT
1110
+ normalW=normalize(TEXRD(bumpSampler,vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);
1111
+ #elif !defined(DETAIL)
1112
+ normalW=perturbNormal(TBN,TEXRD(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);
1113
+ #else
1114
+ vec3 bumpNormal=TEXRD(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
1115
+ #if DETAIL_NORMALBLENDMETHOD==0
1116
+ detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
1117
+ #elif DETAIL_NORMALBLENDMETHOD==1
1118
+ detailNormal.xy*=vDetailInfos.z;bumpNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
1119
+ #endif
1120
+ normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
1121
+ #endif
1122
+ #elif defined(DETAIL)
1123
+ detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
1124
+ #endif
1125
+ `;i.ShaderStore.IncludesShadersStore[Z]||(i.ShaderStore.IncludesShadersStore[Z]=q);let j="decalFragment",Q=`#ifdef DECAL
1126
+ #ifdef GAMMADECAL
1127
+ decalColor.rgb=toLinearSpace(decalColor.rgb);
1128
+ #endif
1129
+ #ifdef DECAL_SMOOTHALPHA
1130
+ decalColor.a*=decalColor.a;
1131
+ #endif
1132
+ surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a);
1133
+ #endif
1134
+ `;i.ShaderStore.IncludesShadersStore[j]||(i.ShaderStore.IncludesShadersStore[j]=Q);let J="depthPrePass",K=`#ifdef DEPTHPREPASS
1135
+ gl_FragColor=vec4(0.,0.,0.,1.0);return;
1136
+ #endif
1137
+ `;i.ShaderStore.IncludesShadersStore[J]||(i.ShaderStore.IncludesShadersStore[J]=K);let $="lightFragment",ee=`#ifdef LIGHT{X}
1138
+ #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
1139
+ #else
1140
+ vec4 diffuse{X}=light{X}.vLightDiffuse;
1141
+ #define CUSTOM_LIGHT{X}_COLOR
1142
+ #if defined(PBR) && defined(CLUSTLIGHT{X}) && defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1143
+ {int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(
1144
+ lightDataTexture{X},
1145
+ tileMaskTexture{X},
1146
+ light{X}.vLightData,
1147
+ ivec2(light{X}.vSliceRanges[sliceIndex]),
1148
+ viewDirectionW,
1149
+ normalW,
1150
+ vPositionW,
1151
+ surfaceAlbedo,
1152
+ reflectivityOut
1153
+ #ifdef IRIDESCENCE
1154
+ ,iridescenceIntensity
1155
+ #endif
1156
+ #ifdef SS_TRANSLUCENCY
1157
+ ,subSurfaceOut
1158
+ #endif
1159
+ #ifdef SPECULARTERM
1160
+ ,AARoughnessFactors.x
1161
+ #endif
1162
+ #ifdef ANISOTROPIC
1163
+ ,anisotropicOut
1164
+ #endif
1165
+ #ifdef SHEEN
1166
+ ,sheenOut
1167
+ #endif
1168
+ #ifdef CLEARCOAT
1169
+ ,clearcoatOut
1170
+ #endif
1171
+ );}
1172
+ #elif defined(PBR)
1173
+ #ifdef SPOTLIGHT{X}
1174
+ preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
1175
+ #elif defined(POINTLIGHT{X})
1176
+ preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
1177
+ #elif defined(HEMILIGHT{X})
1178
+ preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
1179
+ #elif defined(DIRLIGHT{X})
1180
+ preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
1181
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1182
+ #if defined(RECTAREALIGHTEMISSIONTEXTURE{X})
1183
+ preInfo=computeAreaPreLightingInfoWithTexture(areaLightsLTC1Sampler,areaLightsLTC2Sampler,rectAreaLightEmissionTexture{X},viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
1184
+ #else
1185
+ preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
1186
+ #endif
1187
+ #endif
1188
+ preInfo.NdotV=NdotV;
1189
+ #ifdef SPOTLIGHT{X}
1190
+ #ifdef LIGHT_FALLOFF_GLTF{X}
1191
+ preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
1192
+ #ifdef IESLIGHTTEXTURE{X}
1193
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
1194
+ #else
1195
+ preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
1196
+ #endif
1197
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
1198
+ preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
1199
+ #ifdef IESLIGHTTEXTURE{X}
1200
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
1201
+ #else
1202
+ preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
1203
+ #endif
1204
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
1205
+ preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
1206
+ #ifdef IESLIGHTTEXTURE{X}
1207
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
1208
+ #else
1209
+ preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
1210
+ #endif
1211
+ #else
1212
+ preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
1213
+ #ifdef IESLIGHTTEXTURE{X}
1214
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
1215
+ #else
1216
+ preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
1217
+ #endif
1218
+ #endif
1219
+ #elif defined(POINTLIGHT{X})
1220
+ #ifdef LIGHT_FALLOFF_GLTF{X}
1221
+ preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
1222
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
1223
+ preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
1224
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
1225
+ preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
1226
+ #else
1227
+ preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
1228
+ #endif
1229
+ #else
1230
+ preInfo.attenuation=1.0;
1231
+ #endif
1232
+ #if defined(HEMILIGHT{X})
1233
+ preInfo.roughness=roughness;
1234
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1235
+ preInfo.roughness=roughness;
1236
+ #else
1237
+ preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
1238
+ #endif
1239
+ preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
1240
+ #ifdef IRIDESCENCE
1241
+ preInfo.iridescenceIntensity=iridescenceIntensity;
1242
+ #endif
1243
+ #ifdef SS_TRANSLUCENCY
1244
+ info.diffuseTransmission=vec3(0.0);
1245
+ #endif
1246
+ #ifdef HEMILIGHT{X}
1247
+ info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround);
1248
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1249
+ info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb);
1250
+ #elif defined(SS_TRANSLUCENCY)
1251
+ #ifndef SS_TRANSLUCENCY_LEGACY
1252
+ info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
1253
+ #else
1254
+ info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
1255
+ #endif
1256
+ #else
1257
+ info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb);
1258
+ #endif
1259
+ #ifdef SPECULARTERM
1260
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1261
+ info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
1262
+ #else
1263
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
1264
+ {vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);}
1265
+ #else
1266
+ coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
1267
+ #endif
1268
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1269
+ {float NdotH=dot(normalW,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);}
1270
+ #endif
1271
+ #ifdef ANISOTROPIC
1272
+ info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
1273
+ #else
1274
+ info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb);
1275
+ #endif
1276
+ #endif
1277
+ #endif
1278
+ #ifndef AREALIGHT{X}
1279
+ #ifdef SHEEN
1280
+ #ifdef SHEEN_LINKWITHALBEDO
1281
+ preInfo.roughness=sheenOut.sheenIntensity;
1282
+ #else
1283
+ #ifdef HEMILIGHT{X}
1284
+ preInfo.roughness=sheenOut.sheenRoughness;
1285
+ #else
1286
+ preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
1287
+ #endif
1288
+ #endif
1289
+ info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
1290
+ #endif
1291
+ #ifdef CLEARCOAT
1292
+ #ifdef HEMILIGHT{X}
1293
+ preInfo.roughness=clearcoatOut.clearCoatRoughness;
1294
+ #else
1295
+ preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
1296
+ #endif
1297
+ info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb);
1298
+ #ifdef CLEARCOAT_TINT
1299
+ absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
1300
+ #ifdef SS_TRANSLUCENCY
1301
+ info.diffuseTransmission*=absorption;
1302
+ #endif
1303
+ #ifdef SPECULARTERM
1304
+ info.specular*=absorption;
1305
+ #endif
1306
+ #endif
1307
+ info.diffuse*=info.clearCoat.w;
1308
+ #ifdef SS_TRANSLUCENCY
1309
+ info.diffuseTransmission*=info.clearCoat.w;
1310
+ #endif
1311
+ #ifdef SPECULARTERM
1312
+ info.specular*=info.clearCoat.w;
1313
+ #endif
1314
+ #ifdef SHEEN
1315
+ info.sheen*=info.clearCoat.w;
1316
+ #endif
1317
+ #endif
1318
+ #endif
1319
+ #else
1320
+ #ifdef SPOTLIGHT{X}
1321
+ #ifdef IESLIGHTTEXTURE{X}
1322
+ info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X});
1323
+ #else
1324
+ info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
1325
+ #endif
1326
+ #elif defined(HEMILIGHT{X})
1327
+ info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
1328
+ #elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
1329
+ info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
1330
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1331
+ #if defined(RECTAREALIGHTEMISSIONTEXTURE{X})
1332
+ info=computeAreaLightingWithTexture(areaLightsLTC1Sampler,areaLightsLTC2Sampler,rectAreaLightEmissionTexture{X},viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
1333
+ #ifdef AREALIGHTNOROUGHTNESS
1334
+ 0.5
1335
+ #else
1336
+ vReflectionInfos.y
1337
+ #endif
1338
+ #else
1339
+ info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
1340
+ #ifdef AREALIGHTNOROUGHTNESS
1341
+ 0.5
1342
+ #else
1343
+ vReflectionInfos.y
1344
+ #endif
1345
+ #endif
1346
+ );
1347
+ #elif defined(CLUSTLIGHT{X}) && CLUSTLIGHT_BATCH>0
1348
+ {int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},tileMaskTexture{X},viewDirectionW,normalW,light{X}.vLightData,ivec2(light{X}.vSliceRanges[sliceIndex]),glossiness);}
1349
+ #endif
1350
+ #endif
1351
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
1352
+ info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
1353
+ #endif
1354
+ #endif
1355
+ #ifdef SHADOW{X}
1356
+ #ifdef SHADOWCSM{X}
1357
+ for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
1358
+ {
1359
+ #ifdef SHADOWCSM_RIGHTHANDED{X}
1360
+ diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
1361
+ #else
1362
+ diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
1363
+ #endif
1364
+ if (diff{X}>=0.) {index{X}=i;break;}}
1365
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
1366
+ if (index{X}>=0)
1367
+ #endif
1368
+ {
1369
+ #if defined(SHADOWPCF{X})
1370
+ #if defined(SHADOWLOWQUALITY{X})
1371
+ shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1372
+ #elif defined(SHADOWMEDIUMQUALITY{X})
1373
+ shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1374
+ #else
1375
+ shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1376
+ #endif
1377
+ #elif defined(SHADOWPCSS{X})
1378
+ #if defined(SHADOWLOWQUALITY{X})
1379
+ shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
1380
+ #elif defined(SHADOWMEDIUMQUALITY{X})
1381
+ shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
1382
+ #else
1383
+ shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
1384
+ #endif
1385
+ #else
1386
+ shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1387
+ #endif
1388
+ #ifdef SHADOWCSMDEBUG{X}
1389
+ shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
1390
+ #endif
1391
+ #ifndef SHADOWCSMNOBLEND{X}
1392
+ float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
1393
+ {index{X}+=1;float nextShadow=0.;
1394
+ #if defined(SHADOWPCF{X})
1395
+ #if defined(SHADOWLOWQUALITY{X})
1396
+ nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1397
+ #elif defined(SHADOWMEDIUMQUALITY{X})
1398
+ nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1399
+ #else
1400
+ nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1401
+ #endif
1402
+ #elif defined(SHADOWPCSS{X})
1403
+ #if defined(SHADOWLOWQUALITY{X})
1404
+ nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
1405
+ #elif defined(SHADOWMEDIUMQUALITY{X})
1406
+ nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
1407
+ #else
1408
+ nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
1409
+ #endif
1410
+ #else
1411
+ nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1412
+ #endif
1413
+ shadow=mix(nextShadow,shadow,diffRatio);
1414
+ #ifdef SHADOWCSMDEBUG{X}
1415
+ shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
1416
+ #endif
1417
+ }
1418
+ #endif
1419
+ }
1420
+ #elif defined(SHADOWCLOSEESM{X})
1421
+ #if defined(SHADOWCUBE{X})
1422
+ shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
1423
+ #else
1424
+ shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
1425
+ #endif
1426
+ #elif defined(SHADOWESM{X})
1427
+ #if defined(SHADOWCUBE{X})
1428
+ shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
1429
+ #else
1430
+ shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
1431
+ #endif
1432
+ #elif defined(SHADOWPOISSON{X})
1433
+ #if defined(SHADOWCUBE{X})
1434
+ shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
1435
+ #else
1436
+ shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1437
+ #endif
1438
+ #elif defined(SHADOWPCF{X})
1439
+ #if defined(SHADOWLOWQUALITY{X})
1440
+ shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1441
+ #elif defined(SHADOWMEDIUMQUALITY{X})
1442
+ shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1443
+ #else
1444
+ shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1445
+ #endif
1446
+ #elif defined(SHADOWPCSS{X})
1447
+ #if defined(SHADOWLOWQUALITY{X})
1448
+ shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1449
+ #elif defined(SHADOWMEDIUMQUALITY{X})
1450
+ shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1451
+ #else
1452
+ shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1453
+ #endif
1454
+ #else
1455
+ #if defined(SHADOWCUBE{X})
1456
+ shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues);
1457
+ #else
1458
+ shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1459
+ #endif
1460
+ #endif
1461
+ #ifdef SHADOWONLY
1462
+ #ifndef SHADOWINUSE
1463
+ #define SHADOWINUSE
1464
+ #endif
1465
+ globalShadow+=shadow;shadowLightCount+=1.0;
1466
+ #endif
1467
+ #else
1468
+ shadow=1.;
1469
+ #endif
1470
+ aggShadow+=shadow;numLights+=1.0;
1471
+ #ifndef SHADOWONLY
1472
+ #ifdef CUSTOMUSERLIGHTING
1473
+ diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
1474
+ #ifdef SPECULARTERM
1475
+ specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
1476
+ #endif
1477
+ #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
1478
+ diffuseBase+=lightmapColor.rgb*shadow;
1479
+ #ifdef SPECULARTERM
1480
+ #ifndef LIGHTMAPNOSPECULAR{X}
1481
+ specularBase+=info.specular*shadow*lightmapColor.rgb;
1482
+ #endif
1483
+ #endif
1484
+ #ifdef CLEARCOAT
1485
+ #ifndef LIGHTMAPNOSPECULAR{X}
1486
+ clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
1487
+ #endif
1488
+ #endif
1489
+ #ifdef SHEEN
1490
+ #ifndef LIGHTMAPNOSPECULAR{X}
1491
+ sheenBase+=info.sheen.rgb*shadow;
1492
+ #endif
1493
+ #endif
1494
+ #else
1495
+ #ifdef SHADOWCSMDEBUG{X}
1496
+ diffuseBase+=info.diffuse*shadowDebug{X};
1497
+ #else
1498
+ diffuseBase+=info.diffuse*shadow;
1499
+ #endif
1500
+ #ifdef SS_TRANSLUCENCY
1501
+ diffuseTransmissionBase+=info.diffuseTransmission*shadow;
1502
+ #endif
1503
+ #ifdef SPECULARTERM
1504
+ specularBase+=info.specular*shadow;
1505
+ #endif
1506
+ #ifdef CLEARCOAT
1507
+ clearCoatBase+=info.clearCoat.rgb*shadow;
1508
+ #endif
1509
+ #ifdef SHEEN
1510
+ sheenBase+=info.sheen.rgb*shadow;
1511
+ #endif
1512
+ #endif
1513
+ #endif
1514
+ #endif
1515
+ `;i.ShaderStore.IncludesShadersStore[$]||(i.ShaderStore.IncludesShadersStore[$]=ee);let ei="logDepthFragment",et=`#ifdef LOGARITHMICDEPTH
1516
+ gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
1517
+ #endif
1518
+ `;i.ShaderStore.IncludesShadersStore[ei]||(i.ShaderStore.IncludesShadersStore[ei]=et);var eo=e.i(40671);let er="oitFragment",ea=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
1519
+ float fragDepth=gl_FragCoord.z;
1520
+ #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
1521
+ uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x;
1522
+ #endif
1523
+ ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0);
1524
+ #ifdef USE_REVERSE_DEPTHBUFFER
1525
+ float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y;
1526
+ #else
1527
+ float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y;
1528
+ #endif
1529
+ float alphaMultiplier=1.0-lastFrontColor.a;
1530
+ #ifdef USE_REVERSE_DEPTHBUFFER
1531
+ if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
1532
+ #else
1533
+ if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
1534
+ #endif
1535
+ return;}
1536
+ #ifdef USE_REVERSE_DEPTHBUFFER
1537
+ if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
1538
+ #else
1539
+ if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
1540
+ #endif
1541
+ depth.rg=vec2(-fragDepth,fragDepth);return;}
1542
+ #endif
1543
+ `;i.ShaderStore.IncludesShadersStore[er]||(i.ShaderStore.IncludesShadersStore[er]=ea);let en="defaultPixelShader",el=`#define CUSTOM_FRAGMENT_EXTENSION
1544
+ #include<__decl__defaultFragment>
1545
+ #if defined(BUMP) || !defined(NORMAL)
1546
+ #extension GL_OES_standard_derivatives : enable
1547
+ #endif
1548
+ #include<prePassDeclaration>[SCENE_MRT_COUNT]
1549
+ #include<oitDeclaration>
1550
+ #define CUSTOM_FRAGMENT_BEGIN
1551
+ #ifdef LOGARITHMICDEPTH
1552
+ #extension GL_EXT_frag_depth : enable
1553
+ #endif
1554
+ varying vec3 vPositionW;
1555
+ #ifdef NORMAL
1556
+ varying vec3 vNormalW;
1557
+ #endif
1558
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1559
+ varying vec4 vColor;
1560
+ #endif
1561
+ #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1562
+ varying float vViewDepth;
1563
+ #endif
1564
+ #include<mainUVVaryingDeclaration>[1..7]
1565
+ #include<helperFunctions>
1566
+ #include<__decl__lightFragment>[0..maxSimultaneousLights]
1567
+ #include<lightsFragmentFunctions>
1568
+ #include<shadowsFragmentFunctions>
1569
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
1570
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
1571
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
1572
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
1573
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
1574
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
1575
+ #ifdef REFRACTION
1576
+ #ifdef REFRACTIONMAP_3D
1577
+ uniform samplerCube refractionCubeSampler;
1578
+ #else
1579
+ uniform sampler2D refraction2DSampler;
1580
+ #endif
1581
+ #endif
1582
+ #if defined(SPECULARTERM)
1583
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
1584
+ #endif
1585
+ #include<fresnelFunction>
1586
+ #ifdef REFLECTION
1587
+ #ifdef REFLECTIONMAP_3D
1588
+ uniform samplerCube reflectionCubeSampler;
1589
+ #else
1590
+ uniform sampler2D reflection2DSampler;
1591
+ #endif
1592
+ #ifdef REFLECTIONMAP_SKYBOX
1593
+ varying vec3 vPositionUVW;
1594
+ #else
1595
+ #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
1596
+ varying vec3 vDirectionW;
1597
+ #endif
1598
+ #endif
1599
+ #include<reflectionFunction>
1600
+ #endif
1601
+ #include<imageProcessingDeclaration>
1602
+ #include<imageProcessingFunctions>
1603
+ #include<textureRepetitionFunctions>
1604
+ #include<bumpFragmentMainFunctions>
1605
+ #include<bumpFragmentFunctions>
1606
+ #include<clipPlaneFragmentDeclaration>
1607
+ #include<logDepthDeclaration>
1608
+ #include<fogFragmentDeclaration>
1609
+ #define CUSTOM_FRAGMENT_DEFINITIONS
1610
+ void main(void) {
1611
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
1612
+ #include<clipPlaneFragment>
1613
+ vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
1614
+ #ifdef NORMAL
1615
+ vec3 normalW=normalize(vNormalW);
1616
+ #else
1617
+ vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
1618
+ #endif
1619
+ #include<bumpFragment>
1620
+ #ifdef TWOSIDEDLIGHTING
1621
+ normalW=gl_FrontFacing ? normalW : -normalW;
1622
+ #endif
1623
+ #ifdef DIFFUSE
1624
+ baseColor=TEXRD(diffuseSampler,vDiffuseUV+uvOffset);
1625
+ #if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
1626
+ if (baseColor.a<alphaCutOff)
1627
+ discard;
1628
+ #endif
1629
+ #ifdef ALPHAFROMDIFFUSE
1630
+ alpha*=baseColor.a;
1631
+ #endif
1632
+ #define CUSTOM_FRAGMENT_UPDATE_ALPHA
1633
+ baseColor.rgb*=vDiffuseInfos.y;
1634
+ #endif
1635
+ #if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
1636
+ vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
1637
+ #include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
1638
+ #endif
1639
+ #include<depthPrePass>
1640
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1641
+ baseColor.rgb*=vColor.rgb;
1642
+ #endif
1643
+ #ifdef DETAIL
1644
+ baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
1645
+ #endif
1646
+ #if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
1647
+ vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
1648
+ #include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
1649
+ #endif
1650
+ #define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
1651
+ vec3 baseAmbientColor=vec3(1.,1.,1.);
1652
+ #ifdef AMBIENT
1653
+ baseAmbientColor=TEXRD(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
1654
+ #endif
1655
+ #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
1656
+ float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;
1657
+ #ifdef SPECULARTERM
1658
+ #ifdef SPECULAR
1659
+ vec4 specularMapColor=TEXRD(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
1660
+ #ifdef GLOSSINESS
1661
+ glossiness=glossiness*specularMapColor.a;
1662
+ #endif
1663
+ #endif
1664
+ #endif
1665
+ vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;
1666
+ #ifdef SPECULARTERM
1667
+ vec3 specularBase=vec3(0.,0.,0.);
1668
+ #endif
1669
+ float shadow=1.;float aggShadow=0.;float numLights=0.;
1670
+ #ifdef LIGHTMAP
1671
+ vec4 lightmapColor=TEXRD(lightmapSampler,vLightmapUV+uvOffset);
1672
+ #ifdef RGBDLIGHTMAP
1673
+ lightmapColor.rgb=fromRGBD(lightmapColor);
1674
+ #endif
1675
+ lightmapColor.rgb*=vLightmapInfos.y;
1676
+ #endif
1677
+ #include<lightFragment>[0..maxSimultaneousLights]
1678
+ aggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.);
1679
+ #ifdef REFRACTION
1680
+ vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
1681
+ #ifdef REFRACTIONMAP_3D
1682
+ #ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
1683
+ refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
1684
+ #endif
1685
+ refractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
1686
+ #else
1687
+ vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords);
1688
+ #endif
1689
+ #ifdef RGBDREFRACTION
1690
+ refractionColor.rgb=fromRGBD(refractionColor);
1691
+ #endif
1692
+ #ifdef IS_REFRACTION_LINEAR
1693
+ refractionColor.rgb=toGammaSpace(refractionColor.rgb);
1694
+ #endif
1695
+ refractionColor.rgb*=vRefractionInfos.x;
1696
+ #endif
1697
+ vec4 reflectionColor=vec4(0.,0.,0.,1.);
1698
+ #ifdef REFLECTION
1699
+ vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
1700
+ #ifdef REFLECTIONMAP_OPPOSITEZ
1701
+ vReflectionUVW.z*=-1.0;
1702
+ #endif
1703
+ #ifdef REFLECTIONMAP_3D
1704
+ #ifdef ROUGHNESS
1705
+ float bias=vReflectionInfos.y;
1706
+ #ifdef SPECULARTERM
1707
+ #ifdef SPECULAR
1708
+ #ifdef GLOSSINESS
1709
+ bias*=(1.0-specularMapColor.a);
1710
+ #endif
1711
+ #endif
1712
+ #endif
1713
+ reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
1714
+ #else
1715
+ reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
1716
+ #endif
1717
+ #else
1718
+ vec2 coords=vReflectionUVW.xy;
1719
+ #ifdef REFLECTIONMAP_PROJECTION
1720
+ coords/=vReflectionUVW.z;
1721
+ #endif
1722
+ coords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords);
1723
+ #endif
1724
+ #ifdef RGBDREFLECTION
1725
+ reflectionColor.rgb=fromRGBD(reflectionColor);
1726
+ #endif
1727
+ #ifdef IS_REFLECTION_LINEAR
1728
+ reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
1729
+ #endif
1730
+ reflectionColor.rgb*=vReflectionInfos.x;
1731
+ #ifdef REFLECTIONFRESNEL
1732
+ float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
1733
+ #ifdef REFLECTIONFRESNELFROMSPECULAR
1734
+ #ifdef SPECULARTERM
1735
+ reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
1736
+ #else
1737
+ reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
1738
+ #endif
1739
+ #else
1740
+ reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
1741
+ #endif
1742
+ #endif
1743
+ #endif
1744
+ #ifdef REFRACTIONFRESNEL
1745
+ float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
1746
+ #endif
1747
+ #ifdef OPACITY
1748
+ vec4 opacityMap=TEXRD(opacitySampler,vOpacityUV+uvOffset);
1749
+ #ifdef OPACITYRGB
1750
+ opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
1751
+ #else
1752
+ alpha*=opacityMap.a*vOpacityInfos.y;
1753
+ #endif
1754
+ #endif
1755
+ #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1756
+ alpha*=vColor.a;
1757
+ #endif
1758
+ #ifdef OPACITYFRESNEL
1759
+ float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
1760
+ #endif
1761
+ #ifdef ALPHATEST
1762
+ #ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
1763
+ if (alpha<alphaCutOff)
1764
+ discard;
1765
+ #endif
1766
+ #ifndef ALPHABLEND
1767
+ alpha=1.0;
1768
+ #endif
1769
+ #endif
1770
+ vec3 emissiveColor=vEmissiveColor;
1771
+ #ifdef EMISSIVE
1772
+ emissiveColor+=TEXRD(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
1773
+ #endif
1774
+ #ifdef EMISSIVEFRESNEL
1775
+ float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
1776
+ #endif
1777
+ #ifdef DIFFUSEFRESNEL
1778
+ float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
1779
+ #endif
1780
+ #ifdef EMISSIVEASILLUMINATION
1781
+ vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
1782
+ #else
1783
+ #ifdef LINKEMISSIVEWITHDIFFUSE
1784
+ vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
1785
+ #else
1786
+ vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
1787
+ #endif
1788
+ #endif
1789
+ #ifdef SPECULARTERM
1790
+ vec3 finalSpecular=specularBase*specularColor;
1791
+ #ifdef SPECULAROVERALPHA
1792
+ alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
1793
+ #endif
1794
+ #else
1795
+ vec3 finalSpecular=vec3(0.0);
1796
+ #endif
1797
+ #ifdef REFLECTIONOVERALPHA
1798
+ alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
1799
+ #endif
1800
+ #ifdef EMISSIVEASILLUMINATION
1801
+ vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
1802
+ #else
1803
+ vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
1804
+ #endif
1805
+ #ifdef LIGHTMAP
1806
+ #ifndef LIGHTMAPEXCLUDED
1807
+ #ifdef USELIGHTMAPASSHADOWMAP
1808
+ color.rgb*=lightmapColor.rgb;
1809
+ #else
1810
+ color.rgb+=lightmapColor.rgb;
1811
+ #endif
1812
+ #endif
1813
+ #endif
1814
+ #define CUSTOM_FRAGMENT_BEFORE_FOG
1815
+ color.rgb=max(color.rgb,0.);
1816
+ #include<logDepthFragment>
1817
+ #include<fogFragment>
1818
+ #ifdef IMAGEPROCESSINGPOSTPROCESS
1819
+ color.rgb=toLinearSpace(color.rgb);
1820
+ #else
1821
+ #ifdef IMAGEPROCESSING
1822
+ color.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);
1823
+ #endif
1824
+ #endif
1825
+ color.a*=visibility;
1826
+ #ifdef PREMULTIPLYALPHA
1827
+ color.rgb*=color.a;
1828
+ #endif
1829
+ #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
1830
+ #ifdef PREPASS
1831
+ #if SCENE_MRT_COUNT>0
1832
+ float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;
1833
+ #ifdef PREPASS_COLOR
1834
+ gl_FragData[PREPASS_COLOR_INDEX]=color;
1835
+ #endif
1836
+ #ifdef PREPASS_POSITION
1837
+ gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
1838
+ #endif
1839
+ #ifdef PREPASS_LOCAL_POSITION
1840
+ gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);
1841
+ #endif
1842
+ #if defined(PREPASS_VELOCITY)
1843
+ vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
1844
+ #elif defined(PREPASS_VELOCITY_LINEAR)
1845
+ vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
1846
+ #endif
1847
+ #ifdef PREPASS_IRRADIANCE
1848
+ gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
1849
+ #endif
1850
+ #ifdef PREPASS_DEPTH
1851
+ gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
1852
+ #endif
1853
+ #ifdef PREPASS_SCREENSPACE_DEPTH
1854
+ gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
1855
+ #endif
1856
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
1857
+ gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);
1858
+ #endif
1859
+ #ifdef PREPASS_NORMAL
1860
+ #ifdef PREPASS_NORMAL_WORLDSPACE
1861
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
1862
+ #else
1863
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
1864
+ #endif
1865
+ #endif
1866
+ #ifdef PREPASS_WORLD_NORMAL
1867
+ gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
1868
+ #endif
1869
+ #ifdef PREPASS_ALBEDO
1870
+ gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(baseColor.rgb,writeGeometryInfo);
1871
+ #endif
1872
+ #ifdef PREPASS_ALBEDO_SQRT
1873
+ gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqrt(baseColor.rgb),writeGeometryInfo);
1874
+ #endif
1875
+ #ifdef PREPASS_REFLECTIVITY
1876
+ #if defined(SPECULAR)
1877
+ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo;
1878
+ #else
1879
+ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo;
1880
+ #endif
1881
+ #endif
1882
+ #endif
1883
+ #endif
1884
+ #if !defined(PREPASS) || defined(WEBGL2)
1885
+ gl_FragColor=color;
1886
+ #endif
1887
+ #include<oitFragment>
1888
+ #if ORDER_INDEPENDENT_TRANSPARENCY
1889
+ if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;}
1890
+ #endif
1891
+ #define CUSTOM_FRAGMENT_MAIN_END
1892
+ }
1893
+ `;for(let e of(i.ShaderStore.ShadersStore[en]||(i.ShaderStore.ShadersStore[en]=el),[{name:t,shader:o},{name:r,shader:a},n.sceneUboDeclaration,l.meshUboDeclaration,f.defaultUboDeclaration,{name:s,shader:d},{name:c,shader:v},h.mainUVVaryingDeclaration,u.helperFunctions,{name:p,shader:m},{name:S,shader:g},{name:E,shader:C},{name:D,shader:T},{name:L,shader:I},{name:w,shader:x},{name:A,shader:P},{name:R,shader:X},{name:F,shader:N},{name:M,shader:_},{name:O,shader:y},{name:b,shader:U},{name:W,shader:H},{name:z,shader:V},G.clipPlaneFragmentDeclaration,B.logDepthDeclaration,k.fogFragmentDeclaration,Y.clipPlaneFragment,{name:Z,shader:q},{name:j,shader:Q},{name:J,shader:K},{name:$,shader:ee},{name:ei,shader:et},eo.fogFragment,{name:er,shader:ea}]))i.ShaderStore.IncludesShadersStore[e.name]||(i.ShaderStore.IncludesShadersStore[e.name]=e.shader);e.s(["defaultPixelShader",0,{name:en,shader:el}],40042)}]);