PageSourceSearch

https://auramrcomp-b3pjowqc.manus.space/assets/default.fragment-B1Enzn3Y.js

js auramrcomp-b3pjowqc.manus.space collected 2026-10-03 05:00:45 UTC 100,375 bytes, 1,595 lines download raw bytes

1import{S as e}from"./index-0LhFotdt.js";import"./logDepthDeclaration-CnFslgNm.js";import"./helperFunctions-Bvvdmknz.js";import"./clipPlaneFragment-D5FJsegM.js";import"./fogFragment-DKO31M35.js";import"./meshUboDeclaration-C_x-SJCU.js";const t="prePassDeclaration",T=`#ifdef PREPASS
2#ifdef PREPASS_LOCAL_POSITION
3varying vPosition : vec3f;
4#endif
5#ifdef PREPASS_DEPTH
6varying vViewPos: vec3f;
7#endif
8#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
9varying vNormViewDepth: f32;
10#endif
11#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
12varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
13#endif
14#endif
15`;e.IncludesShadersStoreWGSL[t]||(e.IncludesShadersStoreWGSL[t]=T);const i="oitDeclaration",I=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
16#define MAX_DEPTH 99999.0
17var oitDepthSamplerSampler: sampler;var oitDepthSampler: texture_2d<f32>;var oitFrontColorSamplerSampler: sampler;var oitFrontColorSampler: texture_2d<f32>;
18#endif
19`;e.IncludesShadersStoreWGSL[i]||(e.IncludesShadersStoreWGSL[i]=I);const a="lightUboDeclaration",E=`#ifdef LIGHT{X}
20struct Light{X}
21{vLightData: vec4f,
22vLightDiffuse: vec4f,
23vLightSpecular: vec4f,
24#ifdef SPOTLIGHT{X}
25vLightDirection: vec4f,
26vLightFalloff: vec4f,
27#elif defined(POINTLIGHT{X})
28vLightFalloff: vec4f,
29#elif defined(HEMILIGHT{X})
30vLightGround: vec3f,
31#elif defined(CLUSTLIGHT{X})
32vSliceData: vec2f,
33vSliceRanges: array<vec4f,CLUSTLIGHT_SLICES>,
34#endif
35#if defined(AREALIGHT{X})
36vLightWidth: vec4f,
37vLightHeight: vec4f,
38#endif
39shadowsInfo: vec4f,
40depthValues: vec2f} ;var<uniform> light{X} : Light{X};
41#ifdef IESLIGHTTEXTURE{X}
42var iesLightTexture{X}Sampler: sampler;var iesLightTexture{X}: texture_2d<f32>;
43#endif
44#ifdef PROJECTEDLIGHTTEXTURE{X}
45uniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}Sampler: sampler;var projectionLightTexture{X}: texture_2d<f32>;
46#endif
47#ifdef CLUSTLIGHT{X}
48var lightDataTexture{X}: texture_2d<f32>;var<storage,read> tileMaskBuffer{X}: array<u32>;
49#endif
50#ifdef SHADOW{X}
51#ifdef SHADOWCSM{X}
52uniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;uniform viewFrustumZ{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform frustumLengths{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform cascadeBlendFactor{X}: f32;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;var<private> vPositionFromLight{X}: array<vec4f,4>;var<private> vDepthMetric{X} : array<f32,4>;
53#if defined(SHADOWPCSS{X})
54var shadowTexture{X}Sampler: sampler_comparison; 
55var shadowTexture{X}: texture_depth_2d_array;var depthTexture{X}Sampler: sampler;var depthTexture{X}: texture_2d_array<f32>;uniform lightSizeUVCorrection{X}: array<vec2f,SHADOWCSMNUM_CASCADES{X}>;uniform depthCorrection{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform penumbraDarkness{X}: f32;
56#elif defined(SHADOWPCF{X})
57var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d_array;
58#else 
59var shadowTexture{X}Sampler: sampler; 
60var shadowTexture{X}: texture_2d_array<f32>;
61#endif
62#ifdef SHADOWCSMDEBUG{X}
63const vCascadeColorsMultiplier{X}: array<vec3f,8>=array<vec3f,8>
64(
65vec3f ( 1.5,0.0,0.0 ),
66vec3f ( 0.0,1.5,0.0 ),
67vec3f ( 0.0,0.0,5.5 ),
68vec3f ( 1.5,0.0,5.5 ),
69vec3f ( 1.5,1.5,0.0 ),
70vec3f ( 1.0,1.0,1.0 ),
71vec3f ( 0.0,1.0,5.5 ),
72vec3f ( 0.5,3.5,0.75 )
73);
74#endif
75#elif defined(SHADOWCUBE{X})
76var shadowTexture{X}Sampler: sampler;var shadowTexture{X}: texture_cube<f32>;
77#else
78varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;
79#if defined(SHADOWPCSS{X})
80var shadowTexture{X}Sampler: sampler_comparison; 
81var shadowTexture{X}: texture_depth_2d;var depthTexture{X}Sampler: sampler; 
82var depthTexture{X}: texture_2d<f32>;
83#elif defined(SHADOWPCF{X})
84var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d;
85#else
86var shadowTexture{X}Sampler: sampler; 
87var shadowTexture{X}: texture_2d<f32>;
88#endif
89uniform lightMatrix{X}: mat4x4f;
90#endif
91#endif
92#endif
93`;e.IncludesShadersStoreWGSL[a]||(e.IncludesShadersStoreWGSL[a]=E);const o="ltcHelperFunctions",D=`fn LTCUv(N: vec3f,V: vec3f,roughness: f32)->vec2f {var LUTSIZE: f32=64.0;
93var LUTSCALE: f32=( LUTSIZE-1.0 )/LUTSIZE;var LUTBIAS:f32=0.5/LUTSIZE;var dotNV:f32=saturate( dot( N,V ) );var uv:vec2f=vec2f( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;}
94fn LTCClippedSphereFormFactor( f:vec3f )->f32 {var l: f32=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );}
95fn LTCEdgeVectorFormFactor( v1:vec3f,v2:vec3f )->vec3f {var x:f32=dot( v1,v2 );var y:f32=abs( x );var a:f32=0.8543985+( 0.4965155+0.0145206*y )*y;var b:f32=3.4175940+( 4.1616724+y )*y;var v:f32=a/b;var thetaSintheta:f32=0.0;if( x>0.0 )
96{thetaSintheta=v;}
97else
98{thetaSintheta=0.5*inverseSqrt( max( 1.0-x*x,0.00000001 ) )-v;}
99return cross( v1,v2 )*thetaSintheta;}
100fn LTCEvaluate( N:vec3f,V:vec3f,P:vec3f,mInv: mat3x3<f32>,rectCoords0:vec3f,rectCoords1:vec3f,rectCoords2:vec3f,rectCoords3:vec3f )->vec3f {var v1:vec3f=rectCoords1-rectCoords0;var v2:vec3f=rectCoords3-rectCoords0;var lightNormal:vec3f=cross( v1,v2 );if( dot( lightNormal,P-rectCoords0 )<0.0 ){return vec3f( 0.0 );}
101var T1:vec3f=normalize( V-N*dot( V,N ) );var T2:vec3f=- cross( N,T1 ); 
102var mat: mat3x3<f32>=mInv*transposeMat3( mat3x3<f32>( T1,T2,N ) );var coords0: vec3f=mat*( rectCoords0-P );var coords1: vec3f=mat*( rectCoords1-P );var coords2: vec3f=mat*( rectCoords2-P );var coords3: vec3f=mat*( rectCoords3-P );coords0=normalize( coords0 );coords1=normalize( coords1 );coords2=normalize( coords2 );coords3=normalize( coords3 );var vectorFormFactor:vec3f=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords0,coords1 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords1,coords2 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords2,coords3 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords3,coords0 );var result:f32=LTCClippedSphereFormFactor( vectorFormFactor );return vec3f( result );}
103struct areaLightData
104{Diffuse: vec3f,
105Specular: vec3f,
106Fresnel: vec4f};fn computeAreaLightSpecularDiffuseFresnel(ltc1: texture_2d<f32>,ltc1Sampler:sampler,ltc2:texture_2d<f32>,ltc2Sampler:sampler,viewDir: vec3f,normal:vec3f,position:vec3f,lightPos:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->areaLightData {var result: areaLightData;var rectCoords0:vec3f=lightPos+halfWidth-halfHeight; 
107var rectCoords1:vec3f=lightPos-halfWidth-halfHeight;var rectCoords2:vec3f=lightPos-halfWidth+halfHeight;var rectCoords3:vec3f=lightPos+halfWidth+halfHeight;
108#ifdef SPECULARTERM
109var uv:vec2f=LTCUv( normal,viewDir,roughness );var t1:vec4f=textureSample( ltc1,ltc1Sampler,uv );var t2:vec4f=textureSample( ltc2,ltc2Sampler,uv );var mInv:mat3x3<f32>=mat3x3<f32>(
110vec3f( t1.x,0,t1.y ),
111vec3f( 0,1, 0 ),
112vec3f( t1.z,0,t1.w )
113);result.Fresnel=t2;result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords0,rectCoords1,rectCoords2,rectCoords3 );
114#endif
115var mInvEmpty:mat3x3<f32>=mat3x3<f32>(
116vec3f( 1,0,0 ),
117vec3f( 0,1,0 ),
118vec3f( 0,0,1 )
119);result.Diffuse+=LTCEvaluate( normal,viewDir,position,mInvEmpty,rectCoords0,rectCoords1,rectCoords2,rectCoords3 );return result;}`;e.IncludesShadersStoreWGSL[o]||(e.IncludesShadersStoreWGSL[o]=D);const f="clusteredLightingFunctions",A=`struct ClusteredLight {vLightData: vec4f,
120vLightDiffuse: vec4f,
121vLightSpecular: vec4f,
122vLightDirection: vec4f,
123vLightFalloff: vec4f,}
124fn getClusteredLight(lightDataTexture: texture_2d<f32>,index: u32)->ClusteredLight {return ClusteredLight(
125textureLoad(lightDataTexture,vec2u(0,index),0),
126textureLoad(lightDataTexture,vec2u(1,index),0),
127textureLoad(lightDataTexture,vec2u(2,index),0),
128textureLoad(lightDataTexture,vec2u(3,index),0),
129textureLoad(lightDataTexture,vec2u(4,index),0)
130);}
131fn getClusteredSliceIndex(sliceData: vec2f,viewDepth: f32)->i32 {return i32(log(viewDepth)*sliceData.x+sliceData.y);}
132`;e.IncludesShadersStoreWGSL[f]||(e.IncludesShadersStoreWGSL[f]=A);const n="lightsFragmentFunctions",P=`struct lightingInfo
133{diffuse: vec3f,
134#ifdef SPECULARTERM
135specular: vec3f,
136#endif
137#ifdef NDOTL
138ndl: f32,
139#endif
140};fn computeLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var lightVectorW: vec3f;var attenuation: f32=1.0;if (lightData.w==0.)
141{var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
142else
143{lightVectorW=normalize(-lightData.xyz);}
144var ndl: f32=max(0.,dot(vNormal,lightVectorW));
145#ifdef NDOTL
146result.ndl=ndl;
147#endif
148result.diffuse=ndl*diffuseColor*attenuation;
149#ifdef SPECULARTERM
150var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
151#endif
152return result;}
153fn getAttenuation(cosAngle: f32,exponent: f32)->f32 {return max(0.,pow(cosAngle,exponent));}
154fn getIESAttenuation(cosAngle: f32,iesLightTexture: texture_2d<f32>,iesLightTextureSampler: sampler)->f32 {var angle=acos(cosAngle)/PI;return textureSampleLevel(iesLightTexture,iesLightTextureSampler,vec2f(angle,0),0.).r;}
155fn computeBasicSpotLighting(viewDirectionW: vec3f,lightVectorW: vec3f,vNormal: vec3f,attenuation: f32,diffuseColor: vec3f,specularColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=max(0.,dot(vNormal,lightVectorW));
156#ifdef NDOTL
157result.ndl=ndl;
158#endif
159result.diffuse=ndl*diffuseColor*attenuation;
160#ifdef SPECULARTERM
161var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
162#endif
163return result;}
164fn computeIESSpotLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32,iesLightTexture: texture_2d<f32>,iesLightTextureSampler: sampler)->lightingInfo {var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var dotProduct=dot(lightDirection.xyz,-lightVectorW);var cosAngle: f32=max(0.,dotProduct);
164if (cosAngle>=lightDirection.w)
165{attenuation*=getIESAttenuation(dotProduct,iesLightTexture,iesLightTextureSampler);return computeBasicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
166var result: lightingInfo;result.diffuse=vec3f(0.);
167#ifdef SPECULARTERM
168result.specular=vec3f(0.);
169#endif
170#ifdef NDOTL
171result.ndl=0.;
172#endif
173return result;}
174fn computeSpotLighting(viewDirectionW: vec3f,vNormal: vec3f ,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var cosAngle: f32=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
175{attenuation*=getAttenuation(cosAngle,lightData.w);return computeBasicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
176var result: lightingInfo;result.diffuse=vec3f(0.);
177#ifdef SPECULARTERM
178result.specular=vec3f(0.);
179#endif
180#ifdef NDOTL
181result.ndl=0.;
182#endif
183return result;}
184fn computeHemisphericLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,groundColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=dot(vNormal,lightData.xyz)*0.5+0.5;
185#ifdef NDOTL
186result.ndl=ndl;
187#endif
188result.diffuse=mix(groundColor,diffuseColor,ndl);
189#ifdef SPECULARTERM
190var angleW: vec3f=normalize(viewDirectionW+lightData.xyz);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
191#endif
192return result;}
193fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f {var strq: vec4f=textureProjectionMatrix*vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return textureColor;}
194#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
195#include<ltcHelperFunctions>
196var areaLightsLTC1SamplerSampler: sampler;var areaLightsLTC1Sampler: texture_2d<f32>;var areaLightsLTC2SamplerSampler: sampler;var areaLightsLTC2Sampler: texture_2d<f32>;fn computeAreaLighting(ltc1: texture_2d<f32>,ltc1Sampler:sampler,ltc2:texture_2d<f32>,ltc2Sampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightPosition:vec3f,halfWidth:vec3f, halfHeight:vec3f,diffuseColor:vec3f,specularColor:vec3f,roughness:f32 )->lightingInfo
197{var result: lightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc1Sampler,ltc2,ltc2Sampler,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
198#ifdef SPECULARTERM
199var fresnel:vec3f=( specularColor*data.Fresnel.x+( vec3f( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
200#endif
201result.diffuse+=diffuseColor*data.Diffuse;return result;}
202#endif
203#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
204#include<clusteredLightingFunctions>
205fn computeClusteredLighting(
206lightDataTexture: texture_2d<f32>,
207tileMaskBuffer: ptr<storage,array<u32>>,
208viewDirectionW: vec3f,
209vNormal: vec3f,
210lightData: vec4f,
211sliceRange: vec2u,
212glossiness: f32
213)->lightingInfo {var result: lightingInfo;let tilePosition=vec2u(fragmentInputs.position.xy*lightData.xy);let maskResolution=vec2u(lightData.zw);var tileIndex=(tilePosition.x*maskResolution.x+tilePosition.y)*maskResolution.y;let batchRange=sliceRange/CLUSTLIGHT_BATCH;var batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tileIndex+=batchRange.x;for (var i=batchRange.x; i<=batchRange.y; i+=1) {var mask=tileMaskBuffer[tileIndex];tileIndex+=1;let maskOffset=max(sliceRange.x,batchOffset)-batchOffset; 
214let maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while mask != 0 {let trailing=firstTrailingBit(mask);mask ^= 1u<<trailing;let light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+trailing);var info: lightingInfo;if light.vLightDirection.w<0.0 {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);}
215result.diffuse+=info.diffuse;
216#ifdef SPECULARTERM
217result.specular+=info.specular;
218#endif
219}
220batchOffset+=CLUSTLIGHT_BATCH;}
221return result;}
222#endif
223`;e.IncludesShadersStoreWGSL[n]||(e.IncludesShadersStoreWGSL[n]=P);const s="shadowsFragmentFunctions",X
vendor: 28,138 bytes, lines 223-521
223=`#ifdef SHADOWS
224#ifndef SHADOWFLOAT
225fn unpack(color: vec4f)->f32
226{const bit_shift: vec4f= vec4f(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}
227#endif
228fn computeFallOff(value: f32,clipSpace: vec2f,frustumEdgeFalloff: f32)->f32
229{var mask: f32=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
230fn computeShadowCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthValues: vec2f)->f32
231{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
232#ifndef SHADOWFLOAT
233var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
234#else
235var shadow: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
236#endif
237return select(1.0,darkness,depth>shadow);}
238fn computeShadowWithPoissonSamplingCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,mapSize: f32,darkness: f32,depthValues: vec2f)->f32
239{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;var visibility: f32=1.;var poissonDisk: array<vec3f,4>;poissonDisk[0]= vec3f(-1.0,1.0,-1.0);poissonDisk[1]= vec3f(1.0,-1.0,-1.0);poissonDisk[2]= vec3f(-1.0,-1.0,-1.0);poissonDisk[3]= vec3f(1.0,-1.0,1.0);
240#ifndef SHADOWFLOAT
241if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) {visibility-=0.25;};
242#else
243if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) {visibility-=0.25;};
244#endif
245return min(1.0,visibility+darkness);}
246fn computeShadowWithESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32
247{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
248#ifndef SHADOWFLOAT
249var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
250#else
251var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
252#endif
253var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
254fn computeShadowWithCloseESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32
255{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
256#ifndef SHADOWFLOAT
257var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
258#else
259var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
260#endif
261var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
262fn computeShadowCSM(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d_array<f32>,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32
263{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
264#ifndef SHADOWFLOAT
265var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,uv,layer));
266#else
267var shadow: f32=textureSample(shadowTexture,shadowSampler,uv,layer).x;
268#endif
269return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}
270fn computeShadow(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32
271{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
272{return 1.0;}
273else
274{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
275#ifndef SHADOWFLOAT
276var shadow: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
277#else
278var shadow: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
279#endif
280return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}}
281fn computeShadowWithPoissonSampling(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,mapSize: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
282{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
283{return 1.0;}
284else
285{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);var visibility: f32=1.;var poissonDisk: array<vec2f,4>;poissonDisk[0]= vec2f(-0.94201624,-0.39906216);poissonDisk[1]= vec2f(0.94558609,-0.76890725);poissonDisk[2]= vec2f(-0.094184101,-0.92938870);poissonDisk[3]= vec2f(0.34495938,0.29387760);
286#ifndef SHADOWFLOAT
287if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
288if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
289if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
290if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
291#else
292if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
293if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
294if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
295if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
296#endif
297return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
298fn computeShadowWithESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32
299{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
300{return 1.0;}
301else
302{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
303#ifndef SHADOWFLOAT
304var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
305#else
306var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
307#endif
308var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
309fn computeShadowWithCloseESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32
310{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
311{return 1.0;}
312else
313{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0); 
314#ifndef SHADOWFLOAT
315var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
316#else
317var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
318#endif
319var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
320fn getZInClip(clipSpace: vec3f,uvDepth: vec3f)->f32
321{
322#ifdef IS_NDC_HALF_ZRANGE
323return clipSpace.z;
324#else
325return uvDepth.z;
326#endif
327}
328const GREATEST_LESS_THAN_ONE: f32=0.99999994;
329#define DISABLE_UNIFORMITY_ANALYSIS
330fn computeShadowWithCSMPCF1(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32
331{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var shadow: f32=textureSampleCompare(shadowTexture,shadowSampler,uvDepth.xy,layer,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
332fn computeShadowWithCSMPCF3(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
333{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; 
334uv+=0.5; 
335var st: vec2f=fract(uv); 
336var base_uv: vec2f=floor(uv)-0.5; 
337base_uv*=shadowMapSizeAndInverse.y; 
338var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
339fn computeShadowWithCSMPCF5(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
340{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; 
341uv+=0.5; 
342var st: vec2f=fract(uv); 
343var base_uv: vec2f=floor(uv)-0.5; 
344base_uv*=shadowMapSizeAndInverse.y; 
345var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),layer,uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),layer,uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),layer,uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),layer,uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
346fn computeShadowWithPCF1(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32
347{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
348else
349{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var shadow: f32=textureSampleCompareLevel(shadowTexture,shadowSampler,uvDepth.xy,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
350fn computeShadowWithPCF3(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
351{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
352else
353{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; 
354uv+=0.5; 
355var st: vec2f=fract(uv); 
356var base_uv: vec2f=floor(uv)-0.5; 
357base_uv*=shadowMapSizeAndInverse.y; 
358var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
359fn computeShadowWithPCF5(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
360{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
361else
362{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; 
363uv+=0.5; 
364var st: vec2f=fract(uv); 
365var base_uv: vec2f=floor(uv)-0.5; 
366base_uv*=shadowMapSizeAndInverse.y; 
367var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
368const PoissonSamplers32: array<vec3f,64>=array<vec3f,64> (
369vec3f(0.06407013,0.05409927,0.),
370vec3f(0.7366577,0.5789394,0.),
371vec3f(-0.6270542,-0.5320278,0.),
372vec3f(-0.4096107,0.8411095,0.),
373vec3f(0.6849564,-0.4990818,0.),
374vec3f(-0.874181,-0.04579735,0.),
375vec3f(0.9989998,0.0009880066,0.),
376vec3f(-0.004920578,-0.9151649,0.),
377vec3f(0.1805763,0.9747483,0.),
378vec3f(-0.2138451,0.2635818,0.),
379vec3f(0.109845,0.3884785,0.),
380vec3f(0.06876755,-0.3581074,0.),
381vec3f(0.374073,-0.7661266,0.),
382vec3f(0.3079132,-0.1216763,0.),
383vec3f(-0.3794335,-0.8271583,0.),
384vec3f(-0.203878,-0.07715034,0.),
385vec3f(0.5912697,0.1469799,0.),
386vec3f(-0.88069,0.3031784,0.),
387vec3f(0.5040108,0.8283722,0.),
388vec3f(-0.5844124,0.5494877,0.),
389vec3f(0.6017799,-0.1726654,0.),
390vec3f(-0.5554981,0.1559997,0.),
391vec3f(-0.3016369,-0.3900928,0.),
392vec3f(-0.5550632,-0.1723762,0.),
393vec3f(0.925029,0.2995041,0.),
394vec3f(-0.2473137,0.5538505,0.),
395vec3f(0.9183037,-0.2862392,0.),
396vec3f(0.2469421,0.6718712,0.),
397vec3f(0.3916397,-0.4328209,0.),
398vec3f(-0.03576927,-0.6220032,0.),
399vec3f(-0.04661255,0.7995201,0.),
400vec3f(0.4402924,0.3640312,0.),
401vec3f(0.),
402vec3f(0.),
403vec3f(0.),
404vec3f(0.),
405vec3f(0.),
406vec3f(0.),
407vec3f(0.),
408vec3f(0.),
409vec3f(0.),
410vec3f(0.),
411vec3f(0.),
412vec3f(0.),
413vec3f(0.),
414vec3f(0.),
415vec3f(0.),
416vec3f(0.),
417vec3f(0.),
418vec3f(0.),
419vec3f(0.),
420vec3f(0.),
421vec3f(0.),
422vec3f(0.),
423vec3f(0.),
424vec3f(0.),
425vec3f(0.),
426vec3f(0.),
427vec3f(0.),
428vec3f(0.),
429vec3f(0.),
430vec3f(0.),
431vec3f(0.),
432vec3f(0.)
433);const PoissonSamplers64: array<vec3f,64>=array<vec3f,64> (
434vec3f(-0.613392,0.617481,0.),
435vec3f(0.170019,-0.040254,0.),
436vec3f(-0.299417,0.791925,0.),
437vec3f(0.645680,0.493210,0.),
438vec3f(-0.651784,0.717887,0.),
439vec3f(0.421003,0.027070,0.),
440vec3f(-0.817194,-0.271096,0.),
441vec3f(-0.705374,-0.668203,0.),
442vec3f(0.977050,-0.108615,0.),
443vec3f(0.063326,0.142369,0.),
444vec3f(0.203528,0.214331,0.),
445vec3f(-0.667531,0.326090,0.),
446vec3f(-0.098422,-0.295755,0.),
447vec3f(-0.885922,0.215369,0.),
448vec3f(0.566637,0.605213,0.),
449vec3f(0.039766,-0.396100,0.),
450vec3f(0.751946,0.453352,0.),
451vec3f(0.078707,-0.715323,0.),
452vec3f(-0.075838,-0.529344,0.),
453vec3f(0.724479,-0.580798,0.),
454vec3f(0.222999,-0.215125,0.),
455vec3f(-0.467574,-0.405438,0.),
456vec3f(-0.248268,-0.814753,0.),
457vec3f(0.354411,-0.887570,0.),
458vec3f(0.175817,0.382366,0.),
459vec3f(0.487472,-0.063082,0.),
460vec3f(-0.084078,0.898312,0.),
461vec3f(0.488876,-0.783441,0.),
462vec3f(0.470016,0.217933,0.),
463vec3f(-0.696890,-0.549791,0.),
464vec3f(-0.149693,0.605762,0.),
465vec3f(0.034211,0.979980,0.),
466vec3f(0.503098,-0.308878,0.),
467vec3f(-0.016205,-0.872921,0.),
468vec3f(0.385784,-0.393902,0.),
469vec3f(-0.146886,-0.859249,0.),
470vec3f(0.643361,0.164098,0.),
471vec3f(0.634388,-0.049471,0.),
472vec3f(-0.688894,0.007843,0.),
473vec3f(0.464034,-0.188818,0.),
474vec3f(-0.440840,0.137486,0.),
475vec3f(0.364483,0.511704,0.),
476vec3f(0.034028,0.325968,0.),
477vec3f(0.099094,-0.308023,0.),
478vec3f(0.693960,-0.366253,0.),
479vec3f(0.678884,-0.204688,0.),
480vec3f(0.001801,0.780328,0.),
481vec3f(0.145177,-0.898984,0.),
482vec3f(0.062655,-0.611866,0.),
483vec3f(0.315226,-0.604297,0.),
484vec3f(-0.780145,0.486251,0.),
485vec3f(-0.371868,0.882138,0.),
486vec3f(0.200476,0.494430,0.),
487vec3f(-0.494552,-0.711051,0.),
488vec3f(0.612476,0.705252,0.),
489vec3f(-0.578845,-0.768792,0.),
490vec3f(-0.772454,-0.090976,0.),
491vec3f(0.504440,0.372295,0.),
492vec3f(0.155736,0.065157,0.),
493vec3f(0.391522,0.849605,0.),
494vec3f(-0.620106,-0.328104,0.),
495vec3f(0.789239,-0.419965,0.),
496vec3f(-0.545396,0.538133,0.),
497vec3f(-0.178564,-0.596057,0.)
498);fn computeShadowWithCSMPCSS(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array<vec3f,64>,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
499{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uvDepthLayer: vec4f= vec4f(uvDepth.x,uvDepth.y,f32(layer),uvDepth.z);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;for (var i: i32=0; i<searchTapCount; i ++) {blockerDepth=textureSample(depthTexture,depthSampler, uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer).r;numBlocker+=select(0.,1.,blockerDepth<depthMetric);sumBlockerDepth+=select(0.,blockerDepth,blockerDepth<depthMetric);}
500var avgBlockerDepth: f32=sumBlockerDepth/numBlocker;var AAOffset: f32=shadowMapSizeInverse*10.;var penumbraRatio: f32=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);var filterRadius: vec4f= vec4f(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);var random: f32=getRand(vPositionFromLight.xy);var rotationAngle: f32=random*3.1415926;var rotationVector: vec2f= vec2f(cos(rotationAngle),sin(rotationAngle));var shadow: f32=0.;for (var i: i32=0; i<pcfTapCount; i++) {var offset: vec4f= vec4f(poissonSamplers[i],0.);offset= vec4f(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);let coords=uvDepthLayer+offset*filterRadius;shadow+=textureSampleCompare(shadowTexture,shadowSampler,coords.xy,i32(coords.z),coords.w);}
501shadow/= f32(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);return select(computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff),1.0,numBlocker<1.0);}
502fn computeShadowWithPCSS(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array<vec3f,64>)->f32
503{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;var exitCondition: bool=depthMetric>1.0 || depthMetric<0.0;for (var i: i32=0; i<searchTapCount; i ++) {if (exitCondition) {break;}
504blockerDepth=textureSampleLevel(depthTexture,depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0).r;numBlocker+=select(0.,1.,blockerDepth<depthMetric);sumBlockerDepth+=select(0.,blockerDepth,blockerDepth<depthMetric);}
505exitCondition=exitCondition || numBlocker<1.0;var avgBlockerDepth: f32=sumBlockerDepth/numBlocker;var AAOffset: f32=shadowMapSizeInverse*10.;var penumbraRatio: f32=((depthMetric-avgBlockerDepth)+AAOffset);var filterRadius: f32=penumbraRatio*lightSizeUV*shadowMapSizeInverse;var random: f32=getRand(vPositionFromLight.xy);var rotationAngle: f32=random*3.1415926;var rotationVector: vec2f= vec2f(cos(rotationAngle),sin(rotationAngle));var shadow: f32=0.;for (var i: i32=0; i<pcfTapCount; i++) {if (exitCondition) {break;}
506var offset: vec3f=poissonSamplers[i];offset= vec3f(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);let coords=uvDepth+offset*filterRadius;shadow+=textureSampleCompareLevel(shadowTexture,shadowSampler,coords.xy,coords.z);}
507shadow/= f32(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return select(computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff),1.0,exitCondition);}
508fn computeShadowWithPCSS16(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
509{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
510fn computeShadowWithPCSS32(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
511{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
512fn computeShadowWithPCSS64(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
513{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
514fn computeShadowWithCSMPCSS16(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
515{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
516fn computeShadowWithCSMPCSS32(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
517{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
518fn computeShadowWithCSMPCSS64(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
519{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
520#endif
521`;e.IncludesShadersStoreWGSL[s]||(e.IncludesShadersStoreWGSL[s]=
521X);const l="samplerFragmentDeclaration",N=`#ifdef _DEFINENAME_
522#if _DEFINENAME_DIRECTUV==1
523#define v_VARYINGNAME_UV vMainUV1
524#elif _DEFINENAME_DIRECTUV==2
525#define v_VARYINGNAME_UV vMainUV2
526#elif _DEFINENAME_DIRECTUV==3
527#define v_VARYINGNAME_UV vMainUV3
528#elif _DEFINENAME_DIRECTUV==4
529#define v_VARYINGNAME_UV vMainUV4
530#elif _DEFINENAME_DIRECTUV==5
531#define v_VARYINGNAME_UV vMainUV5
532#elif _DEFINENAME_DIRECTUV==6
533#define v_VARYINGNAME_UV vMainUV6
534#else
535varying v_VARYINGNAME_UV: vec2f;
536#endif
537var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d<f32>;
538#endif
539`;e.IncludesShadersStoreWGSL[l]||(e.IncludesShadersStoreWGSL[l]=N);const d="fresnelFunction",_=`#ifdef FRESNEL
540fn computeFresnelTerm(viewDirection: vec3f,worldNormal: vec3f,bias: f32,power: f32)->f32
541{let fresnelTerm: f32=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
542#endif
543`;e.IncludesShadersStoreWGSL[d]||(e.IncludesShadersStoreWGSL[d]=_);const c="reflectionFunction",R=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
544{var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0); }
545fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
546{var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(1.0-s,t,0); }
547fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
548{var cameraToVertex: vec3f=normalize(worldPos.xyz-eyePosition);var r: vec3f=normalize(reflect(cameraToVertex,worldNormal));r= (reflectionMatrix* vec4f(r,0)).xyz;var lon: f32=atan2(r.z,r.x);var lat: f32=acos(r.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0);}
549fn computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
550{var viewDir: vec3f=normalize((view*worldPos).xyz);var viewNormal: vec3f=normalize((view* vec4f(worldNormal,0.0)).xyz);var r: vec3f=reflect(viewDir,viewNormal);r= (reflectionMatrix* vec4f(r,0)).xyz;r.z=r.z-1.0;var m: f32=2.0*length(r);return vec3f(r.x/m+0.5,1.0-r.y/m-0.5,0);}
551fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
552{var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;}
553fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
554{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz;
555#ifdef INVERTCUBICMAP
556coords.y*=-1.0;
557#endif
558return coords;}
559fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f
560{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=(reflectionMatrix* vec4f(coords,0)).xyz;
561#ifdef INVERTCUBICMAP
562coords.y*=-1.0;
563#endif
564return coords;}
565fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
566{return (reflectionMatrix*(view*worldPos)).xyz;}
567fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f
568{return (reflectionMatrix* vec4f(positionW,1.)).xyz;}
569#ifdef REFLECTION
570fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f
571{
572#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
573var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
574#endif
575#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
576var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
577#endif
578#ifdef REFLECTIONMAP_EQUIRECTANGULAR
579return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
580#endif
581#ifdef REFLECTIONMAP_SPHERICAL
582return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix);
583#endif
584#ifdef REFLECTIONMAP_PLANAR
585return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
586#endif
587#ifdef REFLECTIONMAP_CUBIC
588#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
589return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition);
590#else
591return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
592#endif
593#endif
594#ifdef REFLECTIONMAP_PROJECTION
595return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix);
596#endif
597#ifndef REFLECTIONMAP_CUBIC
598#ifdef REFLECTIONMAP_SKYBOX
599return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix);
600#endif
601#endif
602#ifdef REFLECTIONMAP_EXPLICIT
603return vec3f(0,0,0);
604#endif
605}
606#endif
607`;e.IncludesShadersStoreWGSL[c]||(e.IncludesShadersStoreWGSL[c]=R);const v="imageProcessingDeclaration",M=`#ifdef EXPOSURE
608uniform exposureLinear: f32;
609#endif
610#ifdef CONTRAST
611uniform contrast: f32;
612#endif
613#if defined(VIGNETTE) || defined(DITHER)
614uniform vInverseScreenSize: vec2f;
615#endif
616#ifdef VIGNETTE
617uniform vignetteSettings1: vec4f;uniform vignetteSettings2: vec4f;
618#endif
619#ifdef COLORCURVES
620uniform vCameraColorCurveNegative: vec4f;uniform vCameraColorCurveNeutral: vec4f;uniform vCameraColorCurvePositive: vec4f;
621#endif
622#ifdef COLORGRADING
623#ifdef COLORGRADING3D
624var txColorTransformSampler: sampler;var txColorTransform: texture_3d<f32>;
625#else
626var txColorTransformSampler: sampler;var txColorTransform: texture_2d<f32>;
627#endif
628uniform colorTransformSettings: vec4f;
629#endif
630#ifdef DITHER
631uniform ditherIntensity: f32;
632#endif
633`;e.IncludesShadersStoreWGSL[v]||(e.IncludesShadersStoreWGSL[v]=M);const u="imageProcessingFunctions",y=`#if TONEMAPPING==3
634const PBRNeutralStartCompression: f32=0.8-0.04;const PBRNeutralDesaturation: f32=0.15;fn PBRNeutralToneMapping( color: vec3f )->vec3f {var x: f32=min(color.r,min(color.g,color.b));var offset: f32=select(0.04,x-6.25*x*x,x<0.08);var result=color;result-=offset;var peak: f32=max(result.r,max(result.g,result.b));if (peak<PBRNeutralStartCompression) {return result;}
635var d: f32=1.-PBRNeutralStartCompression;var newPeak: f32=1.-d*d/(peak+d-PBRNeutralStartCompression);result*=newPeak/peak;var g: f32=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(result,newPeak* vec3f(1,1,1),g);}
636#endif
637#if TONEMAPPING==2
638const ACESInputMat: mat3x3f= mat3x3f(
639vec3f(0.59719,0.07600,0.02840),
640vec3f(0.35458,0.90834,0.13383),
641vec3f(0.04823,0.01566,0.83777)
642);const ACESOutputMat: mat3x3f= mat3x3f(
643vec3f( 1.60475,-0.10208,-0.00327),
644vec3f(-0.53108, 1.10813,-0.07276),
645vec3f(-0.07367,-0.00605, 1.07602)
646);fn RRTAndODTFit(v: vec3f)->vec3f
647{var a: vec3f=v*(v+0.0245786)-0.000090537;var b: vec3f=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
648fn ACESFitted(color: vec3f)->vec3f
649{var output=ACESInputMat*color;output=RRTAndODTFit(output);output=ACESOutputMat*output;output=saturateVec3(output);return output;}
650#endif
651#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
652fn applyImageProcessing(result: vec4f)->vec4f {
653#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
654var rgb=result.rgb;;
655#ifdef EXPOSURE
656rgb*=uniforms.exposureLinear;
657#endif
658#ifdef VIGNETTE
659var viewportXY: vec2f=fragmentInputs.position.xy*uniforms.vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;var vignetteXY1: vec3f= vec3f(viewportXY*uniforms.vignetteSettings1.xy+uniforms.vignetteSettings1.zw,1.0);var vignetteTerm: f32=dot(vignetteXY1,vignetteXY1);var vignette: f32=pow(vignetteTerm,uniforms.vignetteSettings2.w);var vignetteColor: vec3f=uniforms.vignetteSettings2.rgb;
660#ifdef VIGNETTEBLENDMODEMULTIPLY
661var vignetteColorMultiplier: vec3f=mix(vignetteColor, vec3f(1,1,1),vignette);rgb*=vignetteColorMultiplier;
662#endif
663#ifdef VIGNETTEBLENDMODEOPAQUE
664rgb=mix(vignetteColor,rgb,vignette);
665#endif
666#endif
667#if TONEMAPPING==3
668rgb=PBRNeutralToneMapping(rgb);
669#elif TONEMAPPING==2
670rgb=ACESFitted(rgb);
671#elif TONEMAPPING==1
672const tonemappingCalibration: f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);
673#endif
674rgb=toGammaSpaceVec3(rgb);rgb=saturateVec3(rgb);
675#ifdef CONTRAST
676var resultHighContrast: vec3f=rgb*rgb*(3.0-2.0*rgb);if (uniforms.contrast<1.0) {rgb=mix( vec3f(0.5,0.5,0.5),rgb,uniforms.contrast);}
676 else {rgb=mix(rgb,resultHighContrast,uniforms.contrast-1.0);}
677rgb=max(rgb,vec3f(0.));
678#endif
679#ifdef COLORGRADING
680var colorTransformInput: vec3f=rgb*uniforms.colorTransformSettings.xxx+uniforms.colorTransformSettings.yyy;
681#ifdef COLORGRADING3D
682var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput).rgb;
683#else
684var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput,uniforms.colorTransformSettings.yz).rgb;
685#endif
686rgb=mix(rgb,colorTransformOutput,uniforms.colorTransformSettings.www);
687#endif
688#ifdef COLORCURVES
689var luma: f32=getLuminance(rgb);var curveMix: vec2f=clamp( vec2f(luma*3.0-1.5,luma*-3.0+1.5), vec2f(0.0), vec2f(1.0));var colorCurve: vec4f=uniforms.vCameraColorCurveNeutral+curveMix.x*uniforms.vCameraColorCurvePositive-curveMix.y*uniforms.vCameraColorCurveNegative;rgb*=colorCurve.rgb;rgb=mix( vec3f(luma),rgb,colorCurve.a);
690#endif
691#ifdef DITHER
692var rand: f32=getRand(fragmentInputs.position.xy*uniforms.vInverseScreenSize);var dither: f32=mix(-uniforms.ditherIntensity,uniforms.ditherIntensity,rand);rgb=saturateVec3(rgb+ vec3f(dither));
693#endif
694#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
695return vec4f(rgb,result.a);}`;e.IncludesShadersStoreWGSL[u]||(e.IncludesShadersStoreWGSL[u]=y);const p="bumpFragmentMainFunctions",O=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
696#if defined(TANGENT) && defined(NORMAL) 
697varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
698#endif
699#ifdef OBJECTSPACE_NORMALMAP
700uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f
701{var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0]; 
702var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0]; 
703var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4<f32>(
704(a11*b11-a12*b10+a13*b09)/det,
705(a02*b10-a01*b11-a03*b09)/det,
706(a31*b05-a32*b04+a33*b03)/det,
707(a22*b04-a21*b05-a23*b03)/det,
708(a12*b08-a10*b11-a13*b07)/det,
709(a00*b11-a02*b08+a03*b07)/det,
710(a32*b02-a30*b05-a33*b01)/det,
711(a20*b05-a22*b02+a23*b01)/det,
712(a10*b10-a11*b08+a13*b06)/det,
713(a01*b08-a00*b10-a03*b06)/det,
714(a30*b04-a31*b02+a33*b00)/det,
715(a21*b02-a20*b04-a23*b00)/det,
716(a11*b07-a10*b09-a12*b06)/det,
717(a00*b09-a01*b07+a02*b06)/det,
718(a31*b01-a30*b03-a32*b00)/det,
719(a20*b03-a21*b01+a22*b00)/det);return mat4x4<f32>(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
720mi[0][1],mi[1][1],mi[2][1],mi[3][1],
721mi[0][2],mi[1][2],mi[2][2],mi[3][2],
722mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
723#endif
724fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f
725{var output=normal;
726#ifdef NORMALXYSCALE
727output=normalize(output* vec3f(scale,scale,1.0));
728#endif
729return normalize(cotangentFrame*output);}
730fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f
731{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
732fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f
733{var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);}
734#endif
735`;e.IncludesShadersStoreWGSL[p]||(e.IncludesShadersStoreWGSL[p]=O);const h="bumpFragmentFunctions",F=`#if defined(BUMP)
736#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
737#endif
738#if defined(DETAIL)
739#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
740#endif
741#if defined(BUMP) && defined(PARALLAX)
742const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; i<iMaxSamples; i++)
743{currSampledHeight=textureSample(bumpSampler,bumpSamplerSampler,texCoord+vCurrOffset).w;if (!keepWorking)
744{}
745else if (currSampledHeight>currRayHeight)
746{var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
747else
748{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
749#ifdef PARALLAX_RHS
750vCurrOffset-=stepSize*vMaxOffset;
751#else
752vCurrOffset+=stepSize*vMaxOffset;
753#endif
754lastSampledHeight=currSampledHeight;}}
755return vCurrOffset;}
756fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f
757{var height: f32=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).w;
757var texCoordOffset: vec2f=heightScale*viewDir.xy*height;
758#ifdef PARALLAX_RHS
759return texCoordOffset;
760#else
761return -texCoordOffset;
762#endif
763}
764#endif
765`;e.IncludesShadersStoreWGSL[h]||(e.IncludesShadersStoreWGSL[h]=F);const m="bumpFragment",b=`var uvOffset: vec2f= vec2f(0.0,0.0);
766#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
767#ifdef NORMALXYSCALE
768var normalScale: f32=1.0;
769#elif defined(BUMP)
770var normalScale: f32=uniforms.vBumpInfos.y;
771#else
772var normalScale: f32=1.0;
773#endif
774#if defined(TANGENT) && defined(NORMAL)
775var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2); 
776#elif defined(BUMP)
777var TBNUV: vec2f=select(-fragmentInputs.vBumpUV,fragmentInputs.vBumpUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
778#else
779var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.));
780#endif
781#elif defined(ANISOTROPIC)
782#if defined(TANGENT) && defined(NORMAL)
783var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2); 
784#else
785var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.));
786#endif
787#endif
788#ifdef PARALLAX
789var invTBN: mat3x3f=transposeMat3(TBN);
790#ifdef PARALLAXOCCLUSION
791uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,fragmentInputs.vBumpUV,uniforms.vBumpInfos.z);
792#else
793uvOffset=parallaxOffset(invTBN*viewDirectionW,uniforms.vBumpInfos.z);
794#endif
795#endif
796#ifdef DETAIL
797var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB);
798#endif
799#ifdef BUMP
800#ifdef OBJECTSPACE_NORMALMAP
801#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
802normalW=normalize(textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW);
803#elif !defined(DETAIL)
804normalW=perturbNormal(TBN,textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz,uniforms.vBumpInfos.y);
805#else
806var bumpNormal: vec3f=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz*2.0-1.0;
807#if DETAIL_NORMALBLENDMETHOD==0 
808detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
809#elif DETAIL_NORMALBLENDMETHOD==1 
810detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);bumpNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
811#endif
812normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y);
813#endif
814#elif defined(DETAIL)
815detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z);
816#endif
817`;e.IncludesShadersStoreWGSL[m]||(e.IncludesShadersStoreWGSL[m]=b);const S="decalFragment",W=`#ifdef DECAL
818var decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a;
819#ifdef GAMMADECAL
820decalTempColor=toLinearSpaceVec3(decalColor.rgb);
821#endif
822#ifdef DECAL_SMOOTHALPHA
823decalTempAlpha=decalColor.a*decalColor.a;
824#endif
825surfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha);
826#endif
827`;e.IncludesShadersStoreWGSL[S]||(e.IncludesShadersStoreWGSL[S]=W);const g="depthPrePass",U=`#ifdef DEPTHPREPASS
828fragmentOutputs.color= vec4f(0.,0.,0.,1.0);return fragmentOutputs;
829#endif
830`;e.IncludesShadersStoreWGSL[g]||(e.IncludesShadersStoreWGSL[g]=U);const x="lightFragment",z=`#ifdef LIGHT{X}
831#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
832#else
833var diffuse{X}: vec4f=light{X}.vLightDiffuse;
834#define CUSTOM_LIGHT{X}_COLOR 
835#if defined(PBR) && defined(CLUSTLIGHT{X})
836{let sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,fragmentInputs.vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(
837lightDataTexture{X},
838&tileMaskBuffer{X},
839light{X}.vLightData,
840vec2u(light{X}.vSliceRanges[sliceIndex].xy),
841viewDirectionW,
842normalW,
843fragmentInputs.vPositionW,
844surfaceAlbedo,
845reflectivityOut,
846#ifdef IRIDESCENCE
847iridescenceIntensity,
848#endif
849#ifdef SS_TRANSLUCENCY
850subSurfaceOut,
851#endif
852#ifdef SPECULARTERM
853AARoughnessFactors.x,
854#endif
855#ifdef ANISOTROPIC
856anisotropicOut,
857#endif
858#ifdef SHEEN
859sheenOut,
860#endif
861#ifdef CLEARCOAT
862clearcoatOut,
863#endif
864);}
865#elif defined(PBR)
866#ifdef SPOTLIGHT{X}
867preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);
868#elif defined(POINTLIGHT{X})
869preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);
870#elif defined(HEMILIGHT{X})
871preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
872#elif defined(DIRLIGHT{X})
873preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
874#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)
875preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
876#endif
877preInfo.NdotV=NdotV;
878#ifdef SPOTLIGHT{X}
879#ifdef LIGHT_FALLOFF_GLTF{X}
880preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
881#ifdef IESLIGHTTEXTURE{X}
882preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
883#else
884preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
885#endif
886#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
887preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
888#ifdef IESLIGHTTEXTURE{X}
889preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
890#else
891preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
892#endif
893#elif defined(LIGHT_FALLOFF_STANDARD{X})
894preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
895#ifdef IESLIGHTTEXTURE{X}
896preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
897#else
898preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
899#endif
900#else
901preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
902#ifdef IESLIGHTTEXTURE{X}
903preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
904#else
905preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
906#endif
907#endif
908#elif defined(POINTLIGHT{X})
909#ifdef LIGHT_FALLOFF_GLTF{X}
910preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
911#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
912preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
913#elif defined(LIGHT_FALLOFF_STANDARD{X})
914preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
915#else
916preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
917#endif
918#else
919preInfo.attenuation=1.0;
920#endif
921#if defined(HEMILIGHT{X}) || defined(AREALIGHT{X})
922preInfo.roughness=roughness;
923#else
924preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
925#endif
926preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
927#ifdef IRIDESCENCE
928preInfo.iridescenceIntensity=iridescenceIntensity;
929#endif
930#ifdef SS_TRANSLUCENCY
931info.diffuseTransmission=vec3f(0.0);
932#endif
933#ifdef HEMILIGHT{X}
934info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround);
935#elif defined(AREALIGHT{X})
936info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb);
937#elif defined(SS_TRANSLUCENCY)
938#ifndef SS_TRANSLUCENCY_LEGACY
939info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); 
940#else
941info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
942#endif
943#else
944info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb);
945#endif
946#ifdef SPECULARTERM
947#if AREALIGHT{X}
948info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
949#else
950#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
951{let metalFresnel: vec3f=vec3f(reflectivityOut.specularWeight)*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricFresnel: vec3f=fresnelSchlickGGXVec3(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);}
952#else
953coloredFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
954#endif
955#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
956{let NdotH: f32=dot(normalW,preInfo.H);let fresnel: vec3f=fresnelSchlickGGXVec3(NdotH,vec3f(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3f(1.0)-fresnel);}
957#endif
958#ifdef ANISOTROPIC
959info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
960#else
961info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb);
962#endif
963#endif
964#endif
965#ifndef AREALIGHT{X}
966#ifdef SHEEN
967#ifdef SHEEN_LINKWITHALBEDO
968preInfo.roughness=sheenOut.sheenIntensity;
969#else
970#ifdef HEMILIGHT{X}
971preInfo.roughness=sheenOut.sheenRoughness;
972#else
973preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
974#endif
975#endif
976info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
977#endif
978#ifdef CLEARCOAT
979#ifdef HEMILIGHT{X}
980preInfo.roughness=clearcoatOut.clearCoatRoughness;
981#else
982preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
983#endif
984info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb);
985#ifdef CLEARCOAT_TINT
986absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
987#ifdef SS_TRANSLUCENCY
988info.diffuseTransmission*=absorption;
989#endif
990#ifdef SPECULARTERM
991info.specular*=absorption;
992#endif
993#endif
994info.diffuse*=info.clearCoat.w;
995#ifdef SS_TRANSLUCENCY
996info.diffuseTransmission*=info.clearCoat.w;
997#endif
998#ifdef SPECULARTERM
999info.specular*=info.clearCoat.w;
1000#endif
1001#ifdef SHEEN
1002info.sheen*=info.clearCoat.w;
1003#endif
1004#endif
1005#endif
1006#else
1007#ifdef SPOTLIGHT{X}
1008#ifdef IESLIGHTTEXTURE{X}
1009info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X},iesLightTexture{X}Sampler);
1010#else
1011info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
1012#endif
1013#elif defined(HEMILIGHT{X})
1014info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
1015#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
1016info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
1017#elif define(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)
1018info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
1019#ifdef AREALIGHTNOROUGHTNESS
10200.5
1021#else
1022uniforms.vReflectionInfos.y
1023#endif
1024);
1025#elif defined(CLUSTLIGHT{X})
1026{let sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,fragmentInputs.vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},&tileMaskBuffer{X},viewDirectionW,normalW,light{X}.vLightData,vec2u(light{X}.vSliceRanges[sliceIndex].xy),glossiness);}
1027#endif
1028#endif
1029#ifdef PROJECTEDLIGHTTEXTURE{X}
1030info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,uniforms.textureProjectionMatrix{X},fragmentInputs.vPositionW);
1031#endif
1032#endif
1033#ifdef SHADOW{X}
1034#ifdef SHADOWCSMDEBUG{X}
1035var shadowDebug{X}: vec3f;
1036#endif
1037#ifdef SHADOWCSM{X}
1038#ifdef SHADOWCSMUSESHADOWMAXZ{X}
1039var index{X}: i32=-1;
1040#else
1041var index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1;
1042#endif
1043var diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
1044{
1045#ifdef SHADOWCSM_RIGHTHANDED{X}
1046diff{X}=uniforms.viewFrustumZ{X}[i]+fragmentInputs.vPositionFromCamera{X}.z;
1047#else
1048diff{X}=uniforms.viewFrustumZ{X}[i]-fragmentInputs.vPositionFromCamera{X}.z;
1049#endif
1050if (diff{X}>=0.) {index{X}=i;break;}}
1051#ifdef SHADOWCSMUSESHADOWMAXZ{X}
1052if (index{X}>=0)
1053#endif
1054{
1055#if defined(SHADOWPCF{X})
1056#if defined(SHADOWLOWQUALITY{X})
1057shadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1058#elif defined(SHADOWMEDIUMQUALITY{X})
1059shadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1060#else
1061shadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1062#endif
1063#elif defined(SHADOWPCSS{X})
1064#if defined(SHADOWLOWQUALITY{X})
1065shadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
1066#elif defined(SHADOWMEDIUMQUALITY{X})
1067shadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
1068#else
1069shadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
1070#endif
1071#else
1072shadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1073#endif
1074#ifdef SHADOWCSMDEBUG{X}
1075shadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}];
1076#endif
1077#ifndef SHADOWCSMNOBLEND{X}
1078var frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
1079{index{X}+=1;var nextShadow: f32=0.;
1080#if defined(SHADOWPCF{X})
1081#if defined(SHADOWLOWQUALITY{X})
1082nextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1083#elif defined(SHADOWMEDIUMQUALITY{X})
1084nextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1085#else
1086nextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1087#endif
1088#elif defined(SHADOWPCSS{X})
1089#if defined(SHADOWLOWQUALITY{X})
1090nextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
1091#elif defined(SHADOWMEDIUMQUALITY{X})
1092nextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
1093#else
1094nextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
1095#endif
1096#else
1097nextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1098#endif
1099shadow=mix(nextShadow,shadow,diffRatio);
1100#ifdef SHADOWCSMDEBUG{X}
1101shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
1102#endif
1103}
1104#endif
1105}
1106#elif defined(SHADOWCLOSEESM{X})
1107#if defined(SHADOWCUBE{X})
1108shadow=computeShadowWithCloseESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
1109#else
1110shadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
1111#endif
1112#elif defined(SHADOWESM{X})
1113#if defined(SHADOWCUBE{X})
1114shadow=computeShadowWithESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
1115#else
1116shadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
1117#endif
1118#elif defined(SHADOWPOISSON{X})
1119#if defined(SHADOWCUBE{X})
1120shadow=computeShadowWithPoissonSamplingCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
1121#else
1122shadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1123#endif
1124#elif defined(SHADOWPCF{X})
1125#if defined(SHADOWLOWQUALITY{X})
1126shadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1127#elif defined(SHADOWMEDIUMQUALITY{X})
1128shadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1129#else
1130shadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1131#endif
1132#elif defined(SHADOWPCSS{X})
1133#if defined(SHADOWLOWQUALITY{X})
1134shadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1135#elif defined(SHADOWMEDIUMQUALITY{X})
1136shadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1137#else
1138shadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1139#endif
1140#else
1141#if defined(SHADOWCUBE{X})
1142shadow=computeShadowCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues);
1143#else
1144shadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
1145#endif
1146#endif
1147#ifdef SHADOWONLY
1148#ifndef SHADOWINUSE
1149#define SHADOWINUSE
1150#endif
1151globalShadow+=shadow;shadowLightCount+=1.0;
1152#endif
1153#else
1154shadow=1.;
1155#endif
1156aggShadow+=shadow;numLights+=1.0;
1157#ifndef SHADOWONLY
1158#ifdef CUSTOMUSERLIGHTING
1159diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
1160#ifdef SPECULARTERM
1161specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
1162#endif
1163#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
1164diffuseBase+=lightmapColor.rgb*shadow;
1165#ifdef SPECULARTERM
1166#ifndef LIGHTMAPNOSPECULAR{X}
1167specularBase+=info.specular*shadow*lightmapColor.rgb;
1168#endif
1169#endif
1170#ifdef CLEARCOAT
1171#ifndef LIGHTMAPNOSPECULAR{X}
1172clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
1173#endif
1174#endif
1175#ifdef SHEEN
1176#ifndef LIGHTMAPNOSPECULAR{X}
1177sheenBase+=info.sheen.rgb*shadow;
1178#endif
1179#endif
1180#else
1181#ifdef SHADOWCSMDEBUG{X}
1182diffuseBase+=info.diffuse*shadowDebug{X};
1183#else
1184diffuseBase+=info.diffuse*shadow;
1185#endif
1186#ifdef SS_TRANSLUCENCY
1187diffuseTransmissionBase+=info.diffuseTransmission*shadow;
1188#endif
1189#ifdef SPECULARTERM
1190specularBase+=info.specular*shadow;
1191#endif
1192#ifdef CLEARCOAT
1193clearCoatBase+=info.clearCoat.rgb*shadow;
1194#endif
1195#ifdef SHEEN
1196sheenBase+=info.sheen.rgb*shadow;
1197#endif
1198#endif
1199#endif
1200#endif
1201`;
1201e.IncludesShadersStoreWGSL[x]||(e.IncludesShadersStoreWGSL[x]=z);const C="logDepthFragment",G=`#ifdef LOGARITHMICDEPTH
1202fragmentOutputs.fragDepth=log2(fragmentInputs.vFragmentDepth)*uniforms.logarithmicDepthConstant*0.5;
1203#endif
1204`;e.IncludesShadersStoreWGSL[C]||(e.IncludesShadersStoreWGSL[C]=G);const w="oitFragment",H=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
1205var fragDepth: f32=fragmentInputs.position.z; 
1206#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
1207var halfFloat: u32=pack2x16float( vec2f(fragDepth));var full: vec2f=unpack2x16float(halfFloat);fragDepth=full.x;
1208#endif
1209var fragCoord: vec2i=vec2i(fragmentInputs.position.xy);var lastDepth: vec2f=textureLoad(oitDepthSampler,fragCoord,0).rg;var lastFrontColor: vec4f=textureLoad(oitFrontColorSampler,fragCoord,0);fragmentOutputs.depth=vec2f(-MAX_DEPTH);fragmentOutputs.frontColor=lastFrontColor;fragmentOutputs.backColor= vec4f(0.0);
1210#ifdef USE_REVERSE_DEPTHBUFFER
1211var furthestDepth: f32=-lastDepth.x;var nearestDepth: f32=lastDepth.y;
1212#else
1213var nearestDepth: f32=-lastDepth.x;var furthestDepth: f32=lastDepth.y;
1214#endif
1215var alphaMultiplier: f32=1.0-lastFrontColor.a;
1216#ifdef USE_REVERSE_DEPTHBUFFER
1217if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
1218#else
1219if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
1220#endif
1221return fragmentOutputs;}
1222#ifdef USE_REVERSE_DEPTHBUFFER
1223if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
1224#else
1225if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
1226#endif
1227fragmentOutputs.depth=vec2f(-fragDepth,fragDepth);return fragmentOutputs;}
1228#endif
1229`;e.IncludesShadersStoreWGSL[w]||(e.IncludesShadersStoreWGSL[w]=H);const r="defaultPixelShader",L=`#include<defaultUboDeclaration>
1230#include<prePassDeclaration>[SCENE_MRT_COUNT]
1231#include<oitDeclaration>
1232#define CUSTOM_FRAGMENT_BEGIN
1233varying vPositionW: vec3f;
1234#ifdef NORMAL
1235varying vNormalW: vec3f;
1236#endif
1237#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1238varying vColor: vec4f;
1239#endif
1240#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1241varying vViewDepth: f32;
1242#endif
1243#include<mainUVVaryingDeclaration>[1..7]
1244#include<helperFunctions>
1245#include<lightUboDeclaration>[0..maxSimultaneousLights]
1246#include<lightsFragmentFunctions>
1247#include<shadowsFragmentFunctions>
1248#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
1249#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
1250#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
1251#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
1252#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
1253#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
1254#ifdef REFRACTION
1255#ifdef REFRACTIONMAP_3D
1256var refractionCubeSamplerSampler: sampler;var refractionCubeSampler: texture_cube<f32>;
1257#else
1258var refraction2DSamplerSampler: sampler;var refraction2DSampler: texture_2d<f32>;
1259#endif
1260#endif
1261#if defined(SPECULARTERM)
1262#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
1263#endif
1264#include<fresnelFunction>
1265#ifdef REFLECTION
1266#ifdef REFLECTIONMAP_3D
1267var reflectionCubeSamplerSampler: sampler;var reflectionCubeSampler: texture_cube<f32>;
1268#else
1269var reflection2DSamplerSampler: sampler;var reflection2DSampler: texture_2d<f32>;
1270#endif
1271#ifdef REFLECTIONMAP_SKYBOX
1272varying vPositionUVW: vec3f;
1273#else
1274#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
1275varying vDirectionW: vec3f;
1276#endif
1277#endif
1278#include<reflectionFunction>
1279#endif
1280#include<imageProcessingDeclaration>
1281#include<imageProcessingFunctions>
1282#include<bumpFragmentMainFunctions>
1283#include<bumpFragmentFunctions>
1284#include<clipPlaneFragmentDeclaration>
1285#include<logDepthDeclaration>
1286#include<fogFragmentDeclaration>
1287#define CUSTOM_FRAGMENT_DEFINITIONS
1288@fragment
1289fn main(input: FragmentInputs)->FragmentOutputs {
1290#define CUSTOM_FRAGMENT_MAIN_BEGIN
1291#include<clipPlaneFragment>
1292var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-fragmentInputs.vPositionW);var baseColor: vec4f= vec4f(1.,1.,1.,1.);var diffuseColor: vec3f=uniforms.vDiffuseColor.rgb;var alpha: f32=uniforms.vDiffuseColor.a;
1293#ifdef NORMAL
1294var normalW: vec3f=normalize(fragmentInputs.vNormalW);
1295#else
1296var normalW: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))* scene.vEyePosition.w;
1297#endif
1298#include<bumpFragment>
1299#ifdef TWOSIDEDLIGHTING
1300normalW=select(-normalW,normalW,fragmentInputs.frontFacing);
1301#endif
1302#ifdef DIFFUSE
1303baseColor=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vDiffuseUV+uvOffset);
1304#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
1305if (baseColor.a<uniforms.alphaCutOff) {discard;}
1306#endif
1307#ifdef ALPHAFROMDIFFUSE
1308alpha*=baseColor.a;
1309#endif
1310#define CUSTOM_FRAGMENT_UPDATE_ALPHA
1311baseColor=vec4f(baseColor.rgb*uniforms.vDiffuseInfos.y,baseColor.a);
1312#endif
1313#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
1314var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
1315#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
1316#endif
1317#include<depthPrePass>
1318#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1319baseColor=vec4f(baseColor.rgb*fragmentInputs.vColor.rgb,baseColor.a);
1320#endif
1321#ifdef DETAIL
1322baseColor=vec4f(baseColor.rgb*2.0*mix(0.5,detailColor.r,uniforms.vDetailInfos.y),baseColor.a);
1323#endif
1324#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
1325var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
1326#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
1327#endif
1328#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
1329var baseAmbientColor: vec3f= vec3f(1.,1.,1.);
1330#ifdef AMBIENT
1331baseAmbientColor=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb*uniforms.vAmbientInfos.y;
1332#endif
1333#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
1334var glossiness: f32=uniforms.vSpecularColor.a;var specularColor: vec3f=uniforms.vSpecularColor.rgb;
1335#ifdef SPECULARTERM
1336#ifdef SPECULAR
1337var specularMapColor: vec4f=textureSample(specularSampler,specularSamplerSampler,fragmentInputs.vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
1338#ifdef GLOSSINESS
1339glossiness=glossiness*specularMapColor.a;
1340#endif
1341#endif
1342#endif
1343var diffuseBase: vec3f= vec3f(0.,0.,0.);var info: lightingInfo;
1344#ifdef SPECULARTERM
1345var specularBase: vec3f= vec3f(0.,0.,0.);
1346#endif
1347var shadow: f32=1.;var aggShadow: f32=0.;var numLights: f32=0.;
1348#ifdef LIGHTMAP
1349var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset);
1350#ifdef RGBDLIGHTMAP
1351lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a);
1352#endif
1353lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a);
1354#endif
1355#include<lightFragment>[0..maxSimultaneousLights]
1356aggShadow=aggShadow/numLights;var refractionColor: vec4f= vec4f(0.,0.,0.,1.);
1357#ifdef REFRACTION
1358var refractionVector: vec3f=normalize(refract(-viewDirectionW,normalW,uniforms.vRefractionInfos.y));
1359#ifdef REFRACTIONMAP_3D
1360#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
1361refractionVector=parallaxCorrectNormal(fragmentInputs.vPositionW,refractionVector,uniforms.vRefractionSize,uniforms.vRefractionPosition);
1362#endif
1363refractionVector.y=refractionVector.y*uniforms.vRefractionInfos.w;var refractionLookup: vec4f=textureSample(refractionCubeSampler,refractionCubeSamplerSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
1364#else
1365var vRefractionUVW: vec3f= (uniforms.refractionMatrix*(scene.view* vec4f(fragmentInputs.vPositionW+refractionVector*uniforms.vRefractionInfos.z,1.0))).xyz;var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=textureSample(refraction2DSampler,refraction2DSamplerSampler,refractionCoords);
1366#endif
1367#ifdef RGBDREFRACTION
1368refractionColor=vec4f(fromRGBD(refractionColor),refractionColor.a);
1369#endif
1370#ifdef IS_REFRACTION_LINEAR
1371refractionColor=vec4f(toGammaSpaceVec3(refractionColor.rgb),refractionColor.a);
1372#endif
1373refractionColor=vec4f(refractionColor.rgb*uniforms.vRefractionInfos.x,refractionColor.a);
1374#endif
1375var reflectionColor: vec4f= vec4f(0.,0.,0.,1.);
1376#ifdef REFLECTION
1377var vReflectionUVW: vec3f=computeReflectionCoords( vec4f(fragmentInputs.vPositionW,1.0),normalW);
1378#ifdef REFLECTIONMAP_OPPOSITEZ
1379vReflectionUVW=vec3f(vReflectionUVW.x,vReflectionUVW.y,vReflectionUVW.z*-1.0);
1380#endif
1381#ifdef REFLECTIONMAP_3D
1382#ifdef ROUGHNESS
1383var bias: f32=uniforms.vReflectionInfos.y;
1384#ifdef SPECULARTERM
1385#ifdef SPECULAR
1386#ifdef GLOSSINESS
1387bias*=(1.0-specularMapColor.a);
1388#endif
1389#endif
1390#endif
1391reflectionColor=textureSampleLevel(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW,bias);
1392#else
1393reflectionColor=textureSample(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW);
1394#endif
1395#else
1396var coords: vec2f=vReflectionUVW.xy;
1397#ifdef REFLECTIONMAP_PROJECTION
1398coords/=vReflectionUVW.z;
1399#endif
1400coords.y=1.0-coords.y;reflectionColor=textureSample(reflection2DSampler,reflection2DSamplerSampler,coords);
1401#endif
1402#ifdef RGBDREFLECTION
1403reflectionColor=vec4f(fromRGBD(reflectionColor),reflectionColor.a);
1404#endif
1405#ifdef IS_REFLECTION_LINEAR
1406reflectionColor=vec4f(toGammaSpaceVec3(reflectionColor.rgb),reflectionColor.a);
1407#endif
1408reflectionColor=vec4f(reflectionColor.rgb*uniforms.vReflectionInfos.x,reflectionColor.a);
1409#ifdef REFLECTIONFRESNEL
1410var reflectionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.reflectionRightColor.a,uniforms.reflectionLeftColor.a);
1411#ifdef REFLECTIONFRESNELFROMSPECULAR
1412#ifdef SPECULARTERM
1413reflectionColor=vec4f(reflectionColor.rgb*specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
1414#else
1415reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
1416#endif
1417#else
1418reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
1419#endif
1420#endif
1421#endif
1422#ifdef REFRACTIONFRESNEL
1423var refractionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.refractionRightColor.a,uniforms.refractionLeftColor.a);refractionColor=vec4f(refractionColor.rgb*uniforms.refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*uniforms.refractionRightColor.rgb,refractionColor.a);
1424#endif
1425#ifdef OPACITY
1426var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
1427#ifdef OPACITYRGB
1428opacityMap=vec4f(opacityMap.rgb* vec3f(0.3,0.59,0.11),opacityMap.a);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* uniforms.vOpacityInfos.y;
1429#else
1430alpha*=opacityMap.a*uniforms.vOpacityInfos.y;
1431#endif
1432#endif
1433#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1434alpha*=fragmentInputs.vColor.a;
1435#endif
1436#ifdef OPACITYFRESNEL
1437var opacityFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.opacityParts.z,uniforms.opacityParts.w);alpha+=uniforms.opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*uniforms.opacityParts.y;
1438#endif
1439#ifdef ALPHATEST
1440#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
1441if (alpha<uniforms.alphaCutOff) {discard;}
1442#endif
1443#ifndef ALPHABLEND
1444alpha=1.0;
1445#endif
1446#endif
1447var emissiveColor: vec3f=uniforms.vEmissiveColor;
1448#ifdef EMISSIVE
1449emissiveColor+=textureSample(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb*uniforms.vEmissiveInfos.y;
1450#endif
1451#ifdef EMISSIVEFRESNEL
1452var emissiveFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.emissiveRightColor.a,uniforms.emissiveLeftColor.a);emissiveColor*=uniforms.emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*uniforms.emissiveRightColor.rgb;
1453#endif
1454#ifdef DIFFUSEFRESNEL
1455var diffuseFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.diffuseRightColor.a,uniforms.diffuseLeftColor.a);diffuseBase*=uniforms.diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*uniforms.diffuseRightColor.rgb;
1456#endif
1457#ifdef EMISSIVEASILLUMINATION
1458var finalDiffuse: vec3f=clamp(diffuseBase*diffuseColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
1459#else
1460#ifdef LINKEMISSIVEWITHDIFFUSE
1461var finalDiffuse: vec3f=clamp((diffuseBase+emissiveColor)*diffuseColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
1462#else
1463var finalDiffuse: vec3f=clamp(diffuseBase*diffuseColor+emissiveColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
1464#endif
1465#endif
1466#ifdef SPECULARTERM
1467var finalSpecular: vec3f=specularBase*specularColor;
1468#ifdef SPECULAROVERALPHA
1469alpha=clamp(alpha+dot(finalSpecular, vec3f(0.3,0.59,0.11)),0.0,1.0);
1470#endif
1471#else
1472var finalSpecular: vec3f= vec3f(0.0);
1473#endif
1474#ifdef REFLECTIONOVERALPHA
1475alpha=clamp(alpha+dot(reflectionColor.rgb, vec3f(0.3,0.59,0.11)),0.0,1.0);
1476#endif
1477#ifdef EMISSIVEASILLUMINATION
1478var color: vec4f= vec4f(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
1479#else
1480var color: vec4f= vec4f(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
1481#endif
1482#ifdef LIGHTMAP
1483#ifndef LIGHTMAPEXCLUDED
1484#ifdef USELIGHTMAPASSHADOWMAP
1485color=vec4f(color.rgb*lightmapColor.rgb,color.a);
1486#else
1487color=vec4f(color.rgb+lightmapColor.rgb,color.a);
1488#endif
1489#endif
1490#endif
1491#define CUSTOM_FRAGMENT_BEFORE_FOG
1492color=vec4f(max(color.rgb,vec3f(0.)),color.a);
1493#include<logDepthFragment>
1494#include<fogFragment>
1495#ifdef IMAGEPROCESSINGPOSTPROCESS
1496color=vec4f(toLinearSpaceVec3(color.rgb),color.a);
1497#else
1498#ifdef IMAGEPROCESSING
1499color=vec4f(toLinearSpaceVec3(color.rgb),color.a);color=applyImageProcessing(color);
1500#endif
1501#endif
1502color=vec4f(color.rgb,color.a*mesh.visibility);
1503#ifdef PREMULTIPLYALPHA
1504color=vec4f(color.rgb*color.a, color.a);
1505#endif
1506#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
1507#ifdef PREPASS
1508#if SCENE_MRT_COUNT>0
1509var writeGeometryInfo: f32=select(0.0,1.0,color.a>0.4);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
1510#ifdef PREPASS_COLOR
1511fragData[PREPASS_COLOR_INDEX]=color; 
1512#endif
1513#ifdef PREPASS_POSITION
1514fragData[PREPASS_POSITION_INDEX]=vec4f(fragmentInputs.vPositionW,writeGeometryInfo);
1515#endif
1516#ifdef PREPASS_LOCAL_POSITION
1517fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo);
1518#endif
1519#ifdef PREPASS_VELOCITY
1520var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo);
1521#elif defined(PREPASS_VELOCITY_LINEAR)
1522var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) -
1523(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo);
1524#endif
1525#ifdef PREPASS_IRRADIANCE
1526fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(0.0,0.0,0.0,writeGeometryInfo); 
1527#endif
1528#ifdef PREPASS_DEPTH
1529fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo); 
1530#endif
1531#ifdef PREPASS_SCREENSPACE_DEPTH
1532fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo);
1533#endif
1534#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
1535fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo);
1536#endif
1537#ifdef PREPASS_NORMAL
1538#ifdef PREPASS_NORMAL_WORLDSPACE
1539fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo);
1540#else
1541fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo);
1542#endif
1543#endif
1544#ifdef PREPASS_WORLD_NORMAL
1545fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo);
1546#endif
1547#ifdef PREPASS_ALBEDO
1548fragData[PREPASS_ALBEDO_INDEX]=vec4f(baseColor.rgb,writeGeometryInfo);
1549#endif
1550#ifdef PREPASS_ALBEDO_SQRT
1551fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqrt(baseColor.rgb),writeGeometryInfo);
1552#endif
1553#ifdef PREPASS_REFLECTIVITY
1554#if defined(SPECULAR)
1555fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(toLinearSpaceVec4(specularMapColor))*writeGeometryInfo; 
1556#else
1557fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(toLinearSpaceVec3(specularColor),1.0)*writeGeometryInfo;
1558#endif
1559#endif
1560#if SCENE_MRT_COUNT>0
1561fragmentOutputs.fragData0=fragData[0];
1562#endif
1563#if SCENE_MRT_COUNT>1
1564fragmentOutputs.fragData1=fragData[1];
1565#endif
1566#if SCENE_MRT_COUNT>2
1567fragmentOutputs.fragData2=fragData[2];
1568#endif
1569#if SCENE_MRT_COUNT>3
1570fragmentOutputs.fragData3=fragData[3];
1571#endif
1572#if SCENE_MRT_COUNT>4
1573fragmentOutputs.fragData4=fragData[4];
1574#endif
1575#if SCENE_MRT_COUNT>5
1576fragmentOutputs.fragData5=fragData[5];
1577#endif
1578#if SCENE_MRT_COUNT>6
1579fragmentOutputs.fragData6=fragData[6];
1580#endif
1581#if SCENE_MRT_COUNT>7
1582fragmentOutputs.fragData7=fragData[7];
1583#endif
1584#endif
1585#endif
1586#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
1587fragmentOutputs.color=color;
1588#endif
1589#include<oitFragment>
1590#if ORDER_INDEPENDENT_TRANSPARENCY
1591if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+color.rgb*color.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-color.a));} else {fragmentOutputs.backColor+=color;}
1592#endif
1593#define CUSTOM_FRAGMENT_MAIN_END
1594}
1595`;e.ShadersStoreWGSL[r]||(e.ShadersStoreWGSL[r]=L);const j={name:r,shader:L};export{j as defaultPixelShaderWGSL};

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.