PageSourceSearch

https://ds-k.site/_astro/pbr.fragment.CjECuQvh.js

js ds-k.site collected 2026-10-01 12:38:01 UTC 92,993 bytes, 2,657 lines download raw bytes

1import{S as e}from"./Layout.astro_astro_type_script_index_0_lang.D7HFstIc.js";import"./oitFragment.B2tfLutm.js";import"./pbrUboDeclaration.CYrveHI8.js";import"./pbrDebug.nYDR0-VX.js";import"./logDepthDeclaration.IBIvJwPk.js";import"./helperFunctions.DvCnod2u.js";import"./harmonicsFunctions.B0rHYwwf.js";import"./lightFragment.CEm3T-dv.js";import"./_commonjsHelpers.CqkleIqs.js";import"./meshUboDeclaration.s7bWfEAN.js";const n="pbrFragmentDeclaration",_=`uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform float baseWeight;uniform float baseDiffuseRoughness;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor;
2#ifdef ALBEDO
3uniform vec2 vAlbedoInfos;
4#endif
5#ifdef BASE_WEIGHT
6uniform vec2 vBaseWeightInfos;
7#endif
8#ifdef BASE_DIFFUSE_ROUGHNESS
9uniform vec2 vBaseDiffuseRoughnessInfos;
10#endif
11#ifdef AMBIENT
12uniform vec4 vAmbientInfos;
13#endif
14#ifdef BUMP
15uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
16#endif
17#ifdef OPACITY
18uniform vec2 vOpacityInfos;
19#endif
20#ifdef EMISSIVE
21uniform vec2 vEmissiveInfos;
22#endif
23#ifdef LIGHTMAP
24uniform vec2 vLightmapInfos;
25#endif
26#ifdef REFLECTIVITY
27uniform vec3 vReflectivityInfos;
28#endif
29#ifdef MICROSURFACEMAP
30uniform vec2 vMicroSurfaceSamplerInfos;
31#endif
32#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
33uniform mat4 view;
34#endif
35#ifdef REFLECTION
36uniform vec2 vReflectionInfos;
37#ifdef REALTIME_FILTERING
38uniform vec2 vReflectionFilteringInfo;
39#endif
40uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
41#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
42uniform vec3 vReflectionDominantDirection;
43#endif
44#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
45uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
46#endif
47#endif
48#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
49uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize;
50#endif
51#ifdef CLEARCOAT
52uniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams;
53#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
54uniform vec4 vClearCoatInfos;
55#endif
56#ifdef CLEARCOAT_TEXTURE
57uniform mat4 clearCoatMatrix;
58#endif
59#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
60uniform mat4 clearCoatRoughnessMatrix;
61#endif
62#ifdef CLEARCOAT_BUMP
63uniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix;
64#endif
65#ifdef CLEARCOAT_TINT
66uniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance;
67#ifdef CLEARCOAT_TINT_TEXTURE
68uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
69#endif
70#endif
71#endif
72#ifdef IRIDESCENCE
73uniform vec4 vIridescenceParams;
74#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
75uniform vec4 vIridescenceInfos;
76#endif
77#ifdef IRIDESCENCE_TEXTURE
78uniform mat4 iridescenceMatrix;
79#endif
80#ifdef IRIDESCENCE_THICKNESS_TEXTURE
81uniform mat4 iridescenceThicknessMatrix;
82#endif
83#endif
84#ifdef ANISOTROPIC
85uniform vec3 vAnisotropy;
86#ifdef ANISOTROPIC_TEXTURE
87uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
88#endif
89#endif
90#ifdef SHEEN
91uniform vec4 vSheenColor;
92#ifdef SHEEN_ROUGHNESS
93uniform float vSheenRoughness;
94#endif
95#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
96uniform vec4 vSheenInfos;
97#endif
98#ifdef SHEEN_TEXTURE
99uniform mat4 sheenMatrix;
100#endif
101#ifdef SHEEN_TEXTURE_ROUGHNESS
102uniform mat4 sheenRoughnessMatrix;
103#endif
104#endif
105#ifdef SUBSURFACE
106#ifdef SS_REFRACTION
107uniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
108#ifdef REALTIME_FILTERING
109uniform vec2 vRefractionFilteringInfo;
110#endif
111#ifdef SS_DISPERSION
112uniform float dispersion;
113#endif
114#endif
115#ifdef SS_THICKNESSANDMASK_TEXTURE
116uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
117#endif
118#ifdef SS_REFRACTIONINTENSITY_TEXTURE
119uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
120#endif
121#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
122uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
123#endif
124uniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;uniform vec4 vTranslucencyColor;
125#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
126uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix;
127#endif
128#endif
129#ifdef PREPASS
130#ifdef SS_SCATTERING
131uniform float scatteringDiffusionProfile;
132#endif
133#endif
134#if DEBUGMODE>0
135uniform vec2 vDebugMode;
136#endif
137#ifdef DETAIL
138uniform vec4 vDetailInfos;
139#endif
140#include<decalFragmentDeclaration>
141#ifdef USESPHERICALFROMREFLECTIONMAP
142#ifdef SPHERICAL_HARMONICS
143uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
144#else
145uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
146#endif
147#endif
148#define ADDITIONAL_FRAGMENT_DECLARATION
149`;e.IncludesShadersStore[n]||(e.IncludesShadersStore[n]=_);const a="samplerFragmentAlternateDeclaration",M=`#ifdef _DEFINENAME_
150#if _DEFINENAME_DIRECTUV==1
151#define v_VARYINGNAME_UV vMainUV1
152#elif _DEFINENAME_DIRECTUV==2
153#define v_VARYINGNAME_UV vMainUV2
154#elif _DEFINENAME_DIRECTUV==3
155#define v_VARYINGNAME_UV vMainUV3
156#elif _DEFINENAME_DIRECTUV==4
157#define v_VARYINGNAME_UV vMainUV4
158#elif _DEFINENAME_DIRECTUV==5
159#define v_VARYINGNAME_UV vMainUV5
160#elif _DEFINENAME_DIRECTUV==6
161#define v_VARYINGNAME_UV vMainUV6
162#else
163varying vec2 v_VARYINGNAME_UV;
164#endif
165#endif
166`;e.IncludesShadersStore[a]||(e.IncludesShadersStore[a]=M);const r="pbrFragmentSamplersDeclaration",D=`#include<samplerFragmentDeclaration>
166(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
167#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
168#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
169#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
170#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
171#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
172#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
173#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
174#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
175#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
176#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
177#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
178#ifdef CLEARCOAT
179#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
180#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
181#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
182uniform sampler2D clearCoatRoughnessSampler;
183#endif
184#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
185#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
186#endif
187#ifdef IRIDESCENCE
188#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
189#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
190#endif
191#ifdef SHEEN
192#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
193#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
194#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
195uniform sampler2D sheenRoughnessSampler;
196#endif
197#endif
198#ifdef ANISOTROPIC
199#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
200#endif
201#ifdef REFLECTION
202#ifdef REFLECTIONMAP_3D
203#define sampleReflection(s,c) textureCube(s,c)
204uniform samplerCube reflectionSampler;
205#ifdef LODBASEDMICROSFURACE
206#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
207#else
208uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
209#endif
210#ifdef USEIRRADIANCEMAP
211uniform samplerCube irradianceSampler;
212#endif
213#else
214#define sampleReflection(s,c) texture2D(s,c)
215uniform sampler2D reflectionSampler;
216#ifdef LODBASEDMICROSFURACE
217#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
218#else
219uniform sampler2D reflectionSamplerLow;uniform sampler2D reflectionSamplerHigh;
220#endif
221#ifdef USEIRRADIANCEMAP
222uniform sampler2D irradianceSampler;
223#endif
224#endif
225#ifdef REFLECTIONMAP_SKYBOX
226varying vec3 vPositionUVW;
227#else
228#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
229varying vec3 vDirectionW;
230#endif
231#endif
232#endif
233#ifdef ENVIRONMENTBRDF
234uniform sampler2D environmentBrdfSampler;
235#endif
236#ifdef SUBSURFACE
237#ifdef SS_REFRACTION
238#ifdef SS_REFRACTIONMAP_3D
239#define sampleRefraction(s,c) textureCube(s,c)
240uniform samplerCube refractionSampler;
241#ifdef LODBASEDMICROSFURACE
242#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
243#else
244uniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh;
245#endif
246#else
247#define sampleRefraction(s,c) texture2D(s,c)
248uniform sampler2D refractionSampler;
249#ifdef LODBASEDMICROSFURACE
250#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
251#else
252uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh;
253#endif
254#endif
255#endif
256#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
257#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
258#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
259#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
260#endif
261#ifdef IBL_CDF_FILTERING
262uniform sampler2D icdfSampler;
263#endif
264`;e.IncludesShadersStore[r]||(e.IncludesShadersStore[r]=D);const f="pbrBlockAlbedoOpacity",h=`struct albedoOpacityOutParams
265{vec3 surfaceAlbedo;float alpha;};
266#define pbr_inline
267albedoOpacityOutParams albedoOpacityBlock(
268in vec4 vAlbedoColor
269#ifdef ALBEDO
270,in vec4 albedoTexture
271,in vec2 albedoInfos
272#endif
273,in float baseWeight
274#ifdef BASE_WEIGHT
275,in vec4 baseWeightTexture
276,in vec2 vBaseWeightInfos
277#endif
278#ifdef OPACITY
279,in vec4 opacityMap
280,in vec2 vOpacityInfos
281#endif
282#ifdef DETAIL
283,in vec4 detailColor
284,in vec4 vDetailInfos
285#endif
286#ifdef DECAL
287,in vec4 decalColor
288,in vec4 vDecalInfos
289#endif
290)
291{albedoOpacityOutParams outParams;vec3 surfaceAlbedo=vAlbedoColor.rgb;float alpha=vAlbedoColor.a;
292#ifdef ALBEDO
293#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
294alpha*=albedoTexture.a;
295#endif
296#ifdef GAMMAALBEDO
297surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
298#else
299surfaceAlbedo*=albedoTexture.rgb;
300#endif
301surfaceAlbedo*=albedoInfos.y;
302#endif
303#ifndef DECAL_AFTER_DETAIL
304#include<decalFragment>
305#endif
306#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
307surfaceAlbedo*=vColor.rgb;
308#endif
309#ifdef DETAIL
310float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; 
311#endif
312#ifdef DECAL_AFTER_DETAIL
313#include<decalFragment>
314#endif
315#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
316surfaceAlbedo*=baseWeight;
317#ifdef BASE_WEIGHT
318surfaceAlbedo*=baseWeightTexture.r;
319#endif
320#ifdef OPACITY
321#ifdef OPACITYRGB
322alpha=getLuminance(opacityMap.rgb);
323#else
324alpha*=opacityMap.a;
325#endif
326alpha*=vOpacityInfos.y;
327#endif
328#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
329alpha*=vColor.a;
330#endif
331#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
332#ifdef ALPHATEST
333#if DEBUGMODE != 88
334if (alpha<ALPHATESTVALUE)
335discard;
336#endif
337#ifndef ALPHABLEND
338alpha=1.0;
339#endif
340#endif
341#endif
342outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
343`;e.IncludesShadersStore[f]||(e.IncludesShadersStore[f]=h);const o="pbrBlockReflectivity",F=`struct reflectivityOutParams
344{float microSurface;float roughness;float diffuseRoughness;float reflectanceF0;vec3 reflectanceF90;vec3 colorReflectanceF0;vec3 colorReflectanceF90;
345#ifdef METALLICWORKFLOW
346vec3 surfaceAlbedo;float metallic;float specularWeight;vec3 dielectricColorF0;
347#endif
348#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
349vec3 ambientOcclusionColor;
350#endif
351#if DEBUGMODE>0
352#ifdef METALLICWORKFLOW
353#ifdef REFLECTIVITY
354vec4 surfaceMetallicColorMap;
355#endif
356vec3 metallicF0;
357#else
358#ifdef REFLECTIVITY
359vec4 surfaceReflectivityColorMap;
360#endif
361#endif
362#endif
363};
364#define pbr_inline
365reflectivityOutParams reflectivityBlock(
366in vec4 reflectivityColor
367#ifdef METALLICWORKFLOW
368,in vec3 surfaceAlbedo
369,in vec4 metallicReflectanceFactors
370#endif
371,in float baseDiffuseRoughness
372#ifdef BASE_DIFFUSE_ROUGHNESS
373,in float baseDiffuseRoughnessTexture
374,in vec2 baseDiffuseRoughnessInfos
375#endif
376#ifdef REFLECTIVITY
377,in vec3 reflectivityInfos
378,in vec4 surfaceMetallicOrReflectivityColorMap
379#endif
380#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
381,in vec3 ambientOcclusionColorIn
382#endif
383#ifdef MICROSURFACEMAP
384,in vec4 microSurfaceTexel
385#endif
386#ifdef DETAIL
387,in vec4 detailColor
388,in vec4 vDetailInfos
389#endif
390)
391{reflectivityOutParams outParams;float microSurface=reflectivityColor.a;vec3 surfaceReflectivityColor=reflectivityColor.rgb;
392#ifdef METALLICWORKFLOW
393vec2 metallicRoughness=surfaceReflectivityColor.rg;float ior=surfaceReflectivityColor.b;
394#ifdef REFLECTIVITY
395#if DEBUGMODE>0
396outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
397#endif
398#ifdef AOSTOREINMETALMAPRED
399vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
400#endif
401#ifdef METALLNESSSTOREINMETALMAPBLUE
402metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
403#else
404metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
405#endif
406#ifdef ROUGHNESSSTOREINMETALMAPALPHA
407metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
408#else
409#ifdef ROUGHNESSSTOREINMETALMAPGREEN
410metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
411#endif
412#endif
413#endif
414#ifdef DETAIL
415float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
416#endif
417#ifdef MICROSURFACEMAP
418metallicRoughness.g*=microSurfaceTexel.r;
419#endif
420#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
421microSurface=1.0-metallicRoughness.g;vec3 baseColor=surfaceAlbedo;outParams.metallic=metallicRoughness.r;outParams.specularWeight=metallicReflectanceFactors.a;float dielectricF0=reflectivityColor.a*outParams.specularWeight;surfaceReflectivityColor=metallicReflectanceFactors.rgb;
422#if DEBUGMODE>0
423outParams.metallicF0=vec3(dielectricF0)*surfaceReflectivityColor;
424#endif
425#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
426outParams.surfaceAlbedo=baseColor.rgb*(vec3(1.0)-vec3(dielectricF0)*surfaceReflectivityColor)*(1.0-outParams.metallic);
427#else
428outParams.surfaceAlbedo=baseColor.rgb;
429#endif
430#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
431{vec3 reflectivityColor=mix(dielectricF0*surfaceReflectivityColor,baseColor.rgb,outParams.metallic);outParams.reflectanceF0=max(reflectivityColor.r,max(reflectivityColor.g,reflectivityColor.b));}
432#else
433#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
434float maxF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF0=mix(dielectricF0*maxF0,1.0,outParams.metallic);
435#else
436outParams.reflectanceF0=mix(dielectricF0,1.0,outParams.metallic);
437#endif
438#endif
439#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
440outParams.reflectanceF90=vec3(outParams.specularWeight);float f90Scale=1.0;
441#else
442float f90Scale=clamp(2.0*(ior-1.0),0.0,1.0);outParams.reflectanceF90=vec3(mix(outParams.specularWeight*f90Scale,1.0,outParams.metallic));
443#endif
444outParams.dielectricColorF0=vec3(dielectricF0*surfaceReflectivityColor);vec3 metallicColorF0=baseColor.rgb;outParams.colorReflectanceF0=mix(outParams.dielectricColorF0,metallicColorF0,outParams.metallic);
445#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
446vec3 dielectricColorF90=surfaceReflectivityColor*vec3(outParams.specularWeight)*vec3(f90Scale);
447#else
448vec3 dielectricColorF90=vec3(outParams.specularWeight*f90Scale);
449#endif
450#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
451vec3 conductorColorF90=surfaceReflectivityColor;
452#else
453#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
454vec3 conductorColorF90=outParams.reflectanceF90;
455#else
456vec3 conductorColorF90=vec3(1.0);
457#endif
458#endif
459outParams.colorReflectanceF90=mix(dielectricColorF90,conductorColorF90,outParams.metallic);
460#else
461#ifdef REFLECTIVITY
462surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
463#if DEBUGMODE>0
464outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
465#endif
466#ifdef MICROSURFACEFROMREFLECTIVITYMAP
467microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
468#else
469#ifdef MICROSURFACEAUTOMATIC
470microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
471#endif
472#ifdef MICROSURFACEMAP
473microSurface*=microSurfaceTexel.r;
474#endif
475#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
476#endif
477#endif
478outParams.colorReflectanceF0=surfaceReflectivityColor;outParams.reflectanceF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF90=vec3(1.0);
479#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
480outParams.colorReflectanceF90=surfaceReflectivityColor;
481#else
482outParams.colorReflectanceF90=vec3(1.0);
483#endif
484#endif
485microSurface=saturate(microSurface);float roughness=1.-microSurface;float diffuseRoughness=baseDiffuseRoughness;
486#ifdef BASE_DIFFUSE_ROUGHNESS
487diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y;
488#endif
489outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;}
490`;e.IncludesShadersStore[o]||(e.IncludesShadersStore[o]=F);const t="pbrBlockAmbientOcclusion",g=`struct ambientOcclusionOutParams
491{vec3 ambientOcclusionColor;
492#if DEBUGMODE>0 && defined(AMBIENT)
493vec3 ambientOcclusionColorMap;
494#endif
495};ambientOcclusionOutParams ambientOcclusionBlock(
496#ifdef AMBIENT
497in vec3 ambientOcclusionColorMap_,
498in vec4 vAmbientInfos
499#endif
500)
501{ambientOcclusionOutParams outParams;vec3 ambientOcclusionColor=vec3(1.,1.,1.);
502#ifdef AMBIENT
503vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
504#ifdef AMBIENTINGRAYSCALE
505ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
506#endif
507ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
508#if DEBUGMODE>0
509outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
510#endif
511#endif
512outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
513`;e.IncludesShadersStore[t]||(e.IncludesShadersStore[t]=g);const c="pbrBlockAlphaFresnel",P=`#ifdef ALPHAFRESNEL
514#if defined(ALPHATEST) || defined(ALPHABLEND)
515struct alphaFresnelOutParams
516{float alpha;};
517#define pbr_inline
518alphaFresnelOutParams alphaFresnelBlock(
519in vec3 normalW,
520in vec3 viewDirectionW,
521in float alpha,
522in float microSurface
523)
524{alphaFresnelOutParams outParams;float opacityPerceptual=alpha;
525#ifdef LINEARALPHAFRESNEL
526float opacity0=opacityPerceptual;
527#else
528float opacity0=opacityPerceptual*opacityPerceptual;
529#endif
530float opacity90=fresnelGrazingReflectance(opacity0);vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
531#ifdef ALPHATEST
532if (outParams.alpha<ALPHATESTVALUE)
533discard;
534#ifndef ALPHABLEND
535outParams.alpha=1.0;
536#endif
537#endif
538return outParams;}
539#endif
540#endif
541`;e.IncludesShadersStore[c]||(e.IncludesShadersStore[c]=P);const l="pbrBlockAnisotropic",U=`#ifdef ANISOTROPIC
542struct anisotropicOutParams
543{float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal;
544#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
545vec3 anisotropyMapData;
546#endif
547};
548#define pbr_inline
549anisotropicOutParams anisotropicBlock(
550in vec3 vAnisotropy,
551in float roughness,
552#ifdef ANISOTROPIC_TEXTURE
553in vec3 anisotropyMapData,
554#endif
555in mat3 TBN,
556in vec3 normalW,
557in vec3 viewDirectionW
558)
559{anisotropicOutParams outParams;float anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
560#ifdef ANISOTROPIC_TEXTURE
561anisotropy*=anisotropyMapData.b;
562#if DEBUGMODE>0
563outParams.anisotropyMapData=anisotropyMapData;
564#endif
565anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;
566#ifdef ANISOTROPIC_LEGACY
567anisotropyDirection.rg*=anisotropyMapData.rg;
568#else
569anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);
570#endif
571#endif
572mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
573#endif
574`;e.IncludesShadersStore[l]||(e.IncludesShadersStore[l]=U);const d="pbrBlockReflection",b=`#ifdef REFLECTION
575struct reflectionOutParams
576{vec4 environmentRadiance;vec3 environmentIrradiance;
577#ifdef REFLECTIONMAP_3D
578vec3 reflectionCoords;
579#else
580vec2 reflectionCoords;
581#endif
582#ifdef SS_TRANSLUCENCY
583#ifdef USESPHERICALFROMREFLECTIONMAP
584#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
585vec3 irradianceVector;
586#endif
587#endif
588#endif
589};
590#define pbr_inline
591void createReflectionCoords(
592in vec3 vPositionW,
593in vec3 normalW,
594#ifdef ANISOTROPIC
595in anisotropicOutParams anisotropicOut,
596#endif
597#ifdef REFLECTIONMAP_3D
598out vec3 reflectionCoords
599#else
600out vec2 reflectionCoords
601#endif
602)
603{
604#ifdef ANISOTROPIC
605vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
606#else
607vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
608#endif
609#ifdef REFLECTIONMAP_OPPOSITEZ
610reflectionVector.z*=-1.0;
611#endif
612#ifdef REFLECTIONMAP_3D
613reflectionCoords=reflectionVector;
614#else
615reflectionCoords=reflectionVector.xy;
616#ifdef REFLECTIONMAP_PROJECTION
617reflectionCoords/=reflectionVector.z;
618#endif
619reflectionCoords.y=1.0-reflectionCoords.y;
620#endif
621}
622#define pbr_inline
623#define inline
624void sampleReflectionTexture(
625in float alphaG,
626in vec3 vReflectionMicrosurfaceInfos,
627in vec2 vReflectionInfos,
628in vec3 vReflectionColor,
629#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
630in float NdotVUnclamped,
631#endif
632#ifdef LINEARSPECULARREFLECTION
633in float roughness,
634#endif
635#ifdef REFLECTIONMAP_3D
636in samplerCube reflectionSampler,
637const vec3 reflectionCoords,
638#else
639in sampler2D reflectionSampler,
640const vec2 reflectionCoords,
641#endif
642#ifndef LODBASEDMICROSFURACE
643#ifdef REFLECTIONMAP_3D
644in samplerCube reflectionSamplerLow,
645in samplerCube reflectionSamplerHigh,
646#else
647in sampler2D reflectionSamplerLow,
648in sampler2D reflectionSamplerHigh,
649#endif
650#endif
651#ifdef REALTIME_FILTERING
652in vec2 vReflectionFilteringInfo,
653#endif
654out vec4 environmentRadiance
655)
656{
657#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
658float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
659#elif defined(LINEARSPECULARREFLECTION)
660float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
661#else
662float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
663#endif
664#ifdef LODBASEDMICROSFURACE
665reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
666#ifdef LODINREFLECTIONALPHA
667float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
668#else
669float requestedReflectionLOD=reflectionLOD;
670#endif
671#ifdef REALTIME_FILTERING
672environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
673#else
674environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
675#endif
676#else
677float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
678sampleReflection(reflectionSamplerHigh,reflectionCoords),
679environmentMid,
680lodReflectionNormalizedDoubled
681);} else {environmentRadiance=mix(
682environmentMid,
683sampleReflection(reflectionSamplerLow,reflectionCoords),
684lodReflectionNormalizedDoubled-1.0
685);}
686#endif
687#ifdef RGBDREFLECTION
688environmentRadiance.rgb=fromRGBD(environmentRadiance);
689#endif
690#ifdef GAMMAREFLECTION
691environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
692#endif
693environmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;}
694#define pbr_inline
695#define inline
696reflectionOutParams reflectionBlock(
697in vec3 vPositionW
698,in vec3 normalW
699,in float alphaG
700,in vec3 vReflectionMicrosurfaceInfos
701,in vec2 vReflectionInfos
702,in vec3 vReflectionColor
703#ifdef ANISOTROPIC
704,in anisotropicOutParams anisotropicOut
705#endif
706#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
707,in float NdotVUnclamped
708#endif
709#ifdef LINEARSPECULARREFLECTION
710,in float roughness
711#endif
712#ifdef REFLECTIONMAP_3D
713,in samplerCube reflectionSampler
714#else
715,in sampler2D reflectionSampler
716#endif
717#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
718,in vec3 vEnvironmentIrradiance
719#endif
720#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
721,in mat4 reflectionMatrix
722#endif
723#ifdef USEIRRADIANCEMAP
724#ifdef REFLECTIONMAP_3D
725,in samplerCube irradianceSampler
726#else
727,in sampler2D irradianceSampler
728#endif
729#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
730,in vec3 reflectionDominantDirection
731#endif
732#endif
733#ifndef LODBASEDMICROSFURACE
734#ifdef REFLECTIONMAP_3D
735,in samplerCube reflectionSamplerLow
736,in samplerCube reflectionSamplerHigh
737#else
738,in sampler2D reflectionSamplerLow
739,in sampler2D reflectionSamplerHigh
740#endif
741#endif
742#ifdef REALTIME_FILTERING
743,in vec2 vReflectionFilteringInfo
744#ifdef IBL_CDF_FILTERING
745,in sampler2D icdfSampler
746#endif
747#endif
748,in vec3 viewDirectionW
749,in float diffuseRoughness
750,in vec3 surfaceAlbedo
751)
752{reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.);
753#ifdef REFLECTIONMAP_3D
754vec3 reflectionCoords=vec3(0.);
755#else
756vec2 reflectionCoords=vec2(0.);
757#endif
758createReflectionCoords(
759vPositionW,
760normalW,
761#ifdef ANISOTROPIC
762anisotropicOut,
763#endif
764reflectionCoords
765);sampleReflectionTexture(
766alphaG,
767vReflectionMicrosurfaceInfos,
768vReflectionInfos,
769vReflectionColor,
770#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
771NdotVUnclamped,
772#endif
773#ifdef LINEARSPECULARREFLECTION
774roughness,
775#endif
776#ifdef REFLECTIONMAP_3D
777reflectionSampler,
778reflectionCoords,
779#else
780reflectionSampler,
781reflectionCoords,
782#endif
783#ifndef LODBASEDMICROSFURACE
784reflectionSamplerLow,
785reflectionSamplerHigh,
786#endif
787#ifdef REALTIME_FILTERING
788vReflectionFilteringInfo,
789#endif
790environmentRadiance
791);vec3 environmentIrradiance=vec3(0.,0.,0.);
792#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
793#ifdef ANISOTROPIC
794vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
795#else
796vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
797#endif
798vec3 irradianceView=vec3(reflectionMatrix*vec4(viewDirectionW,0)).xyz;
799#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
800#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
801float NdotV=max(dot(normalW,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);
802#endif
803#endif
804#ifdef REFLECTIONMAP_OPPOSITEZ
805irradianceVector.z*=-1.0;
806#endif
807#ifdef INVERTCUBICMAP
808irradianceVector.y*=-1.0;
809#endif
810#endif
811#ifdef USESPHERICALFROMREFLECTIONMAP
812#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
813environmentIrradiance=vEnvironmentIrradiance;
814#else
815#if defined(REALTIME_FILTERING)
816environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
817#ifdef IBL_CDF_FILTERING
818,icdfSampler
819#endif
820);
821#else
822environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
823#endif
824#ifdef SS_TRANSLUCENCY
825outParams.irradianceVector=irradianceVector;
826#endif
827#endif
828#elif defined(USEIRRADIANCEMAP)
829#ifdef REFLECTIONMAP_3D
830vec4 environmentIrradiance4=sampleReflection(irradianceSampler,irradianceVector);
831#else
832vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
833#endif
834environmentIrradiance=environmentIrradiance4.rgb;
835#ifdef RGBDREFLECTION
836environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
837#endif
838#ifdef GAMMAREFLECTION
839environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
840#endif
841#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
842vec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0);
843#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
844float LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0)));
845#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
846vec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
847#endif
848environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
849#endif
850#endif
851environmentIrradiance*=vReflectionColor.rgb*vReflectionInfos.x;
852#ifdef MIX_IBL_RADIANCE_WITH_IRRADIANCE
853outParams.environmentRadiance=vec4(mix(environmentRadiance.rgb,environmentIrradiance,alphaG),environmentRadiance.a);
854#else
855outParams.environmentRadiance=environmentRadiance;
856#endif
857outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
858#endif
859`;e.IncludesShadersStore[d]||(e.IncludesShadersStore[d]=b);const s="pbrBlockSheen",y=`#ifdef SHEEN
860struct sheenOutParams
861{float sheenIntensity;vec3 sheenColor;float sheenRoughness;
862#ifdef SHEEN_LINKWITHALBEDO
863vec3 surfaceAlbedo;
864#endif
865#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
866float sheenAlbedoScaling;
867#endif
868#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
869vec3 finalSheenRadianceScaled;
870#endif
871#if DEBUGMODE>0
872#ifdef SHEEN_TEXTURE
873vec4 sheenMapData;
874#endif
875#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
876vec3 sheenEnvironmentReflectance;
877#endif
878#endif
879};
880#define pbr_inline
881#define inline
882sheenOutParams sheenBlock(
883in vec4 vSheenColor
884#ifdef SHEEN_ROUGHNESS
885,in float vSheenRoughness
886#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
887,in vec4 sheenMapRoughnessData
888#endif
889#endif
890,in float roughness
891#ifdef SHEEN_TEXTURE
892,in vec4 sheenMapData
893,in float sheenMapLevel
894#endif
895,in float reflectance
896#ifdef SHEEN_LINKWITHALBEDO
897,in vec3 baseColor
898,in vec3 surfaceAlbedo
899#endif
900#ifdef ENVIRONMENTBRDF
901,in float NdotV
902,in vec3 environmentBrdf
903#endif
904#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
905,in vec2 AARoughnessFactors
906,in vec3 vReflectionMicrosurfaceInfos
907,in vec2 vReflectionInfos
908,in vec3 vReflectionColor
909,in vec4 vLightingIntensity
910#ifdef REFLECTIONMAP_3D
911,in samplerCube reflectionSampler
912,in vec3 reflectionCoords
913#else
914,in sampler2D reflectionSampler
915,in vec2 reflectionCoords
916#endif
917,in float NdotVUnclamped
918#ifndef LODBASEDMICROSFURACE
919#ifdef REFLECTIONMAP_3D
920,in samplerCube reflectionSamplerLow
921,in samplerCube reflectionSamplerHigh
922#else
923,in sampler2D reflectionSamplerLow
924,in sampler2D reflectionSamplerHigh
925#endif
926#endif
927#ifdef REALTIME_FILTERING
928,in vec2 vReflectionFilteringInfo
929#endif
930#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
931,in float seo
932#endif
933#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
934,in float eho
935#endif
936#endif
937)
938{sheenOutParams outParams;float sheenIntensity=vSheenColor.a;
939#ifdef SHEEN_TEXTURE
940#if DEBUGMODE>0
941outParams.sheenMapData=sheenMapData;
942#endif
943#endif
944#ifdef SHEEN_LINKWITHALBEDO
945float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
946#ifdef SHEEN_TEXTURE
947sheenIntensity*=sheenMapData.a;
948#endif
949#else
950vec3 sheenColor=vSheenColor.rgb;
951#ifdef SHEEN_TEXTURE
952#ifdef SHEEN_GAMMATEXTURE
953sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
954#else
955sheenColor.rgb*=sheenMapData.rgb;
956#endif
957sheenColor.rgb*=sheenMapLevel;
958#endif
959#ifdef SHEEN_ROUGHNESS
960float sheenRoughness=vSheenRoughness;
961#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
962#if defined(SHEEN_TEXTURE)
963sheenRoughness*=sheenMapData.a;
964#endif
965#elif defined(SHEEN_TEXTURE_ROUGHNESS)
966sheenRoughness*=sheenMapRoughnessData.a;
967#endif
968#else
969float sheenRoughness=roughness;
970#ifdef SHEEN_TEXTURE
971sheenIntensity*=sheenMapData.a;
972#endif
973#endif
974#if !defined(SHEEN_ALBEDOSCALING)
975sheenIntensity*=(1.-reflectance);
976#endif
977sheenColor*=sheenIntensity;
978#endif
979#ifdef ENVIRONMENTBRDF
980/*#ifdef SHEEN_SOFTER
981vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
982#else*/
983#ifdef SHEEN_ROUGHNESS
984vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
985#else
986vec3 environmentSheenBrdf=environmentBrdf;
987#endif
988/*#endif*/
989#endif
990#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
991float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
992#ifdef SPECULARAA
993sheenAlphaG+=AARoughnessFactors.y;
994#endif
995vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture(
996sheenAlphaG,
997vReflectionMicrosurfaceInfos,
998vReflectionInfos,
999vReflectionColor,
1000#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1001NdotVUnclamped,
1002#endif
1003#ifdef LINEARSPECULARREFLECTION
1004sheenRoughness,
1005#endif
1006reflectionSampler,
1007reflectionCoords,
1008#ifndef LODBASEDMICROSFURACE
1009reflectionSamplerLow,
1010reflectionSamplerHigh,
1011#endif
1012#ifdef REALTIME_FILTERING
1013vReflectionFilteringInfo,
1014#endif
1015environmentSheenRadiance
1016);vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
1017#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
1018sheenEnvironmentReflectance*=seo;
1019#endif
1020#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
1021sheenEnvironmentReflectance*=eho;
1022#endif
1023#if DEBUGMODE>0
1024outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
1025#endif
1026outParams.finalSheenRadianceScaled=
1027environmentSheenRadiance.rgb *
1028sheenEnvironmentReflectance *
1029vLightingIntensity.z;
1030#endif
1031#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1032outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
1033#endif
1034outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
1035#endif
1036`;e.IncludesShadersStore[s]||(e.IncludesShadersStore[s]=y);const E="pbrBlockClearcoat",B=`struct clearcoatOutParams
1037{vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness;
1038#ifdef REFLECTION
1039vec3 finalClearCoatRadianceScaled;
1040#endif
1041#ifdef CLEARCOAT_TINT
1042vec3 absorption;float clearCoatNdotVRefract;vec3 clearCoatColor;float clearCoatThickness;
1043#endif
1044#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1045vec3 energyConservationFactorClearCoat;
1046#endif
1047#if DEBUGMODE>0
1048#ifdef CLEARCOAT_BUMP
1049mat3 TBNClearCoat;
1050#endif
1051#ifdef CLEARCOAT_TEXTURE
1052vec2 clearCoatMapData;
1053#endif
1054#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
1055vec4 clearCoatTintMapData;
1056#endif
1057#ifdef REFLECTION
1058vec4 environmentClearCoatRadiance;vec3 clearCoatEnvironmentReflectance;
1059#endif
1060float clearCoatNdotV;
1061#endif
1062};
1063#ifdef CLEARCOAT
1064#define pbr_inline
1065#define inline
1066clearcoatOutParams clearcoatBlock(
1067in vec3 vPositionW
1068,in vec3 geometricNormalW
1069,in vec3 viewDirectionW
1070,in vec2 vClearCoatParams
1071#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
1072,in vec4 clearCoatMapRoughnessData
1073#endif
1074,in vec3 specularEnvironmentR0
1075#ifdef CLEARCOAT_TEXTURE
1076,in vec2 clearCoatMapData
1077#endif
1078#ifdef CLEARCOAT_TINT
1079,in vec4 vClearCoatTintParams
1080,in float clearCoatColorAtDistance
1081,in vec4 vClearCoatRefractionParams
1082#ifdef CLEARCOAT_TINT_TEXTURE
1083,in vec4 clearCoatTintMapData
1084#endif
1085#endif
1086#ifdef CLEARCOAT_BUMP
1087,in vec2 vClearCoatBumpInfos
1088,in vec4 clearCoatBumpMapData
1089,in vec2 vClearCoatBumpUV
1090#if defined(TANGENT) && defined(NORMAL)
1091,in mat3 vTBN
1092#else
1093,in vec2 vClearCoatTangentSpaceParams
1094#endif
1095#ifdef OBJECTSPACE_NORMALMAP
1096,in mat4 normalMatrix
1097#endif
1098#endif
1099#if defined(FORCENORMALFORWARD) && defined(NORMAL)
1100,in vec3 faceNormal
1101#endif
1102#ifdef REFLECTION
1103,in vec3 vReflectionMicrosurfaceInfos
1104,in vec2 vReflectionInfos
1105,in vec3 vReflectionColor
1106,in vec4 vLightingIntensity
1107#ifdef REFLECTIONMAP_3D
1108,in samplerCube reflectionSampler
1109#else
1110,in sampler2D reflectionSampler
1111#endif
1112#ifndef LODBASEDMICROSFURACE
1113#ifdef REFLECTIONMAP_3D
1114,in samplerCube reflectionSamplerLow
1115,in samplerCube reflectionSamplerHigh
1116#else
1117,in sampler2D reflectionSamplerLow
1118,in sampler2D reflectionSamplerHigh
1119#endif
1120#endif
1121#ifdef REALTIME_FILTERING
1122,in vec2 vReflectionFilteringInfo
1123#endif
1124#endif
1125#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
1126,in float frontFacingMultiplier
1127#endif
1128)
1129{clearcoatOutParams outParams;float clearCoatIntensity=vClearCoatParams.x;float clearCoatRoughness=vClearCoatParams.y;
1130#ifdef CLEARCOAT_TEXTURE
1131clearCoatIntensity*=clearCoatMapData.x;
1132#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
1133clearCoatRoughness*=clearCoatMapData.y;
1134#endif
1135#if DEBUGMODE>0
1136outParams.clearCoatMapData=clearCoatMapData;
1137#endif
1138#endif
1139#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
1140clearCoatRoughness*=clearCoatMapRoughnessData.y;
1141#endif
1142outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
1143#ifdef CLEARCOAT_TINT
1144vec3 clearCoatColor=vClearCoatTintParams.rgb;float clearCoatThickness=vClearCoatTintParams.a;
1145#ifdef CLEARCOAT_TINT_TEXTURE
1146#ifdef CLEARCOAT_TINT_GAMMATEXTURE
1147clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
1148#else
1149clearCoatColor*=clearCoatTintMapData.rgb;
1150#endif
1151clearCoatThickness*=clearCoatTintMapData.a;
1152#if DEBUGMODE>0
1153outParams.clearCoatTintMapData=clearCoatTintMapData;
1154#endif
1155#endif
1156outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
1157#endif
1158#ifdef CLEARCOAT_REMAP_F0
1159vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
1160#else
1161vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
1162#endif
1163outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);vec3 clearCoatNormalW=geometricNormalW;
1164#ifdef CLEARCOAT_BUMP
1165#ifdef NORMALXYSCALE
1166float clearCoatNormalScale=1.0;
1167#else
1168float clearCoatNormalScale=vClearCoatBumpInfos.y;
1169#endif
1170#if defined(TANGENT) && defined(NORMAL)
1171mat3 TBNClearCoat=vTBN;
1172#else
1173vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
1174#endif
1175#if DEBUGMODE>0
1176outParams.TBNClearCoat=TBNClearCoat;
1177#endif
1178#ifdef OBJECTSPACE_NORMALMAP
1179clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
1180#else
1181clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
1182#endif
1183#endif
1184#if defined(FORCENORMALFORWARD) && defined(NORMAL)
1185clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
1186#endif
1187#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1188clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
1189#endif
1190outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
1191#if DEBUGMODE>0
1192outParams.clearCoatNdotV=clearCoatNdotV;
1193#endif
1194#ifdef CLEARCOAT_TINT
1195vec3 clearCoatVRefract=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
1196#endif
1197#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
1198vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
1199#endif
1200#if defined(REFLECTION)
1201float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
1202#ifdef SPECULARAA
1203clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
1204#endif
1205vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
1206#ifdef REFLECTIONMAP_OPPOSITEZ
1207clearCoatReflectionVector.z*=-1.0;
1208#endif
1209#ifdef REFLECTIONMAP_3D
1210vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
1211#else
1212vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
1213#ifdef REFLECTIONMAP_PROJECTION
1214clearCoatReflectionCoords/=clearCoatReflectionVector.z;
1215#endif
1216clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
1217#endif
1218sampleReflectionTexture(
1219clearCoatAlphaG,
1220vReflectionMicrosurfaceInfos,
1221vReflectionInfos,
1222vReflectionColor,
1223#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1224clearCoatNdotVUnclamped,
1225#endif
1226#ifdef LINEARSPECULARREFLECTION
1227clearCoatRoughness,
1228#endif
1229reflectionSampler,
1230clearCoatReflectionCoords,
1231#ifndef LODBASEDMICROSFURACE
1232reflectionSamplerLow,
1233reflectionSamplerHigh,
1234#endif
1235#ifdef REALTIME_FILTERING
1236vReflectionFilteringInfo,
1237#endif
1238environmentClearCoatRadiance
1239);
1240#if DEBUGMODE>0
1241outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
1242#endif
1243#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1244vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
1245#ifdef HORIZONOCCLUSION
1246#ifdef BUMP
1247#ifdef REFLECTIONMAP_3D
1248float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
1249#endif
1250#endif
1251#endif
1252#else
1253vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
1254#endif
1255clearCoatEnvironmentReflectance*=clearCoatIntensity;
1256#if DEBUGMODE>0
1257outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
1258#endif
1259outParams.finalClearCoatRadianceScaled=
1260environmentClearCoatRadiance.rgb *
1261clearCoatEnvironmentReflectance *
1262vLightingIntensity.z;
1263#endif
1264#if defined(CLEARCOAT_TINT)
1265outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
1266#endif
1267float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
1268#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1269outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
1270#endif
1271return outParams;}
1272#endif
1273`;e.IncludesShadersStore[E]||(e.IncludesShadersStore[E]=B);const R="pbrBlockIridescence",G=`struct iridescenceOutParams
1274{float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;};
1275#ifdef IRIDESCENCE
1276#define pbr_inline
1277#define inline
1278iridescenceOutParams iridescenceBlock(
1279in vec4 vIridescenceParams
1280,in float viewAngle
1281,in vec3 specularEnvironmentR0
1282#ifdef IRIDESCENCE_TEXTURE
1283,in vec2 iridescenceMapData
1284#endif
1285#ifdef IRIDESCENCE_THICKNESS_TEXTURE
1286,in vec2 iridescenceThicknessMapData
1287#endif
1288#ifdef CLEARCOAT
1289,in float NdotVUnclamped
1290,in vec2 vClearCoatParams
1291#ifdef CLEARCOAT_TEXTURE
1292,in vec2 clearCoatMapData
1293#endif
1294#endif
1295)
1296{iridescenceOutParams outParams;float iridescenceIntensity=vIridescenceParams.x;float iridescenceIOR=vIridescenceParams.y;float iridescenceThicknessMin=vIridescenceParams.z;float iridescenceThicknessMax=vIridescenceParams.w;float iridescenceThicknessWeight=1.;
1297#ifdef IRIDESCENCE_TEXTURE
1298iridescenceIntensity*=iridescenceMapData.x;
1299#endif
1300#if defined(IRIDESCENCE_THICKNESS_TEXTURE)
1301iridescenceThicknessWeight=iridescenceThicknessMapData.g;
1302#endif
1303float iridescenceThickness=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);float topIor=1.; 
1304#ifdef CLEARCOAT
1305float clearCoatIntensity=vClearCoatParams.x;
1306#ifdef CLEARCOAT_TEXTURE
1307clearCoatIntensity*=clearCoatMapData.x;
1308#endif
1309topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+square(1.0/topIor)*(square(NdotVUnclamped)-1.0));
1310#endif
1311vec3 iridescenceFresnel=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
1312#endif
1313`;e.IncludesShadersStore[R]||(e.IncludesShadersStore[R]=G);const C="pbrBlockSubSurface",V=`struct subSurfaceOutParams
1314{vec3 specularEnvironmentReflectance;
1315#ifdef SS_REFRACTION
1316vec3 finalRefraction;vec3 surfaceAlbedo;
1317#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1318float alpha;
1319#endif
1320float refractionOpacity;
1321#endif
1322#ifdef SS_TRANSLUCENCY
1323vec3 transmittance;float translucencyIntensity;
1324#ifdef REFLECTION
1325vec3 refractionIrradiance;
1326#endif
1327#endif
1328#if DEBUGMODE>0
1329#ifdef SS_THICKNESSANDMASK_TEXTURE
1330vec4 thicknessMap;
1331#endif
1332#ifdef SS_REFRACTION
1333vec4 environmentRefraction;vec3 refractionTransmittance;
1334#endif
1335#endif
1336};
1337#ifdef SUBSURFACE
1338#ifdef SS_REFRACTION
1339#define pbr_inline
1340#define inline
1341vec4 sampleEnvironmentRefraction(
1342in float ior
1343,in float thickness
1344,in float refractionLOD
1345,in vec3 normalW
1346,in vec3 vPositionW
1347,in vec3 viewDirectionW
1348,in mat4 view
1349,in vec4 vRefractionInfos
1350,in mat4 refractionMatrix
1351,in vec4 vRefractionMicrosurfaceInfos
1352,in float alphaG
1353#ifdef SS_REFRACTIONMAP_3D
1354,in samplerCube refractionSampler
1355#ifndef LODBASEDMICROSFURACE
1356,in samplerCube refractionSamplerLow
1357,in samplerCube refractionSamplerHigh
1358#endif
1359#else
1360,in sampler2D refractionSampler
1361#ifndef LODBASEDMICROSFURACE
1362,in sampler2D refractionSamplerLow
1363,in sampler2D refractionSamplerHigh
1364#endif
1365#endif
1366#ifdef ANISOTROPIC
1367,in anisotropicOutParams anisotropicOut
1368#endif
1369#ifdef REALTIME_FILTERING
1370,in vec2 vRefractionFilteringInfo
1371#endif
1372#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1373,in vec3 refractionPosition
1374,in vec3 refractionSize
1375#endif
1376) {vec4 environmentRefraction=vec4(0.,0.,0.,0.);
1377#ifdef ANISOTROPIC
1378vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
1379#else
1380vec3 refractionVector=refract(-viewDirectionW,normalW,ior);
1381#endif
1382#ifdef SS_REFRACTIONMAP_OPPOSITEZ
1383refractionVector.z*=-1.0;
1384#endif
1385#ifdef SS_REFRACTIONMAP_3D
1386#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1387refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
1388#endif
1389refractionVector.y=refractionVector.y*vRefractionInfos.w;vec3 refractionCoords=refractionVector;refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
1390#else
1391#ifdef SS_USE_THICKNESS_AS_DEPTH
1392vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
1393#else
1394vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
1395#endif
1396vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
1397#endif
1398#ifdef LODBASEDMICROSFURACE
1399refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
1400#ifdef SS_LODINREFRACTIONALPHA
1401float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
1402#else
1403float requestedRefractionLOD=refractionLOD;
1404#endif
1405#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
1406environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
1407#else
1408environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
1409#endif
1410#else
1411float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
1412sampleRefraction(refractionSamplerHigh,refractionCoords),
1413environmentRefractionMid,
1414lodRefractionNormalizedDoubled
1415);} else {environmentRefraction=mix(
1416environmentRefractionMid,
1417sampleRefraction(refractionSamplerLow,refractionCoords),
1418lodRefractionNormalizedDoubled-1.0
1419);}
1420#endif
1421#ifdef SS_RGBDREFRACTION
1422environmentRefraction.rgb=fromRGBD(environmentRefraction);
1423#endif
1424#ifdef SS_GAMMAREFRACTION
1425environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
1426#endif
1427return environmentRefraction;}
1428#endif
1429#define pbr_inline
1430#define inline
1431subSurfaceOutParams subSurfaceBlock(
1432in vec3 vSubSurfaceIntensity
1433,in vec2 vThicknessParam
1434,in vec4 vTintColor
1435,in vec3 normalW
1436,in vec3 vSpecularEnvironmentReflectance
1437#ifdef SS_THICKNESSANDMASK_TEXTURE
1438,in vec4 thicknessMap
1439#endif
1440#ifdef SS_REFRACTIONINTENSITY_TEXTURE
1441,in vec4 refractionIntensityMap
1442#endif
1443#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
1444,in vec4 translucencyIntensityMap
1445#endif
1446#ifdef REFLECTION
1447#ifdef SS_TRANSLUCENCY
1448,in mat4 reflectionMatrix
1449#ifdef USESPHERICALFROMREFLECTIONMAP
1450#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
1451,in vec3 irradianceVector_
1452#endif
1453#if defined(REALTIME_FILTERING)
1454,in samplerCube reflectionSampler
1455,in vec2 vReflectionFilteringInfo
1456#ifdef IBL_CDF_FILTERING
1457,in sampler2D icdfSampler
1458#endif
1459#endif
1460#endif
1461#ifdef USEIRRADIANCEMAP
1462#ifdef REFLECTIONMAP_3D
1463,in samplerCube irradianceSampler
1464#else
1465,in sampler2D irradianceSampler
1466#endif
1467#endif
1468#endif
1469#endif
1470#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
1471,in vec3 surfaceAlbedo
1472#endif
1473#ifdef SS_REFRACTION
1474,in vec3 vPositionW
1475,in vec3 viewDirectionW
1476,in mat4 view
1477,in vec4 vRefractionInfos
1478,in mat4 refractionMatrix
1479,in vec4 vRefractionMicrosurfaceInfos
1480,in vec4 vLightingIntensity
1481#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1482,in float alpha
1483#endif
1484#ifdef SS_LODINREFRACTIONALPHA
1485,in float NdotVUnclamped
1486#endif
1487#ifdef SS_LINEARSPECULARREFRACTION
1488,in float roughness
1489#endif
1490,in float alphaG
1491#ifdef SS_REFRACTIONMAP_3D
1492,in samplerCube refractionSampler
1493#ifndef LODBASEDMICROSFURACE
1494,in samplerCube refractionSamplerLow
1495,in samplerCube refractionSamplerHigh
1496#endif
1497#else
1498,in sampler2D refractionSampler
1499#ifndef LODBASEDMICROSFURACE
1500,in sampler2D refractionSamplerLow
1501,in sampler2D refractionSamplerHigh
1502#endif
1503#endif
1504#ifdef ANISOTROPIC
1505,in anisotropicOutParams anisotropicOut
1506#endif
1507#ifdef REALTIME_FILTERING
1508,in vec2 vRefractionFilteringInfo
1509#endif
1510#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1511,in vec3 refractionPosition
1512,in vec3 refractionSize
1513#endif
1514#ifdef SS_DISPERSION
1515,in float dispersion
1516#endif
1517#endif
1518#ifdef SS_TRANSLUCENCY
1519,in vec3 vDiffusionDistance
1520,in vec4 vTranslucencyColor
1521#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
1522,in vec4 translucencyColorMap
1523#endif
1524#endif
1525)
1526{subSurfaceOutParams outParams;outParams.specularEnvironmentReflectance=vSpecularEnvironmentReflectance;
1527#ifdef SS_REFRACTION
1528float refractionIntensity=vSubSurfaceIntensity.x;
1529#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1530refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
1531#endif
1532#endif
1533#ifdef SS_TRANSLUCENCY
1534float translucencyIntensity=vSubSurfaceIntensity.y;
1535#endif
1536#ifdef SS_THICKNESSANDMASK_TEXTURE
1537#ifdef SS_USE_GLTF_TEXTURES
1538float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
1539#else
1540float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
1541#endif
1542#if DEBUGMODE>0
1543outParams.thicknessMap=thicknessMap;
1544#endif
1545#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
1546#ifdef SS_USE_GLTF_TEXTURES
1547refractionIntensity*=thicknessMap.r;
1548#else
1549refractionIntensity*=thicknessMap.g;
1550#endif
1551#endif
1552#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
1553#ifdef SS_USE_GLTF_TEXTURES
1554translucencyIntensity*=thicknessMap.a;
1555#else
1556translucencyIntensity*=thicknessMap.b;
1557#endif
1558#endif
1559#else
1560float thickness=vThicknessParam.y;
1561#endif
1562#if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
1563#ifdef SS_USE_GLTF_TEXTURES
1564refractionIntensity*=refractionIntensityMap.r;
1565#else
1566refractionIntensity*=refractionIntensityMap.g;
1567#endif
1568#endif
1569#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
1570#ifdef SS_USE_GLTF_TEXTURES
1571translucencyIntensity*=translucencyIntensityMap.a;
1572#else
1573translucencyIntensity*=translucencyIntensityMap.b;
1574#endif
1575#endif
1576#ifdef SS_TRANSLUCENCY
1577thickness=maxEps(thickness);vec4 translucencyColor=vTranslucencyColor;
1578#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
1579translucencyColor*=translucencyColorMap;
1580#endif
1581vec3 transmittance=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
1582#endif
1583#ifdef SS_REFRACTION
1584vec4 environmentRefraction=vec4(0.,0.,0.,0.);
1585#ifdef SS_HAS_THICKNESS
1586float ior=vRefractionInfos.y;
1587#else
1588float ior=vRefractionMicrosurfaceInfos.w;
1589#endif
1590#ifdef SS_LODINREFRACTIONALPHA
1591float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
1592#elif defined(SS_LINEARSPECULARREFRACTION)
1593float refractionRoughness=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
1594#else
1595float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
1596#endif
1597float refraction_ior=vRefractionInfos.y;
1598#ifdef SS_DISPERSION
1599float realIOR=1.0/refraction_ior;float iorDispersionSpread=0.04*dispersion*(realIOR-1.0);vec3 iors=vec3(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (int i=0; i<3; i++) {refraction_ior=iors[i];
1600#endif
1601vec4 envSample=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
1602#ifdef SS_REFRACTIONMAP_3D
1603,refractionSampler
1604#ifndef LODBASEDMICROSFURACE
1605,refractionSamplerLow
1606,refractionSamplerHigh
1607#endif
1608#else
1609,refractionSampler
1610#ifndef LODBASEDMICROSFURACE
1611,refractionSamplerLow
1612,refractionSamplerHigh
1613#endif
1614#endif
1615#ifdef ANISOTROPIC
1616,anisotropicOut
1617#endif
1618#ifdef REALTIME_FILTERING
1619,vRefractionFilteringInfo
1620#endif
1621#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1622,refractionPosition
1623,refractionSize
1624#endif
1625);
1626#ifdef SS_DISPERSION
1627environmentRefraction[i]=envSample[i];}
1628#else
1629environmentRefraction=envSample;
1630#endif
1631environmentRefraction.rgb*=vRefractionInfos.x;
1632#endif
1633#ifdef SS_REFRACTION
1634vec3 refractionTransmittance=vec3(refractionIntensity);
1635#ifdef SS_THICKNESSANDMASK_TEXTURE
1636vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
1637#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
1638float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);environmentRefraction.rgb*=volumeAlbedo;
1639#else
1640vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
1641#endif
1642#ifdef SS_ALBEDOFORREFRACTIONTINT
1643environmentRefraction.rgb*=surfaceAlbedo.rgb;
1644#endif
1645outParams.surfaceAlbedo=surfaceAlbedo;outParams.refractionOpacity=1.-refractionIntensity;
1646#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
1647outParams.surfaceAlbedo*=outParams.refractionOpacity;
1648#endif
1649#ifdef UNUSED_MULTIPLEBOUNCES
1650vec3 bounceSpecularEnvironmentReflectance=(2.0*vSpecularEnvironmentReflectance)/(1.0+vSpecularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,vSpecularEnvironmentReflectance,refractionIntensity);
1651#endif
1652#if DEBUGMODE>0
1653outParams.refractionTransmittance=refractionTransmittance;
1654#endif
1655outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;outParams.finalRefraction*=vec3(1.0)-vSpecularEnvironmentReflectance;
1656#if DEBUGMODE>0
1657outParams.environmentRefraction=environmentRefraction;
1658#endif
1659#endif
1660#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
1661#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
1662vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
1663#ifdef REFLECTIONMAP_OPPOSITEZ
1664irradianceVector.z*=-1.0;
1665#endif
1666#ifdef INVERTCUBICMAP
1667irradianceVector.y*=-1.0;
1668#endif
1669#else
1670vec3 irradianceVector=irradianceVector_;
1671#endif
1672#if defined(USESPHERICALFROMREFLECTIONMAP)
1673#if defined(REALTIME_FILTERING)
1674vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo,0.0,surfaceAlbedo,irradianceVector
1675#ifdef IBL_CDF_FILTERING
1676,icdfSampler
1677#endif
1678);
1679#else
1680vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
1681#endif
1682#elif defined(USEIRRADIANCEMAP)
1683#ifdef REFLECTIONMAP_3D
1684vec3 irradianceCoords=irradianceVector;
1685#else
1686vec2 irradianceCoords=irradianceVector.xy;
1687#ifdef REFLECTIONMAP_PROJECTION
1688irradianceCoords/=irradianceVector.z;
1689#endif
1690irradianceCoords.y=1.0-irradianceCoords.y;
1691#endif
1692vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
1693#ifdef RGBDREFLECTION
1694refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
1695#endif
1696#ifdef GAMMAREFLECTION
1697refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
1698#endif
1699#else
1700vec4 refractionIrradiance=vec4(0.);
1701#endif
1702refractionIrradiance.rgb*=transmittance;
1703#ifdef SS_ALBEDOFORTRANSLUCENCYTINT
1704refractionIrradiance.rgb*=surfaceAlbedo.rgb;
1705#endif
1706outParams.refractionIrradiance=refractionIrradiance.rgb;
1707#endif
1708return outParams;}
1709#endif
1710`;e.IncludesShadersStore[C]||(e.IncludesShadersStore[C]=V);const u="pbrBlockReflectance0",H=`float reflectanceF0=reflectivityOut.reflectanceF0;vec3 specularEnvironmentR0=reflectivityOut.colorReflectanceF0;vec3 specularEnvironmentR90=reflectivityOut.colorReflectanceF90;
1711#ifdef ALPHAFRESNEL
1712float reflectance90=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
1713#endif
1714`;e.IncludesShadersStore[u]||(e.IncludesShadersStore[u]=H);const S="pbrClusteredLightingFunctions",x=`#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1715#include<clusteredLightingFunctions>
1716#define inline
1717lightingInfo computeClusteredLighting(
1718sampler2D lightDataTexture,
1719sampler2D tileMaskTexture,
1720vec4 lightData,
1721ivec2 sliceRange,
1722vec3 V,
1723vec3 N,
1724vec3 posW,
1725vec3 surfaceAlbedo,
1726reflectivityOutParams reflectivityOut
1727#ifdef IRIDESCENCE
1728,float iridescenceIntensity
1729#endif
1730#ifdef SS_TRANSLUCENCY
1731,subSurfaceOutParams subSurfaceOut
1732#endif
1733#ifdef SPECULARTERM
1734,float AARoughnessFactor
1735#endif
1736#ifdef ANISOTROPIC
1737,anisotropicOutParams anisotropicOut
1738#endif
1739#ifdef SHEEN
1740,sheenOutParams sheenOut
1741#endif
1742#ifdef CLEARCOAT
1743,clearcoatOutParams clearcoatOut
1744#endif
1745) {float NdotV=absEps(dot(N,V));
1746#include<pbrBlockReflectance0>
1747#ifdef CLEARCOAT
1748specularEnvironmentR0=clearcoatOut.specularEnvironmentR0;
1749#endif
1750lightingInfo 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);preLightingInfo preInfo=computePointAndSpotPreLightingInfo(light.vLightData,V,N,posW);preInfo.NdotV=NdotV;preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light.vLightFalloff.x,light.vLightFalloff.y);if (light.vLightDirection.w>=0.0) {preInfo.attenuation*=computeDirectionalLightFalloff(light.vLightDirection.xyz,preInfo.L,light.vLightDirection.w,light.vLightData.w,light.vLightFalloff.z,light.vLightFalloff.w);}
1751preInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
1752#ifdef IRIDESCENCE
1753preInfo.iridescenceIntensity=iridescenceIntensity;
1754#endif
1755lightingInfo info;
1756#ifdef SS_TRANSLUCENCY
1757#ifdef SS_TRANSLUCENCY_LEGACY
1758info.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0);
1759#else
1760info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);
1761#endif
1762#else
1763info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb);
1764#endif
1765#ifdef SPECULARTERM
1766#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR
1767vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);vec3 coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);
1768#else
1769vec3 coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
1770#endif
1771#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1772float NdotH=dot(N,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);
1773#endif
1774#ifdef ANISOTROPIC
1775info.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1776#else
1777info.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb);
1778#endif
1779#endif
1780#ifdef SHEEN
1781#ifdef SHEEN_LINKWITHALBEDO
1782preInfo.roughness=sheenOut.sheenIntensity;
1783#else
1784preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance);
1785#endif
1786info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1787#endif
1788#ifdef CLEARCOAT
1789preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb);
1790#ifdef CLEARCOAT_TINT
1791float absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
1792#ifdef SS_TRANSLUCENCY
1793info.diffuseTransmission*=absorption;
1794#endif
1795#ifdef SPECULARTERM
1796info.specular*=absorption;
1797#endif
1798#endif
1799info.diffuse*=info.clearCoat.w;
1800#ifdef SS_TRANSLUCENCY
1801info.diffuseTransmission*=info.clearCoat.w;
1802#endif
1803#ifdef SPECULARTERM
1804info.specular*=info.clearCoat.w;
1805#endif
1806#ifdef SHEEN
1807info.sheen*=info.clearCoat.w;
1808#endif
1809#endif
1810result.diffuse+=info.diffuse;
1811#ifdef SS_TRANSLUCENCY
1812result.diffuseTransmission+=info.diffuseTransmission;
1813#endif
1814#ifdef SPECULARTERM
1815result.specular+=info.specular;
1816#endif
1817#ifdef CLEARCOAT
1818result.clearCoat+=info.clearCoat;
1819#endif
1820#ifdef SHEEN
1821result.sheen+=info.sheen;
1822#endif
1823}
1824batchOffset+=CLUSTLIGHT_BATCH;}
1825return result;}
1826#endif
1827`;e.IncludesShadersStore[S]||(e.IncludesShadersStore[S]=x);const m="pbrBlockNormalFinal",W=`#if defined(FORCENORMALFORWARD) && defined(NORMAL)
1828vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
1829#if defined(TWOSIDEDLIGHTING)
1830faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
1831#endif
1832normalW*=sign(dot(normalW,faceNormal));
1833#endif
1834#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1835#if defined(MIRRORED)
1836normalW=gl_FrontFacing ? -normalW : normalW;
1837#else
1838normalW=gl_FrontFacing ? normalW : -normalW;
1839#endif
1840#endif
1841`;e.IncludesShadersStore[m]||(e.IncludesShadersStore[m]=W);const A="pbrBlockLightmapInit",Y=`#ifdef LIGHTMAP
1842vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
1843#ifdef RGBDLIGHTMAP
1844lightmapColor.rgb=fromRGBD(lightmapColor);
1845#endif
1846#ifdef GAMMALIGHTMAP
1847lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
1848#endif
1849lightmapColor.rgb*=vLightmapInfos.y;
1850#endif
1851`;e.IncludesShadersStore[A]||(e.IncludesShadersStore[A]=Y);const I="pbrBlockGeometryInfo",k=`float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
1852#ifdef SPECULARAA
1853alphaG+=AARoughnessFactors.y;
1854#endif
1855#if defined(ENVIRONMENTBRDF)
1856vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
1857#endif
1858#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1859#ifdef RADIANCEOCCLUSION
1860#ifdef AMBIENTINGRAYSCALE
1861float ambientMonochrome=aoOut.ambientOcclusionColor.r;
1862#else
1863float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
1864#endif
1865float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
1866#endif
1867#ifdef HORIZONOCCLUSION
1868#ifdef BUMP
1869#ifdef REFLECTIONMAP_3D
1870float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
1871#endif
1872#endif
1873#endif
1874#endif
1875`;e.IncludesShadersStore[I]||(e.IncludesShadersStore[I]=k);const v="pbrBlockReflectance",X=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1876vec3 baseSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(reflectanceF0),reflectivityOut.reflectanceF90,environmentBrdf);
1877#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
1878vec3 metalEnvironmentReflectance=reflectivityOut.specularWeight*getF82Specular(NdotV,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricEnvironmentReflectance=getReflectanceFromBRDFLookup(reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90,environmentBrdf);vec3 colorSpecularEnvironmentReflectance=mix(dielectricEnvironmentReflectance,metalEnvironmentReflectance,reflectivityOut.metallic);
1879#else
1880vec3 colorSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,environmentBrdf);
1881#endif
1882#ifdef RADIANCEOCCLUSION
1883colorSpecularEnvironmentReflectance*=seo;
1884#endif
1885#ifdef HORIZONOCCLUSION
1886#ifdef BUMP
1887#ifdef REFLECTIONMAP_3D
1888colorSpecularEnvironmentReflectance*=eho;
1889#endif
1890#endif
1891#endif
1892#else
1893vec3 colorSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));vec3 baseSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,vec3(reflectanceF0),reflectivityOut.reflectanceF90,sqrt(microSurface));
1894#endif
1895#ifdef CLEARCOAT
1896colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor;
1897#if defined(CLEARCOAT_TINT)
1898colorSpecularEnvironmentReflectance*=clearcoatOut.absorption;
1899#endif
1900#endif
1901`;e.IncludesShadersStore[v]||(e.IncludesShadersStore[v]=X);const N="pbrBlockDirectLighting",w=`vec3 diffuseBase=vec3(0.,0.,0.);
1902#ifdef SS_TRANSLUCENCY
1903vec3 diffuseTransmissionBase=vec3(0.,0.,0.);
1904#endif
1905#ifdef SPECULARTERM
1906vec3 specularBase=vec3(0.,0.,0.);
1907#endif
1908#ifdef CLEARCOAT
1909vec3 clearCoatBase=vec3(0.,0.,0.);
1910#endif
1911#ifdef SHEEN
1912vec3 sheenBase=vec3(0.,0.,0.);
1913#endif
1914#if defined(SPECULARTERM) && defined(LIGHT0)
1915vec3 coloredFresnel;
1916#endif
1917preLightingInfo preInfo;lightingInfo info;float shadow=1.; 
1918float aggShadow=0.;float numLights=0.;
1919#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
1920vec3 absorption=vec3(0.);
1921#endif
1922`;e.IncludesShadersStore[N]||(e.IncludesShadersStore[N]=w);const T="pbrBlockFinalLitComponents",K=`aggShadow=aggShadow/numLights;
1923#if defined(ENVIRONMENTBRDF)
1924#ifdef MS_BRDF_ENERGY_CONSERVATION
1925vec3 baseSpecularEnergyConservationFactor=getEnergyConservationFactor(vec3(reflectanceF0),environmentBrdf);vec3 coloredEnergyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
1926#endif
1927#endif
1928#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
1929surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
1930#endif
1931#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
1932#ifndef METALLICWORKFLOW
1933#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
1934surfaceAlbedo.rgb=(1.-reflectanceF0)*surfaceAlbedo.rgb;
1935#endif
1936#endif
1937#endif
1938#ifdef REFLECTION
1939vec3 finalIrradiance=reflectionOut.environmentIrradiance;
1940#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1941#if defined(METALLICWORKFLOW) || defined(SPECULAR_GLOSSINESS_ENERGY_CONSERVATION)
1942vec3 baseSpecularEnergy=vec3(baseSpecularEnvironmentReflectance);
1943#if defined(ENVIRONMENTBRDF)
1944#ifdef MS_BRDF_ENERGY_CONSERVATION
1945baseSpecularEnergy*=baseSpecularEnergyConservationFactor;
1946#endif
1947#endif
1948finalIrradiance*=clamp(vec3(1.0)-baseSpecularEnergy,0.0,1.0);
1949#endif
1950#endif
1951#if defined(CLEARCOAT)
1952finalIrradiance*=clearcoatOut.conservationFactor;
1953#if defined(CLEARCOAT_TINT)
1954finalIrradiance*=clearcoatOut.absorption;
1955#endif
1956#endif
1957#ifndef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
1958finalIrradiance*=surfaceAlbedo.rgb;
1959#endif
1960#if defined(SS_REFRACTION)
1961finalIrradiance*=subSurfaceOut.refractionOpacity;
1962#endif
1963#if defined(SS_TRANSLUCENCY)
1964finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
1965#endif
1966#ifdef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
1967finalIrradiance*=surfaceAlbedo.rgb;
1968#endif
1969finalIrradiance*=vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
1970#endif
1971#ifdef SPECULARTERM
1972vec3 finalSpecular=specularBase;finalSpecular=max(finalSpecular,0.0);vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
1973#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1974finalSpecularScaled*=coloredEnergyConservationFactor;
1975#endif
1976#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1977finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
1978#endif
1979#endif
1980#ifdef REFLECTION
1981vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;finalRadiance*=colorSpecularEnvironmentReflectance;vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
1982#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1983finalRadianceScaled*=coloredEnergyConservationFactor;
1984#endif
1985#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1986finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
1987#endif
1988#endif
1989#ifdef SHEEN
1990vec3 finalSheen=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,0.0);vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
1991#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
1992sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
1993#if defined(CLEARCOAT_TINT)
1994sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
1995#endif
1996#endif
1997#endif
1998#ifdef CLEARCOAT
1999vec3 finalClearCoat=clearCoatBase;finalClearCoat=max(finalClearCoat,0.0);vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
2000#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
2001finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
2002#endif
2003#ifdef SS_REFRACTION
2004subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
2005#ifdef CLEARCOAT_TINT
2006subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
2007#endif
2008#endif
2009#endif
2010#ifdef ALPHABLEND
2011float luminanceOverAlpha=0.0;
2012#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
2013luminanceOverAlpha+=getLuminance(finalRadianceScaled);
2014#if defined(CLEARCOAT)
2015luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
2016#endif
2017#endif
2018#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
2019luminanceOverAlpha+=getLuminance(finalSpecularScaled);
2020#endif
2021#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
2022luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
2023#endif
2024#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
2025alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
2026#endif
2027#endif
2028`;e.IncludesShadersStore[T]||(e.IncludesShadersStore[T]=K);const O="pbrBlockFinalUnlitComponents",z=`vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo;
2029#if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION)
2030finalDiffuse*=subSurfaceOut.refractionOpacity;
2031#endif
2032#if defined(SS_TRANSLUCENCY) && !defined(UNLIT)
2033finalDiffuse+=diffuseTransmissionBase;
2034#endif
2035finalDiffuse=max(finalDiffuse,0.0);finalDiffuse*=vLightingIntensity.x;vec3 finalAmbient=vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;vec3 finalEmissive=vEmissiveColor;
2036#ifdef EMISSIVE
2037vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
2038#ifdef GAMMAEMISSIVE
2039finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
2040#else
2041finalEmissive*=emissiveColorTex.rgb;
2042#endif
2043finalEmissive*= vEmissiveInfos.y;
2044#endif
2045finalEmissive*=vLightingIntensity.y;
2046#ifdef AMBIENT
2047vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
2048#else
2049vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
2050#endif
2051finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
2052`;e.IncludesShadersStore[O]||(e.IncludesShadersStore[O]=z);const p="pbrBlockFinalColorComposition",$=`vec4 finalColor=vec4(
2053#ifndef UNLIT
2054#ifdef REFLECTION
2055finalIrradiance +
2056#endif
2057#ifdef SPECULARTERM
2058finalSpecularScaled +
2059#endif
2060#ifdef SHEEN
2061finalSheenScaled +
2062#endif
2063#ifdef CLEARCOAT
2064finalClearCoatScaled +
2065#endif
2066#ifdef REFLECTION
2067finalRadianceScaled +
2068#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
2069sheenOut.finalSheenRadianceScaled +
2070#endif
2071#ifdef CLEARCOAT
2072clearcoatOut.finalClearCoatRadianceScaled +
2073#endif
2074#endif
2075#ifdef SS_REFRACTION
2076subSurfaceOut.finalRefraction +
2077#endif
2078#endif
2079finalAmbient +
2080finalDiffuse,
2081alpha);
2082#ifdef LIGHTMAP
2083#ifndef LIGHTMAPEXCLUDED
2084#ifdef USELIGHTMAPASSHADOWMAP
2085finalColor.rgb*=lightmapColor.rgb;
2086#else
2087finalColor.rgb+=lightmapColor.rgb;
2088#endif
2089#endif
2090#endif
2091finalColor.rgb+=finalEmissive;
2092#define CUSTOM_FRAGMENT_BEFORE_FOG
2093finalColor=max(finalColor,0.0);
2094`;e.IncludesShadersStore[p]||(e.IncludesShadersStore[p]=$);const i="pbrPixelShader",L=`#define PBR_FRAGMENT_SHADER
2095#define CUSTOM_FRAGMENT_EXTENSION
2096#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
2097#extension GL_OES_standard_derivatives : enable
2098#endif
2099#ifdef LODBASEDMICROSFURACE
2100#extension GL_EXT_shader_texture_lod : enable
2101#endif
2102#define CUSTOM_FRAGMENT_BEGIN
2103#ifdef LOGARITHMICDEPTH
2104#extension GL_EXT_frag_depth : enable
2105#endif
2106#if SCENE_MRT_COUNT>0
2107#include<prePassDeclaration>[SCENE_MRT_COUNT]
2108#endif
2109precision highp float;
2110#include<oitDeclaration>
2111#ifndef FROMLINEARSPACE
2112#define FROMLINEARSPACE
2113#endif
2114#include<__decl__pbrFragment>
2115#include<pbrFragmentExtraDeclaration>
2116#include<__decl__lightFragment>[0..maxSimultaneousLights]
2117#include<pbrFragmentSamplersDeclaration>
2118#include<imageProcessingDeclaration>
2119#include<clipPlaneFragmentDeclaration>
2120#include<logDepthDeclaration>
2121#include<fogFragmentDeclaration>
2122#include<helperFunctions>
2123#include<subSurfaceScatteringFunctions>
2124#include<importanceSampling>
2125#include<pbrHelperFunctions>
2126#include<imageProcessingFunctions>
2127#include<shadowsFragmentFunctions>
2128#include<harmonicsFunctions>
2129#include<pbrDirectLightingSetupFunctions>
2130#include<pbrDirectLightingFalloffFunctions>
2131#include<pbrBRDFFunctions>
2132#include<hdrFilteringFunctions>
2133#include<pbrDirectLightingFunctions>
2134#include<pbrIBLFunctions>
2135#include<bumpFragmentMainFunctions>
2136#include<bumpFragmentFunctions>
2137#ifdef REFLECTION
2138#include<reflectionFunction>
2139#endif
2140#define CUSTOM_FRAGMENT_DEFINITIONS
2141#include<pbrBlockAlbedoOpacity>
2142#include<pbrBlockReflectivity>
2143#include<pbrBlockAmbientOcclusion>
2144#include<pbrBlockAlphaFresnel>
2145#include<pbrBlockAnisotropic>
2146#include<pbrBlockReflection>
2147#include<pbrBlockSheen>
2148#include<pbrBlockClearcoat>
2149#include<pbrBlockIridescence>
2150#include<pbrBlockSubSurface>
2151#include<pbrClusteredLightingFunctions>
2152void main(void) {
2153#define CUSTOM_FRAGMENT_MAIN_BEGIN
2154#include<clipPlaneFragment>
2155#include<pbrBlockNormalGeometric>
2156#include<bumpFragment>
2157#include<pbrBlockNormalFinal>
2158albedoOpacityOutParams albedoOpacityOut;
2159#ifdef ALBEDO
2160vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
2161#endif
2162#ifdef BASE_WEIGHT
2163vec4 baseWeightTexture=texture2D(baseWeightSampler,vBaseWeightUV+uvOffset);
2164#endif
2165#ifdef OPACITY
2166vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
2167#endif
2168#ifdef DECAL
2169vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
2170#endif
2171albedoOpacityOut=albedoOpacityBlock(
2172vAlbedoColor
2173#ifdef ALBEDO
2174,albedoTexture
2175,vAlbedoInfos
2176#endif
2177,baseWeight
2178#ifdef BASE_WEIGHT
2179,baseWeightTexture
2180,vBaseWeightInfos
2181#endif
2182#ifdef OPACITY
2183,opacityMap
2184,vOpacityInfos
2185#endif
2186#ifdef DETAIL
2187,detailColor
2188,vDetailInfos
2189#endif
2190#ifdef DECAL
2191,decalColor
2192,vDecalInfos
2193#endif
2194);vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
2195#define CUSTOM_FRAGMENT_UPDATE_ALPHA
2196#include<depthPrePass>
2197#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
2198ambientOcclusionOutParams aoOut;
2199#ifdef AMBIENT
2200vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
2201#endif
2202aoOut=ambientOcclusionBlock(
2203#ifdef AMBIENT
2204ambientOcclusionColorMap,
2205vAmbientInfos
2206#endif
2207);
2208#include<pbrBlockLightmapInit>
2209#ifdef UNLIT
2210vec3 diffuseBase=vec3(1.,1.,1.);
2211#else 
2212vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
2213#if defined(REFLECTIVITY)
2214vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
2215#ifndef METALLICWORKFLOW
2216#ifdef REFLECTIVITY_GAMMA
2217surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
2218#endif
2219surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
2220#endif
2221#endif
2222#if defined(MICROSURFACEMAP)
2223vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
2224#endif
2225#ifdef METALLICWORKFLOW
2226vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
2227#ifdef REFLECTANCE
2228vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
2229#ifdef REFLECTANCE_GAMMA
2230reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
2231#endif
2232metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
2233#endif
2234#ifdef METALLIC_REFLECTANCE
2235vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
2236#ifdef METALLIC_REFLECTANCE_GAMMA
2237metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
2238#endif
2239#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
2240metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
2241#endif
2242metallicReflectanceFactors.a*=metallicReflectanceFactorsMap.a;
2243#endif
2244#endif
2245#ifdef BASE_DIFFUSE_ROUGHNESS
2246float baseDiffuseRoughnessTexture=texture2D(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r;
2247#endif
2248reflectivityOut=reflectivityBlock(
2249vReflectivityColor
2250#ifdef METALLICWORKFLOW
2251,surfaceAlbedo
2252,metallicReflectanceFactors
2253#endif
2254,baseDiffuseRoughness
2255#ifdef BASE_DIFFUSE_ROUGHNESS
2256,baseDiffuseRoughnessTexture
2257,vBaseDiffuseRoughnessInfos
2258#endif
2259#ifdef REFLECTIVITY
2260,vReflectivityInfos
2261,surfaceMetallicOrReflectivityColorMap
2262#endif
2263#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
2264,aoOut.ambientOcclusionColor
2265#endif
2266#ifdef MICROSURFACEMAP
2267,microSurfaceTexel
2268#endif
2269#ifdef DETAIL
2270,detailColor
2271,vDetailInfos
2272#endif
2273);float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;float diffuseRoughness=reflectivityOut.diffuseRoughness;
2274#ifdef METALLICWORKFLOW
2275surfaceAlbedo=reflectivityOut.surfaceAlbedo;
2276#endif
2277#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
2278aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
2279#endif
2280#ifdef ALPHAFRESNEL
2281#if defined(ALPHATEST) || defined(ALPHABLEND)
2282alphaFresnelOutParams alphaFresnelOut;alphaFresnelOut=alphaFresnelBlock(
2283normalW,
2284viewDirectionW,
2285alpha,
2286microSurface
2287);alpha=alphaFresnelOut.alpha;
2288#endif
2289#endif
2290#include<pbrBlockGeometryInfo>
2291#ifdef ANISOTROPIC
2292anisotropicOutParams anisotropicOut;
2293#ifdef ANISOTROPIC_TEXTURE
2294vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
2295#endif
2296anisotropicOut=anisotropicBlock(
2297vAnisotropy,
2298roughness,
2299#ifdef ANISOTROPIC_TEXTURE
2300anisotropyMapData,
2301#endif
2302TBN,
2303normalW,
2304viewDirectionW
2305);
2306#endif
2307#ifdef REFLECTION
2308reflectionOutParams reflectionOut;
2309#ifndef USE_CUSTOM_REFLECTION
2310reflectionOut=reflectionBlock(
2311vPositionW
2312,normalW
2313,alphaG
2314,vReflectionMicrosurfaceInfos
2315,vReflectionInfos
2316,vReflectionColor
2317#ifdef ANISOTROPIC
2318,anisotropicOut
2319#endif
2320#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
2321,NdotVUnclamped
2322#endif
2323#ifdef LINEARSPECULARREFLECTION
2324,roughness
2325#endif
2326,reflectionSampler
2327#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
2328,vEnvironmentIrradiance
2329#endif
2330#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
2331,reflectionMatrix
2332#endif
2333#ifdef USEIRRADIANCEMAP
2334,irradianceSampler
2335#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
2336,vReflectionDominantDirection
2337#endif
2338#endif
2339#ifndef LODBASEDMICROSFURACE
2340,reflectionSamplerLow
2341,reflectionSamplerHigh
2342#endif
2343#ifdef REALTIME_FILTERING
2344,vReflectionFilteringInfo
2345#ifdef IBL_CDF_FILTERING
2346,icdfSampler
2347#endif
2348#endif
2349,viewDirectionW
2350,diffuseRoughness
2351,baseColor
2352);
2353#else
2354#define CUSTOM_REFLECTION
2355#endif
2356#endif
2357#include<pbrBlockReflectance0>
2358#ifdef SHEEN
2359sheenOutParams sheenOut;
2360#ifdef SHEEN_TEXTURE
2361vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
2362#endif
2363#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
2364vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
2365#endif
2366sheenOut=sheenBlock(
2367vSheenColor
2368#ifdef SHEEN_ROUGHNESS
2369,vSheenRoughness
2370#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
2371,sheenMapRoughnessData
2372#endif
2373#endif
2374,roughness
2375#ifdef SHEEN_TEXTURE
2376,sheenMapData
2377,vSheenInfos.y
2378#endif
2379,reflectanceF0
2380#ifdef SHEEN_LINKWITHALBEDO
2381,baseColor
2382,surfaceAlbedo
2383#endif
2384#ifdef ENVIRONMENTBRDF
2385,NdotV
2386,environmentBrdf
2387#endif
2388#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
2389,AARoughnessFactors
2390,vReflectionMicrosurfaceInfos
2391,vReflectionInfos
2392,vReflectionColor
2393,vLightingIntensity
2394,reflectionSampler
2395,reflectionOut.reflectionCoords
2396,NdotVUnclamped
2397#ifndef LODBASEDMICROSFURACE
2398,reflectionSamplerLow
2399,reflectionSamplerHigh
2400#endif
2401#ifdef REALTIME_FILTERING
2402,vReflectionFilteringInfo
2403#endif
2404#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
2405,seo
2406#endif
2407#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
2408,eho
2409#endif
2410#endif
2411);
2412#ifdef SHEEN_LINKWITHALBEDO
2413surfaceAlbedo=sheenOut.surfaceAlbedo;
2414#endif
2415#endif
2416#ifdef CLEARCOAT
2417#ifdef CLEARCOAT_TEXTURE
2418vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
2419#endif
2420#endif
2421#ifdef IRIDESCENCE
2422iridescenceOutParams iridescenceOut;
2423#ifdef IRIDESCENCE_TEXTURE
2424vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
2425#endif
2426#ifdef IRIDESCENCE_THICKNESS_TEXTURE
2427vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
2428#endif
2429iridescenceOut=iridescenceBlock(
2430vIridescenceParams
2431,NdotV
2432,specularEnvironmentR0
2433#ifdef IRIDESCENCE_TEXTURE
2434,iridescenceMapData
2435#endif
2436#ifdef IRIDESCENCE_THICKNESS_TEXTURE
2437,iridescenceThicknessMapData
2438#endif
2439#ifdef CLEARCOAT
2440,NdotVUnclamped
2441,vClearCoatParams
2442#ifdef CLEARCOAT_TEXTURE
2443,clearCoatMapData
2444#endif
2445#endif
2446);float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
2447#endif
2448clearcoatOutParams clearcoatOut;
2449#ifdef CLEARCOAT
2450#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2451vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
2452#endif
2453#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
2454vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
2455#endif
2456#ifdef CLEARCOAT_BUMP
2457vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
2458#endif
2459clearcoatOut=clearcoatBlock(
2460vPositionW
2461,geometricNormalW
2462,viewDirectionW
2463,vClearCoatParams
2464#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2465,clearCoatMapRoughnessData
2466#endif
2467,specularEnvironmentR0
2468#ifdef CLEARCOAT_TEXTURE
2469,clearCoatMapData
2470#endif
2471#ifdef CLEARCOAT_TINT
2472,vClearCoatTintParams
2473,clearCoatColorAtDistance
2474,vClearCoatRefractionParams
2475#ifdef CLEARCOAT_TINT_TEXTURE
2476,clearCoatTintMapData
2477#endif
2478#endif
2479#ifdef CLEARCOAT_BUMP
2480,vClearCoatBumpInfos
2481,clearCoatBumpMapData
2482,vClearCoatBumpUV
2483#if defined(TANGENT) && defined(NORMAL)
2484,vTBN
2485#else
2486,vClearCoatTangentSpaceParams
2487#endif
2488#ifdef OBJECTSPACE_NORMALMAP
2489,normalMatrix
2490#endif
2491#endif
2492#if defined(FORCENORMALFORWARD) && defined(NORMAL)
2493,faceNormal
2494#endif
2495#ifdef REFLECTION
2496,vReflectionMicrosurfaceInfos
2497,vReflectionInfos
2498,vReflectionColor
2499,vLightingIntensity
2500,reflectionSampler
2501#ifndef LODBASEDMICROSFURACE
2502,reflectionSamplerLow
2503,reflectionSamplerHigh
2504#endif
2505#ifdef REALTIME_FILTERING
2506,vReflectionFilteringInfo
2507#endif
2508#endif
2509#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
2510,(gl_FrontFacing ? 1. : -1.)
2511#endif
2512);
2513#else
2514clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
2515#endif
2516#include<pbrBlockReflectance>
2517subSurfaceOutParams subSurfaceOut;
2518#ifdef SUBSURFACE
2519#ifdef SS_THICKNESSANDMASK_TEXTURE
2520vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
2521#endif
2522#ifdef SS_REFRACTIONINTENSITY_TEXTURE
2523vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
2524#endif
2525#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2526vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
2527#endif
2528#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2529vec4 translucencyColorMap=texture2D(translucencyColorSampler,vTranslucencyColorUV+uvOffset);
2530#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA
2531translucencyColorMap=toLinearSpace(translucencyColorMap);
2532#endif
2533#endif
2534#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
2535vec3 vSpecularEnvironmentReflectance=vec3(max(colorSpecularEnvironmentReflectance.r,max(colorSpecularEnvironmentReflectance.g,colorSpecularEnvironmentReflectance.b)));
2536#endif
2537subSurfaceOut=subSurfaceBlock(
2538vSubSurfaceIntensity
2539,vThicknessParam
2540,vTintColor
2541,normalW
2542#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
2543,vSpecularEnvironmentReflectance
2544#else
2545,baseSpecularEnvironmentReflectance
2546#endif
2547#ifdef SS_THICKNESSANDMASK_TEXTURE
2548,thicknessMap
2549#endif
2550#ifdef SS_REFRACTIONINTENSITY_TEXTURE
2551,refractionIntensityMap
2552#endif
2553#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2554,translucencyIntensityMap
2555#endif
2556#ifdef REFLECTION
2557#ifdef SS_TRANSLUCENCY
2558,reflectionMatrix
2559#ifdef USESPHERICALFROMREFLECTIONMAP
2560#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
2561,reflectionOut.irradianceVector
2562#endif
2563#if defined(REALTIME_FILTERING)
2564,reflectionSampler
2565,vReflectionFilteringInfo
2566#ifdef IBL_CDF_FILTERING
2567,icdfSampler
2568#endif
2569#endif
2570#endif
2571#ifdef USEIRRADIANCEMAP
2572,irradianceSampler
2573#endif
2574#endif
2575#endif
2576#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
2577,surfaceAlbedo
2578#endif
2579#ifdef SS_REFRACTION
2580,vPositionW
2581,viewDirectionW
2582,view
2583,vRefractionInfos
2584,refractionMatrix
2585,vRefractionMicrosurfaceInfos
2586,vLightingIntensity
2587#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2588,alpha
2589#endif
2590#ifdef SS_LODINREFRACTIONALPHA
2591,NdotVUnclamped
2592#endif
2593#ifdef SS_LINEARSPECULARREFRACTION
2594,roughness
2595#endif
2596,alphaG
2597,refractionSampler
2598#ifndef LODBASEDMICROSFURACE
2599,refractionSamplerLow
2600,refractionSamplerHigh
2601#endif
2602#ifdef ANISOTROPIC
2603,anisotropicOut
2604#endif
2605#ifdef REALTIME_FILTERING
2606,vRefractionFilteringInfo
2607#endif
2608#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2609,vRefractionPosition
2610,vRefractionSize
2611#endif
2612#ifdef SS_DISPERSION
2613,dispersion
2614#endif
2615#endif
2616#ifdef SS_TRANSLUCENCY
2617,vDiffusionDistance
2618,vTranslucencyColor
2619#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2620,translucencyColorMap
2621#endif
2622#endif
2623);
2624#ifdef SS_REFRACTION
2625surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
2626#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2627alpha=subSurfaceOut.alpha;
2628#endif
2629#endif
2630#else
2631subSurfaceOut.specularEnvironmentReflectance=colorSpecularEnvironmentReflectance;
2632#endif
2633#include<pbrBlockDirectLighting>
2634#include<lightFragment>[0..maxSimultaneousLights]
2635#include<pbrBlockFinalLitComponents>
2636#endif 
2637#include<pbrBlockFinalUnlitComponents>
2638#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
2639#include<pbrBlockFinalColorComposition>
2640#include<logDepthFragment>
2641#include<fogFragment>(color,finalColor)
2642#include<pbrBlockImageProcessing>
2643#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
2644#ifdef PREPASS
2645#include<pbrBlockPrePass>
2646#endif
2647#if !defined(PREPASS) || defined(WEBGL2)
2648gl_FragColor=finalColor;
2649#endif
2650#include<oitFragment>
2651#if ORDER_INDEPENDENT_TRANSPARENCY
2652if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
2653#endif
2654#include<pbrDebug>
2655#define CUSTOM_FRAGMENT_MAIN_END
2656}
2657`;e.ShadersStore[i]||(e.ShadersStore[i]=L);const fe={name:i,shader:L};export{fe as pbrPixelShader};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.