UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines 89.6 kB
import{S as e}from"./index-OM-TXt9s.esm.min.js";import{p as n,o as i,d as o,t as r,a as t,b as a}from"./oitFragment-DN0xZ7lS.esm.min.js";import{s,o as c,a as f,b as l,d as _,c as d}from"./openpbrTransmissionLayerData-CwsRijg-.esm.min.js";import{s as m}from"./sceneUboDeclaration-BqJB1ktI.esm.min.js";import{m as u}from"./meshUboDeclaration-jclcCKgL.esm.min.js";import{o as g}from"./openpbrUboDeclaration-B0GRe2Dw.esm.min.js";import{m as E}from"./mainUVVaryingDeclaration-Bgqog3P1.esm.min.js";import{p as v,s as p,a as R,b as h,c as I,d as S,e as T,f as A,g as N}from"./pbrDebug-CFMYADAx.esm.min.js";import{l as b,a as L,s as F,b as O}from"./shadowsFragmentFunctions-jGioz7TJ.esm.min.js";import{s as C}from"./samplerFragmentDeclaration-BQ4p3hnA.esm.min.js";import{p as D,a as P}from"./pbrIBLFunctions-CkfOVNLW.esm.min.js";import{i as M,a as G}from"./imageProcessingFunctions-BvqPcgCp.esm.min.js";import{c as x,a as y}from"./clipPlaneFragment-C8xq8qY9.esm.min.js";import{l as z}from"./logDepthDeclaration-D6vFOx1S.esm.min.js";import{f as U,a as X}from"./fogFragment-DNiwnDSQ.esm.min.js";import{h as w}from"./helperFunctions-lJ8wAEhb.esm.min.js";import{i as W,h as H}from"./hdrFilteringFunctions-CZEz2z_f.esm.min.js";import{h as B}from"./harmonicsFunctions-D3vmcEA4.esm.min.js";import{p as V}from"./pbrBRDFFunctions-IoIT1nfq.esm.min.js";import{r as k}from"./reflectionFunction-Doa10rIb.esm.min.js";import{l as Y}from"./logDepthFragment-C05zSCAs.esm.min.js";const Z="openpbrFragmentDeclaration",j="uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vTransmissionWeight;uniform vec3 vTransmissionColor;uniform float vTransmissionDepth;uniform vec3 vTransmissionScatter;uniform float vTransmissionScatterAnisotropy;uniform float vTransmissionDispersionScale;uniform float vTransmissionDispersionAbbeNumber;uniform float vSubsurfaceWeight;uniform vec3 vSubsurfaceColor;uniform float vSubsurfaceRadius;uniform vec3 vSubsurfaceRadiusScale;uniform float vSubsurfaceScatterAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform float vFuzzWeight;uniform vec3 vFuzzColor;uniform float vFuzzRoughness;uniform vec2 vGeometryCoatTangent;uniform float vGeometryThickness;uniform vec3 vEmissionColor;uniform float vThinFilmWeight;uniform vec2 vThinFilmThickness;uniform float vThinFilmIor;uniform float vGeometryThinWalled;uniform vec4 vLightingIntensity;uniform float visibility;uniform vec2 renderTargetSize;\n#ifdef BASE_COLOR\nuniform vec2 vBaseColorInfos;\n#endif\n#ifdef BASE_WEIGHT\nuniform vec2 vBaseWeightInfos;\n#endif\n#ifdef BASE_METALNESS\nuniform vec2 vBaseMetalnessInfos;\n#endif\n#ifdef BASE_DIFFUSE_ROUGHNESS\nuniform vec2 vBaseDiffuseRoughnessInfos;\n#endif\n#ifdef SPECULAR_WEIGHT\nuniform vec2 vSpecularWeightInfos;\n#endif\n#ifdef SPECULAR_COLOR\nuniform vec2 vSpecularColorInfos;\n#endif\n#ifdef SPECULAR_ROUGHNESS\nuniform vec2 vSpecularRoughnessInfos;\n#endif\n#ifdef SPECULAR_ROUGHNESS_ANISOTROPY\nuniform vec2 vSpecularRoughnessAnisotropyInfos;\n#endif\n#ifdef SPECULAR_IOR\nuniform vec2 vSpecularIorInfos;\n#endif\n#ifdef AMBIENT_OCCLUSION\nuniform vec2 vAmbientOcclusionInfos;\n#endif\n#ifdef GEOMETRY_NORMAL\nuniform vec2 vGeometryNormalInfos;\n#endif\n#ifdef GEOMETRY_TANGENT\nuniform vec2 vGeometryTangentInfos;\n#endif\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef GEOMETRY_COAT_NORMAL\nuniform vec2 vGeometryCoatNormalInfos;\n#endif\n#ifdef GEOMETRY_OPACITY\nuniform vec2 vGeometryOpacityInfos;\n#endif\n#ifdef GEOMETRY_THICKNESS\nuniform vec2 vGeometryThicknessInfos;\n#endif\n#ifdef EMISSION_COLOR\nuniform vec2 vEmissionColorInfos;\n#endif\n#ifdef TRANSMISSION_WEIGHT\nuniform vec2 vTransmissionWeightInfos;\n#endif\n#ifdef TRANSMISSION_COLOR\nuniform vec2 vTransmissionColorInfos;\n#endif\n#ifdef TRANSMISSION_DEPTH\nuniform vec2 vTransmissionDepthInfos;\n#endif\n#ifdef TRANSMISSION_SCATTER\nuniform vec2 vTransmissionScatterInfos;\n#endif\n#ifdef TRANSMISSION_DISPERSION_SCALE\nuniform vec2 vTransmissionDispersionScaleInfos;\n#endif\n#ifdef SUBSURFACE_WEIGHT\nuniform vec2 vSubsurfaceWeightInfos;\n#endif\n#ifdef SUBSURFACE_COLOR\nuniform vec2 vSubsurfaceColorInfos;\n#endif\n#ifdef SUBSURFACE_RADIUS_SCALE\nuniform vec2 vSubsurfaceRadiusScaleInfos;\n#endif\n#ifdef COAT_WEIGHT\nuniform vec2 vCoatWeightInfos;\n#endif\n#ifdef COAT_COLOR\nuniform vec2 vCoatColorInfos;\n#endif\n#ifdef COAT_ROUGHNESS\nuniform vec2 vCoatRoughnessInfos;\n#endif\n#ifdef COAT_ROUGHNESS_ANISOTROPY\nuniform vec2 vCoatRoughnessAnisotropyInfos;\n#endif\n#ifdef COAT_IOR\nuniform vec2 vCoatIorInfos;\n#endif\n#ifdef COAT_DARKENING\nuniform vec2 vCoatDarkeningInfos;\n#endif\n#ifdef FUZZ_WEIGHT\nuniform vec2 vFuzzWeightInfos;\n#endif\n#ifdef FUZZ_COLOR\nuniform vec2 vFuzzColorInfos;\n#endif\n#ifdef FUZZ_ROUGHNESS\nuniform vec2 vFuzzRoughnessInfos;\n#endif\n#ifdef GEOMETRY_COAT_TANGENT\nuniform vec2 vGeometryCoatTangentInfos;\n#endif\n#ifdef THIN_FILM_WEIGHT\nuniform vec2 vThinFilmWeightInfos;\n#endif\n#ifdef THIN_FILM_THICKNESS\nuniform vec2 vThinFilmThicknessInfos;\n#endif\n#include<sceneFragmentDeclaration>\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\nuniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)\nuniform vec3 vReflectionDominantDirection;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef PREPASS\n#ifdef SS_SCATTERING\nuniform float scatteringDiffusionProfile;\n#endif\n#endif\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#include<decalFragmentDeclaration>\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;\n#endif\n#endif\n#ifdef REFRACTED_BACKGROUND\nuniform mat4 backgroundRefractionMatrix;uniform vec3 vBackgroundRefractionInfos;\n#endif\n#if TEXTURE_REPETITION_MODE>0\nuniform vec4 vTextureRepetitionHexTilingParams;\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";e.IncludesShadersStore[Z]||(e.IncludesShadersStore[Z]=j);const q={name:Z,shader:j},K="openpbrFragmentSamplersDeclaration",Q="#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_SAMPLERNAME_,transmissionColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_SAMPLERNAME_,transmissionDepth)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_SAMPLERNAME_,transmissionScatter)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_SAMPLERNAME_,transmissionDispersionScale)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_SAMPLERNAME_,subsurfaceColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_SAMPLERNAME_,subsurfaceRadiusScale)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_SAMPLERNAME_,fuzzWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_SAMPLERNAME_,fuzzColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_SAMPLERNAME_,fuzzRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_SAMPLERNAME_,geometryThickness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_SAMPLERNAME_,thinFilmWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_SAMPLERNAME_,thinFilmThickness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)\n#include<pbrFragmentReflectionDeclaration>\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n#ifdef FUZZENVIRONMENTBRDF\nuniform sampler2D environmentFuzzBrdfSampler;\n#endif\n#ifdef REFRACTED_BACKGROUND\nuniform sampler2D backgroundRefractionSampler;\n#endif\n#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING\nuniform sampler2D sceneIrradianceSampler;uniform sampler2D sceneDepthSampler;\n#endif\n#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)\nuniform sampler2D blueNoiseSampler;\n#endif\n#ifdef IBL_CDF_FILTERING\nuniform sampler2D icdfSampler;\n#endif\n";e.IncludesShadersStore[K]||(e.IncludesShadersStore[K]=Q);const J={name:K,shader:Q},$="openpbrNormalMapFragmentMainFunctions",ee="#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#if defined(WEBGL2) || defined(WEBGPU)\nmat4 toNormalMatrix(mat4 wMatrix)\n{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;}\n#else\nmat4 toNormalMatrix(mat4 m)\n{float\na00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],\na10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],\na20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],\na30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],\nb00=a00*a11-a01*a10,\nb01=a00*a12-a02*a10,\nb02=a00*a13-a03*a10,\nb03=a01*a12-a02*a11,\nb04=a01*a13-a03*a11,\nb05=a02*a13-a03*a12,\nb06=a20*a31-a21*a30,\nb07=a20*a32-a22*a30,\nb08=a20*a33-a23*a30,\nb09=a21*a32-a22*a31,\nb10=a21*a33-a23*a31,\nb11=a22*a33-a23*a32,\ndet=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(\na11*b11-a12*b10+a13*b09,\na02*b10-a01*b11-a03*b09,\na31*b05-a32*b04+a33*b03,\na22*b04-a21*b05-a23*b03,\na12*b08-a10*b11-a13*b07,\na00*b11-a02*b08+a03*b07,\na32*b02-a30*b05-a33*b01,\na20*b05-a22*b02+a23*b01,\na10*b10-a11*b08+a13*b06,\na01*b08-a00*b10-a03*b06,\na30*b04-a31*b02+a33*b00,\na21*b02-a20*b04-a23*b00,\na11*b07-a10*b09-a12*b06,\na00*b09-a01*b07+a02*b06,\na31*b01-a30*b03-a32*b00,\na20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],\nmi[0][1],mi[1][1],mi[2][1],mi[3][1],\nmi[0][2],mi[1][2],mi[2][2],mi[3][2],\nmi[0][3],mi[1][3],mi[2][3],mi[3][3]);}\n#endif\n#endif\nvec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)\n{\n#ifdef NORMALXYSCALE\nnormal=normalize(normal*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*normal);}\nvec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)\n{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);}\n#endif\n";e.IncludesShadersStore[$]||(e.IncludesShadersStore[$]=ee);const ne={name:$,shader:ee},ie="openpbrNormalMapFragmentFunctions",oe="#if defined(GEOMETRY_NORMAL)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal)\n#endif\n#if defined(GEOMETRY_COAT_NORMAL)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_SAMPLERNAME_,geometryCoatNormal)\n#endif\n#if defined(DETAIL)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)\n#endif\n#if defined(GEOMETRY_NORMAL) && defined(PARALLAX)\nconst float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++)\n{currSampledHeight=texture2D(geometryNormalSampler,texCoord+vCurrOffset).w;if (!keepWorking)\n{}\nelse if (currSampledHeight>currRayHeight)\n{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}\nelse\n{currRayHeight-=stepSize;vLastOffset=vCurrOffset;\n#ifdef PARALLAX_RHS\nvCurrOffset-=stepSize*vMaxOffset;\n#else\nvCurrOffset+=stepSize*vMaxOffset;\n#endif\nlastSampledHeight=currSampledHeight;}}\nreturn vCurrOffset;}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{float height=texture2D(geometryNormalSampler,vGeometryNormalUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;\n#ifdef PARALLAX_RHS\nreturn texCoordOffset;\n#else\nreturn -texCoordOffset;\n#endif\n}\n#endif\n";e.IncludesShadersStore[ie]||(e.IncludesShadersStore[ie]=oe);const re={name:ie,shader:oe},te="openpbrConductorReflectance",ae="#define pbr_inline\nReflectanceParams conductorReflectance(in vec3 baseColor,in vec3 specularColor,in float specularWeight)\n{ReflectanceParams outParams;\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)\noutParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor*specularWeight;\n#else\noutParams.coloredF0=baseColor;outParams.coloredF90=vec3(1.0);\n#endif\noutParams.F0=1.0;outParams.F90=1.0;return outParams;}";e.IncludesShadersStore[te]||(e.IncludesShadersStore[te]=ae);const se={name:te,shader:ae},ce="openpbrAmbientOcclusionFunctions",fe="float compute_specular_occlusion(const float n_dot_v,const float metallic,const float ambient_occlusion,const float roughness)\n{float specular_occlusion=saturate(pow(n_dot_v+ambient_occlusion,exp2(-16.0*roughness-1.0))-1.0+ambient_occlusion);return mix(specular_occlusion,1.0,metallic*square(1.0-roughness));}\n";e.IncludesShadersStore[ce]||(e.IncludesShadersStore[ce]=fe);const le={name:ce,shader:fe},_e="openpbrVolumeFunctions",de="struct OpenPBRHomogeneousVolume {vec3 extinction_coeff; \nvec3 ss_albedo; \nvec3 multi_scatter_color; \nvec3 absorption_coeff; \nvec3 scatter_coeff; \nfloat anisotropy; };OpenPBRHomogeneousVolume computeOpenPBRTransmissionVolume(\nin vec3 transmission_color,\nin float transmission_depth,\nin vec3 transmission_scatter,\nin float anisotropy\n)\n{OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;\n#ifdef GEOMETRY_THIN_WALLED\nvolumeParams.scatter_coeff=vec3(1.0);volumeParams.anisotropy=1.0; \nvolumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(1.0);\n#else\nif (transmission_depth>0.0) {vec3 invDepth=vec3(1./maxEps(transmission_depth));volumeParams.extinction_coeff=-log(maxEps(transmission_color.rgb))*invDepth;volumeParams.scatter_coeff=transmission_scatter.rgb*invDepth;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);}\nvolumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/(volumeParams.extinction_coeff);} else {volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(0.0);}\n#endif\nreturn volumeParams;}\nOpenPBRHomogeneousVolume computeOpenPBRSubsurfaceVolume(\nin vec3 subsurface_color,\nin float subsurface_radius,\nin vec3 subsurface_radius_scale,\nin float anisotropy\n)\n{OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;volumeParams.multi_scatter_color=subsurface_color;vec3 mfp=subsurface_radius_scale*vec3(subsurface_radius);volumeParams.extinction_coeff=vec3(1.0)/maxEps(mfp);volumeParams.ss_albedo=multiScatterToSingleScatterAlbedo(subsurface_color,anisotropy);volumeParams.scatter_coeff=volumeParams.ss_albedo*volumeParams.extinction_coeff;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);}\nvolumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;return volumeParams;}\nvec3 sss_pdf(float r,vec3 d)\n{d=max(vec3(1e-4f),d);return (exp(-r/d)+exp(-r/(3.0f*d)))/max(vec3(1e-5f),8.0f*PI*d*r);}\nfloat sss_samples_pdf(float r,float d)\n{d=max(1e-4f,d);return exp(-r/(3.0f*d))/(6.0f*PI*d*r);}\nfloat sss_samples_icdf(float x,float d)\n{d=max(1e-4f,d);x=max(1e-4f,x);return -3.0f*log(x)*d;}\nfloat samples_scale(float x,float d)\n{return 1.0f-exp(-x/(3.0f*d));}\nvec3 sss_get_position(sampler2D depth_texture,vec2 tex_coord,vec2 render_resolution,mat4 inv_proj)\n{vec4 P=vec4(tex_coord,texelFetch(depth_texture,ivec2(tex_coord*render_resolution),0).x,1.0f);P.xy=2.0f*P.xy-1.0f;P=inv_proj*P;return P.xyz/P.w;}\nfloat sss_filter_scale(float currZ,mat4 proj)\n{return 1.0f/dot(vec2(proj[2].w,proj[3].w),vec2(currZ,1.0f));}\nfloat projective_to_pixels(float proj_dist,mat4 proj,vec2 resolution)\n{return proj_dist*proj[1][1]*resolution.y;}\nfloat pixels_to_projective(float pixel_dist,mat4 proj,vec2 resolution)\n{return pixel_dist/(proj[1][1]*resolution.y);}\nvec3 sss_convolve(sampler2D sss_irradiance_texture,sampler2D depth_texture,vec2 render_resolution,vec3 d,mat4 proj,mat4 inv_proj,int sample_count,vec2 noise)\n{vec2 tex_coord=gl_FragCoord.xy/render_resolution;vec3 unconvolved_irradiance=texelFetch(sss_irradiance_texture,ivec2(gl_FragCoord.xy),0).rgb;vec3 curr_pos=sss_get_position(depth_texture,tex_coord,render_resolution,inv_proj);float dmax=max3(d);float max_dmax=0.1*float(sample_count);if (dmax>max_dmax)\n{d.rgb*=max_dmax/dmax;dmax=max_dmax;}\nfloat dz=dmax*sss_filter_scale(curr_pos.z,proj);mat2 projMat2d=mat2(proj);if (determinant(projMat2d)*dz<1e-4f)\nreturn unconvolved_irradiance;float overscan_size_in_pixels=max(render_resolution.x,render_resolution.y)*0.1;const float filter_crop_ratio=0.8f; \nfloat crop_radius=projective_to_pixels(sss_samples_icdf(1.0f-filter_crop_ratio,dz),proj,render_resolution);if (crop_radius>overscan_size_in_pixels)\n{d.rgb*=overscan_size_in_pixels/crop_radius;dz*=overscan_size_in_pixels/crop_radius;}\nfloat filter_samples_scale=samples_scale(pixels_to_projective(overscan_size_in_pixels,proj,render_resolution),dz);vec3 irradiance_sum=vec3(0.0f);vec3 weight_sum=vec3(0.0f);for (int i=0; i<sample_count; i++)\n{vec2 r=fract(plasticSequence(uint(i))+noise);r.x*=TWO_PI;r.y*=filter_samples_scale;float icdf=sss_samples_icdf(1.0-r.y,dz);vec2 sample_uv=tex_coord+icdf*projMat2d*vec2(cos(r.x),sin(r.x));vec4 sss_irradiance=texelFetch(sss_irradiance_texture,ivec2(sample_uv*render_resolution),0);float dist=distance(curr_pos,sss_get_position(depth_texture,sample_uv,render_resolution,inv_proj));if (dist>0.0f)\n{vec3 weights=sss_irradiance.a/sss_samples_pdf(icdf,dz)*sss_pdf(dist,d.rgb);irradiance_sum+=weights*sss_irradiance.rgb;weight_sum+=weights;}}\nreturn vec3(weight_sum.r<1e-5f ? unconvolved_irradiance.r : irradiance_sum.r/weight_sum.r,\nweight_sum.g<1e-5f ? unconvolved_irradiance.g : irradiance_sum.g/weight_sum.g,\nweight_sum.b<1e-5f ? unconvolved_irradiance.b : irradiance_sum.b/weight_sum.b);}";e.IncludesShadersStore[_e]||(e.IncludesShadersStore[_e]=de);const me={name:_e,shader:de},ue="openpbrNormalMapFragment",ge="vec2 uvOffset=vec2(0.0,0.0);\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(PARALLAX) || defined(DETAIL)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#elif defined(GEOMETRY_NORMAL)\nfloat normalScale=vGeometryNormalInfos.y;\n#else\nfloat normalScale=1.0;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#elif defined(GEOMETRY_NORMAL)\nvec2 TBNUV=gl_FrontFacing ? vGeometryNormalUV : -vGeometryNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);\n#elif defined(GEOMETRY_COAT_NORMAL)\nvec2 TBNUV=gl_FrontFacing ? vGeometryCoatNormalUV : -vGeometryCoatNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);\n#else\nvec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#elif defined(ANISOTROPIC) || defined(FUZZ)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nvec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\n#else\n#endif\n#endif\n#ifdef DETAIL\nvec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB);\n#endif\n#ifdef GEOMETRY_COAT_NORMAL\ncoatNormalW=perturbNormal(TBN,TEXRD(geometryCoatNormalSampler,vGeometryCoatNormalUV+uvOffset).xyz,vGeometryCoatNormalInfos.y);\n#endif\n#ifdef GEOMETRY_NORMAL\n#ifdef OBJECTSPACE_NORMALMAP\n#define CUSTOM_FRAGMENT_BUMP_FRAGMENT\nnormalW=normalize(TEXRD(geometryNormalSampler,vGeometryNormalUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);\n#elif !defined(DETAIL)\nnormalW=perturbNormal(TBN,TEXRD(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz,vGeometryNormalInfos.y);\n#else\nvec3 sampledNormal=TEXRD(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz*2.0-1.0;\n#if DETAIL_NORMALBLENDMETHOD==0 \ndetailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(sampledNormal.xy+detailNormal.xy,sampledNormal.z*detailNormal.z));\n#elif DETAIL_NORMALBLENDMETHOD==1 \ndetailNormal.xy*=vDetailInfos.z;sampledNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=sampledNormal*dot(sampledNormal,detailNormal)/sampledNormal.z-detailNormal;\n#endif\nnormalW=perturbNormalBase(TBN,blendedNormal,vGeometryNormalInfos.y);\n#endif\n#elif defined(DETAIL)\ndetailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);\n#endif\n";e.IncludesShadersStore[ue]||(e.IncludesShadersStore[ue]=ge);const Ee={name:ue,shader:ge},ve="openpbrBlockNormalFinal",pe="#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));coatNormalW*=sign(dot(coatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\n#if defined(MIRRORED)\nnormalW=gl_FrontFacing ? -normalW : normalW;coatNormalW=gl_FrontFacing ? -coatNormalW : coatNormalW;\n#else\nnormalW=gl_FrontFacing ? normalW : -normalW;coatNormalW=gl_FrontFacing ? coatNormalW : -coatNormalW;\n#endif\n#endif\n";e.IncludesShadersStore[ve]||(e.IncludesShadersStore[ve]=pe);const Re={name:ve,shader:pe},he="openpbrBaseLayerData",Ie="vec3 base_color=vec3(0.8);float base_metalness=0.0;float base_diffuse_roughness=0.0;float specular_weight=1.0;float specular_roughness=0.3;vec3 specular_color=vec3(1.0);float specular_roughness_anisotropy=0.0;float specular_ior=1.5;float alpha=1.0;vec2 geometry_tangent=vec2(1.0,0.0);float geometry_thickness=0.0;\n#ifdef BASE_WEIGHT\nvec4 baseWeightFromTexture=TEXRD(baseWeightSampler,vBaseWeightUV+uvOffset);\n#endif\n#ifdef BASE_COLOR\nvec4 baseColorFromTexture=TEXRD(baseColorSampler,vBaseColorUV+uvOffset);\n#endif\n#ifdef BASE_METALNESS\nvec4 metallicFromTexture=TEXRD(baseMetalnessSampler,vBaseMetalnessUV+uvOffset);\n#endif\n#if defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS)\nfloat roughnessFromTexture=metallicFromTexture.g;\n#elif defined(SPECULAR_ROUGHNESS)\nfloat roughnessFromTexture=TEXRD(specularRoughnessSampler,vSpecularRoughnessUV+uvOffset).r;\n#endif\n#ifdef GEOMETRY_TANGENT\nvec3 geometryTangentFromTexture=TEXRD(geometryTangentSampler,vGeometryTangentUV+uvOffset).rgb;\n#endif\n#ifdef SPECULAR_ROUGHNESS_ANISOTROPY\nfloat anisotropyFromTexture=TEXRD(specularRoughnessAnisotropySampler,vSpecularRoughnessAnisotropyUV+uvOffset).r*vSpecularRoughnessAnisotropyInfos.y;\n#endif\n#ifdef BASE_DIFFUSE_ROUGHNESS\nfloat baseDiffuseRoughnessFromTexture=TEXRD(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r;\n#endif\n#ifdef GEOMETRY_OPACITY\nvec4 opacityFromTexture=TEXRD(geometryOpacitySampler,vGeometryOpacityUV+uvOffset);\n#endif\n#ifdef GEOMETRY_THICKNESS\nvec4 thicknessFromTexture=TEXRD(geometryThicknessSampler,vGeometryThicknessUV+uvOffset);\n#endif\n#ifdef DECAL\nvec4 decalFromTexture=texture2D(decalSampler,vDecalUV+uvOffset);\n#endif\n#ifdef SPECULAR_COLOR\nvec4 specularColorFromTexture=TEXRD(specularColorSampler,vSpecularColorUV+uvOffset);\n#endif\n#ifdef SPECULAR_WEIGHT\n#ifdef SPECULAR_WEIGHT_IN_ALPHA\nfloat specularWeightFromTexture=TEXRD(specularWeightSampler,vSpecularWeightUV+uvOffset).a;\n#else\nfloat specularWeightFromTexture=TEXRD(specularWeightSampler,vSpecularWeightUV+uvOffset).r;\n#endif\n#endif\n#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)\nvec3 noise=vec3(2.0)*TEXRD(blueNoiseSampler,gl_FragCoord.xy/256.0).xyz-vec3(1.0);\n#endif\nbase_color=vBaseColor.rgb;\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbase_color*=vColor.rgb;\n#endif\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nbase_color*=vec3(vBaseWeight);alpha=vBaseColor.a;base_metalness=vReflectanceInfo.x;base_diffuse_roughness=vBaseDiffuseRoughness;specular_roughness=vReflectanceInfo.y;specular_color=vSpecularColor.rgb;specular_weight=vReflectanceInfo.a;specular_ior=vReflectanceInfo.z;specular_roughness_anisotropy=vSpecularAnisotropy.b;geometry_tangent=vSpecularAnisotropy.rg;geometry_thickness=vGeometryThickness;\n#ifdef BASE_COLOR\n#ifdef BASE_COLOR_GAMMA\nbase_color*=toLinearSpace(baseColorFromTexture.rgb);\n#else\nbase_color*=baseColorFromTexture.rgb;\n#endif\nbase_color*=vBaseColorInfos.y;\n#endif\n#ifdef BASE_WEIGHT\nbase_color*=baseWeightFromTexture.r;\n#endif\n#if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE)\nalpha*=baseColorFromTexture.a;\n#elif defined(GEOMETRY_OPACITY)\nalpha*=opacityFromTexture.r;alpha*=vGeometryOpacityInfos.y;\n#endif\n#ifdef GEOMETRY_THICKNESS\n#ifdef GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL\ngeometry_thickness*=thicknessFromTexture.g;\n#else\ngeometry_thickness*=thicknessFromTexture.r;\n#endif\ngeometry_thickness*=vGeometryThicknessInfos.y;\n#endif\n#ifdef ALPHATEST\n#if DEBUGMODE != 88\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#endif\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\n#ifdef BASE_METALNESS\n#ifdef BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE\nbase_metalness*=metallicFromTexture.b;\n#else\nbase_metalness*=metallicFromTexture.r;\n#endif\n#endif\n#ifdef BASE_DIFFUSE_ROUGHNESS\nbase_diffuse_roughness*=baseDiffuseRoughnessFromTexture*vBaseDiffuseRoughnessInfos.y;\n#endif\n#ifdef SPECULAR_COLOR\n#ifdef SPECULAR_COLOR_GAMMA\nspecular_color*=toLinearSpace(specularColorFromTexture.rgb);\n#else\nspecular_color*=specularColorFromTexture.rgb;\n#endif\n#ifdef SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE\nspecular_weight*=specularColorFromTexture.a;\n#elif defined(SPECULAR_WEIGHT)\nspecular_weight*=specularWeightFromTexture;\n#endif\n#endif\n#if defined(SPECULAR_ROUGHNESS) || (defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS))\nspecular_roughness*=roughnessFromTexture;\n#endif\n#ifdef GEOMETRY_TANGENT\n{vec2 tangentFromTexture=normalize(geometryTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_tangent.y,geometry_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_tangent=vec2(cos(tangent_angle),sin(tangent_angle));}\n#endif\n#if defined(GEOMETRY_TANGENT) && defined(SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)\nspecular_roughness_anisotropy*=geometryTangentFromTexture.b;\n#elif defined(SPECULAR_ROUGHNESS_ANISOTROPY)\nspecular_roughness_anisotropy*=anisotropyFromTexture;\n#endif\n#ifdef DETAIL\nfloat detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,specular_roughness,detailRoughness*2.);float hiLerp=mix(specular_roughness,1.,(detailRoughness-0.5)*2.);specular_roughness=mix(loLerp,hiLerp,step(detailRoughness,0.5));\n#endif\n#ifdef USE_GLTF_STYLE_ANISOTROPY\nfloat baseAlpha=specular_roughness*specular_roughness;float roughnessT=mix(baseAlpha,1.0,specular_roughness_anisotropy*specular_roughness_anisotropy);float roughnessB=baseAlpha;specular_roughness_anisotropy=1.0-roughnessB/max(roughnessT,0.00001);specular_roughness=sqrt(roughnessT/sqrt(2.0/(1.0+(1.0-specular_roughness_anisotropy)*(1.0-specular_roughness_anisotropy))));\n#endif\n";e.IncludesShadersStore[he]||(e.IncludesShadersStore[he]=Ie);const Se={name:he,shader:Ie},Te="openpbrCoatLayerData",Ae="float coat_weight=0.0;vec3 coat_color=vec3(1.0);float coat_roughness=0.0;float coat_roughness_anisotropy=0.0;float coat_ior=1.6;float coat_darkening=1.0;vec2 geometry_coat_tangent=vec2(1.0,0.0);\n#ifdef COAT_WEIGHT\nvec4 coatWeightFromTexture=TEXRD(coatWeightSampler,vCoatWeightUV+uvOffset);\n#endif\n#ifdef COAT_COLOR\nvec4 coatColorFromTexture=TEXRD(coatColorSampler,vCoatColorUV+uvOffset);\n#endif\n#ifdef COAT_ROUGHNESS\nvec4 coatRoughnessFromTexture=TEXRD(coatRoughnessSampler,vCoatRoughnessUV+uvOffset);\n#endif\n#ifdef COAT_ROUGHNESS_ANISOTROPY\nfloat coatRoughnessAnisotropyFromTexture=TEXRD(coatRoughnessAnisotropySampler,vCoatRoughnessAnisotropyUV+uvOffset).r;\n#endif\n#ifdef COAT_DARKENING\nvec4 coatDarkeningFromTexture=TEXRD(coatDarkeningSampler,vCoatDarkeningUV+uvOffset);\n#endif\n#ifdef GEOMETRY_COAT_TANGENT\nvec3 geometryCoatTangentFromTexture=TEXRD(geometryCoatTangentSampler,vGeometryCoatTangentUV+uvOffset).rgb;\n#endif\ncoat_color=vCoatColor.rgb;coat_weight=vCoatWeight;coat_roughness=vCoatRoughness;coat_roughness_anisotropy=vCoatRoughnessAnisotropy;coat_ior=vCoatIor;coat_darkening=vCoatDarkening;geometry_coat_tangent=vGeometryCoatTangent.rg;\n#ifdef COAT_WEIGHT\ncoat_weight*=coatWeightFromTexture.r;\n#endif\n#ifdef COAT_COLOR\n#ifdef COAT_COLOR_GAMMA\ncoat_color*=toLinearSpace(coatColorFromTexture.rgb);\n#else\ncoat_color*=coatColorFromTexture.rgb;\n#endif\ncoat_color*=vCoatColorInfos.y;\n#endif\n#ifdef COAT_ROUGHNESS\n#ifdef COAT_ROUGHNESS_FROM_GREEN_CHANNEL\ncoat_roughness*=coatRoughnessFromTexture.g;\n#else\ncoat_roughness*=coatRoughnessFromTexture.r;\n#endif\n#endif\n#if defined(GEOMETRY_COAT_TANGENT) && defined(COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)\ncoat_roughness_anisotropy*=geometryCoatTangentFromTexture.b;\n#elif defined(COAT_ROUGHNESS_ANISOTROPY)\ncoat_roughness_anisotropy*=coatRoughnessAnisotropyFromTexture;\n#endif\n#ifdef COAT_DARKENING\ncoat_darkening*=coatDarkeningFromTexture.r;\n#endif\n#ifdef GEOMETRY_COAT_TANGENT\n{vec2 tangentFromTexture=normalize(geometryCoatTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_coat_tangent.y,geometry_coat_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_coat_tangent=vec2(cos(tangent_angle),sin(tangent_angle));}\n#endif\n#ifdef USE_GLTF_STYLE_ANISOTROPY\nfloat coatAlpha=coat_roughness*coat_roughness;float coatRoughnessT=mix(coatAlpha,1.0,coat_roughness_anisotropy*coat_roughness_anisotropy);float coatRoughnessB=coatAlpha;coat_roughness_anisotropy=1.0-coatRoughnessB/max(coatRoughnessT,0.00001);coat_roughness=sqrt(coatRoughnessT/sqrt(2.0/(1.0+(1.0-coat_roughness_anisotropy)*(1.0-coat_roughness_anisotropy))));\n#endif\n";e.IncludesShadersStore[Te]||(e.IncludesShadersStore[Te]=Ae);const Ne={name:Te,shader:Ae},be="openpbrThinFilmLayerData",Le="#ifdef THIN_FILM\nfloat thin_film_weight=vThinFilmWeight;float thin_film_thickness=vThinFilmThickness.r*1000.0; \nfloat thin_film_ior=vThinFilmIor;\n#ifdef THIN_FILM_WEIGHT\nfloat thinFilmWeightFromTexture=TEXRD(thinFilmWeightSampler,vThinFilmWeightUV+uvOffset).r*vThinFilmWeightInfos.y;\n#endif\n#ifdef THIN_FILM_THICKNESS\nfloat thinFilmThicknessFromTexture=TEXRD(thinFilmThicknessSampler,vThinFilmThicknessUV+uvOffset).g*vThinFilmThicknessInfos.y;\n#endif\n#ifdef THIN_FILM_WEIGHT\nthin_film_weight*=thinFilmWeightFromTexture;\n#endif\n#ifdef THIN_FILM_THICKNESS\nthin_film_thickness*=thinFilmThicknessFromTexture;\n#endif\nfloat thin_film_ior_scale=clamp(2.0f*abs(thin_film_ior-1.0f),0.0f,1.0f);\n#endif\n";e.IncludesShadersStore[be]||(e.IncludesShadersStore[be]=Le);const Fe={name:be,shader:Le},Oe="openpbrFuzzLayerData",Ce="float fuzz_weight=0.0;vec3 fuzz_color=vec3(1.0);float fuzz_roughness=0.0;\n#ifdef FUZZ\n#ifdef FUZZ_WEIGHT\nvec4 fuzzWeightFromTexture=TEXRD(fuzzWeightSampler,vFuzzWeightUV+uvOffset);\n#endif\n#ifdef FUZZ_COLOR\nvec4 fuzzColorFromTexture=TEXRD(fuzzColorSampler,vFuzzColorUV+uvOffset);\n#endif\n#ifdef FUZZ_ROUGHNESS\nvec4 fuzzRoughnessFromTexture=TEXRD(fuzzRoughnessSampler,vFuzzRoughnessUV+uvOffset);\n#endif\nfuzz_color=vFuzzColor.rgb;fuzz_weight=vFuzzWeight;fuzz_roughness=vFuzzRoughness;\n#ifdef FUZZ_WEIGHT\nfuzz_weight*=fuzzWeightFromTexture.r;\n#endif\n#ifdef FUZZ_COLOR\n#ifdef FUZZ_COLOR_GAMMA\nfuzz_color*=toLinearSpace(fuzzColorFromTexture.rgb);\n#else\nfuzz_color*=fuzzColorFromTexture.rgb;\n#endif\nfuzz_color*=vFuzzColorInfos.y;\n#endif\n#if defined(FUZZ_ROUGHNESS) && defined(FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA)\nfuzz_roughness*=fuzzRoughnessFromTexture.a;\n#elif defined(FUZZ_ROUGHNESS)\nfuzz_roughness*=fuzzRoughnessFromTexture.r;\n#endif\n#endif\n";e.IncludesShadersStore[Oe]||(e.IncludesShadersStore[Oe]=Ce);const De={name:Oe,shader:Ce},Pe="openpbrAmbientOcclusionData",Me="vec3 ambient_occlusion=vec3(1.0);float specular_ambient_occlusion=1.0;float coat_specular_ambient_occlusion=1.0;\n#ifdef AMBIENT_OCCLUSION\nvec3 ambientOcclusionFromTexture=TEXRD(ambientOcclusionSampler,vAmbientOcclusionUV+uvOffset).rgb;ambient_occlusion=vec3(ambientOcclusionFromTexture.r*vAmbientOcclusionInfos.y+(1.0-vAmbientOcclusionInfos.y));\n#endif\n";e.IncludesShadersStore[Pe]||(e.IncludesShadersStore[Pe]=Me);const Ge={name:Pe,shader:Me},xe="openpbrBackgroundTransmission",ye="vec4 slab_translucent_background=vec4(0.,0.,0.,1.);\n#ifdef REFRACTED_BACKGROUND\n{float refractionLOD=min(transmission_roughness,0.8)*vBackgroundRefractionInfos.x;float lodTexelSize=pow(2.0,refractionLOD-vBackgroundRefractionInfos.x);\n#ifdef DISPERSION\n{\n#ifdef REFRACTION_HIGH_QUALITY_BLUR\n{vec3 dispResult=vec3(0.0);vec3 dispWeight=vec3(0.0);vec2 noiseOffset=noise.xy*(refractionLOD>0.0 ? lodTexelSize : 0.0);for (int k=0; k<6; k++) {float t=(float(k)+noise.y)/6.0;float t_rg=clamp(t*2.0,0.0,1.0);float t_gb=clamp((t-0.5)*2.0,0.0,1.0);vec3 refVec=mix(mix(refractedViewVectors[0],refractedViewVectors[1],t_rg),refractedViewVectors[2],t_gb);vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refVec*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;vec4 s=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD);float rw=max(0.0,1.0-2.0*t);float gw=max(0.0,1.0-abs(2.0*t-1.0));float bw=max(0.0,2.0*t-1.0);vec3 w=vec3(rw,gw,bw);dispResult+=s.rgb*w;dispWeight+=w;}\nslab_translucent_background=vec4(dispResult/max(dispWeight,vec3(1e-6)),1.0);}\n#else\nfor (int i=0; i<3; i++) {vec3 refractedViewVector=refractedViewVectors[i];vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;if (refractionLOD>0.0) {vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD)[i];} else {slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords,0.0)[i];}}\n#endif\n}\n#else\n{vec3 refractionUVW=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 refractionCoords=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;if (refractionLOD>0.0) {\n#ifdef REFRACTION_HIGH_QUALITY_BLUR\nfloat cosA=cos(noise.x*PI);float sinA=sin(noise.x*PI);vec2 u=vec2( cosA,sinA)*(0.5*lodTexelSize);vec2 v=vec2(-sinA,cosA)*(0.5*lodTexelSize);slab_translucent_background=0.25*(\ntexture2DLodEXT(backgroundRefractionSampler,refractionCoords+u+v,refractionLOD) +\ntexture2DLodEXT(backgroundRefractionSampler,refractionCoords-u+v,refractionLOD) +\ntexture2DLodEXT(backgroundRefractionSampler,refractionCoords+u-v,refractionLOD) +\ntexture2DLodEXT(backgroundRefractionSampler,refractionCoords-u-v,refractionLOD)\n);\n#else\nvec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords+noiseOffset,refractionLOD);\n#endif\n} else {slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords,0.0);}}\n#endif\n}\n#endif\n";e.IncludesShadersStore[xe]||(e.IncludesShadersStore[xe]=ye);const ze={name:xe,shader:ye},Ue="openpbrEnvironmentLighting",Xe="#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND)\nvec3 coatAbsorption=vec3(1.0);float coatIblFresnel=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);float hemisphere_avg_fresnel=coatReflectance.F0+0.5*(1.0-coatReflectance.F0);float averageReflectance=(coatIblFresnel+hemisphere_avg_fresnel)*0.5;float roughnessFactor=1.0-coat_roughness*0.5;averageReflectance*=roughnessFactor;float darkened_transmission=(1.0-averageReflectance)*(1.0-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior)*coat_weight;float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;float effectivePathLength=coatPathLength*coat_weight;vec3 colored_transmission=pow(coat_color,vec3(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0,darkened_transmission,coat_weight);}\n#endif\n#ifdef REFLECTION\n#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)\nvec3 environmentFuzzBrdf=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));\n#endif\nvec3 baseDiffuseEnvironmentLight=sampleIrradiance(\nnormalW\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradiance\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n#endif\n,vReflectionInfos\n,viewDirectionW\n,base_diffuse_roughness\n,base_color\n);\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.,0.,0.);\n#else\nvec2 reflectionCoords=vec2(0.,0.);\n#endif\nfloat specularAlphaG=specular_roughness*specular_roughness;\n#ifdef ANISOTROPIC_BASE\nvec3 baseSpecularEnvironmentLight=sampleRadianceAnisotropic(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n,normalW\n,viewDirectionW\n,vPositionW\n,noise\n,false \n,1.0 \n,reflectionSampler\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#else\nreflectionCoords=createReflectionCoords(vPositionW,normalW);vec3 baseSpecularEnvironmentLight=sampleRadiance(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef ANISOTROPIC_BASE\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG*max(1.0-baseGeoInfo.anisotropy,0.3));\n#else\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);\n#endif\nvec3 coatEnvironmentLight=vec3(0.,0.,0.);if (coat_weight>0.0) {\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.,0.,0.);\n#else\nvec2 reflectionCoords=vec2(0.,0.);\n#endif\nreflectionCoords=createReflectionCoords(vPositionW,coatNormalW);float coatAlphaG=coat_roughness*coat_roughness;\n#ifdef ANISOTROPIC_COAT\ncoatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,coatGeoInfo\n,coatNormalW\n,viewDirectionW\n,vPositionW\n,noise\n,false \n,1.0 \n,reflectionSampler\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#else\ncoatEnvironmentLight=sampleRadiance(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,coatGeoInfo\n,reflectionSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#endif\n}\n#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)\nfloat modifiedFuzzRoughness=clamp(fuzz_roughness*fuzz_roughness*(1.0+0.5*environmentFuzzBrdf.y),0.0,1.0);vec3 fuzzEnvironmentLight=vec3(0.0);float fuzzIblFresnel=min(environmentFuzzBrdf.z*2.0,1.0);vec2 viewTangent=vec2(dot(viewDirectionW,fuzzTangent),dot(viewDirectionW,fuzzBitangent));float centerAngle=atan(viewTangent.y,viewTangent.x);for (int i=0; i<FUZZ_IBL_SAMPLES; ++i) {float angle=centerAngle+(float(i)/float(FUZZ_IBL_SAMPLES)-0.5+noise.x/float(FUZZ_IBL_SAMPLES))*3.141592;vec3 fiberCylinderNormal=normalize(cos(angle)*fuzzTangent+sin(angle)*fuzzBitangent);vec3 fuzzReflectionCoords=vec3(reflectionMatrix*vec4(fiberCylinderNormal,0));vec3 radianceSample=sampleRadiance(modifiedFuzzRoughness,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,fuzzGeoInfo\n,reflectionSampler\n,fuzzReflectionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);fuzzEnvironmentLight+=radianceSample;}\nfuzzEnvironmentLight/=float(FUZZ_IBL_SAMPLES);\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)\nvec3 fuzzDiffuseEnvironmentLight=sampleIrradiance(\nfuzzNormalW\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradiance\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n#endif\n,vReflectionInfos\n,viewDirectionW\n,0.0\n,vec3(1.0)\n);\n#else\nvec3 fuzzDiffuseEnvironmentLight=baseDiffuseEnvironmentLight;\n#endif\nfuzzEnvironmentLight=mix(min(fuzzEnvironmentLight,fuzzDiffuseEnvironmentLight),fuzzDiffuseEnvironmentLight,modifiedFuzzRoughness);\n#endif\nfloat dielectricIblFresnel=computeDielectricIblFresnel(baseDielectricReflectance,baseGeoInfo.environmentBrdf);vec3 dielectricIblColoredFresnel=dielectricIblFresnel*specular_color;\n#ifdef THIN_FILM\nfloat thin_film_cos_theta=max(baseGeoInfo.NdotV,specularAlphaG);float thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001*thin_film_cos_theta);float tf_brdf_x=baseGeoInfo.environmentBrdf.x;float tf_E_ss =baseGeoInfo.environmentBrdf.y;vec3 thinFilmDielectricF0=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricF0=mix(thinFilmDielectricF0,vec3(dot(thinFilmDielectricF0,vec3(0.3333))),thin_film_desaturation_scale);vec3 thinFilmDielectricDir=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricDir=mix(thinFilmDielectricDir,vec3(dot(thinFilmDielectricDir,vec3(0.3333))),thin_film_desaturation_scale);float tf_f0d_avg =dot(thinFilmDielectricF0, vec3(0.3333));float tf_dird_avg=dot(thinFilmDielectricDir,vec3(0.3333));vec3 thinFilmDielectricFresnel=thinFilmDielectricDir*(tf_f0d_avg/max(tf_dird_avg,1e-5));vec3 tf_E_dielectric=(vec3(1.0)-thinFilmDielectricFresnel)*vec3(tf_brdf_x)+thinFilmDielectricFresnel*vec3(tf_E_ss);vec3 tf_F_avg_dielectric=thinFilmDielectricFresnel+(vec3(1.0)-thinFilmDielectricFresnel)/21.0;vec3 tf_ECF_dielectric=vec3(1.0)+tf_F_avg_dielectric*(vec3(1.0)/vec3(tf_E_ss)-vec3(1.0));thinFilmDielectricFresnel=clamp(tf_E_dielectric*tf_ECF_dielectric,vec3(0.0),vec3(1.0));dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);dielectricIblFresnel=max(dielectricIblColoredFresnel.r,max(dielectricIblColoredFresnel.g,dielectricIblColoredFresnel.b));\n#endif\nvec3 conductorIblFresnel=computeConductorIblFresnel(baseConductorReflectance,baseGeoInfo.environmentBrdf);\n#ifdef THIN_FILM\nvec3 thinFilmConductorF0=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorF0=mix(thinFilmConductorF0,vec3(dot(thinFilmConductorF0,vec3(0.3333))),thin_film_desaturation_scale);vec3 thinFilmConductorDir=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorDir=mix(thinFilmConductorDir,vec3(dot(thinFilmConductorDir,vec3(0.3333))),thin_film_desaturation_scale);float tf_f0c_avg =dot(thinFilmConductorF0, vec3(0.3333));float tf_dirc_avg=dot(thinFilmConductorDir,vec3(0.3333));vec3 thinFilmConductorRaw=thinFilmConductorDir*(tf_f0c_avg/max(tf_dirc_avg,1e-5));\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)\nvec3 tf_b=getF82B(baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);float tf_brdf_z=baseGeoInfo.environmentBrdf.z/BRDF_Z_SCALE;vec3 tf_E_conductor=(vec3(1.0)-thinFilmConductorRaw)*vec3(tf_brdf_x)+thinFilmConductorRaw*vec3(tf_E_ss)-tf_b*vec3(tf_brdf_z);vec3 tf_F_avg_conductor=thinFilmConductorRaw+(vec3(1.0)-thinFilmConductorRaw)/21.0-tf_b/126.0;\n#else\nvec3 tf_E_conductor=(vec3(1.0)-thinFilmConductorRaw)*vec3(tf_brdf_x)+thinFilmConductorRaw*vec3(tf_E_ss);vec3 tf_F_avg_conductor=thinFilmConductorRaw+(vec3(1.0)-thinFilmConductorRaw)/21.0;\n#endif\nvec3 tf_ECF_conductor=vec3(1.0)+tf_F_avg_conductor*(vec3(1.0)/vec3(tf_E_ss)-vec3(1.0));vec3 thinFilmConductorFresnel=specular_weight*clamp(tf_E_conductor*tf_ECF_conductor,vec3(0.0),vec3(1.0));conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);\n#endif\nvec3 slab_diffuse_ibl=vec3(0.,0.,0.);vec3 slab_glossy_ibl=vec3(0.,0.,0.);vec3 slab_metal_ibl=vec3(0.,0.,0.);vec3 slab_coat_ibl=vec3(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*vLightingIntensity.z;\n#ifdef AMBIENT_OCCLUSION\nspecular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);\n#endif\nslab_glossy_ibl=baseSpecularEnvironmentLight*vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*vLightingIntensity.z;if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*vLightingIntensity.z;\n#ifdef AMBIENT_OCCLUSION\ncoat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);\n#endif\n}\n#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)\nvec3 slab_fuzz_ibl=fuzzEnvironmentLight*vLightingIntensity.z;\n#endif\nvec3 slab_translucent_base_ibl=vec3(0.0);vec3 slab_subsurface_ibl=vec3(0.,0.,0.);\n#ifdef REFRACTED_ENVIRONMENT\n#ifdef ANISOTROPIC_BASE\nvec3 forwardScatteredEnvironmentLight=sampleRadianceAnisotropic(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n#ifdef GEOMETRY_THIN_WALLED\n,viewDirectionW\n#else\n,normalW\n#endif\n,viewDirectionW\n,vPositionW\n,noise\n,true \n#ifdef GEOMETRY_THIN_WALLED\n,1.05 \n#else\n,specular_ior \n#endif\n,reflectionSampler\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#else\nvec3 forwardScatteredEnvironmentLight=vec3(0.,0.,0.);\n#ifdef DISPERSION\nfor (int i=0; i<3; i++) {vec3 iblRefractionCoords=refractedViewVectors[i];\n#else\nvec3 iblRefractionCoords=refractedViewVector;\n#endif\n#ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ\niblRefractionCoords.z*=-1.0;\n#endif\n#ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE\niblRefractionCoords=parallaxCorrectNormal(vPositionW,refractedViewVector,refractionSize,refractionPosition);\n#endif\niblRefractionCoords=vec3(reflectionMatrix*vec4(iblRefractionCoords,0));\n#ifdef DISPERSION\nforwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,iblRefractionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n)[i];\n#else\nforwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,iblRefractionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef DISPERSION\n}\n#endif\n#endif\n#ifdef REFRACTED_BACKGROUND\n#ifdef GEOMETRY_THIN_WALLED\nforwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha);\n#else\nforwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha));\n#endif\n#endif\n#ifdef SCATTERING\n#ifdef GEOMETRY_THIN_WALLED\nvec3 scatterVector=normalW;\n#else\n#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)\nvec3 scatterVector=mix(vReflectionDominantDirection,normalW,max3(iso_scatter_density));\n#else\nvec3 scatterVector=normalW;\n#endif\nscatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);\n#endif\n#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED)\nvec3 scatteredEnvironmentLight=scattered_light_from_irradiance_texture;\n#else\nvec3 scatteredEnvironmentLight=sampleIrradiance(\nscatterVector\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradiance\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n#endif\n,vReflectionInfos\n,viewDirectionW\n#if defined(GEOMETRY_THIN_WALLED)\n,base_diffuse_roughness\n,subsurface_color.rgb\n#else\n,1.0\n,volumeParams.multi_scatter_color\n#endif\n);\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nvec3 forward_scattered_light=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);\n#else\nvec3 forward_scattered_light=forwardScatteredEnvironmentLight*volume_absorption;vec3 back_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);vec3 iso_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#endif\n#else\nslab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption;\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION\nslab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;vec3 material_dielectric_base_ibl=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3(1.0));\n#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)\nslab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3(1.0),fuzz_color);\n#else\nmaterial_surface_ibl=material_coated_base_ibl;\n#endif\n#elif defined(REFRACTED_BACKGROUND)\nvec3 black=vec3(0.0);vec3 slab_translucent_base_ibl=vec3(0.0);\n#ifdef GEOMETRY_THIN_WALLED\n#ifdef SCATTERING\nvec3 forward_scattered_light=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);\n#else\nslab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint;\n#endif\n#else\n#ifdef SCATTERING\nvec3 forward_scattered_light=slab_translucent_background.rgb*volume_absorption;vec3 iso_scattered_light=(1.0-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#else\nslab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint;\n#endif\n#endif\nvec3 material_dielectric_base_ibl=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(baseGeoInfo.NdotV);vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,black,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3(1.0));material_surface_ibl=material_coated_base_ibl;\n#endif\n";e.IncludesShadersStore[Ue]||(e.IncludesShadersStore[Ue]=Xe);const we={name:Ue,shader:Xe},We="openpbrDirectLightingInit",He="#ifdef LIGHT{X}\npreLightingInfo preInfo{X};preLightingInfo preInfoCoat{X};vec4 lightColor{X}=light{X}.vLightDiffuse;float shadow{X}=1.;\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n#else\n#define CUSTOM_LIGHT{X}_COLOR \n#ifdef SPOTLIGHT{X}\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);\n#elif defined(POINTLIGHT{X})\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);\n#elif defined(HEMILIGHT{X})\npreInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);\n#elif defined(DIRLIGHT{X})\npreInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\npreInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);\n#endif\npreInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);\n#endif\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#endif\n#else\npreInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo{X}.attenuation=1.0;\n#endif\npreInfoCoat{X}.attenuation=preInfo{X}.attenuation;\n#if defined(HEMILIGHT{X})\npreInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\npreInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;\n#else\npreInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);\n#endif\npreInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;\n#endif\n#endif\n";e.IncludesShadersStore[We]||(e.IncludesShadersStore[We]=He);const Be={name:We,shader:He},Ve="openpbrDirectLighting",ke="#ifdef LIGHT{X}\n{vec3 slab_diffuse=vec3(0.,0.,0.);vec3 slab_translucent=vec3(0.,0.,0.);vec3 slab_glossy=vec3(0.,0.,0.);float specularFresnel=0.0;vec3 specularColoredFresnel=vec3(0.,0.,0.);vec3 slab_metal=vec3(0.,0.,0.);vec3 slab_coat=vec3(0.,0.,0.);float coatFresnel=0.0;vec3 slab_fuzz=vec3(0.,0.,0.);float fuzzFresnel=0.0;\n#ifdef HEMILIGHT{X}\nslab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\nslab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);\n#else\nslab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nslab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);\n#endif\n#ifdef FUZZ\nfloat fuzzNdotH=max(dot(fuzzNormalW,preInfo{X}.H),0.0);vec3 fuzzBrdf=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));\n#endif\n#ifdef THIN_FILM\nfloat thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001);\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\nslab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);\n#else\n{\n#ifdef ANISOTROPIC_BASE\nslab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,\nbaseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,\n0.0,lightColor{X}.rgb);\n#else\nslab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb);\n#endif\nspecularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color;\n#ifdef THIN_FILM\nvec3 thinFilmDielectricFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3(dot(thinFilmDielectricFresnel,vec3(0.3333))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);\n#endif\n}\n#endif\n#ifdef REFRACTED_LIGHTS\nvec3 forwardScatteredLight=vec3(0.0);\n#if AREALIGHT{X}\n#else\n{preLightingInfo preInfoTrans=preInfo{X};\n#ifdef SCATTERING\npreInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05)));\n#else\npreInfoTrans.roughness=transmission_roughness;\n#endif\nif (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;}\n#ifdef GEOMETRY_THIN_WALLED\nvec3 refractNormalW=viewDirectionW;\n#else\nvec3 refractNormalW=normalW;\n#endif\npreInfoTrans.NdotL=0.5*max(dot(-refractNormalW,preInfoTrans.L),0.0)+0.5;\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\nfloat diff=min(dispersion_iors[2]-dispersion_iors[0],max(dispersion_iors[0]-1.0,1.0));dispersion_iors[2]+=diff;dispersion_iors[0]-=diff;for (int i=0; i<3; i++) {float eta=1.0/dispersion_iors[i];\n#elif defined(GEOMETRY_THIN_WALLED)\nfloat eta=1.0;\n#else\nfloat eta=1.0/specular_ior;\n#endif\npreInfoTrans.H=preInfoTrans.L+min(eta,0.95)*viewDirectionW;float len2=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inversesqrt(len2);}\n#ifdef ANISOTROPIC_BASE\npreInfoTrans.H=-preInfoTrans.H;\n#endif\npreInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H);\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\nforwardScatteredLight[i]+=\n#else\nforwardScatteredLight+=\n#endif\n#if defined(ANISOTROPIC_BASE)\ncomputeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,\nbaseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,\ntransmission_roughness_alpha,lightColor{X}.rgb\n#else\ncomputeSpecularLighting(preInfoTrans,-refractNormalW,vec3(1.0),vec3(1.0),transmission_roughness_alpha,lightColor{X}.rgb\n#endif\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\n)[i];}\n#else\n);\n#endif\n#if !defined(GEOMETRY_THIN_WALLED)\nforwardScatteredLight=mix(forwardScatteredLight,0.25*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0,1.0));\n#endif\n#ifdef REFRACTED_BACKGROUND\n#ifdef GEOMETRY_THIN_WALLED\nforwardScatteredLight=mix(vec3(0.0),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha);\n#else\nforwardScatteredLight=max(vec3(0.0),mix(vec3(0.0),forwardScatteredLight,transmission_roughness_alpha));\n#endif\n#endif\n#ifdef SCATTERING\n#if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)\npreInfoTrans.roughness=1.0;vec3 diffused_forward_scattered_light=computeSpecularLighting(preInfoTrans,normalW,vec3(1.0),vec3(1.0),1.0,lightColor{X}.rgb)*volume_absorption;\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nvec3 forward_scattered_light=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);\n#else\nvec3 back_scattered_normal=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0,1.0);preInfoTrans.roughness=0.2;vec3 back_scattered_light=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3(1.0),vec3(0.08),0.0,lightColor{X}.rgb);vec3 forward_scattered_light=(forwardScatteredLight*volume_absorption);vec3 iso_scattered_light=slab_diffuse;vec3 back_scattering=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);\n#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)\nvec3 iso_scattering=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density);\n#else\nvec3 iso_scattering=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);\n#endif\nslab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#endif\n#else\nslab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;\n#endif\n}\n#endif\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\nslab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);\n#else\n{\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)\nvec3 coloredFresnel=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);\n#else\nvec3 coloredFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);\n#endif\n#ifdef THIN_FILM\nfloat thinFilmConductorAngle=max(preInfo{X}.VdotH,specular_roughness);vec3 thinFilmConductorFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,thinFilmConductorAngle,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3(0.3333))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);\n#endif\n#ifdef ANISOTROPIC_BASE\nslab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);\n#else\nslab_metal=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),coloredFresnel,specular_roughness,lightColor{X}.rgb);\n#endif\n}\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\nslab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);\n#else\n{\n#ifdef ANISOTROPIC_COAT\nslab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,\ncoatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,\n0.0,lightColor{X}.rgb);\n#else\nslab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3(coatReflectance.F0),vec3(1.0),coat_roughness,lightColor{X}.rgb);\n#endif\nfloat NdotH=max(dot(coatNormalW,preInfoCoat{X}.H),0.0);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}\n#endif\nvec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {float cosTheta_view=max(preInfoCoat{X}.NdotV,0.001);float cosTheta_light=max(preInfoCoat{X}.NdotL,0.001);float fresnel_view=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_view,5.0);float fresnel_light=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_light,5.0);float averageReflectance=(fresnel_view+fresnel_light)*0.5;float darkened_transmission=(1.0-averageReflectance)/(1.0+averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-cosTheta_view*cosTheta_view;sin2=sin2/(coat_ior*coat_ior)*coat_weight;float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;float effectivePathLength=coatPathLength*coat_weight;vec3 colored_transmission=pow(coat_color,vec3(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0,darkened_transmission,coat_weight);}\n#ifdef FUZZ\nfuzzFresnel=fuzzBrdf.z;vec3 fuzzNormalW=mix(normalW,coatNormalW,coat_weight);float fuzzNdotV=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0);float fuzzNdotL=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf);\n#else\nvec3 fuzz_color=vec3(0.0);\n#endif\n#ifdef PREPASS_IRRADIANCE\ntotal_direct_diffuse+=slab_diffuse;\n#endif\nvec3 material_dielectric_base=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);vec3 material_dielectric_gloss=material_dielectric_base*(1.0-specularFresnel)+slab_glossy*specularColoredFresnel;vec3 material_base_substrate=mix(material_dielectric_gloss,slab_metal,base_metalness);vec3 material_coated_base=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3(1.0));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3(1.0),fuzz_color);}\n#endif\n";e.IncludesShadersStore[Ve]||(e.IncludesShadersStore[Ve]=ke);const Ye={name:Ve,shader:ke},Ze="openpbrBlockPrePass",je="#if SCENE_MRT_COUNT>0\nfloat writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0;\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_LOCAL_POSITION\ngl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);\n#endif\n#if defined(PREPASS_VELOCITY)\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#elif defined(PREPASS_VELOCITY_LINEAR)\nvec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_ALBEDO\ngl_FragData[PREPASS_ALBEDO_INDEX]=vec4(base_color,writeGeometryInfo);\n#endif\n#ifdef PREPASS_ALBEDO_SQRT\nvec3 sqAlbedo=sqrt(base_color);\n#endif\n#ifdef PREPASS_IRRADIANCE\nvec3 irradiance=total_direct_diffuse;\n#ifndef UNLIT\n#ifdef REFLECTION\nirradiance+=slab_diffuse_ibl;\n#endif\n#endif\n#ifdef SCATTERING\nfloat scatter_mask=min(subsurface_weight+transmission_weight,1.0);\n#else\nfloat scatter_mask=0.0;\n#endif\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,writeGeometryInfo*scatter_mask);\n#endif\n#if defined(PREPASS_COLOR)\ngl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a);\n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_SCREENSPACE_DEPTH\ngl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_NORMALIZED_VIEW_DEPTH\ngl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_NORMAL\n#ifdef PREPASS_NORMAL_WORLDSPACE\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);\n#else\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);\n#endif\n#endif\n#ifdef PREPASS_WORLD_NORMAL\ngl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo); \n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#ifndef UNLIT\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;\n#endif\n#endif\n#endif\n";e.IncludesShadersStore[Ze]||(e.IncludesShadersStore[Ze]=je);const qe={name:Ze,shader:je},Ke="openpbrPixelShader",Qe="#define OPENPBR_FRAGMENT_SHADER\n#define CUSTOM_FRAGMENT_EXTENSION\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\nprecision highp float;\n#include<oitDeclaration>\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE\n#endif\n#include<__decl__openpbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<openpbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#include<textureRepetitionFunctions>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<importanceSampling>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<openpbrNormalMapFragmentMainFunctions>\n#include<openpbrNormalMapFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#include<openpbrDielectricReflectance>\n#include<openpbrConductorReflectance>\n#include<openpbrAmbientOcclusionFunctions>\n#include<openpbrGeometryInfo>\n#include<openpbrIblFunctions>\n#include<openpbrVolumeFunctions>\nvec3 layer(vec3 slab_bottom,vec3 slab_top,float lerp_factor,vec3 bottom_multiplier,vec3 top_multiplier) {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);}\nvoid main(void) {\n#ifdef PREPASS_IRRADIANCE\nvec3 total_direct_diffuse=vec3(0.0);\n#endif\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#include<pbrBlockNormalGeometric>\nvec3 coatNormalW=normalW;\n#include<openpbrNormalMapFragment>\n#include<openpbrBlockNormalFinal>\n#include<openpbrBaseLayerData>\n#include<openpbrTransmissionLayerData>\n#include<openpbrSubsurfaceLayerData>\n#include<openpbrCoatLayerData>\n#include<openpbrThinFilmLayerData>\n#include<openpbrFuzzLayerData>\n#include<openpbrAmbientOcclusionData>\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef ANISOTROPIC_COAT\ngeometryInfoAnisoOutParams coatGeoInfo=geometryInfoAniso(\ncoatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW\n,vec3(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN\n);\n#else\ngeometryInfoOutParams coatGeoInfo=geometryInfo(\ncoatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW\n);\n#endif\nspecular_roughness=mix(specular_roughness,pow(min(1.0,pow(specular_roughness,4.0)+2.0*pow(coat_roughness,4.0)),0.25),coat_weight);\n#ifdef ANISOTROPIC_BASE\ngeometryInfoAnisoOutParams baseGeoInfo=geometryInfoAniso(\nnormalW,viewDirectionW.xyz,specular_roughness,geometricNormalW\n,vec3(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN\n);\n#else\ngeometryInfoOutParams baseGeoInfo=geometryInfo(\nnormalW,viewDirectionW.xyz,specular_roughness,geometricNormalW\n);\n#endif\n#ifdef FUZZ\nvec3 fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));vec3 fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);vec3 fuzzBitangent=cross(fuzzNormalW,fuzzTangent);geometryInfoOutParams fuzzGeoInfo=geometryInfo(\nfuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW\n);\n#endif\nReflectanceParams coatReflectance;coatReflectance=dielectricReflectance(\ncoat_ior \n,1.0 \n,vec3(1.0)\n,coat_weight\n);\n#ifdef THIN_FILM\nfloat thin_film_outside_ior=mix(1.0,coat_ior,coat_weight);\n#endif\nReflectanceParams baseDielectricReflectance;{float effectiveCoatIor=mix(1.0,coat_ior,coat_weight);baseDielectricReflectance=dielectricReflectance(\nspecular_ior \n,effectiveCoatIor \n,specular_color\n,specular_weight\n);}\nReflectanceParams baseConductorReflectance;baseConductorReflectance=conductorReflectance(base_color,specular_color,specular_weight);vec3 volume_absorption=vec3(1.0);vec3 transmission_tint=vec3(1.0);float surface_translucency_weight=0.0;\n#if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS)\n#if defined(GEOMETRY_THIN_WALLED)\nvec3 refractedViewVector=-viewDirectionW;\n#else\n#ifdef DISPERSION\nvec3 refractedViewVectors[3];float iorDispersionSpread=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0);vec3 dispersion_iors=vec3(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (int i=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); }\n#else\nvec3 refractedViewVector=double_refract(-viewDirectionW,normalW,specular_ior);\n#endif\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nfloat transmission_roughness=specular_roughness;\n#else\nfloat transmission_roughness=specular_roughness*clamp(4.0*(specular_ior-1.0),0.001,1.0);\n#endif\n#if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB))\nOpenPBRHomogeneousVolume volumeParams;{\n#if defined(TRANSMISSION_SLAB)\nOpenPBRHomogeneousVolume transmissionVolumeParams=computeOpenPBRTransmissionVolume(\ntransmission_color.rgb,\ntransmission_depth,\ntransmission_scatter.rgb,\ntransmission_scatter_anisotropy\n);\n#endif\n#if defined(SUBSURFACE_SLAB)\nOpenPBRHomogeneousVolume subsurfaceVolumeParams=computeOpenPBRSubsurfaceVolume(\nsubsurface_color.rgb,\nsubsurface_radius,\nsubsurface_radius_scale.rgb,\nsubsurface_scatter_anisotropy\n);\n#endif\n#if !defined(TRANSMISSION_SLAB)\nvolumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight;\n#elif !defined(SUBSURFACE_SLAB)\nvolumeParams=transmissionVolumeParams;\n#ifdef TRANSMISSION_SLAB_VOLUME\nvolumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);\n#endif\nsurface_translucency_weight=transmission_weight;\n#else\nfloat subsurface_fraction_of_dielectric=(1.0f-transmission_weight)*subsurface_weight;float subsurface_and_transmission_fraction_of_dielectric=subsurface_fraction_of_dielectric+transmission_weight;float reciprocal_of_subsurface_and_transmission_fraction_of_dielectric =\n1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);float trans_weight=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;float subsurf_weight=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEps(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric;\n#endif\n}\nvolume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);vec3 backscatter_color=vec3(1.0);{vec3 reduced_scatter=volumeParams.scatter_coeff*vec3(1.0-volumeParams.anisotropy);vec3 reduced_albedo=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);vec3 sqrt_term=max(sqrt(1.0-reduced_albedo),0.0001);backscatter_color=(1.0-sqrt_term)/(1.0+sqrt_term);}\n#elif defined(TRANSMISSION_SLAB)\nsurface_translucency_weight=transmission_weight;\n#endif\n#ifdef SCATTERING\n#ifdef GEOMETRY_THIN_WALLED\nvec3 iso_scatter_density=vec3(1.0);\n#else\n#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING\nvec3 mfp=vec3(100.0)/volumeParams.extinction_coeff;vec3 scattered_light_from_irradiance_texture=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,renderTargetSize,mfp,projection,inverseProjection,SSS_SAMPLE_COUNT,noise.xy);float numLights=float(LIGHTCOUNT);\n#ifdef REFLECTION\nnumLights+=1.0;\n#endif\nscattered_light_from_irradiance_texture/=numLights;\n#else\nvec3 scattered_light_from_irradiance_texture=vec3(0.0);\n#endif\nfloat back_to_iso_scattering_blend=min(1.0+volumeParams.anisotropy,1.0);float iso_to_forward_scattering_blend=max(volumeParams.anisotropy,0.0);vec3 iso_scatter_transmittance=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3(0.2));vec3 iso_scatter_density=clamp(vec3(1.0)-iso_scatter_transmittance,0.0,1.0);transmission_roughness=min(transmission_roughness+pow((1.0-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0),1.0);\n#endif\nvolumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density));\n#endif\n#if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED))\ntransmission_tint*=transmission_color.rgb;\n#ifdef GEOMETRY_THIN_WALLED\nfloat sin2=1.0-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);float cos_t=sqrt(1.0-sin2);float pathLength=1.0/cos_t;transmission_tint=pow(transmission_tint,vec3(pathLength));\n#else\ntransmission_tint*=transmission_color.rgb;\n#endif\n#endif\n#if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED)\nfloat unweighted_translucency=max(mix(subsurface_weight,1.0f,transmission_weight),0.0001);transmission_tint=mix(vec3(1.0),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0,transmission_roughness,transmission_weight/unweighted_translucency);\n#endif\nfloat transmission_roughness_alpha=transmission_roughness*transmission_roughness;\n#endif\n#include<openpbrBackgroundTransmission>\nvec3 material_surface_ibl=vec3(0.,0.,0.);\n#include<openpbrEnvironmentLighting>\nvec3 material_surface_direct=vec3(0.,0.,0.);\n#if defined(LIGHT0)\nfloat aggShadow=0.;\n#include<openpbrDirectLightingInit>[0..maxSimultaneousLights]\n#include<openpbrDirectLighting>[0..maxSimultaneousLights]\n#endif\nvec3 material_surface_emission=vEmissionColor;\n#ifdef EMISSION_COLOR\nvec3 emissionColorTex=TEXRD(emissionColorSampler,vEmissionColorUV+uvOffset).rgb;\n#ifdef EMISSION_COLOR_GAMMA\nmaterial_surface_emission*=toLinearSpace(emissionColorTex.rgb);\n#else\nmaterial_surface_emission*=emissionColorTex.rgb;\n#endif\nmaterial_surface_emission*= vEmissionColorInfos.y;\n#endif\nmaterial_surface_emission*=vLightingIntensity.y;\n#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\nvec4 finalColor=vec4(material_surface_ibl+material_surface_direct+material_surface_emission,alpha);\n#define CUSTOM_FRAGMENT_BEFORE_FOG\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#include<pbrBlockImageProcessing>\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\n#include<openpbrBlockPrePass>\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=finalColor;\n#endif\n#include<oitFragment>\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}\n#endif\n#include<pbrDebug>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";e.ShadersStore[Ke]||(e.ShadersStore[Ke]=Qe);const Je=[n,i,s,o,q,m,u,g,E,v,b,L,C,D,J,M,x,z,U,r,w,p,W,R,G,F,B,O,h,I,V,H,S,P,ne,re,k,c,se,le,f,l,me,y,T,Ee,Re,Se,_,d,Ne,Fe,De,Ge,t,ze,we,Be,Ye,Y,X,A,qe,a,N];for(const n of Je)e.IncludesShadersStore[n.name]||(e.IncludesShadersStore[n.name]=n.shader);const $e={name:Ke,shader:Qe};export{$e as openpbrPixelShader};
//# sourceMappingURL=openpbr.fragment-C7R9gO6U.esm.min.js.map