1import{t as e}from"./shaderStore-D-XQlhUT.js";import"./ltcHelperFunctions-DS3Utz6C.js";import"./mainUVVaryingDeclaration-BBamQlxR.js";var t=`pbrFragmentExtraDeclaration`,n=`varying vec3 vPositionW; 2#if DEBUGMODE>0 3varying vec4 vClipSpacePosition; 4#endif 5#include<mainUVVaryingDeclaration>[1..7] 6#ifdef NORMAL 7varying vec3 vNormalW; 8#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) 9varying vec3 vEnvironmentIrradiance; 10#endif 11#endif 12#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) 13varying vec4 vColor; 14#endif 15#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 16varying float vViewDepth; 17#endif 18`;e.IncludesShadersStore[t]||(e.IncludesShadersStore[t]=n);var r={name:t,shader:n},i=`pbrHelperFunctions`,a=`#define MINIMUMVARIANCE 0.0005 19#ifndef TEXRD_DEFINED 20#define TEXRD(s,uv) texture2D(s,uv) 21#define TEXRD_DEFINED 22#endif 23float convertRoughnessToAverageSlope(float roughness) 24{return square(roughness)+MINIMUMVARIANCE;} 25float fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;} 26vec2 getAARoughnessFactors(vec3 normalVector) { 27#ifdef SPECULARAA 28vec3 nDfdx=dFdx(normalVector.xyz);vec3 nDfdy=dFdy(normalVector.xyz);float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);float geometricAlphaGFactor=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2(geometricRoughnessFactor,geometricAlphaGFactor); 29#else 30return vec2(0.); 31#endif 32} 33#ifdef ANISOTROPIC 34#ifdef ANISOTROPIC_LEGACY 35vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);} 36vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 anisotropicFrameDirection;if (anisotropy>=0.0) {anisotropicFrameDirection=B;} else {anisotropicFrameDirection=T;} 37vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;} 38#elif ANISOTROPIC_OPENPBR 39vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*alphaG*sqrt(2.0/(1.0+(1.0-anisotropy)*(1.0-anisotropy))),MINIMUMVARIANCE);float alphaB=max(alphaT*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);} 40#else 41vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG,MINIMUMVARIANCE);return vec2(alphaT,alphaB);} 42vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 bentNormal=cross(B,V);bentNormal=normalize(cross(bentNormal,B));float a=square(square(1.0-anisotropy*(1.0-roughness)));bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;} 43#endif 44#endif 45#if defined(CLEARCOAT) || defined(SS_REFRACTION) 46vec3 cocaLambert(vec3 alpha,float distance) {return exp(-alpha*distance);} 47vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));} 48vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {return -log(color)/distance;} 49vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 clearCoatAbsorption=mix(vec3(1.0), 50cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness), 51clearCoatIntensity);return clearCoatAbsorption;} 52#endif 53#ifdef MICROSURFACEAUTOMATIC 54float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor) 55{const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;float reflectivityLuminance=getLuminance(reflectivityColor);float reflectivityLuma=sqrt(reflectivityLuminance);microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return microSurface;} 56#endif 57`;e.IncludesShadersStore[i]||(e.IncludesShadersStore[i]=a);var o={name:i,shader:a},s=`pbrDirectLightingSetupFunctions`,c=`struct preLightingInfo 58{vec3 lightOffset;float lightDistanceSquared;float lightDistance;float attenuation;vec3 L;vec3 H;float NdotV;float NdotLUnclamped;float NdotL;float VdotH;float LdotV;float roughness;float diffuseRoughness;vec3 surfaceAlbedo; 59#ifdef IRIDESCENCE 60float iridescenceIntensity; 61#endif 62#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) 63vec3 areaLightDiffuse; 64#ifdef SPECULARTERM 65vec3 areaLightSpecular;vec4 areaLightFresnel; 66#endif 67#endif 68};preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N,vec3 posW) {preLightingInfo result;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} 69preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=dot(result.L,V);result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} 70preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL; 71#ifdef SPECULARTERM 72result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H)); 73#endif 74result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} 75#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) 76#include<ltcHelperFunctions> 77uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler;preLightingInfo computeAreaPreLightingInfo(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec4 lightData,vec3 halfWidth,vec3 halfHeight,float roughness ) 78{preLightingInfo result;result.lightOffset=lightData.xyz-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightData.xyz,halfWidth,halfHeight,roughness); 79#ifdef SPECULARTERM 80result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular; 81#endif 82result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} 83preLightingInfo computeAreaPreLightingInfoWithTexture(sampler2D ltc1,sampler2D ltc2,sampler2D emissionTexture,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec4 lightData,vec3 halfWidth,vec3 halfHeight,float roughness ) 84{preLightingInfo result;result.lightOffset=lightData.xyz-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);areaLightData data=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc2,emissionTexture,viewDirectionW,vNormal,vPosition,lightData.xyz,halfWidth,halfHeight,roughness); 85#ifdef SPECULARTERM 86result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular; 87#endif 88result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} 89#endif 90`;e.IncludesShadersStore[s]||(e.IncludesShadersStore[s]=c);var l={name:s,shader:c},u=`pbrDirectLightingFalloffFunctions`,d=`float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range) 91{return max(0.,1.0-length(lightOffset)/range);} 92float computeDistanceLightFalloff_Physical(float lightDistanceSquared) 93{return 1.0/maxEps(lightDistanceSquared);} 94float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange) 95{float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);float factor=lightDistanceSquared*inverseSquaredRange;
95float attenuation=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;} 96float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange) 97{ 98#ifdef USEPHYSICALLIGHTFALLOFF 99return computeDistanceLightFalloff_Physical(lightDistanceSquared); 100#elif defined(USEGLTFLIGHTFALLOFF) 101return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange); 102#else 103return computeDistanceLightFalloff_Standard(lightOffset,range); 104#endif 105} 106float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent) 107{float falloff=0.0;float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle) 108{falloff=max(0.,pow(cosAngle,exponent));} 109return falloff;} 110float computeDirectionalLightFalloff_IES(vec3 lightDirection,vec3 directionToLightCenterW,sampler2D iesLightSampler) 111{float cosAngle=dot(-lightDirection,directionToLightCenterW);float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;} 112float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle) 113{const float kMinusLog2ConeAngleIntensityRatio=6.64385618977; 114float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;} 115float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset) 116{float cd=dot(-lightDirection,directionToLightCenterW);float falloff=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;} 117float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset) 118{ 119#ifdef USEPHYSICALLIGHTFALLOFF 120return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle); 121#elif defined(USEGLTFLIGHTFALLOFF) 122return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset); 123#else 124return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent); 125#endif 126}`;e.IncludesShadersStore[u]||(e.IncludesShadersStore[u]=d);var f={name:u,shader:d},p=`pbrDirectLightingFunctions`,m=`#define CLEARCOATREFLECTANCE90 1.0 127struct lightingInfo 128{vec3 diffuse; 129#ifdef SS_TRANSLUCENCY 130vec3 diffuseTransmission; 131#endif 132#ifdef SPECULARTERM 133vec3 specular; 134#endif 135#ifdef CLEARCOAT 136vec4 clearCoat; 137#endif 138#ifdef SHEEN 139vec3 sheen; 140#endif 141};
141float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) { 142#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF) 143float lightRoughness=lightRadius/lightDistance;float totalRoughness=saturate(lightRoughness+roughness);return totalRoughness; 144#else 145return roughness; 146#endif 147} 148vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {return mix(groundColor,lightColor,info.NdotL);} 149#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) 150vec3 computeAreaDiffuseLighting(preLightingInfo info,vec3 lightColor) {return info.areaLightDiffuse*lightColor;} 151#endif 152vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {vec3 diffuseTerm=vec3(1.0/PI); 153#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY 154diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness)); 155#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY 156diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness)); 157#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON 158vec3 clampedAlbedo=clamp(info.surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo; 159#endif 160return diffuseTerm*info.attenuation*info.NdotL*lightColor;} 161#define inline 162vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return toLinearSpace(textureColor);} 163#ifdef SS_TRANSLUCENCY 164vec3 computeDiffuseTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {vec3 transmittanceNdotL=vec3(0.);float NdotL=absEps(info.NdotLUnclamped); 165#ifndef SS_TRANSLUCENCY_LEGACY 166if (info.NdotLUnclamped<0.0) { 167#endif 168float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);float trAdapt=step(0.,info.NdotLUnclamped);transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt); 169#ifndef SS_TRANSLUCENCY_LEGACY 170} 171vec3 diffuseTerm=vec3(1.0/PI); 172#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY 173diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness)); 174#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY 175diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness)); 176#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON 177vec3 clampedAlbedo=clamp(info.surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo; 178#endif 179#else 180float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness); 181#endif 182return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;} 183#endif 184#ifdef SPECULARTERM 185vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 fresnel,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness); 186#ifdef IRIDESCENCE 187fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity); 188#endif 189float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG); 190#ifdef BRDF_V_HEIGHT_CORRELATED 191float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG); 192#else 193float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG); 194#endif 195vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;} 196#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) 197vec3 computeAreaSpecularLighting(preLightingInfo info,vec3 specularColor,vec3 reflectance0,vec3 reflectance90) {vec3 fresnel=specularColor*info.areaLightFresnel.x*reflectance0+( vec3( 1.0 )-specularColor )*info.areaLightFresnel.y*reflectance90;return specularColor*fresnel*info.areaLightSpecular;} 198vec3 computeOpenPBRAreaSpecularLighting(preLightingInfo info,vec3 lightColor,vec3 reflectance0,vec3 reflectance90) {vec3 fresnel=reflectance0*info.areaLightFresnel.x+(reflectance90-reflectance0)*info.areaLightFresnel.y;return lightColor*fresnel*info.areaLightSpecular;} 199#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR 200vec3 computeOpenPBRAreaConductorSpecularLighting(preLightingInfo info,vec3 lightColor,vec3 reflectance0,vec3 edgeTint) {vec3 b=getF82B(reflectance0,edgeTint);float normalizedSchlickMoment=clamp(info.areaLightFresnel.y/max(info.areaLightFresnel.x,Epsilon),0.0,1.0);float representativeOneMinusCosTheta=pow(normalizedSchlickMoment,0.2);float f82DipMoment=info.areaLightFresnel.y*representativeOneMinusCosTheta*(1.0-representativeOneMinusCosTheta);vec3 fresnel=reflectance0*info.areaLightFresnel.x+(vec3(1.0)-reflectance0)*info.areaLightFresnel.y-b*f82DipMoment;return lightColor*clamp(fresnel,vec3(0.0),vec3(info.areaLightFresnel.x))*info.areaLightSpecular;} 201#endif
202float computeOpenPBRAreaFresnel(preLightingInfo info,float reflectance0,float reflectance90) {return reflectance0*info.areaLightFresnel.x+(reflectance90-reflectance0)*info.areaLightFresnel.y;} 203#endif 204#endif 205#ifdef FUZZ 206float evalFuzz(vec3 L,float NdotL,float NdotV,vec3 T,vec3 B,vec3 ltcLut) 207{if (NdotL<=0.0 || NdotV<=0.0) 208return 0.0;mat3 M=mat3( 209vec3(ltcLut.r,0.0,0.0), 210vec3(ltcLut.g,1.0,0.0), 211vec3(0.0,0.0,1.0) 212);vec3 Llocal=vec3(dot(L,T),dot(L,B),NdotL);vec3 Lwarp=normalize(M*Llocal);float cosThetaWarp=max(Lwarp.z,0.0);return cosThetaWarp*NdotL;} 213#endif 214#if defined(ANISOTROPIC) && defined(ANISOTROPIC_OPENPBR) 215vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=vec3(distribution*smithVisibility);return specTerm*info.attenuation*info.NdotL*lightColor;} 216#elif defined(ANISOTROPIC) 217vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,square(geometricRoughnessFactor));vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90); 218#ifdef IRIDESCENCE 219fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity); 220#endif 221float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;} 222#endif 223#ifdef CLEARCOAT 224vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {float NccdotL=saturateEps(dot(Ncc,info.L));float NccdotH=saturateEps(dot(Ncc,info.H));float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);float kelemenVisibility=visibility_Kelemen(info.VdotH);float clearCoatTerm=fresnel*distribution*kelemenVisibility;return vec4( 225clearCoatTerm*info.attenuation*NccdotL*lightColor, 2261.0-fresnel 227);} 228vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);float NdotLRefract=saturateEps(dot(Ncc,LRefract));vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;} 229#endif 230#ifdef SHEEN 231vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);float fresnel=1.;float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER 232float visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG); 233#else */ 234float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */ 235float sheenTerm=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;} 236#endif 237`;e.IncludesShadersStore[p]||(e.IncludesShadersStore[p]=m);var h={name:p,shader:m},g=`pbrBlockNormalGeometric`,_=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW); 238#ifdef NORMAL 239vec3 normalW=normalize(vNormalW); 240#else 241vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; 242#endif 243vec3 geometricNormalW=normalW; 244#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) 245geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW; 246#endif 247`;e.IncludesShadersStore[g]||(e.IncludesShadersStore[g]=_);var v={name:g,shader:_},y=`pbrBlockImageProcessing`,b=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) 248#if !defined(SKIPFINALCOLORCLAMP) 249finalColor.rgb=clamp(finalColor.rgb,0.,30.0); 250#endif 251#else 252finalColor=applyImageProcessing(finalColor); 253#endif 254finalColor.a*=visibility; 255#ifdef PREMULTIPLYALPHA 256finalColor.rgb*=finalColor.a; 257#endif 258`;e.IncludesShadersStore[y]||(e.IncludesShadersStore[y]=b);var x={name:y,shader:b},S=`pbrDebug`,C=`#if DEBUGMODE>0 259if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) { 260#if DEBUGMODE==1 261gl_FragColor.rgb=vPositionW.rgb; 262#define DEBUGMODE_NORMALIZE 263#elif DEBUGMODE==2 && defined(NORMAL) 264gl_FragColor.rgb=vNormalW.rgb; 265#define DEBUGMODE_NORMALIZE 266#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC) 267gl_FragColor.rgb=TBN[0]; 268#define DEBUGMODE_NORMALIZE 269#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC) 270gl_FragColor.rgb=TBN[1]; 271#define DEBUGMODE_NORMALIZE 272#elif DEBUGMODE==5 273gl_FragColor.rgb=normalW; 274#define DEBUGMODE_NORMALIZE 275#elif DEBUGMODE==6 && defined(MAINUV1) 276gl_FragColor.rgb=vec3(vMainUV1,0.0); 277#elif DEBUGMODE==7 && defined(MAINUV2) 278gl_FragColor.rgb=vec3(vMainUV2,0.0); 279#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) 280gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0]; 281#define DEBUGMODE_NORMALIZE 282#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) 283gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1]; 284#define DEBUGMODE_NORMALIZE 285#elif DEBUGMODE==10 && defined(CLEARCOAT) 286gl_FragColor.rgb=clearcoatOut.clearCoatNormalW; 287#define DEBUGMODE_NORMALIZE 288#elif DEBUGMODE==11 && defined(ANISOTROPIC) 289gl_FragColor.rgb=anisotropicOut.anisotropicNormal; 290#define DEBUGMODE_NORMALIZE 291#elif DEBUGMODE==12 && defined(ANISOTROPIC) 292gl_FragColor.rgb=anisotropicOut.anisotropicTangent; 293#define DEBUGMODE_NORMALIZE 294#elif DEBUGMODE==13 && defined(ANISOTROPIC) 295gl_FragColor.rgb=anisotropicOut.anisotropicBitangent; 296#define DEBUGMODE_NORMALIZE 297#elif DEBUGMODE==20 && defined(ALBEDO) 298gl_FragColor.rgb=albedoTexture.rgb; 299#ifndef GAMMAALBEDO 300#define DEBUGMODE_GAMMA 301#endif 302#elif DEBUGMODE==21 && defined(AMBIENT) 303gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb; 304#elif DEBUGMODE==22 && defined(OPACITY) 305gl_FragColor.rgb=opacityMap.rgb; 306#elif DEBUGMODE==23 && defined(EMISSIVE) 307gl_FragColor.rgb=emissiveColorTex.rgb; 308#ifndef GAMMAEMISSIVE 309#define DEBUGMODE_GAMMA 310#endif 311#elif DEBUGMODE==24 && defined(LIGHTMAP) 312gl_FragColor.rgb=lightmapColor.rgb; 313#ifndef GAMMALIGHTMAP 314#define DEBUGMODE_GAMMA 315#endif 316#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW) 317gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb; 318#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW) 319gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb; 320#define DEBUGMODE_GAMMA 321#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE) 322gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0); 323#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) 324gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb; 325#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE) 326gl_FragColor.rgb=sheenOut.sheenMapData.rgb; 327#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
328gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb; 329#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE) 330gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb; 331#elif DEBUGMODE==32 && defined(BUMP) 332gl_FragColor.rgb=texture2D(bumpSampler,vBumpUV).rgb; 333#elif DEBUGMODE==40 && defined(SS_REFRACTION) 334gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb; 335#define DEBUGMODE_GAMMA 336#elif DEBUGMODE==41 && defined(REFLECTION) 337gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb; 338#ifndef GAMMAREFLECTION 339#define DEBUGMODE_GAMMA 340#endif 341#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION) 342gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb; 343#define DEBUGMODE_GAMMA 344#elif DEBUGMODE==50 345gl_FragColor.rgb=diffuseBase.rgb; 346#define DEBUGMODE_GAMMA 347#elif DEBUGMODE==51 && defined(SPECULARTERM) 348gl_FragColor.rgb=specularBase.rgb; 349#define DEBUGMODE_GAMMA 350#elif DEBUGMODE==52 && defined(CLEARCOAT) 351gl_FragColor.rgb=clearCoatBase.rgb; 352#define DEBUGMODE_GAMMA 353#elif DEBUGMODE==53 && defined(SHEEN) 354gl_FragColor.rgb=sheenBase.rgb; 355#define DEBUGMODE_GAMMA 356#elif DEBUGMODE==54 && defined(REFLECTION) 357gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb; 358#ifndef GAMMAREFLECTION 359#define DEBUGMODE_GAMMA 360#endif 361#elif DEBUGMODE==60 362gl_FragColor.rgb=surfaceAlbedo.rgb; 363#define DEBUGMODE_GAMMA 364#elif DEBUGMODE==61 365gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0; 366#define DEBUGMODE_GAMMA 367#elif DEBUGMODE==62 && defined(METALLICWORKFLOW) 368gl_FragColor.rgb=vec3(reflectivityOut.metallic); 369#elif DEBUGMODE==71 && defined(METALLICWORKFLOW) 370gl_FragColor.rgb=reflectivityOut.metallicF0; 371#elif DEBUGMODE==63 372gl_FragColor.rgb=vec3(roughness); 373#elif DEBUGMODE==64 374gl_FragColor.rgb=vec3(alphaG); 375#elif DEBUGMODE==65 376gl_FragColor.rgb=vec3(NdotV); 377#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) 378gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb; 379#define DEBUGMODE_GAMMA 380#elif DEBUGMODE==67 && defined(CLEARCOAT) 381gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness); 382#elif DEBUGMODE==68 && defined(CLEARCOAT) 383gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV); 384#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY) 385gl_FragColor.rgb=subSurfaceOut.transmittance; 386#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION) 387gl_FragColor.rgb=subSurfaceOut.refractionTransmittance; 388#elif DEBUGMODE==72 389gl_FragColor.rgb=vec3(microSurface); 390#elif DEBUGMODE==73 391gl_FragColor.rgb=vAlbedoColor.rgb; 392#define DEBUGMODE_GAMMA 393#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW) 394gl_FragColor.rgb=vReflectivityColor.rgb; 395#define DEBUGMODE_GAMMA 396#elif DEBUGMODE==75 397gl_FragColor.rgb=vEmissiveColor.rgb; 398#define DEBUGMODE_GAMMA 399#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION) 400gl_FragColor.rgb=vec3(seo); 401#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) 402gl_FragColor.rgb=vec3(eho); 403#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION) 404gl_FragColor.rgb=vec3(energyConservationFactor); 405#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) 406gl_FragColor.rgb=baseSpecularEnvironmentReflectance; 407#define DEBUGMODE_GAMMA 408#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) 409gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance; 410#define DEBUGMODE_GAMMA 411#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION) 412gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance; 413#define DEBUGMODE_GAMMA 414#elif DEBUGMODE==86 && defined(ALPHABLEND) 415gl_FragColor.rgb=vec3(luminanceOverAlpha); 416#elif DEBUGMODE==87 417gl_FragColor.rgb=vec3(alpha); 418#elif DEBUGMODE==88 && defined(ALBEDO) 419gl_FragColor.rgb=vec3(albedoTexture.a); 420#elif DEBUGMODE==89 421gl_FragColor.rgb=aoOut.ambientOcclusionColor.rgb; 422#else 423float stripeWidth=30.;float stripePos=floor(gl_FragCoord.x/stripeWidth);float whichColor=mod(stripePos,2.);vec3 color1=vec3(.6,.2,.2);vec3 color2=vec3(.3,.1,.1);gl_FragColor.rgb=mix(color1,color2,whichColor); 424#endif 425gl_FragColor.rgb*=vDebugMode.y; 426#ifdef DEBUGMODE_NORMALIZE 427gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5; 428#endif 429#ifdef DEBUGMODE_GAMMA 430gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb); 431#endif 432gl_FragColor.a=1.0; 433#ifdef PREPASS 434gl_FragData[0]=toLinearSpace(gl_FragColor); 435gl_FragData[1]=vec4(0.,0.,0.,0.); 436#endif 437#ifdef DEBUGMODE_FORCERETURN 438return; 439#endif 440} 441#endif 442`;e.IncludesShadersStore[S]||(e.IncludesShadersStore[S]=C);var w={name:S,shader:C};export{f as a,r as c,h as i,x as n,l as o,v as r,o as s,w as t};
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.