@galacean/engine-shader 1.6.0-beta.0 → 1.6.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/package.json +4 -4
package/dist/browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@galacean/engine')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', '@galacean/engine'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.ShaderFragment = {}), global.Galacean));
|
|
5
5
|
})(this, (function (exports, engine) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _array_like_to_array(arr, len) {
|
package/dist/browser.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],a):a(((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean=e.Galacean||{},e.Galacean.Shader={}),e.Galacean)}(this,function(e,a){"use strict";function t(e,a){(null==a||a>e.length)&&(a=e.length);for(var t=0,n=Array(a);t<a;t++)n[t]=e[t];return n}var n=[].concat([{source:"#ifndef BLENDSHAPE_INCLUDED\n#define BLENDSHAPE_INCLUDED\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nmediump sampler2DArray renderer_BlendShapeTexture;ivec3 renderer_BlendShapeTextureInfo;float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];vec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return(texelFetch(renderer_BlendShapeTexture,uv,0)).xyz;}\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nfloat renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nfloat renderer_BlendShapeWeights[4];\n#else\nfloat renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\nvoid calculateBlendShape(Attributes attributes,inout vec4 position\n#ifdef RENDERER_HAS_NORMAL\n,inout vec3 normal\n#ifdef RENDERER_HAS_TANGENT\n,inout vec4 tangent\n#endif\n#endif\n){\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT)\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n}}\n#else\nposition.xyz+=attributes.POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=attributes.POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifdef RENDERER_HAS_NORMAL\nnormal+=attributes.NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=attributes.NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#ifdef RENDERER_HAS_TANGENT\ntangent.xyz+=attributes.TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=attributes.TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nposition.xyz+=attributes.POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=attributes.POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=attributes.NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=attributes.NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=attributes.NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=attributes.NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT )\ntangent.xyz+=attributes.TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=attributes.TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=attributes.TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=attributes.TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#else\nposition.xyz+=attributes.POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=attributes.POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=attributes.POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=attributes.POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=attributes.POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=attributes.POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n}\n#endif\n#endif\n",includeKey:"BlendShape.glsl"},{source:"#ifndef COMMON_INCLUDED\n#define COMMON_INCLUDED\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define HALF_MIN 6.103515625e-5\n#define HALF_EPS 4.8828125e-4\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 value){return vec4(pow(value.rgb,vec3(2.2)),value.a);}vec4 linearToGamma(vec4 value){value=max(value,0.0);return vec4(pow(value.rgb,vec3(1.0/2.2)),value.a);}float sRGBToLinear(float value){float linearRGBLo=value/12.92;float linearRGBHi=pow((value+0.055)/1.055,2.4);float linearRGB=(value<=0.04045)? linearRGBLo : linearRGBHi;return linearRGB;}vec4 sRGBToLinear(vec4 value){return vec4(sRGBToLinear(value.r),sRGBToLinear(value.g),sRGBToLinear(value.b),value.a);}float linearToSRGB(float value){value=max(value,0.0);return(value<=0.0031308)?(value*12.9232102): 1.055*pow(value,1.0/2.4)-0.055;}vec4 linearToSRGB(vec4 value){return vec4(linearToSRGB(value.r),linearToSRGB(value.g),linearToSRGB(value.b),value.a);}vec4 texture2DSRGB(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifdef ENGINE_NO_SRGB\ncolor=sRGBToLinear(color);\n#endif\nreturn color;}vec4 outputSRGBCorrection(vec4 linearIn){\n#ifdef ENGINE_OUTPUT_SRGB_CORRECT\nreturn linearToSRGB(linearIn);\n#else\nreturn linearIn;\n#endif\n}vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\nvec3 safeNormalize(vec3 inVec){float dp3=max(float(HALF_MIN),dot(inVec,inVec));return inVec*inversesqrt(dp3);}\n#endif\n",includeKey:"Common.glsl"},{source:"#ifndef FOG_INCLUDED\n#define FOG_INCLUDED\n#if SCENE_FOG_MODE != 0\nvec4 scene_FogColor;vec4 scene_FogParams;vec4 fog(vec4 color,vec3 positionVS){float fogDepth=length(positionVS);\n#if SCENE_FOG_MODE == 1\nfloat fogIntensity=clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nfloat fogIntensity=clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;float fogIntensity=clamp(exp2(-factor*factor),0.0,1.0);\n#endif\ncolor.rgb=mix(scene_FogColor.rgb,color.rgb,fogIntensity);return color;}\n#endif\n#endif\n",includeKey:"Fog.glsl"},{source:"#ifndef LIGHT_INCLUDED\n#define LIGHT_INCLUDED\nivec4 renderer_Layer;\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#ifdef GRAPHICS_API_WEBGL2\nDirectLight getDirectLight(int index){DirectLight light;light.color=scene_DirectLightColor[index];light.direction=scene_DirectLightDirection[index];return light;}\n#endif\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#ifdef GRAPHICS_API_WEBGL2\nPointLight getPointLight(int index){PointLight light;light.color=scene_PointLightColor[index];light.position=scene_PointLightPosition[index];light.distance=scene_PointLightDistance[index];return light;}\n#endif\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#ifdef GRAPHICS_API_WEBGL2\nSpotLight getSpotLight(int index){SpotLight light;light.color=scene_SpotLightColor[index];light.position=scene_SpotLightPosition[index];light.direction=scene_SpotLightDirection[index];light.distance=scene_SpotLightDistance[index];light.angleCos=scene_SpotLightAngleCos[index];light.penumbraCos=scene_SpotLightPenumbraCos[index];return light;}\n#endif\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};EnvMapLight scene_EnvMapLight;\n#ifdef SCENE_USE_SH\nvec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nsamplerCube scene_EnvSpecularSampler;\n#endif\n#endif\n",includeKey:"Light.glsl"},{source:"#ifndef NORMAL_INCLUDED\n#define NORMAL_INCLUDED\nvec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=(texture2D(normalTexture,uv)).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBNByDerivatives(vec2 uv,vec3 normal,vec3 position,bool isFrontFacing){\n#ifdef HAS_DERIVATIVES\nuv=isFrontFacing? uv:-uv;vec3 dp1=dFdx(position);vec3 dp2=dFdy(position);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;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);return mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nreturn mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n}\n#endif\n",includeKey:"Normal.glsl"},{source:"#ifndef SHADOW_SAMPLE_TENT_INCLUDED\n#define SHADOW_SAMPLE_TENT_INCLUDED\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}\n#endif\n",includeKey:"ShadowSampleTent.glsl"},{source:'#ifndef SHADOW_INCLUDED\n#define SHADOW_INCLUDED\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define NEED_CALCULATE_SHADOWS\n#endif\n#ifdef NEED_CALCULATE_SHADOWS\nmat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4((dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w),(dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w),(dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w),(dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w));comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(vec3 positionWS){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(positionWS);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(positionWS,1.0);return shadowCoord.xyz;}\n#endif\n#ifdef NEED_CALCULATE_SHADOWS\nvec4 scene_ShadowInfo;vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nmediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nsampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float textureShadowMapDowngrade(sampler2D scene_ShadowMap,vec3 shadowCoord){vec4 rgbaDepth=texture2D(scene_ShadowMap,shadowCoord.xy);float unpackDepth=dot(rgbaDepth,bitShift);return unpackDepth<shadowCoord.z ? 0.0 : 1.0;}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureShadowMapDowngrade(textureName, coord3)\n#else\nfloat textureShadowMapDowngrade(sampler2D scene_ShadowMap,vec3 shadowCoord){float depth=texture2D(scene_ShadowMap,shadowCoord.xy).r;return depth<shadowCoord.z ? 0.0 : 1.0;}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureShadowMapDowngrade(textureName, coord3)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include "ShadowSampleTent.glsl"\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(vec3 positionWS,vec3 shadowCoord){float attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nattenuation=mix(1.0,attenuation,scene_ShadowInfo.x);}float shadowFade=getShadowFade(positionWS);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);return attenuation;}\n#endif\n#endif\n',includeKey:"Shadow.glsl"},{source:"#ifndef TRANSFORM_INCLUDED\n#define TRANSFORM_INCLUDED\nmat4 renderer_LocalMat;mat4 renderer_ModelMat;mat4 camera_ViewMat;mat4 camera_ProjMat;mat4 renderer_MVMat;mat4 renderer_MVPMat;mat4 renderer_NormalMat;vec3 camera_Position;vec3 camera_Forward;vec4 camera_ProjectionParams;\n#endif\n",includeKey:"Transform.glsl"},{source:"#ifndef SKIN_INCLUDED\n#define SKIN_INCLUDED\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nsampler2D renderer_JointSampler;float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nmat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\nmat4 getSkinMatrix(Attributes attributes){\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=attributes.WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.x)+attributes.WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.y)+attributes.WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.z)+attributes.WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.w);\n#else\nmat4 skinMatrix=attributes.WEIGHTS_0.x*renderer_JointMatrix[int(attributes.JOINTS_0.x)]+attributes.WEIGHTS_0.y*renderer_JointMatrix[int(attributes.JOINTS_0.y)]+attributes.WEIGHTS_0.z*renderer_JointMatrix[int(attributes.JOINTS_0.z)]+attributes.WEIGHTS_0.w*renderer_JointMatrix[int(attributes.JOINTS_0.w)];\n#endif\nreturn skinMatrix;}\n#endif\n#endif\n",includeKey:"Skin.glsl"}],[{source:'#ifndef FORWARD_PASS_PBR_INCLUDED\n#define FORWARD_PASS_PBR_INCLUDED\n#include "Common.glsl"\n#include "Fog.glsl"\n#include "Transform.glsl"\n#include "Skin.glsl"\n#include "BlendShape.glsl"\n#include "Shadow.glsl"\n#include "AttributesPBR.glsl"\n#include "VaryingsPBR.glsl"\n#include "LightDirectPBR.glsl"\n#include "LightIndirectPBR.glsl"\n#include "VertexPBR.glsl"\n#include "FragmentPBR.glsl"\nVaryings PBRVertex(Attributes attributes){Varyings varyings;varyings.uv=getUV0(attributes);\n#ifdef RENDERER_HAS_UV1\nvaryings.uv1=attributes.TEXCOORD_1;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvaryings.vertexColor=attributes.COLOR_0;\n#endif\nVertexInputs vertexInputs=getVertexInputs(attributes);varyings.positionWS=vertexInputs.positionWS;\n#if SCENE_FOG_MODE != 0\nvaryings.positionVS=vertexInputs.positionVS;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvaryings.normalWS=vertexInputs.normalWS;\n#ifdef RENDERER_HAS_TANGENT\nvaryings.tangentWS=vertexInputs.tangentWS;varyings.bitangentWS=vertexInputs.bitangentWS;\n#endif\n#endif\n#if defined(NEED_CALCULATE_SHADOWS) && (SCENE_SHADOW_CASCADED_COUNT == 1)\nvaryings.shadowCoord=getShadowCoord(vertexInputs.positionWS);\n#endif\ngl_Position=renderer_MVPMat*vertexInputs.positionOS;return varyings;}void PBRFragment(Varyings varyings){BSDFData bsdfData;vec2 aoUV=varyings.uv;\n#if defined(MATERIAL_HAS_OCCLUSION_TEXTURE) && defined(RENDERER_HAS_UV1)\nif(material_OcclusionTextureCoord==1.0){aoUV=varyings.uv1;}\n#endif\nSurfaceData surfaceData=getSurfaceData(varyings,aoUV,gl_FrontFacing);initBSDFData(surfaceData,bsdfData);vec3 totalDiffuseColor=vec3(0,0,0);vec3 totalSpecularColor=vec3(0,0,0);float shadowAttenuation=1.0;\n#if defined(SCENE_DIRECT_LIGHT_COUNT) && defined(NEED_CALCULATE_SHADOWS)\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=varyings.shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord(varyings.positionWS);\n#endif\nshadowAttenuation*=sampleShadowMap(varyings.positionWS,shadowCoord);\n#endif\nevaluateDirectRadiance(varyings,surfaceData,bsdfData,shadowAttenuation,totalDiffuseColor,totalSpecularColor);evaluateIBL(varyings,surfaceData,bsdfData,totalDiffuseColor,totalSpecularColor);\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nvec3 refractionTransmitted=evaluateTransmission(surfaceData,bsdfData);totalDiffuseColor=mix(totalDiffuseColor,refractionTransmitted,surfaceData.transmission);\n#endif\nvec4 color=vec4((totalDiffuseColor+totalSpecularColor).rgb,surfaceData.opacity);color.rgb+=surfaceData.emissiveColor;\n#if SCENE_FOG_MODE != 0\ncolor=fog(color,varyings.positionVS);\n#endif\ngl_FragColor=color;}\n#endif\n',includeKey:"ForwardPassPBR.glsl"},{source:"#ifndef ATTRIBUTES_PBR_INCLUDED\n#define ATTRIBUTES_PBR_INCLUDED\nstruct Attributes{vec3 POSITION;\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifndef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 POSITION_BS0;vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nvec3 NORMAL_BS0;vec3 NORMAL_BS1;vec3 TANGENT_BS0;vec3 TANGENT_BS1;\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nvec3 POSITION_BS2;vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nvec3 NORMAL_BS0;vec3 NORMAL_BS1;vec3 NORMAL_BS2;vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nvec3 TANGENT_BS0;vec3 TANGENT_BS1;vec3 TANGENT_BS2;vec3 TANGENT_BS3;\n#endif\n#else\nvec3 POSITION_BS2;vec3 POSITION_BS3;vec3 POSITION_BS4;vec3 POSITION_BS5;vec3 POSITION_BS6;vec3 POSITION_BS7;\n#endif\n#endif\n#endif\n#endif\n#ifdef RENDERER_HAS_UV\nvec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nvec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nvec4 JOINTS_0;vec4 WEIGHTS_0;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvec4 COLOR_0;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 TANGENT;\n#endif\n};\n#endif\n",includeKey:"AttributesPBR.glsl"},{source:"#ifndef VARYINGS_PBR_INCLUDED\n#define VARYINGS_PBR_INCLUDED\nstruct Varyings{vec2 uv;\n#ifdef RENDERER_HAS_UV1\nvec2 uv1;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvec4 vertexColor;\n#endif\nvec3 positionWS;\n#if SCENE_FOG_MODE != 0\nvec3 positionVS;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS;\n#ifdef RENDERER_HAS_TANGENT\nvec3 tangentWS;vec3 bitangentWS;\n#endif\n#endif\n#if defined(NEED_CALCULATE_SHADOWS) && (SCENE_SHADOW_CASCADED_COUNT == 1)\nvec3 shadowCoord;\n#endif\n};\n#endif\n",includeKey:"VaryingsPBR.glsl"},{source:'#ifndef MATERIAL_INPUT_PBR_INCLUDED\n#define MATERIAL_INPUT_PBR_INCLUDED\n#include "Normal.glsl"\nfloat material_AlphaCutoff;vec4 material_BaseColor;float material_Metal;float material_Roughness;float material_IOR;vec3 material_EmissiveColor;float material_NormalIntensity;float material_OcclusionIntensity;float material_OcclusionTextureCoord;float material_SpecularIntensity;vec3 material_SpecularColor;\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nsampler2D material_SpecularIntensityTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\nsampler2D material_SpecularColorTexture;\n#endif\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat material_ClearCoat;float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nsampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nsampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nsampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nsampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec4 material_IridescenceInfo;\n#ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\nsampler2D material_IridescenceThicknessTexture;\n#endif\n#ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\nsampler2D material_IridescenceTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat material_SheenRoughness;vec3 material_SheenColor;\n#ifdef MATERIAL_HAS_SHEEN_TEXTURE\nsampler2D material_SheenTexture;\n#endif\n#ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\nsampler2D material_SheenRoughnessTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nfloat material_Transmission;\n#ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\nsampler2D material_TransmissionTexture;\n#endif\n#ifdef MATERIAL_HAS_THICKNESS\nvec3 material_AttenuationColor;float material_AttenuationDistance;float material_Thickness;\n#ifdef MATERIAL_HAS_THICKNESS_TEXTURE\nsampler2D material_ThicknessTexture;\n#endif\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nsampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nsampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nsampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nsampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nsampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(SurfaceData surfaceData){vec3 anisotropyDirection=(surfaceData.anisotropy>=0.0)? surfaceData.anisotropicB : surfaceData.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,surfaceData.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(surfaceData.normal,anisotropicNormal,abs(surfaceData.anisotropy)*saturate(5.0*surfaceData.roughness)));return bentNormal;}\n#endif\nSurfaceData getSurfaceData(Varyings v,vec2 aoUV,bool isFrontFacing){SurfaceData surfaceData;vec2 uv=v.uv;vec4 baseColor=material_BaseColor;float metallic=material_Metal;float roughness=material_Roughness;vec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nbaseColor*=texture2DSRGB(material_BaseTexture,uv);\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v.vertexColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,uv);roughness*=metalRoughMapColor.g;metallic*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nemissiveRadiance*=texture2DSRGB(material_EmissiveTexture,uv).rgb;\n#endif\nsurfaceData.albedoColor=baseColor.rgb;surfaceData.emissiveColor=emissiveRadiance;surfaceData.metallic=metallic;surfaceData.roughness=roughness;surfaceData.IOR=material_IOR;\n#ifdef MATERIAL_IS_TRANSPARENT\nsurfaceData.opacity=baseColor.a;\n#else\nsurfaceData.opacity=1.0;\n#endif\nsurfaceData.position=v.positionWS;\n#ifdef CAMERA_ORTHOGRAPHIC\nsurfaceData.viewDir=-camera_Forward;\n#else\nsurfaceData.viewDir=normalize(camera_Position-v.positionWS);\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v.normalWS);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v.positionWS);vec3 pos_dy=dFdy(v.positionWS);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;surfaceData.normal=normal;\n#ifdef NEED_TANGENT\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT)\nsurfaceData.tangent=v.tangentWS;surfaceData.bitangent=v.bitangentWS;mat3 tbn=mat3(v.tangentWS,v.bitangentWS,v.normalWS);\n#else\nmat3 tbn=getTBNByDerivatives(uv,normal,v.positionWS,isFrontFacing);surfaceData.tangent=tbn[0];surfaceData.bitangent=tbn[1];\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nsurfaceData.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,uv,isFrontFacing);\n#endif\n#endif\nsurfaceData.dotNV=saturate(dot(surfaceData.normal,surfaceData.viewDir));surfaceData.specularIntensity=material_SpecularIntensity;surfaceData.specularColor=material_SpecularColor;\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nsurfaceData.specularIntensity*=texture2D(material_SpecularIntensityTexture,uv).a;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\nsurfaceData.specularColor*=texture2D(material_SpecularColorTexture,uv).rgb;\n#endif\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nsurfaceData.clearCoatNormal=getNormalByNormalTexture(mat3(surfaceData.tangent,surfaceData.bitangent,surfaceData.normal),material_ClearCoatNormalTexture,material_NormalIntensity,uv,isFrontFacing);\n#else\nsurfaceData.clearCoatNormal=normal;\n#endif\nsurfaceData.clearCoatDotNV=saturate(dot(surfaceData.clearCoatNormal,surfaceData.viewDir));surfaceData.clearCoat=material_ClearCoat;surfaceData.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nsurfaceData.clearCoat*=(texture2D(material_ClearCoatTexture,uv)).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nsurfaceData.clearCoatRoughness*=(texture2D(material_ClearCoatRoughnessTexture,uv)).g;\n#endif\nsurfaceData.clearCoat=saturate(surfaceData.clearCoat);surfaceData.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(surfaceData.clearCoatRoughness+getAARoughnessFactor(surfaceData.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=(texture2D(material_AnisotropyTexture,uv)).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\nsurfaceData.anisotropy=anisotropy;surfaceData.anisotropicT=normalize(mat3(surfaceData.tangent,surfaceData.bitangent,surfaceData.normal)*anisotropicDirection);surfaceData.anisotropicB=normalize(cross(surfaceData.normal,surfaceData.anisotropicT));surfaceData.anisotropicN=getAnisotropicBentNormal(surfaceData);\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nsurfaceData.iridescenceFactor=material_IridescenceInfo.x;surfaceData.iridescenceIOR=material_IridescenceInfo.y;\n#ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\nfloat iridescenceThicknessWeight=texture2D(material_IridescenceThicknessTexture,uv).g;surfaceData.iridescenceThickness=mix(material_IridescenceInfo.z,material_IridescenceInfo.w,iridescenceThicknessWeight);\n#else\nsurfaceData.iridescenceThickness=material_IridescenceInfo.w;\n#endif\n#ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\nsurfaceData.iridescenceFactor*=texture2D(material_IridescenceTexture,uv).r;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nvec3 sheenColor=material_SheenColor;\n#ifdef MATERIAL_HAS_SHEEN_TEXTURE\nsheenColor*=texture2DSRGB(material_SheenTexture,uv).rgb;\n#endif\nsurfaceData.sheenColor=sheenColor;surfaceData.sheenRoughness=material_SheenRoughness;\n#ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\nsurfaceData.sheenRoughness*=texture2D(material_SheenRoughnessTexture,uv).a;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nsurfaceData.transmission=material_Transmission;\n#ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\nsurfaceData.transmission*=texture2D(material_TransmissionTexture,uv).r;\n#endif\n#ifdef MATERIAL_HAS_THICKNESS\nsurfaceData.absorptionCoefficient=-log(material_AttenuationColor+HALF_EPS)/max(HALF_EPS,material_AttenuationDistance);surfaceData.thickness=max(material_Thickness,0.0001);\n#ifdef MATERIAL_HAS_THICKNESS_TEXTURE\nsurfaceData.thickness*=texture2D(material_ThicknessTexture,uv).g;\n#endif\n#endif\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nsurfaceData.ambientOcclusion=((texture2D(material_OcclusionTexture,aoUV)).r-1.0)*material_OcclusionIntensity+1.0;\n#else\nsurfaceData.ambientOcclusion=1.0;\n#endif\nreturn surfaceData;}\n#endif\n',includeKey:"FragmentPBR.glsl"},{source:'\n#ifndef LIGHT_DIRECT_PBR_INCLUDED\n#define LIGHT_DIRECT_PBR_INCLUDED\n#ifndef FUNCTION_SURFACE_SHADING\n#define FUNCTION_SURFACE_SHADING surfaceShading\n#endif\n#ifndef FUNCTION_DIFFUSE_LOBE\n#define FUNCTION_DIFFUSE_LOBE diffuseLobe\n#endif\n#ifndef FUNCTION_SPECULAR_LOBE\n#define FUNCTION_SPECULAR_LOBE specularLobe\n#endif\n#ifndef FUNCTION_CLEAR_COAT_LOBE\n#define FUNCTION_CLEAR_COAT_LOBE clearCoatLobe\n#endif\n#ifndef FUNCTION_SHEEN_LOBE\n#define FUNCTION_SHEEN_LOBE sheenLobe\n#endif\n#include "BSDF.glsl"\n#include "Light.glsl"\n#include "ReflectionLobe.glsl"\nvoid surfaceShading(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 lightColor,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 diffuseColor=vec3(0);vec3 specularColor=vec3(0);float dotNL=saturate(dot(surfaceData.normal,incidentDirection));vec3 irradiance=dotNL*lightColor*PI;float attenuation=FUNCTION_CLEAR_COAT_LOBE(varyings,surfaceData,bsdfData,incidentDirection,lightColor,specularColor);vec3 attenuationIrradiance=attenuation*irradiance;FUNCTION_DIFFUSE_LOBE(varyings,surfaceData,bsdfData,attenuationIrradiance,diffuseColor);FUNCTION_SPECULAR_LOBE(varyings,surfaceData,bsdfData,incidentDirection,attenuationIrradiance,specularColor);FUNCTION_SHEEN_LOBE(varyings,surfaceData,bsdfData,incidentDirection,attenuationIrradiance,diffuseColor,specularColor);totalDiffuseColor+=diffuseColor;totalSpecularColor+=specularColor;}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,DirectLight directionalLight,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 lightColor=directionalLight.color;vec3 direction=-directionalLight.direction;FUNCTION_SURFACE_SHADING(varyings,surfaceData,bsdfData,direction,lightColor,totalDiffuseColor,totalSpecularColor);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,PointLight pointLight,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 lVector=pointLight.position-surfaceData.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 lightColor=pointLight.color;lightColor*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);FUNCTION_SURFACE_SHADING(varyings,surfaceData,bsdfData,direction,lightColor,totalDiffuseColor,totalSpecularColor);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,SpotLight spotLight,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 lVector=spotLight.position-surfaceData.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 lightColor=spotLight.color;lightColor*=spotEffect*decayEffect;FUNCTION_SURFACE_SHADING(varyings,surfaceData,bsdfData,direction,lightColor,totalDiffuseColor,totalSpecularColor);}\n#endif\nvoid evaluateDirectRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,float shadowAttenuation,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nfor(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){\n#ifdef GRAPHICS_API_WEBGL2\nDirectLight directionalLight=getDirectLight(i);\n#else\nDirectLight directionalLight;directionalLight.color=scene_DirectLightColor[i];directionalLight.direction=scene_DirectLightDirection[i];\n#endif\n#ifdef NEED_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\naddDirectionalDirectLightRadiance(varyings,surfaceData,bsdfData,directionalLight,totalDiffuseColor,totalSpecularColor);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nfor(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){\n#ifdef GRAPHICS_API_WEBGL2\nPointLight pointLight=getPointLight(i);\n#else\nPointLight pointLight;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];\n#endif\naddPointDirectLightRadiance(varyings,surfaceData,bsdfData,pointLight,totalDiffuseColor,totalSpecularColor);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nfor(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){\n#ifdef GRAPHICS_API_WEBGL2\nSpotLight spotLight=getSpotLight(i);\n#else\nSpotLight spotLight;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];\n#endif\naddSpotDirectLightRadiance(varyings,surfaceData,bsdfData,spotLight,totalDiffuseColor,totalSpecularColor);}}\n#endif\n}\n#endif\n',includeKey:"LightDirectPBR.glsl"},{source:'\n#ifndef LIGHT_INDIRECT_PBR_INCLUDED\n#define LIGHT_INDIRECT_PBR_INCLUDED\n#ifndef FUNCTION_DIFFUSE_IBL\n#define FUNCTION_DIFFUSE_IBL evaluateDiffuseIBL\n#endif\n#ifndef FUNCTION_SPECULAR_IBL\n#define FUNCTION_SPECULAR_IBL evaluateSpecularIBL\n#endif\n#ifndef FUNCTION_CLEAR_COAT_IBL\n#define FUNCTION_CLEAR_COAT_IBL evaluateClearCoatIBL\n#endif\n#ifndef FUNCTION_SHEEN_IBL\n#define FUNCTION_SHEEN_IBL evaluateSheenIBL\n#endif\n#include "LightIndirectFunctions.glsl"\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}void evaluateDiffuseIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,inout vec3 diffuseColor){\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,surfaceData.normal);irradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\ndiffuseColor+=bsdfData.diffuseAO*irradiance*BRDF_Diffuse_Lambert(bsdfData.diffuseColor);}float evaluateClearCoatIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,inout vec3 specularColor){float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(surfaceData,surfaceData.clearCoatNormal,bsdfData.clearCoatRoughness);float specularAO=evaluateSpecularOcclusion(surfaceData.dotNV,bsdfData.diffuseAO,bsdfData.clearCoatRoughness);specularColor+=specularAO*clearCoatRadiance*surfaceData.clearCoat*envBRDFApprox(bsdfData.clearCoatSpecularColor,1.0,bsdfData.clearCoatRoughness,surfaceData.clearCoatDotNV);radianceAttenuation-=surfaceData.clearCoat*F_Schlick(0.04,1.0,surfaceData.clearCoatDotNV);\n#endif\nreturn radianceAttenuation;}void evaluateSpecularIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,float radianceAttenuation,inout vec3 outSpecularColor){vec3 radiance=getLightProbeRadiance(surfaceData,surfaceData.normal,bsdfData.roughness);\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec3 speculaColor=mix(bsdfData.specularF0,bsdfData.iridescenceSpecularColor,surfaceData.iridescenceFactor);\n#else\nvec3 speculaColor=bsdfData.specularF0;\n#endif\nfloat specularAO=evaluateSpecularOcclusion(surfaceData.dotNV,bsdfData.diffuseAO,bsdfData.roughness);outSpecularColor+=specularAO*radianceAttenuation*radiance*envBRDFApprox(speculaColor,bsdfData.specularF90,bsdfData.roughness,surfaceData.dotNV);}void evaluateSheenIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,float radianceAttenuation,inout vec3 diffuseColor,inout vec3 specularColor){\n#ifdef MATERIAL_ENABLE_SHEEN\ndiffuseColor*=bsdfData.sheenScaling;specularColor*=bsdfData.sheenScaling;float specularAO=evaluateSpecularOcclusion(surfaceData.dotNV,bsdfData.diffuseAO,bsdfData.sheenRoughness);vec3 reflectance=specularAO*radianceAttenuation*bsdfData.approxIBLSheenDG*surfaceData.sheenColor;specularColor+=reflectance;\n#endif\n}void evaluateIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 diffuseColor=vec3(0);vec3 specularColor=vec3(0);FUNCTION_DIFFUSE_IBL(varyings,surfaceData,bsdfData,diffuseColor);float radianceAttenuation=FUNCTION_CLEAR_COAT_IBL(varyings,surfaceData,bsdfData,specularColor);FUNCTION_SPECULAR_IBL(varyings,surfaceData,bsdfData,radianceAttenuation,specularColor);FUNCTION_SHEEN_IBL(varyings,surfaceData,bsdfData,radianceAttenuation,diffuseColor,specularColor);totalDiffuseColor+=diffuseColor;totalSpecularColor+=specularColor;}\n#endif\n',includeKey:"LightIndirectPBR.glsl"},{source:"#ifndef VERTEX_INCLUDE\n#define VERTEX_INCLUDE\nstruct VertexInputs{vec4 positionOS;vec3 positionWS;\n#if SCENE_FOG_MODE != 0\nvec3 positionVS;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS;\n#ifdef RENDERER_HAS_TANGENT\nvec3 tangentWS;vec3 bitangentWS;\n#endif\n#endif\n};vec4 material_TilingOffset;vec2 getUV0(Attributes attributes){vec2 uv0=vec2(0);\n#ifdef RENDERER_HAS_UV\nuv0=attributes.TEXCOORD_0;\n#endif\nreturn uv0*material_TilingOffset.xy+material_TilingOffset.zw;}VertexInputs getVertexInputs(Attributes attributes){VertexInputs inputs;vec4 position=vec4(attributes.POSITION,1.0);\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(attributes.NORMAL);\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(attributes.TANGENT);\n#endif\n#endif\n#ifdef RENDERER_HAS_BLENDSHAPE\ncalculateBlendShape(attributes,position\n#ifdef RENDERER_HAS_NORMAL\n,normal\n#ifdef RENDERER_HAS_TANGENT\n,tangent\n#endif\n#endif\n);\n#endif\n#ifdef RENDERER_HAS_SKIN\nmat4 skinMatrix=getSkinMatrix(attributes);position=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#ifdef RENDERER_HAS_TANGENT\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n#ifdef RENDERER_HAS_NORMAL\ninputs.normalWS=normalize(mat3(renderer_NormalMat)*normal);\n#ifdef RENDERER_HAS_TANGENT\nvec3 tangentWS=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentWS=cross(inputs.normalWS,tangentWS)*tangent.w;inputs.tangentWS=tangentWS;inputs.bitangentWS=bitangentWS;\n#endif\n#endif\ninputs.positionOS=position;vec4 positionWS=renderer_ModelMat*position;inputs.positionWS=positionWS.xyz/positionWS.w;\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;inputs.positionVS=positionVS.xyz/positionVS.w;\n#endif\nreturn inputs;}\n#endif\n",includeKey:"VertexPBR.glsl"},{source:"#ifndef LIGHT_INDIRECT_FUNCTIONS_INCLUDED\n#define LIGHT_INDIRECT_FUNCTIONS_INCLUDED\nvec3 getReflectedVector(SurfaceData surfaceData,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-surfaceData.viewDir,surfaceData.anisotropicN);\n#else\nvec3 r=reflect(-surfaceData.viewDir,n);\n#endif\nreturn r;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(SurfaceData surfaceData,vec3 normal,float roughness){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(surfaceData,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,int(scene_EnvMapLight.mipMapLevel));\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=(RGBMToLinear(envMapColor,5.0)).rgb;\n#elif defined(ENGINE_NO_SRGB)\nenvMapColor=sRGBToLinear(envMapColor);\n#endif\nreturn envMapColor.rgb*scene_EnvMapLight.specularIntensity;\n#endif\n}float evaluateSpecularOcclusion(float dotNV,float diffuseAO,float roughness){float specularAOFactor=1.0;\n#if defined(MATERIAL_HAS_OCCLUSION_TEXTURE) && defined(SCENE_USE_SPECULAR_ENV)\nspecularAOFactor=saturate(pow(dotNV+diffuseAO,exp2(-16.0*roughness-1.0))-1.0+diffuseAO);\n#endif\nreturn specularAOFactor;}\n#endif\n",includeKey:"LightIndirectFunctions.glsl"},{source:"#ifndef REFLECTION_LOBE_INCLUDED\n#define REFLECTION_LOBE_INCLUDED\nvoid diffuseLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 attenuationIrradiance,inout vec3 diffuseColor){diffuseColor+=attenuationIrradiance*BRDF_Diffuse_Lambert(bsdfData.diffuseColor);}void specularLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 attenuationIrradiance,inout vec3 specularColor){specularColor+=attenuationIrradiance*BRDF_Specular_GGX(incidentDirection,surfaceData,bsdfData,surfaceData.normal,bsdfData.specularF0,bsdfData.roughness);}void sheenLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 attenuationIrradiance,inout vec3 diffuseColor,inout vec3 specularColor){\n#ifdef MATERIAL_ENABLE_SHEEN\ndiffuseColor*=bsdfData.sheenScaling;specularColor*=bsdfData.sheenScaling;specularColor+=attenuationIrradiance*sheenBRDF(incidentDirection,surfaceData,surfaceData.sheenColor,bsdfData.sheenRoughness);\n#endif\n}float clearCoatLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 color,inout vec3 specularColor){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(surfaceData.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;specularColor+=surfaceData.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,surfaceData,bsdfData,surfaceData.clearCoatNormal,bsdfData.clearCoatSpecularColor,bsdfData.clearCoatRoughness);attenuation-=surfaceData.clearCoat*F_Schlick(0.04,1.0,surfaceData.clearCoatDotNV);\n#endif\nreturn attenuation;}\n#endif\n",includeKey:"ReflectionLobe.glsl"},{source:"#ifndef REFRACTION_INCLUDED\n#define REFRACTION_INCLUDED\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nstruct RefractionModelResult{float transmissionLength;vec3 positionExit;};void refractionModelSphere(vec3 V,vec3 positionWS,vec3 normalWS,float ior,float thickness,out RefractionModelResult ray){vec3 R1=refract(V,normalWS,1.0/ior);float dist=dot(-normalWS,R1)*thickness;vec3 P1=positionWS+R1*dist;ray.transmissionLength=dist;ray.positionExit=P1;}void refractionModelPlanar(vec3 V,vec3 positionWS,vec3 normalWS,float ior,float thickness,out RefractionModelResult ray){vec3 R=refract(V,normalWS,1.0/ior);float dist=thickness/max(dot(-normalWS,R),1e-5f);ray.transmissionLength=dist;ray.positionExit=vec3(positionWS+R*dist);}\n#endif\n#endif\n",includeKey:"Refraction.glsl"},{source:'#ifndef BSDF_INCLUDED\n#define BSDF_INCLUDED\n#include "Refraction.glsl"\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n#if defined(RENDERER_HAS_TANGENT) || defined(MATERIAL_ENABLE_ANISOTROPY) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_HAS_NORMALTEXTURE)\n#define NEED_TANGENT\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nsampler2D scene_PrefilteredDFG;\n#endif\nstruct SurfaceData{vec3 albedoColor;vec3 emissiveColor;float metallic;float roughness;float ambientOcclusion;float opacity;float IOR;vec3 position;vec3 normal;\n#ifdef NEED_TANGENT\nvec3 tangent;vec3 bitangent;\n#endif\nvec3 viewDir;float dotNV;float specularIntensity;vec3 specularColor;\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy;vec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;\n#endif\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;vec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nfloat iridescenceIOR;float iridescenceFactor;float iridescenceThickness;\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat sheenRoughness;vec3 sheenColor;\n#endif\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nvec3 absorptionCoefficient;float transmission;float thickness;\n#endif\n};struct BSDFData{vec3 diffuseColor;float roughness;vec3 envSpecularDFG;float diffuseAO;vec3 specularF0;float specularF90;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatSpecularColor;float clearCoatRoughness;\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec3 iridescenceSpecularColor;\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat sheenRoughness;float sheenScaling;float approxIBLSheenDG;\n#endif\n};float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}float F_Schlick(float f0,float f90,float dotLH){return f0+(f90-f0)*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 f0,float f90,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(f90-f0)*fresnel+f0;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nfloat DG_GGX(float alpha,float dotNV,float dotNL,float dotNH){float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return G*D;}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat DG_GGX_anisotropic(vec3 h,vec3 l,SurfaceData surfaceData,float alpha,float dotNV,float dotNL,float dotNH){vec3 t=surfaceData.anisotropicT;vec3 b=surfaceData.anisotropicB;vec3 v=surfaceData.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+surfaceData.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-surfaceData.anisotropy),MIN_ROUGHNESS);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return G*D;}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,SurfaceData surfaceData,BSDFData bsdfData,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+surfaceData.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,surfaceData.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,bsdfData.specularF90,dotLH);\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nF=mix(F,bsdfData.iridescenceSpecularColor,surfaceData.iridescenceFactor);\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat GD=DG_GGX_anisotropic(halfDir,incidentDirection,surfaceData,alpha,dotNV,dotNL,dotNH);\n#else\nfloat GD=DG_GGX(alpha,dotNV,dotNL,dotNH);\n#endif\nreturn F*GD;}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec3 iorToFresnel0(vec3 transmittedIOR,float incidentIOR){return pow((transmittedIOR-incidentIOR)/(transmittedIOR+incidentIOR),vec3(2.0));}float iorToFresnel0(float transmittedIOR,float incidentIOR){return pow((transmittedIOR-incidentIOR)/(transmittedIOR+incidentIOR),2.0);}vec3 fresnelToIOR(vec3 f0){vec3 sqrtF0=sqrt(f0);return(vec3(1.0)+sqrtF0)/(vec3(1.0)-sqrtF0);}vec3 evalSensitivity(float opd,vec3 shift){float phase=2.0*PI*opd*1.0e-9;const vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);const vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);const vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-var*pow2(phase));xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*pow2(phase));xyz/=1.0685e-7;const mat3 XYZ_TO_RGB=mat3(3.2404542,-0.9692660,0.0556434,-1.5371385,1.8760108,-0.2040259,-0.4985314,0.0415560,1.0572252);vec3 rgb=XYZ_TO_RGB*xyz;return rgb;}vec3 evalIridescenceSpecular(float outsideIOR,float dotNV,float thinIOR,vec3 baseF0,float baseF90,float iridescenceThickness){vec3 iridescence=vec3(1.0);float iridescenceIOR=mix(outsideIOR,thinIOR,smoothstep(0.0,0.03,iridescenceThickness));float sinTheta2Sq=pow(outsideIOR/iridescenceIOR,2.0)*(1.0-pow(dotNV,2.0));float cosTheta2Sq=1.0-sinTheta2Sq;if(cosTheta2Sq<0.0){return iridescence;}float cosTheta2=sqrt(cosTheta2Sq);float f0=iorToFresnel0(iridescenceIOR,outsideIOR);float reflectance=F_Schlick(f0,baseF90,dotNV);float t121=1.0-reflectance;float phi12=0.0;float phi21=PI-phi12;vec3 baseIOR=fresnelToIOR(clamp(baseF0,0.0,0.9999));vec3 r1=iorToFresnel0(baseIOR,iridescenceIOR);vec3 r23=F_Schlick(r1,baseF90,cosTheta2);vec3 phi23=vec3(0.0);if(baseIOR[0]<iridescenceIOR){phi23[0]=PI;}if(baseIOR[1]<iridescenceIOR){phi23[1]=PI;}if(baseIOR[2]<iridescenceIOR){phi23[2]=PI;}float opd=2.0*iridescenceIOR*iridescenceThickness*cosTheta2;vec3 phi=vec3(phi21)+phi23;vec3 r123=clamp(reflectance*r23,1e-5,0.9999);vec3 sr123=sqrt(r123);vec3 rs=pow2(t121)*r23/(vec3(1.0)-r123);vec3 c0=reflectance+rs;iridescence=c0;vec3 cm=rs-t121;for(int m=1;m<=2;++m){cm*=sr123;vec3 sm=2.0*evalSensitivity(float(m)*opd,float(m)*phi);iridescence+=cm*sm;}return iridescence=max(iridescence,vec3(0.0));}\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat D_Charlie(float roughness,float dotNH){float invAlpha=1.0/roughness;float cos2h=dotNH*dotNH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invAlpha)*pow(sin2h,invAlpha*0.5)/(2.0*PI);}float V_Neubelt(float NoV,float NoL){return saturate(1.0/(4.0*(NoL+NoV-NoL*NoV)));}vec3 sheenBRDF(vec3 incidentDirection,SurfaceData surfaceData,vec3 sheenColor,float sheenRoughness){vec3 halfDir=normalize(incidentDirection+surfaceData.viewDir);float dotNL=saturate(dot(surfaceData.normal,incidentDirection));float dotNH=saturate(dot(surfaceData.normal,halfDir));float D=D_Charlie(sheenRoughness,dotNH);float V=V_Neubelt(surfaceData.dotNV,dotNL);vec3 F=sheenColor;return D*V*F;}float prefilteredSheenDFG(float dotNV,float sheenRoughness){\n#ifdef HAS_TEX_LOD\nreturn texture2DLodEXT(scene_PrefilteredDFG,vec2(dotNV,sheenRoughness),0.0).b;\n#else\nreturn texture2D(scene_PrefilteredDFG,vec2(dotNV,sheenRoughness),0.0).b;\n#endif\n}\n#endif\nvec3 envBRDFApprox(vec3 f0,float f90,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return f0*AB.x+f90*AB.y;}\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nsampler2D camera_OpaqueTexture;vec3 evaluateTransmission(SurfaceData surfaceData,BSDFData bsdfData){RefractionModelResult ray;\n#if REFRACTION_MODE == 0\nrefractionModelSphere(-surfaceData.viewDir,surfaceData.position,surfaceData.normal,surfaceData.IOR,surfaceData.thickness,ray);\n#elif REFRACTION_MODE == 1\nrefractionModelPlanar(-surfaceData.viewDir,surfaceData.position,surfaceData.normal,surfaceData.IOR,surfaceData.thickness,ray);\n#endif\nvec3 refractedRayExit=ray.positionExit;vec4 samplingPositionNDC=camera_ProjMat*camera_ViewMat*vec4(refractedRayExit,1.0);vec2 refractionCoords=(samplingPositionNDC.xy/samplingPositionNDC.w)*0.5+0.5;vec3 refractionTransmitted=texture2DSRGB(camera_OpaqueTexture,refractionCoords).rgb;refractionTransmitted*=bsdfData.diffuseColor;refractionTransmitted*=(1.0-max(max(bsdfData.envSpecularDFG.r,bsdfData.envSpecularDFG.g),bsdfData.envSpecularDFG.b));\n#ifdef MATERIAL_HAS_THICKNESS\nvec3 transmittance=min(vec3(1.0),exp(-surfaceData.absorptionCoefficient*ray.transmissionLength));refractionTransmitted*=transmittance;\n#endif\nreturn refractionTransmitted;}\n#endif\nvoid initBSDFData(SurfaceData surfaceData,out BSDFData bsdfData){vec3 albedoColor=surfaceData.albedoColor;float metallic=surfaceData.metallic;float roughness=surfaceData.roughness;vec3 dielectricBaseF0=vec3(pow2((surfaceData.IOR-1.0)/(surfaceData.IOR+1.0)));vec3 dielectricF0=min(dielectricBaseF0*surfaceData.specularColor,vec3(1.0))*surfaceData.specularIntensity;float dielectricF90=surfaceData.specularIntensity;bsdfData.specularF0=mix(dielectricF0,albedoColor,metallic);bsdfData.specularF90=mix(dielectricF90,1.0,metallic);bsdfData.diffuseColor=albedoColor*(1.0-metallic)*(1.0-max(max(dielectricF0.r,dielectricF0.g),dielectricF0.b));bsdfData.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(roughness+getAARoughnessFactor(surfaceData.normal),1.0));bsdfData.envSpecularDFG=envBRDFApprox(bsdfData.specularF0,bsdfData.specularF90,bsdfData.roughness,surfaceData.dotNV);bsdfData.diffuseAO=surfaceData.ambientOcclusion;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nbsdfData.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(surfaceData.clearCoatRoughness+getAARoughnessFactor(surfaceData.clearCoatNormal),1.0));bsdfData.clearCoatSpecularColor=vec3(0.04);\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nfloat topIOR=1.0;bsdfData.iridescenceSpecularColor=evalIridescenceSpecular(topIOR,surfaceData.dotNV,surfaceData.iridescenceIOR,bsdfData.specularF0,bsdfData.specularF90,surfaceData.iridescenceThickness);\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nbsdfData.sheenRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(surfaceData.sheenRoughness+getAARoughnessFactor(surfaceData.normal),1.0));bsdfData.approxIBLSheenDG=prefilteredSheenDFG(surfaceData.dotNV,bsdfData.sheenRoughness);bsdfData.sheenScaling=1.0-bsdfData.approxIBLSheenDG*max(max(surfaceData.sheenColor.r,surfaceData.sheenColor.g),surfaceData.sheenColor.b);\n#endif\n}\n#endif\n',includeKey:"BSDF.glsl"}]),i=!1;e.PBRSource='Shader "PBRShaderName"{Editor{Properties{Header("Base"){material_IOR("IOR",Range(0,5,0.01))=1.5;material_BaseColor("BaseColor",Color)=(1,1,1,1);material_BaseTexture("BaseTexture",Texture2D);}Header("Metal Roughness"){material_Metal("Metal",Range(0,1,0.01))=1;material_Roughness("Roughness",Range(0,1,0.01))=1;material_RoughnessMetallicTexture("RoughnessMetallicTexture",Texture2D);}Header("Specular"){material_SpecularIntensity("Intensity",Range(0,2,0.01))=1;material_SpecularColor("Color",Color)=(1,1,1,1);material_SpecularIntensityTexture("IntensityTexture",Texture2D);material_SpecularColorTexture("ColorTexture",Texture2D);}Header("Anisotropy"){anisotropy("Intensity",Range(0,1,0.01))=0;anisotropyRotation("Rotation",Range(0,360,1))=0;material_AnisotropyTexture("Texture",Texture2D);}Header("Normal"){material_NormalTexture("NormalTexture",Texture2D);material_NormalIntensity("NormalIntensity",Range(0,5,0.01))=1;}Header("Emissive"){material_EmissiveColor("EmissiveColor",HDRColor)=(0,0,0,1);material_EmissiveTexture("EmissiveTexture",Texture2D);}Header("Occlusion"){material_OcclusionTexture("OcclusionTexture",Texture2D);material_OcclusionIntensity("OcclusionIntensity",Range(0,5,0.01))=1;material_OcclusionTextureCoord("OcclusionTextureCoord",Float)=0;}Header("Clear Coat"){material_ClearCoat("ClearCoat",Range(0,1,0.01))=0;material_ClearCoatTexture("ClearCoatTexture",Texture2D);material_ClearCoatRoughness("ClearCoatRoughness",Range(0,1,0.01))=0;material_ClearCoatRoughnessTexture("ClearCoatRoughnessTexture",Texture2D);material_ClearCoatNormalTexture("ClearCoatNormalTexture",Texture2D);}Header("Thin Film Iridescence"){iridescence("Iridescence",Range(0,1,0.01))=0;iridescenceIOR("IOR",Range(1,5,0.01))=1.3;iridescenceRange("ThicknessRange",Vector2)=(100,400);material_IridescenceThicknessTexture("ThicknessTexture",Texture2D);material_IridescenceTexture("IridescenceTexture",Texture2D);}Header("Sheen"){sheenColor("Color",Color)=(0,0,0,1);sheenIntensity("Intensity",Range(0,1,0.01))=1;material_SheenRoughness("Roughness",Range(0,1,0.01))=0;material_SheenTexture("ColorTexture",Texture2D);material_SheenRoughnessTexture("RoughnessTexture",Texture2D);}Header("Transmission"){material_Transmission("Transmission",Range(0,1,0.01))=0;material_TransmissionTexture("TransmissionTexture",Texture2D);material_Thickness("Thickness",Range(0,5,0.01))=0;material_ThicknessTexture("ThicknessTexture",Texture2D);refractionMode("RefractionMode",Enum(Sphere:0,Planar:1))=1;material_AttenuationColor("AttenuationColor",Color)=(1,1,1,1);material_AttenuationDistance("AttenuationDistance",Range(0,1,0.01))=0;}Header("Common"){isTransparent("Transparent",Boolean)=false;renderFace("Render Face",Enum(Front:0,Back:1,Double:2))=0;blendMode("Blend Mode",Enum(Normal:0,Additive:1))=0;material_AlphaCutoff("AlphaCutoff",Range(0,1,0.01))=0;material_TilingOffset("TilingOffset",Vector4)=(1,1,0,0);}}UIScript "UIScriptPath";}SubShader "Default"{UsePass "pbr/Default/ShadowCaster"Pass "Forward Pass"{Tags{pipelineStage="Forward"}RenderQueueType renderQueueType;BlendFactor sourceColorBlendFactor;BlendFactor destinationColorBlendFactor;BlendFactor sourceAlphaBlendFactor;BlendFactor destinationAlphaBlendFactor;CullMode rasterStateCullMode;Bool blendEnabled;Bool depthWriteEnabled;DepthState customDepthState{WriteEnabled=depthWriteEnabled;}BlendState customBlendState{Enabled=blendEnabled;SourceColorBlendFactor=sourceColorBlendFactor;DestinationColorBlendFactor=destinationColorBlendFactor;SourceAlphaBlendFactor=sourceAlphaBlendFactor;DestinationAlphaBlendFactor=destinationAlphaBlendFactor;}RasterState customRasterState{CullMode=rasterStateCullMode;}DepthState=customDepthState;BlendState=customBlendState;RasterState=customRasterState;RenderQueueType=renderQueueType;VertexShader=PBRVertex;FragmentShader=PBRFragment;\n#include "ForwardPassPBR.glsl"\n}}}',e.fragmentList=n,e.registerIncludes=function(){if(!i){for(var e,r=function(e,a){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,a){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,void 0)}}(e))){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(n);!(e=r()).done;){var o=e.value;a.ShaderFactory.registerInclude(o.includeKey,o.source)}i=!0}},Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],a):a(((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean=e.Galacean||{},e.Galacean.ShaderFragment={}),e.Galacean)}(this,function(e,a){"use strict";function t(e,a){(null==a||a>e.length)&&(a=e.length);for(var t=0,n=Array(a);t<a;t++)n[t]=e[t];return n}var n=[].concat([{source:"#ifndef BLENDSHAPE_INCLUDED\n#define BLENDSHAPE_INCLUDED\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nmediump sampler2DArray renderer_BlendShapeTexture;ivec3 renderer_BlendShapeTextureInfo;float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];vec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return(texelFetch(renderer_BlendShapeTexture,uv,0)).xyz;}\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nfloat renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nfloat renderer_BlendShapeWeights[4];\n#else\nfloat renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\nvoid calculateBlendShape(Attributes attributes,inout vec4 position\n#ifdef RENDERER_HAS_NORMAL\n,inout vec3 normal\n#ifdef RENDERER_HAS_TANGENT\n,inout vec4 tangent\n#endif\n#endif\n){\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT)\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n}}\n#else\nposition.xyz+=attributes.POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=attributes.POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifdef RENDERER_HAS_NORMAL\nnormal+=attributes.NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=attributes.NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#ifdef RENDERER_HAS_TANGENT\ntangent.xyz+=attributes.TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=attributes.TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nposition.xyz+=attributes.POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=attributes.POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=attributes.NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=attributes.NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=attributes.NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=attributes.NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT )\ntangent.xyz+=attributes.TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=attributes.TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=attributes.TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=attributes.TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#else\nposition.xyz+=attributes.POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=attributes.POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=attributes.POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=attributes.POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=attributes.POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=attributes.POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n}\n#endif\n#endif\n",includeKey:"BlendShape.glsl"},{source:"#ifndef COMMON_INCLUDED\n#define COMMON_INCLUDED\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define HALF_MIN 6.103515625e-5\n#define HALF_EPS 4.8828125e-4\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 value){return vec4(pow(value.rgb,vec3(2.2)),value.a);}vec4 linearToGamma(vec4 value){value=max(value,0.0);return vec4(pow(value.rgb,vec3(1.0/2.2)),value.a);}float sRGBToLinear(float value){float linearRGBLo=value/12.92;float linearRGBHi=pow((value+0.055)/1.055,2.4);float linearRGB=(value<=0.04045)? linearRGBLo : linearRGBHi;return linearRGB;}vec4 sRGBToLinear(vec4 value){return vec4(sRGBToLinear(value.r),sRGBToLinear(value.g),sRGBToLinear(value.b),value.a);}float linearToSRGB(float value){value=max(value,0.0);return(value<=0.0031308)?(value*12.9232102): 1.055*pow(value,1.0/2.4)-0.055;}vec4 linearToSRGB(vec4 value){return vec4(linearToSRGB(value.r),linearToSRGB(value.g),linearToSRGB(value.b),value.a);}vec4 texture2DSRGB(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifdef ENGINE_NO_SRGB\ncolor=sRGBToLinear(color);\n#endif\nreturn color;}vec4 outputSRGBCorrection(vec4 linearIn){\n#ifdef ENGINE_OUTPUT_SRGB_CORRECT\nreturn linearToSRGB(linearIn);\n#else\nreturn linearIn;\n#endif\n}vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\nvec3 safeNormalize(vec3 inVec){float dp3=max(float(HALF_MIN),dot(inVec,inVec));return inVec*inversesqrt(dp3);}\n#endif\n",includeKey:"Common.glsl"},{source:"#ifndef FOG_INCLUDED\n#define FOG_INCLUDED\n#if SCENE_FOG_MODE != 0\nvec4 scene_FogColor;vec4 scene_FogParams;vec4 fog(vec4 color,vec3 positionVS){float fogDepth=length(positionVS);\n#if SCENE_FOG_MODE == 1\nfloat fogIntensity=clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nfloat fogIntensity=clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;float fogIntensity=clamp(exp2(-factor*factor),0.0,1.0);\n#endif\ncolor.rgb=mix(scene_FogColor.rgb,color.rgb,fogIntensity);return color;}\n#endif\n#endif\n",includeKey:"Fog.glsl"},{source:"#ifndef LIGHT_INCLUDED\n#define LIGHT_INCLUDED\nivec4 renderer_Layer;\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#ifdef GRAPHICS_API_WEBGL2\nDirectLight getDirectLight(int index){DirectLight light;light.color=scene_DirectLightColor[index];light.direction=scene_DirectLightDirection[index];return light;}\n#endif\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#ifdef GRAPHICS_API_WEBGL2\nPointLight getPointLight(int index){PointLight light;light.color=scene_PointLightColor[index];light.position=scene_PointLightPosition[index];light.distance=scene_PointLightDistance[index];return light;}\n#endif\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#ifdef GRAPHICS_API_WEBGL2\nSpotLight getSpotLight(int index){SpotLight light;light.color=scene_SpotLightColor[index];light.position=scene_SpotLightPosition[index];light.direction=scene_SpotLightDirection[index];light.distance=scene_SpotLightDistance[index];light.angleCos=scene_SpotLightAngleCos[index];light.penumbraCos=scene_SpotLightPenumbraCos[index];return light;}\n#endif\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};EnvMapLight scene_EnvMapLight;\n#ifdef SCENE_USE_SH\nvec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nsamplerCube scene_EnvSpecularSampler;\n#endif\n#endif\n",includeKey:"Light.glsl"},{source:"#ifndef NORMAL_INCLUDED\n#define NORMAL_INCLUDED\nvec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=(texture2D(normalTexture,uv)).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBNByDerivatives(vec2 uv,vec3 normal,vec3 position,bool isFrontFacing){\n#ifdef HAS_DERIVATIVES\nuv=isFrontFacing? uv:-uv;vec3 dp1=dFdx(position);vec3 dp2=dFdy(position);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;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);return mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nreturn mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n}\n#endif\n",includeKey:"Normal.glsl"},{source:"#ifndef SHADOW_SAMPLE_TENT_INCLUDED\n#define SHADOW_SAMPLE_TENT_INCLUDED\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}\n#endif\n",includeKey:"ShadowSampleTent.glsl"},{source:'#ifndef SHADOW_INCLUDED\n#define SHADOW_INCLUDED\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define NEED_CALCULATE_SHADOWS\n#endif\n#ifdef NEED_CALCULATE_SHADOWS\nmat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4((dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w),(dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w),(dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w),(dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w));comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(vec3 positionWS){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(positionWS);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(positionWS,1.0);return shadowCoord.xyz;}\n#endif\n#ifdef NEED_CALCULATE_SHADOWS\nvec4 scene_ShadowInfo;vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nmediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nsampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float textureShadowMapDowngrade(sampler2D scene_ShadowMap,vec3 shadowCoord){vec4 rgbaDepth=texture2D(scene_ShadowMap,shadowCoord.xy);float unpackDepth=dot(rgbaDepth,bitShift);return unpackDepth<shadowCoord.z ? 0.0 : 1.0;}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureShadowMapDowngrade(textureName, coord3)\n#else\nfloat textureShadowMapDowngrade(sampler2D scene_ShadowMap,vec3 shadowCoord){float depth=texture2D(scene_ShadowMap,shadowCoord.xy).r;return depth<shadowCoord.z ? 0.0 : 1.0;}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureShadowMapDowngrade(textureName, coord3)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include "ShadowSampleTent.glsl"\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(vec3 positionWS,vec3 shadowCoord){float attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nattenuation=mix(1.0,attenuation,scene_ShadowInfo.x);}float shadowFade=getShadowFade(positionWS);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);return attenuation;}\n#endif\n#endif\n',includeKey:"Shadow.glsl"},{source:"#ifndef TRANSFORM_INCLUDED\n#define TRANSFORM_INCLUDED\nmat4 renderer_LocalMat;mat4 renderer_ModelMat;mat4 camera_ViewMat;mat4 camera_ProjMat;mat4 renderer_MVMat;mat4 renderer_MVPMat;mat4 renderer_NormalMat;vec3 camera_Position;vec3 camera_Forward;vec4 camera_ProjectionParams;\n#endif\n",includeKey:"Transform.glsl"},{source:"#ifndef SKIN_INCLUDED\n#define SKIN_INCLUDED\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nsampler2D renderer_JointSampler;float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nmat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\nmat4 getSkinMatrix(Attributes attributes){\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=attributes.WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.x)+attributes.WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.y)+attributes.WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.z)+attributes.WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,attributes.JOINTS_0.w);\n#else\nmat4 skinMatrix=attributes.WEIGHTS_0.x*renderer_JointMatrix[int(attributes.JOINTS_0.x)]+attributes.WEIGHTS_0.y*renderer_JointMatrix[int(attributes.JOINTS_0.y)]+attributes.WEIGHTS_0.z*renderer_JointMatrix[int(attributes.JOINTS_0.z)]+attributes.WEIGHTS_0.w*renderer_JointMatrix[int(attributes.JOINTS_0.w)];\n#endif\nreturn skinMatrix;}\n#endif\n#endif\n",includeKey:"Skin.glsl"}],[{source:'#ifndef FORWARD_PASS_PBR_INCLUDED\n#define FORWARD_PASS_PBR_INCLUDED\n#include "Common.glsl"\n#include "Fog.glsl"\n#include "Transform.glsl"\n#include "Skin.glsl"\n#include "BlendShape.glsl"\n#include "Shadow.glsl"\n#include "AttributesPBR.glsl"\n#include "VaryingsPBR.glsl"\n#include "LightDirectPBR.glsl"\n#include "LightIndirectPBR.glsl"\n#include "VertexPBR.glsl"\n#include "FragmentPBR.glsl"\nVaryings PBRVertex(Attributes attributes){Varyings varyings;varyings.uv=getUV0(attributes);\n#ifdef RENDERER_HAS_UV1\nvaryings.uv1=attributes.TEXCOORD_1;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvaryings.vertexColor=attributes.COLOR_0;\n#endif\nVertexInputs vertexInputs=getVertexInputs(attributes);varyings.positionWS=vertexInputs.positionWS;\n#if SCENE_FOG_MODE != 0\nvaryings.positionVS=vertexInputs.positionVS;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvaryings.normalWS=vertexInputs.normalWS;\n#ifdef RENDERER_HAS_TANGENT\nvaryings.tangentWS=vertexInputs.tangentWS;varyings.bitangentWS=vertexInputs.bitangentWS;\n#endif\n#endif\n#if defined(NEED_CALCULATE_SHADOWS) && (SCENE_SHADOW_CASCADED_COUNT == 1)\nvaryings.shadowCoord=getShadowCoord(vertexInputs.positionWS);\n#endif\ngl_Position=renderer_MVPMat*vertexInputs.positionOS;return varyings;}void PBRFragment(Varyings varyings){BSDFData bsdfData;vec2 aoUV=varyings.uv;\n#if defined(MATERIAL_HAS_OCCLUSION_TEXTURE) && defined(RENDERER_HAS_UV1)\nif(material_OcclusionTextureCoord==1.0){aoUV=varyings.uv1;}\n#endif\nSurfaceData surfaceData=getSurfaceData(varyings,aoUV,gl_FrontFacing);initBSDFData(surfaceData,bsdfData);vec3 totalDiffuseColor=vec3(0,0,0);vec3 totalSpecularColor=vec3(0,0,0);float shadowAttenuation=1.0;\n#if defined(SCENE_DIRECT_LIGHT_COUNT) && defined(NEED_CALCULATE_SHADOWS)\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=varyings.shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord(varyings.positionWS);\n#endif\nshadowAttenuation*=sampleShadowMap(varyings.positionWS,shadowCoord);\n#endif\nevaluateDirectRadiance(varyings,surfaceData,bsdfData,shadowAttenuation,totalDiffuseColor,totalSpecularColor);evaluateIBL(varyings,surfaceData,bsdfData,totalDiffuseColor,totalSpecularColor);\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nvec3 refractionTransmitted=evaluateTransmission(surfaceData,bsdfData);totalDiffuseColor=mix(totalDiffuseColor,refractionTransmitted,surfaceData.transmission);\n#endif\nvec4 color=vec4((totalDiffuseColor+totalSpecularColor).rgb,surfaceData.opacity);color.rgb+=surfaceData.emissiveColor;\n#if SCENE_FOG_MODE != 0\ncolor=fog(color,varyings.positionVS);\n#endif\ngl_FragColor=color;}\n#endif\n',includeKey:"ForwardPassPBR.glsl"},{source:"#ifndef ATTRIBUTES_PBR_INCLUDED\n#define ATTRIBUTES_PBR_INCLUDED\nstruct Attributes{vec3 POSITION;\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifndef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 POSITION_BS0;vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nvec3 NORMAL_BS0;vec3 NORMAL_BS1;vec3 TANGENT_BS0;vec3 TANGENT_BS1;\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nvec3 POSITION_BS2;vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nvec3 NORMAL_BS0;vec3 NORMAL_BS1;vec3 NORMAL_BS2;vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nvec3 TANGENT_BS0;vec3 TANGENT_BS1;vec3 TANGENT_BS2;vec3 TANGENT_BS3;\n#endif\n#else\nvec3 POSITION_BS2;vec3 POSITION_BS3;vec3 POSITION_BS4;vec3 POSITION_BS5;vec3 POSITION_BS6;vec3 POSITION_BS7;\n#endif\n#endif\n#endif\n#endif\n#ifdef RENDERER_HAS_UV\nvec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nvec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nvec4 JOINTS_0;vec4 WEIGHTS_0;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvec4 COLOR_0;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 TANGENT;\n#endif\n};\n#endif\n",includeKey:"AttributesPBR.glsl"},{source:"#ifndef VARYINGS_PBR_INCLUDED\n#define VARYINGS_PBR_INCLUDED\nstruct Varyings{vec2 uv;\n#ifdef RENDERER_HAS_UV1\nvec2 uv1;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvec4 vertexColor;\n#endif\nvec3 positionWS;\n#if SCENE_FOG_MODE != 0\nvec3 positionVS;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS;\n#ifdef RENDERER_HAS_TANGENT\nvec3 tangentWS;vec3 bitangentWS;\n#endif\n#endif\n#if defined(NEED_CALCULATE_SHADOWS) && (SCENE_SHADOW_CASCADED_COUNT == 1)\nvec3 shadowCoord;\n#endif\n};\n#endif\n",includeKey:"VaryingsPBR.glsl"},{source:'#ifndef MATERIAL_INPUT_PBR_INCLUDED\n#define MATERIAL_INPUT_PBR_INCLUDED\n#include "Normal.glsl"\nfloat material_AlphaCutoff;vec4 material_BaseColor;float material_Metal;float material_Roughness;float material_IOR;vec3 material_EmissiveColor;float material_NormalIntensity;float material_OcclusionIntensity;float material_OcclusionTextureCoord;float material_SpecularIntensity;vec3 material_SpecularColor;\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nsampler2D material_SpecularIntensityTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\nsampler2D material_SpecularColorTexture;\n#endif\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat material_ClearCoat;float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nsampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nsampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nsampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nsampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec4 material_IridescenceInfo;\n#ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\nsampler2D material_IridescenceThicknessTexture;\n#endif\n#ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\nsampler2D material_IridescenceTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat material_SheenRoughness;vec3 material_SheenColor;\n#ifdef MATERIAL_HAS_SHEEN_TEXTURE\nsampler2D material_SheenTexture;\n#endif\n#ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\nsampler2D material_SheenRoughnessTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nfloat material_Transmission;\n#ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\nsampler2D material_TransmissionTexture;\n#endif\n#ifdef MATERIAL_HAS_THICKNESS\nvec3 material_AttenuationColor;float material_AttenuationDistance;float material_Thickness;\n#ifdef MATERIAL_HAS_THICKNESS_TEXTURE\nsampler2D material_ThicknessTexture;\n#endif\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nsampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nsampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nsampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nsampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nsampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(SurfaceData surfaceData){vec3 anisotropyDirection=(surfaceData.anisotropy>=0.0)? surfaceData.anisotropicB : surfaceData.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,surfaceData.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(surfaceData.normal,anisotropicNormal,abs(surfaceData.anisotropy)*saturate(5.0*surfaceData.roughness)));return bentNormal;}\n#endif\nSurfaceData getSurfaceData(Varyings v,vec2 aoUV,bool isFrontFacing){SurfaceData surfaceData;vec2 uv=v.uv;vec4 baseColor=material_BaseColor;float metallic=material_Metal;float roughness=material_Roughness;vec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nbaseColor*=texture2DSRGB(material_BaseTexture,uv);\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v.vertexColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,uv);roughness*=metalRoughMapColor.g;metallic*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nemissiveRadiance*=texture2DSRGB(material_EmissiveTexture,uv).rgb;\n#endif\nsurfaceData.albedoColor=baseColor.rgb;surfaceData.emissiveColor=emissiveRadiance;surfaceData.metallic=metallic;surfaceData.roughness=roughness;surfaceData.IOR=material_IOR;\n#ifdef MATERIAL_IS_TRANSPARENT\nsurfaceData.opacity=baseColor.a;\n#else\nsurfaceData.opacity=1.0;\n#endif\nsurfaceData.position=v.positionWS;\n#ifdef CAMERA_ORTHOGRAPHIC\nsurfaceData.viewDir=-camera_Forward;\n#else\nsurfaceData.viewDir=normalize(camera_Position-v.positionWS);\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v.normalWS);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v.positionWS);vec3 pos_dy=dFdy(v.positionWS);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;surfaceData.normal=normal;\n#ifdef NEED_TANGENT\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT)\nsurfaceData.tangent=v.tangentWS;surfaceData.bitangent=v.bitangentWS;mat3 tbn=mat3(v.tangentWS,v.bitangentWS,v.normalWS);\n#else\nmat3 tbn=getTBNByDerivatives(uv,normal,v.positionWS,isFrontFacing);surfaceData.tangent=tbn[0];surfaceData.bitangent=tbn[1];\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nsurfaceData.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,uv,isFrontFacing);\n#endif\n#endif\nsurfaceData.dotNV=saturate(dot(surfaceData.normal,surfaceData.viewDir));surfaceData.specularIntensity=material_SpecularIntensity;surfaceData.specularColor=material_SpecularColor;\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nsurfaceData.specularIntensity*=texture2D(material_SpecularIntensityTexture,uv).a;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\nsurfaceData.specularColor*=texture2D(material_SpecularColorTexture,uv).rgb;\n#endif\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nsurfaceData.clearCoatNormal=getNormalByNormalTexture(mat3(surfaceData.tangent,surfaceData.bitangent,surfaceData.normal),material_ClearCoatNormalTexture,material_NormalIntensity,uv,isFrontFacing);\n#else\nsurfaceData.clearCoatNormal=normal;\n#endif\nsurfaceData.clearCoatDotNV=saturate(dot(surfaceData.clearCoatNormal,surfaceData.viewDir));surfaceData.clearCoat=material_ClearCoat;surfaceData.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nsurfaceData.clearCoat*=(texture2D(material_ClearCoatTexture,uv)).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nsurfaceData.clearCoatRoughness*=(texture2D(material_ClearCoatRoughnessTexture,uv)).g;\n#endif\nsurfaceData.clearCoat=saturate(surfaceData.clearCoat);surfaceData.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(surfaceData.clearCoatRoughness+getAARoughnessFactor(surfaceData.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=(texture2D(material_AnisotropyTexture,uv)).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\nsurfaceData.anisotropy=anisotropy;surfaceData.anisotropicT=normalize(mat3(surfaceData.tangent,surfaceData.bitangent,surfaceData.normal)*anisotropicDirection);surfaceData.anisotropicB=normalize(cross(surfaceData.normal,surfaceData.anisotropicT));surfaceData.anisotropicN=getAnisotropicBentNormal(surfaceData);\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nsurfaceData.iridescenceFactor=material_IridescenceInfo.x;surfaceData.iridescenceIOR=material_IridescenceInfo.y;\n#ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\nfloat iridescenceThicknessWeight=texture2D(material_IridescenceThicknessTexture,uv).g;surfaceData.iridescenceThickness=mix(material_IridescenceInfo.z,material_IridescenceInfo.w,iridescenceThicknessWeight);\n#else\nsurfaceData.iridescenceThickness=material_IridescenceInfo.w;\n#endif\n#ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\nsurfaceData.iridescenceFactor*=texture2D(material_IridescenceTexture,uv).r;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nvec3 sheenColor=material_SheenColor;\n#ifdef MATERIAL_HAS_SHEEN_TEXTURE\nsheenColor*=texture2DSRGB(material_SheenTexture,uv).rgb;\n#endif\nsurfaceData.sheenColor=sheenColor;surfaceData.sheenRoughness=material_SheenRoughness;\n#ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\nsurfaceData.sheenRoughness*=texture2D(material_SheenRoughnessTexture,uv).a;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nsurfaceData.transmission=material_Transmission;\n#ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\nsurfaceData.transmission*=texture2D(material_TransmissionTexture,uv).r;\n#endif\n#ifdef MATERIAL_HAS_THICKNESS\nsurfaceData.absorptionCoefficient=-log(material_AttenuationColor+HALF_EPS)/max(HALF_EPS,material_AttenuationDistance);surfaceData.thickness=max(material_Thickness,0.0001);\n#ifdef MATERIAL_HAS_THICKNESS_TEXTURE\nsurfaceData.thickness*=texture2D(material_ThicknessTexture,uv).g;\n#endif\n#endif\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nsurfaceData.ambientOcclusion=((texture2D(material_OcclusionTexture,aoUV)).r-1.0)*material_OcclusionIntensity+1.0;\n#else\nsurfaceData.ambientOcclusion=1.0;\n#endif\nreturn surfaceData;}\n#endif\n',includeKey:"FragmentPBR.glsl"},{source:'\n#ifndef LIGHT_DIRECT_PBR_INCLUDED\n#define LIGHT_DIRECT_PBR_INCLUDED\n#ifndef FUNCTION_SURFACE_SHADING\n#define FUNCTION_SURFACE_SHADING surfaceShading\n#endif\n#ifndef FUNCTION_DIFFUSE_LOBE\n#define FUNCTION_DIFFUSE_LOBE diffuseLobe\n#endif\n#ifndef FUNCTION_SPECULAR_LOBE\n#define FUNCTION_SPECULAR_LOBE specularLobe\n#endif\n#ifndef FUNCTION_CLEAR_COAT_LOBE\n#define FUNCTION_CLEAR_COAT_LOBE clearCoatLobe\n#endif\n#ifndef FUNCTION_SHEEN_LOBE\n#define FUNCTION_SHEEN_LOBE sheenLobe\n#endif\n#include "BSDF.glsl"\n#include "Light.glsl"\n#include "ReflectionLobe.glsl"\nvoid surfaceShading(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 lightColor,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 diffuseColor=vec3(0);vec3 specularColor=vec3(0);float dotNL=saturate(dot(surfaceData.normal,incidentDirection));vec3 irradiance=dotNL*lightColor*PI;float attenuation=FUNCTION_CLEAR_COAT_LOBE(varyings,surfaceData,bsdfData,incidentDirection,lightColor,specularColor);vec3 attenuationIrradiance=attenuation*irradiance;FUNCTION_DIFFUSE_LOBE(varyings,surfaceData,bsdfData,attenuationIrradiance,diffuseColor);FUNCTION_SPECULAR_LOBE(varyings,surfaceData,bsdfData,incidentDirection,attenuationIrradiance,specularColor);FUNCTION_SHEEN_LOBE(varyings,surfaceData,bsdfData,incidentDirection,attenuationIrradiance,diffuseColor,specularColor);totalDiffuseColor+=diffuseColor;totalSpecularColor+=specularColor;}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,DirectLight directionalLight,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 lightColor=directionalLight.color;vec3 direction=-directionalLight.direction;FUNCTION_SURFACE_SHADING(varyings,surfaceData,bsdfData,direction,lightColor,totalDiffuseColor,totalSpecularColor);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,PointLight pointLight,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 lVector=pointLight.position-surfaceData.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 lightColor=pointLight.color;lightColor*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);FUNCTION_SURFACE_SHADING(varyings,surfaceData,bsdfData,direction,lightColor,totalDiffuseColor,totalSpecularColor);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,SpotLight spotLight,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 lVector=spotLight.position-surfaceData.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 lightColor=spotLight.color;lightColor*=spotEffect*decayEffect;FUNCTION_SURFACE_SHADING(varyings,surfaceData,bsdfData,direction,lightColor,totalDiffuseColor,totalSpecularColor);}\n#endif\nvoid evaluateDirectRadiance(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,float shadowAttenuation,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nfor(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){\n#ifdef GRAPHICS_API_WEBGL2\nDirectLight directionalLight=getDirectLight(i);\n#else\nDirectLight directionalLight;directionalLight.color=scene_DirectLightColor[i];directionalLight.direction=scene_DirectLightDirection[i];\n#endif\n#ifdef NEED_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\naddDirectionalDirectLightRadiance(varyings,surfaceData,bsdfData,directionalLight,totalDiffuseColor,totalSpecularColor);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nfor(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){\n#ifdef GRAPHICS_API_WEBGL2\nPointLight pointLight=getPointLight(i);\n#else\nPointLight pointLight;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];\n#endif\naddPointDirectLightRadiance(varyings,surfaceData,bsdfData,pointLight,totalDiffuseColor,totalSpecularColor);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nfor(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){\n#ifdef GRAPHICS_API_WEBGL2\nSpotLight spotLight=getSpotLight(i);\n#else\nSpotLight spotLight;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];\n#endif\naddSpotDirectLightRadiance(varyings,surfaceData,bsdfData,spotLight,totalDiffuseColor,totalSpecularColor);}}\n#endif\n}\n#endif\n',includeKey:"LightDirectPBR.glsl"},{source:'\n#ifndef LIGHT_INDIRECT_PBR_INCLUDED\n#define LIGHT_INDIRECT_PBR_INCLUDED\n#ifndef FUNCTION_DIFFUSE_IBL\n#define FUNCTION_DIFFUSE_IBL evaluateDiffuseIBL\n#endif\n#ifndef FUNCTION_SPECULAR_IBL\n#define FUNCTION_SPECULAR_IBL evaluateSpecularIBL\n#endif\n#ifndef FUNCTION_CLEAR_COAT_IBL\n#define FUNCTION_CLEAR_COAT_IBL evaluateClearCoatIBL\n#endif\n#ifndef FUNCTION_SHEEN_IBL\n#define FUNCTION_SHEEN_IBL evaluateSheenIBL\n#endif\n#include "LightIndirectFunctions.glsl"\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}void evaluateDiffuseIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,inout vec3 diffuseColor){\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,surfaceData.normal);irradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\ndiffuseColor+=bsdfData.diffuseAO*irradiance*BRDF_Diffuse_Lambert(bsdfData.diffuseColor);}float evaluateClearCoatIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,inout vec3 specularColor){float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(surfaceData,surfaceData.clearCoatNormal,bsdfData.clearCoatRoughness);float specularAO=evaluateSpecularOcclusion(surfaceData.dotNV,bsdfData.diffuseAO,bsdfData.clearCoatRoughness);specularColor+=specularAO*clearCoatRadiance*surfaceData.clearCoat*envBRDFApprox(bsdfData.clearCoatSpecularColor,1.0,bsdfData.clearCoatRoughness,surfaceData.clearCoatDotNV);radianceAttenuation-=surfaceData.clearCoat*F_Schlick(0.04,1.0,surfaceData.clearCoatDotNV);\n#endif\nreturn radianceAttenuation;}void evaluateSpecularIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,float radianceAttenuation,inout vec3 outSpecularColor){vec3 radiance=getLightProbeRadiance(surfaceData,surfaceData.normal,bsdfData.roughness);\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec3 speculaColor=mix(bsdfData.specularF0,bsdfData.iridescenceSpecularColor,surfaceData.iridescenceFactor);\n#else\nvec3 speculaColor=bsdfData.specularF0;\n#endif\nfloat specularAO=evaluateSpecularOcclusion(surfaceData.dotNV,bsdfData.diffuseAO,bsdfData.roughness);outSpecularColor+=specularAO*radianceAttenuation*radiance*envBRDFApprox(speculaColor,bsdfData.specularF90,bsdfData.roughness,surfaceData.dotNV);}void evaluateSheenIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,float radianceAttenuation,inout vec3 diffuseColor,inout vec3 specularColor){\n#ifdef MATERIAL_ENABLE_SHEEN\ndiffuseColor*=bsdfData.sheenScaling;specularColor*=bsdfData.sheenScaling;float specularAO=evaluateSpecularOcclusion(surfaceData.dotNV,bsdfData.diffuseAO,bsdfData.sheenRoughness);vec3 reflectance=specularAO*radianceAttenuation*bsdfData.approxIBLSheenDG*surfaceData.sheenColor;specularColor+=reflectance;\n#endif\n}void evaluateIBL(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,inout vec3 totalDiffuseColor,inout vec3 totalSpecularColor){vec3 diffuseColor=vec3(0);vec3 specularColor=vec3(0);FUNCTION_DIFFUSE_IBL(varyings,surfaceData,bsdfData,diffuseColor);float radianceAttenuation=FUNCTION_CLEAR_COAT_IBL(varyings,surfaceData,bsdfData,specularColor);FUNCTION_SPECULAR_IBL(varyings,surfaceData,bsdfData,radianceAttenuation,specularColor);FUNCTION_SHEEN_IBL(varyings,surfaceData,bsdfData,radianceAttenuation,diffuseColor,specularColor);totalDiffuseColor+=diffuseColor;totalSpecularColor+=specularColor;}\n#endif\n',includeKey:"LightIndirectPBR.glsl"},{source:"#ifndef VERTEX_INCLUDE\n#define VERTEX_INCLUDE\nstruct VertexInputs{vec4 positionOS;vec3 positionWS;\n#if SCENE_FOG_MODE != 0\nvec3 positionVS;\n#endif\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS;\n#ifdef RENDERER_HAS_TANGENT\nvec3 tangentWS;vec3 bitangentWS;\n#endif\n#endif\n};vec4 material_TilingOffset;vec2 getUV0(Attributes attributes){vec2 uv0=vec2(0);\n#ifdef RENDERER_HAS_UV\nuv0=attributes.TEXCOORD_0;\n#endif\nreturn uv0*material_TilingOffset.xy+material_TilingOffset.zw;}VertexInputs getVertexInputs(Attributes attributes){VertexInputs inputs;vec4 position=vec4(attributes.POSITION,1.0);\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(attributes.NORMAL);\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(attributes.TANGENT);\n#endif\n#endif\n#ifdef RENDERER_HAS_BLENDSHAPE\ncalculateBlendShape(attributes,position\n#ifdef RENDERER_HAS_NORMAL\n,normal\n#ifdef RENDERER_HAS_TANGENT\n,tangent\n#endif\n#endif\n);\n#endif\n#ifdef RENDERER_HAS_SKIN\nmat4 skinMatrix=getSkinMatrix(attributes);position=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#ifdef RENDERER_HAS_TANGENT\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n#ifdef RENDERER_HAS_NORMAL\ninputs.normalWS=normalize(mat3(renderer_NormalMat)*normal);\n#ifdef RENDERER_HAS_TANGENT\nvec3 tangentWS=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentWS=cross(inputs.normalWS,tangentWS)*tangent.w;inputs.tangentWS=tangentWS;inputs.bitangentWS=bitangentWS;\n#endif\n#endif\ninputs.positionOS=position;vec4 positionWS=renderer_ModelMat*position;inputs.positionWS=positionWS.xyz/positionWS.w;\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;inputs.positionVS=positionVS.xyz/positionVS.w;\n#endif\nreturn inputs;}\n#endif\n",includeKey:"VertexPBR.glsl"},{source:"#ifndef LIGHT_INDIRECT_FUNCTIONS_INCLUDED\n#define LIGHT_INDIRECT_FUNCTIONS_INCLUDED\nvec3 getReflectedVector(SurfaceData surfaceData,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-surfaceData.viewDir,surfaceData.anisotropicN);\n#else\nvec3 r=reflect(-surfaceData.viewDir,n);\n#endif\nreturn r;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(SurfaceData surfaceData,vec3 normal,float roughness){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(surfaceData,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,int(scene_EnvMapLight.mipMapLevel));\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=(RGBMToLinear(envMapColor,5.0)).rgb;\n#elif defined(ENGINE_NO_SRGB)\nenvMapColor=sRGBToLinear(envMapColor);\n#endif\nreturn envMapColor.rgb*scene_EnvMapLight.specularIntensity;\n#endif\n}float evaluateSpecularOcclusion(float dotNV,float diffuseAO,float roughness){float specularAOFactor=1.0;\n#if defined(MATERIAL_HAS_OCCLUSION_TEXTURE) && defined(SCENE_USE_SPECULAR_ENV)\nspecularAOFactor=saturate(pow(dotNV+diffuseAO,exp2(-16.0*roughness-1.0))-1.0+diffuseAO);\n#endif\nreturn specularAOFactor;}\n#endif\n",includeKey:"LightIndirectFunctions.glsl"},{source:"#ifndef REFLECTION_LOBE_INCLUDED\n#define REFLECTION_LOBE_INCLUDED\nvoid diffuseLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 attenuationIrradiance,inout vec3 diffuseColor){diffuseColor+=attenuationIrradiance*BRDF_Diffuse_Lambert(bsdfData.diffuseColor);}void specularLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 attenuationIrradiance,inout vec3 specularColor){specularColor+=attenuationIrradiance*BRDF_Specular_GGX(incidentDirection,surfaceData,bsdfData,surfaceData.normal,bsdfData.specularF0,bsdfData.roughness);}void sheenLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 attenuationIrradiance,inout vec3 diffuseColor,inout vec3 specularColor){\n#ifdef MATERIAL_ENABLE_SHEEN\ndiffuseColor*=bsdfData.sheenScaling;specularColor*=bsdfData.sheenScaling;specularColor+=attenuationIrradiance*sheenBRDF(incidentDirection,surfaceData,surfaceData.sheenColor,bsdfData.sheenRoughness);\n#endif\n}float clearCoatLobe(Varyings varyings,SurfaceData surfaceData,BSDFData bsdfData,vec3 incidentDirection,vec3 color,inout vec3 specularColor){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(surfaceData.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;specularColor+=surfaceData.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,surfaceData,bsdfData,surfaceData.clearCoatNormal,bsdfData.clearCoatSpecularColor,bsdfData.clearCoatRoughness);attenuation-=surfaceData.clearCoat*F_Schlick(0.04,1.0,surfaceData.clearCoatDotNV);\n#endif\nreturn attenuation;}\n#endif\n",includeKey:"ReflectionLobe.glsl"},{source:"#ifndef REFRACTION_INCLUDED\n#define REFRACTION_INCLUDED\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nstruct RefractionModelResult{float transmissionLength;vec3 positionExit;};void refractionModelSphere(vec3 V,vec3 positionWS,vec3 normalWS,float ior,float thickness,out RefractionModelResult ray){vec3 R1=refract(V,normalWS,1.0/ior);float dist=dot(-normalWS,R1)*thickness;vec3 P1=positionWS+R1*dist;ray.transmissionLength=dist;ray.positionExit=P1;}void refractionModelPlanar(vec3 V,vec3 positionWS,vec3 normalWS,float ior,float thickness,out RefractionModelResult ray){vec3 R=refract(V,normalWS,1.0/ior);float dist=thickness/max(dot(-normalWS,R),1e-5f);ray.transmissionLength=dist;ray.positionExit=vec3(positionWS+R*dist);}\n#endif\n#endif\n",includeKey:"Refraction.glsl"},{source:'#ifndef BSDF_INCLUDED\n#define BSDF_INCLUDED\n#include "Refraction.glsl"\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n#if defined(RENDERER_HAS_TANGENT) || defined(MATERIAL_ENABLE_ANISOTROPY) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_HAS_NORMALTEXTURE)\n#define NEED_TANGENT\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nsampler2D scene_PrefilteredDFG;\n#endif\nstruct SurfaceData{vec3 albedoColor;vec3 emissiveColor;float metallic;float roughness;float ambientOcclusion;float opacity;float IOR;vec3 position;vec3 normal;\n#ifdef NEED_TANGENT\nvec3 tangent;vec3 bitangent;\n#endif\nvec3 viewDir;float dotNV;float specularIntensity;vec3 specularColor;\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy;vec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;\n#endif\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;vec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nfloat iridescenceIOR;float iridescenceFactor;float iridescenceThickness;\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat sheenRoughness;vec3 sheenColor;\n#endif\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nvec3 absorptionCoefficient;float transmission;float thickness;\n#endif\n};struct BSDFData{vec3 diffuseColor;float roughness;vec3 envSpecularDFG;float diffuseAO;vec3 specularF0;float specularF90;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatSpecularColor;float clearCoatRoughness;\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec3 iridescenceSpecularColor;\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat sheenRoughness;float sheenScaling;float approxIBLSheenDG;\n#endif\n};float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}float F_Schlick(float f0,float f90,float dotLH){return f0+(f90-f0)*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 f0,float f90,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(f90-f0)*fresnel+f0;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nfloat DG_GGX(float alpha,float dotNV,float dotNL,float dotNH){float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return G*D;}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat DG_GGX_anisotropic(vec3 h,vec3 l,SurfaceData surfaceData,float alpha,float dotNV,float dotNL,float dotNH){vec3 t=surfaceData.anisotropicT;vec3 b=surfaceData.anisotropicB;vec3 v=surfaceData.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+surfaceData.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-surfaceData.anisotropy),MIN_ROUGHNESS);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return G*D;}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,SurfaceData surfaceData,BSDFData bsdfData,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+surfaceData.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,surfaceData.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,bsdfData.specularF90,dotLH);\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nF=mix(F,bsdfData.iridescenceSpecularColor,surfaceData.iridescenceFactor);\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat GD=DG_GGX_anisotropic(halfDir,incidentDirection,surfaceData,alpha,dotNV,dotNL,dotNH);\n#else\nfloat GD=DG_GGX(alpha,dotNV,dotNL,dotNH);\n#endif\nreturn F*GD;}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nvec3 iorToFresnel0(vec3 transmittedIOR,float incidentIOR){return pow((transmittedIOR-incidentIOR)/(transmittedIOR+incidentIOR),vec3(2.0));}float iorToFresnel0(float transmittedIOR,float incidentIOR){return pow((transmittedIOR-incidentIOR)/(transmittedIOR+incidentIOR),2.0);}vec3 fresnelToIOR(vec3 f0){vec3 sqrtF0=sqrt(f0);return(vec3(1.0)+sqrtF0)/(vec3(1.0)-sqrtF0);}vec3 evalSensitivity(float opd,vec3 shift){float phase=2.0*PI*opd*1.0e-9;const vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);const vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);const vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-var*pow2(phase));xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*pow2(phase));xyz/=1.0685e-7;const mat3 XYZ_TO_RGB=mat3(3.2404542,-0.9692660,0.0556434,-1.5371385,1.8760108,-0.2040259,-0.4985314,0.0415560,1.0572252);vec3 rgb=XYZ_TO_RGB*xyz;return rgb;}vec3 evalIridescenceSpecular(float outsideIOR,float dotNV,float thinIOR,vec3 baseF0,float baseF90,float iridescenceThickness){vec3 iridescence=vec3(1.0);float iridescenceIOR=mix(outsideIOR,thinIOR,smoothstep(0.0,0.03,iridescenceThickness));float sinTheta2Sq=pow(outsideIOR/iridescenceIOR,2.0)*(1.0-pow(dotNV,2.0));float cosTheta2Sq=1.0-sinTheta2Sq;if(cosTheta2Sq<0.0){return iridescence;}float cosTheta2=sqrt(cosTheta2Sq);float f0=iorToFresnel0(iridescenceIOR,outsideIOR);float reflectance=F_Schlick(f0,baseF90,dotNV);float t121=1.0-reflectance;float phi12=0.0;float phi21=PI-phi12;vec3 baseIOR=fresnelToIOR(clamp(baseF0,0.0,0.9999));vec3 r1=iorToFresnel0(baseIOR,iridescenceIOR);vec3 r23=F_Schlick(r1,baseF90,cosTheta2);vec3 phi23=vec3(0.0);if(baseIOR[0]<iridescenceIOR){phi23[0]=PI;}if(baseIOR[1]<iridescenceIOR){phi23[1]=PI;}if(baseIOR[2]<iridescenceIOR){phi23[2]=PI;}float opd=2.0*iridescenceIOR*iridescenceThickness*cosTheta2;vec3 phi=vec3(phi21)+phi23;vec3 r123=clamp(reflectance*r23,1e-5,0.9999);vec3 sr123=sqrt(r123);vec3 rs=pow2(t121)*r23/(vec3(1.0)-r123);vec3 c0=reflectance+rs;iridescence=c0;vec3 cm=rs-t121;for(int m=1;m<=2;++m){cm*=sr123;vec3 sm=2.0*evalSensitivity(float(m)*opd,float(m)*phi);iridescence+=cm*sm;}return iridescence=max(iridescence,vec3(0.0));}\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nfloat D_Charlie(float roughness,float dotNH){float invAlpha=1.0/roughness;float cos2h=dotNH*dotNH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invAlpha)*pow(sin2h,invAlpha*0.5)/(2.0*PI);}float V_Neubelt(float NoV,float NoL){return saturate(1.0/(4.0*(NoL+NoV-NoL*NoV)));}vec3 sheenBRDF(vec3 incidentDirection,SurfaceData surfaceData,vec3 sheenColor,float sheenRoughness){vec3 halfDir=normalize(incidentDirection+surfaceData.viewDir);float dotNL=saturate(dot(surfaceData.normal,incidentDirection));float dotNH=saturate(dot(surfaceData.normal,halfDir));float D=D_Charlie(sheenRoughness,dotNH);float V=V_Neubelt(surfaceData.dotNV,dotNL);vec3 F=sheenColor;return D*V*F;}float prefilteredSheenDFG(float dotNV,float sheenRoughness){\n#ifdef HAS_TEX_LOD\nreturn texture2DLodEXT(scene_PrefilteredDFG,vec2(dotNV,sheenRoughness),0.0).b;\n#else\nreturn texture2D(scene_PrefilteredDFG,vec2(dotNV,sheenRoughness),0.0).b;\n#endif\n}\n#endif\nvec3 envBRDFApprox(vec3 f0,float f90,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return f0*AB.x+f90*AB.y;}\n#ifdef MATERIAL_ENABLE_TRANSMISSION\nsampler2D camera_OpaqueTexture;vec3 evaluateTransmission(SurfaceData surfaceData,BSDFData bsdfData){RefractionModelResult ray;\n#if REFRACTION_MODE == 0\nrefractionModelSphere(-surfaceData.viewDir,surfaceData.position,surfaceData.normal,surfaceData.IOR,surfaceData.thickness,ray);\n#elif REFRACTION_MODE == 1\nrefractionModelPlanar(-surfaceData.viewDir,surfaceData.position,surfaceData.normal,surfaceData.IOR,surfaceData.thickness,ray);\n#endif\nvec3 refractedRayExit=ray.positionExit;vec4 samplingPositionNDC=camera_ProjMat*camera_ViewMat*vec4(refractedRayExit,1.0);vec2 refractionCoords=(samplingPositionNDC.xy/samplingPositionNDC.w)*0.5+0.5;vec3 refractionTransmitted=texture2DSRGB(camera_OpaqueTexture,refractionCoords).rgb;refractionTransmitted*=bsdfData.diffuseColor;refractionTransmitted*=(1.0-max(max(bsdfData.envSpecularDFG.r,bsdfData.envSpecularDFG.g),bsdfData.envSpecularDFG.b));\n#ifdef MATERIAL_HAS_THICKNESS\nvec3 transmittance=min(vec3(1.0),exp(-surfaceData.absorptionCoefficient*ray.transmissionLength));refractionTransmitted*=transmittance;\n#endif\nreturn refractionTransmitted;}\n#endif\nvoid initBSDFData(SurfaceData surfaceData,out BSDFData bsdfData){vec3 albedoColor=surfaceData.albedoColor;float metallic=surfaceData.metallic;float roughness=surfaceData.roughness;vec3 dielectricBaseF0=vec3(pow2((surfaceData.IOR-1.0)/(surfaceData.IOR+1.0)));vec3 dielectricF0=min(dielectricBaseF0*surfaceData.specularColor,vec3(1.0))*surfaceData.specularIntensity;float dielectricF90=surfaceData.specularIntensity;bsdfData.specularF0=mix(dielectricF0,albedoColor,metallic);bsdfData.specularF90=mix(dielectricF90,1.0,metallic);bsdfData.diffuseColor=albedoColor*(1.0-metallic)*(1.0-max(max(dielectricF0.r,dielectricF0.g),dielectricF0.b));bsdfData.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(roughness+getAARoughnessFactor(surfaceData.normal),1.0));bsdfData.envSpecularDFG=envBRDFApprox(bsdfData.specularF0,bsdfData.specularF90,bsdfData.roughness,surfaceData.dotNV);bsdfData.diffuseAO=surfaceData.ambientOcclusion;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nbsdfData.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(surfaceData.clearCoatRoughness+getAARoughnessFactor(surfaceData.clearCoatNormal),1.0));bsdfData.clearCoatSpecularColor=vec3(0.04);\n#endif\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\nfloat topIOR=1.0;bsdfData.iridescenceSpecularColor=evalIridescenceSpecular(topIOR,surfaceData.dotNV,surfaceData.iridescenceIOR,bsdfData.specularF0,bsdfData.specularF90,surfaceData.iridescenceThickness);\n#endif\n#ifdef MATERIAL_ENABLE_SHEEN\nbsdfData.sheenRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(surfaceData.sheenRoughness+getAARoughnessFactor(surfaceData.normal),1.0));bsdfData.approxIBLSheenDG=prefilteredSheenDFG(surfaceData.dotNV,bsdfData.sheenRoughness);bsdfData.sheenScaling=1.0-bsdfData.approxIBLSheenDG*max(max(surfaceData.sheenColor.r,surfaceData.sheenColor.g),surfaceData.sheenColor.b);\n#endif\n}\n#endif\n',includeKey:"BSDF.glsl"}]),i=!1;e.PBRSource='Shader "PBRShaderName"{Editor{Properties{Header("Base"){material_IOR("IOR",Range(0,5,0.01))=1.5;material_BaseColor("BaseColor",Color)=(1,1,1,1);material_BaseTexture("BaseTexture",Texture2D);}Header("Metal Roughness"){material_Metal("Metal",Range(0,1,0.01))=1;material_Roughness("Roughness",Range(0,1,0.01))=1;material_RoughnessMetallicTexture("RoughnessMetallicTexture",Texture2D);}Header("Specular"){material_SpecularIntensity("Intensity",Range(0,2,0.01))=1;material_SpecularColor("Color",Color)=(1,1,1,1);material_SpecularIntensityTexture("IntensityTexture",Texture2D);material_SpecularColorTexture("ColorTexture",Texture2D);}Header("Anisotropy"){anisotropy("Intensity",Range(0,1,0.01))=0;anisotropyRotation("Rotation",Range(0,360,1))=0;material_AnisotropyTexture("Texture",Texture2D);}Header("Normal"){material_NormalTexture("NormalTexture",Texture2D);material_NormalIntensity("NormalIntensity",Range(0,5,0.01))=1;}Header("Emissive"){material_EmissiveColor("EmissiveColor",HDRColor)=(0,0,0,1);material_EmissiveTexture("EmissiveTexture",Texture2D);}Header("Occlusion"){material_OcclusionTexture("OcclusionTexture",Texture2D);material_OcclusionIntensity("OcclusionIntensity",Range(0,5,0.01))=1;material_OcclusionTextureCoord("OcclusionTextureCoord",Float)=0;}Header("Clear Coat"){material_ClearCoat("ClearCoat",Range(0,1,0.01))=0;material_ClearCoatTexture("ClearCoatTexture",Texture2D);material_ClearCoatRoughness("ClearCoatRoughness",Range(0,1,0.01))=0;material_ClearCoatRoughnessTexture("ClearCoatRoughnessTexture",Texture2D);material_ClearCoatNormalTexture("ClearCoatNormalTexture",Texture2D);}Header("Thin Film Iridescence"){iridescence("Iridescence",Range(0,1,0.01))=0;iridescenceIOR("IOR",Range(1,5,0.01))=1.3;iridescenceRange("ThicknessRange",Vector2)=(100,400);material_IridescenceThicknessTexture("ThicknessTexture",Texture2D);material_IridescenceTexture("IridescenceTexture",Texture2D);}Header("Sheen"){sheenColor("Color",Color)=(0,0,0,1);sheenIntensity("Intensity",Range(0,1,0.01))=1;material_SheenRoughness("Roughness",Range(0,1,0.01))=0;material_SheenTexture("ColorTexture",Texture2D);material_SheenRoughnessTexture("RoughnessTexture",Texture2D);}Header("Transmission"){material_Transmission("Transmission",Range(0,1,0.01))=0;material_TransmissionTexture("TransmissionTexture",Texture2D);material_Thickness("Thickness",Range(0,5,0.01))=0;material_ThicknessTexture("ThicknessTexture",Texture2D);refractionMode("RefractionMode",Enum(Sphere:0,Planar:1))=1;material_AttenuationColor("AttenuationColor",Color)=(1,1,1,1);material_AttenuationDistance("AttenuationDistance",Range(0,1,0.01))=0;}Header("Common"){isTransparent("Transparent",Boolean)=false;renderFace("Render Face",Enum(Front:0,Back:1,Double:2))=0;blendMode("Blend Mode",Enum(Normal:0,Additive:1))=0;material_AlphaCutoff("AlphaCutoff",Range(0,1,0.01))=0;material_TilingOffset("TilingOffset",Vector4)=(1,1,0,0);}}UIScript "UIScriptPath";}SubShader "Default"{UsePass "pbr/Default/ShadowCaster"Pass "Forward Pass"{Tags{pipelineStage="Forward"}RenderQueueType renderQueueType;BlendFactor sourceColorBlendFactor;BlendFactor destinationColorBlendFactor;BlendFactor sourceAlphaBlendFactor;BlendFactor destinationAlphaBlendFactor;CullMode rasterStateCullMode;Bool blendEnabled;Bool depthWriteEnabled;DepthState customDepthState{WriteEnabled=depthWriteEnabled;}BlendState customBlendState{Enabled=blendEnabled;SourceColorBlendFactor=sourceColorBlendFactor;DestinationColorBlendFactor=destinationColorBlendFactor;SourceAlphaBlendFactor=sourceAlphaBlendFactor;DestinationAlphaBlendFactor=destinationAlphaBlendFactor;}RasterState customRasterState{CullMode=rasterStateCullMode;}DepthState=customDepthState;BlendState=customBlendState;RasterState=customRasterState;RenderQueueType=renderQueueType;VertexShader=PBRVertex;FragmentShader=PBRFragment;\n#include "ForwardPassPBR.glsl"\n}}}',e.fragmentList=n,e.registerIncludes=function(){if(!i){for(var e,r=function(e,a){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,a){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,void 0)}}(e))){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(n);!(e=r()).done;){var o=e.value;a.ShaderFactory.registerInclude(o.includeKey,o.source)}i=!0}},Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|
package/dist/browser.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.min.js","sources":["../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_array_like_to_array.js","../src/shaders/index.ts","../src/shaders/shadingPBR/index.ts","../src/index.ts","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_create_for_of_iterator_helper_loose.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js"],"sourcesContent":["function _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\nexport { _array_like_to_array as _ };\n","import BlendShape from \"./BlendShape.glsl\";\nimport Common from \"./Common.glsl\";\nimport Fog from \"./Fog.glsl\";\nimport Light from \"./Light.glsl\";\nimport Normal from \"./Normal.glsl\";\nimport PBRSource from \"./PBR.gs\";\nimport Shadow from \"./Shadow.glsl\";\nimport ShadowSampleTent from \"./ShadowSampleTent.glsl\";\nimport Skin from \"./Skin.glsl\";\nimport Transform from \"./Transform.glsl\";\nimport shadingPBR from \"./shadingPBR\";\n\ninterface IShaderFragment {\n includeKey: string;\n source: string;\n}\n\nconst fragmentList: IShaderFragment[] = [\n { source: BlendShape, includeKey: \"BlendShape.glsl\" },\n { source: Common, includeKey: \"Common.glsl\" },\n { source: Fog, includeKey: \"Fog.glsl\" },\n { source: Light, includeKey: \"Light.glsl\" },\n { source: Normal, includeKey: \"Normal.glsl\" },\n { source: ShadowSampleTent, includeKey: \"ShadowSampleTent.glsl\" },\n { source: Shadow, includeKey: \"Shadow.glsl\" },\n { source: Transform, includeKey: \"Transform.glsl\" },\n { source: Skin, includeKey: \"Skin.glsl\" },\n\n ...shadingPBR\n];\nexport { PBRSource, fragmentList };\n","import AttributesPBR from \"./AttributesPBR.glsl\";\nimport ForwardPassPBR from \"./ForwardPassPBR.glsl\";\nimport FragmentPBR from \"./FragmentPBR.glsl\";\nimport LightDirectPBR from \"./LightDirectPBR.glsl\";\nimport LightIndirectFunctions from \"./LightIndirectFunctions.glsl\";\nimport LightIndirectPBR from \"./LightIndirectPBR.glsl\";\nimport ReflectionLobe from \"./ReflectionLobe.glsl\";\nimport VaryingsPBR from \"./VaryingsPBR.glsl\";\nimport VertexPBR from \"./VertexPBR.glsl\";\nimport Refraction from \"./Refraction.glsl\";\nimport BSDF from \"./BSDF.glsl\";\n\nexport default [\n { source: ForwardPassPBR, includeKey: \"ForwardPassPBR.glsl\" },\n { source: AttributesPBR, includeKey: \"AttributesPBR.glsl\" },\n { source: VaryingsPBR, includeKey: \"VaryingsPBR.glsl\" },\n { source: FragmentPBR, includeKey: \"FragmentPBR.glsl\" },\n { source: LightDirectPBR, includeKey: \"LightDirectPBR.glsl\" },\n { source: LightIndirectPBR, includeKey: \"LightIndirectPBR.glsl\" },\n { source: VertexPBR, includeKey: \"VertexPBR.glsl\" },\n { source: LightIndirectFunctions, includeKey: \"LightIndirectFunctions.glsl\" },\n { source: ReflectionLobe, includeKey: \"ReflectionLobe.glsl\" },\n { source: Refraction, includeKey: \"Refraction.glsl\" },\n { source: BSDF, includeKey: \"BSDF.glsl\" }\n];\n","import { ShaderFactory } from \"@galacean/engine\";\nimport { PBRSource, fragmentList } from \"./shaders\";\n\nlet includeRegistered = false;\n\nexport function registerIncludes() {\n if (includeRegistered) return;\n\n for (const sourceFragment of fragmentList) {\n ShaderFactory.registerInclude(sourceFragment.includeKey, sourceFragment.source);\n }\n\n includeRegistered = true;\n}\n\nexport { PBRSource, fragmentList };\n","import { _ as _unsupported_iterable_to_array } from \"./_unsupported_iterable_to_array.js\";\n\nfunction _create_for_of_iterator_helper_loose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (it) return (it = it.call(o)).next.bind(it);\n // Fallback for engines without symbol support\n if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n\n var i = 0;\n\n return function() {\n if (i >= o.length) return { done: true };\n\n return { done: false, value: o[i++] };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _create_for_of_iterator_helper_loose as _ };\n","import { _ as _array_like_to_array } from \"./_array_like_to_array.js\";\n\nfunction _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\nexport { _unsupported_iterable_to_array as _ };\n"],"names":["_array_like_to_array","arr","len","length","i","arr2","Array","fragmentList","source","includeKey","shadingPBR","includeRegistered","_step","_iterator","_create_for_of_iterator_helper_loose","o","allowArrayLike","it","Symbol","iterator","call","next","bind","isArray","_unsupported_iterable_to_array","minLen","n","Object","prototype","toString","slice","constructor","name","from","test","done","value","TypeError","sourceFragment","ShaderFactory","registerInclude"],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.min.js","sources":["../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_array_like_to_array.js","../src/shaders/index.ts","../src/shaders/shadingPBR/index.ts","../src/index.ts","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_create_for_of_iterator_helper_loose.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js"],"sourcesContent":["function _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\nexport { _array_like_to_array as _ };\n","import BlendShape from \"./BlendShape.glsl\";\nimport Common from \"./Common.glsl\";\nimport Fog from \"./Fog.glsl\";\nimport Light from \"./Light.glsl\";\nimport Normal from \"./Normal.glsl\";\nimport PBRSource from \"./PBR.gs\";\nimport Shadow from \"./Shadow.glsl\";\nimport ShadowSampleTent from \"./ShadowSampleTent.glsl\";\nimport Skin from \"./Skin.glsl\";\nimport Transform from \"./Transform.glsl\";\nimport shadingPBR from \"./shadingPBR\";\n\ninterface IShaderFragment {\n includeKey: string;\n source: string;\n}\n\nconst fragmentList: IShaderFragment[] = [\n { source: BlendShape, includeKey: \"BlendShape.glsl\" },\n { source: Common, includeKey: \"Common.glsl\" },\n { source: Fog, includeKey: \"Fog.glsl\" },\n { source: Light, includeKey: \"Light.glsl\" },\n { source: Normal, includeKey: \"Normal.glsl\" },\n { source: ShadowSampleTent, includeKey: \"ShadowSampleTent.glsl\" },\n { source: Shadow, includeKey: \"Shadow.glsl\" },\n { source: Transform, includeKey: \"Transform.glsl\" },\n { source: Skin, includeKey: \"Skin.glsl\" },\n\n ...shadingPBR\n];\nexport { PBRSource, fragmentList };\n","import AttributesPBR from \"./AttributesPBR.glsl\";\nimport ForwardPassPBR from \"./ForwardPassPBR.glsl\";\nimport FragmentPBR from \"./FragmentPBR.glsl\";\nimport LightDirectPBR from \"./LightDirectPBR.glsl\";\nimport LightIndirectFunctions from \"./LightIndirectFunctions.glsl\";\nimport LightIndirectPBR from \"./LightIndirectPBR.glsl\";\nimport ReflectionLobe from \"./ReflectionLobe.glsl\";\nimport VaryingsPBR from \"./VaryingsPBR.glsl\";\nimport VertexPBR from \"./VertexPBR.glsl\";\nimport Refraction from \"./Refraction.glsl\";\nimport BSDF from \"./BSDF.glsl\";\n\nexport default [\n { source: ForwardPassPBR, includeKey: \"ForwardPassPBR.glsl\" },\n { source: AttributesPBR, includeKey: \"AttributesPBR.glsl\" },\n { source: VaryingsPBR, includeKey: \"VaryingsPBR.glsl\" },\n { source: FragmentPBR, includeKey: \"FragmentPBR.glsl\" },\n { source: LightDirectPBR, includeKey: \"LightDirectPBR.glsl\" },\n { source: LightIndirectPBR, includeKey: \"LightIndirectPBR.glsl\" },\n { source: VertexPBR, includeKey: \"VertexPBR.glsl\" },\n { source: LightIndirectFunctions, includeKey: \"LightIndirectFunctions.glsl\" },\n { source: ReflectionLobe, includeKey: \"ReflectionLobe.glsl\" },\n { source: Refraction, includeKey: \"Refraction.glsl\" },\n { source: BSDF, includeKey: \"BSDF.glsl\" }\n];\n","import { ShaderFactory } from \"@galacean/engine\";\nimport { PBRSource, fragmentList } from \"./shaders\";\n\nlet includeRegistered = false;\n\nexport function registerIncludes() {\n if (includeRegistered) return;\n\n for (const sourceFragment of fragmentList) {\n ShaderFactory.registerInclude(sourceFragment.includeKey, sourceFragment.source);\n }\n\n includeRegistered = true;\n}\n\nexport { PBRSource, fragmentList };\n","import { _ as _unsupported_iterable_to_array } from \"./_unsupported_iterable_to_array.js\";\n\nfunction _create_for_of_iterator_helper_loose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (it) return (it = it.call(o)).next.bind(it);\n // Fallback for engines without symbol support\n if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n\n var i = 0;\n\n return function() {\n if (i >= o.length) return { done: true };\n\n return { done: false, value: o[i++] };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _create_for_of_iterator_helper_loose as _ };\n","import { _ as _array_like_to_array } from \"./_array_like_to_array.js\";\n\nfunction _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\nexport { _unsupported_iterable_to_array as _ };\n"],"names":["_array_like_to_array","arr","len","length","i","arr2","Array","fragmentList","source","includeKey","shadingPBR","includeRegistered","_step","_iterator","_create_for_of_iterator_helper_loose","o","allowArrayLike","it","Symbol","iterator","call","next","bind","isArray","_unsupported_iterable_to_array","minLen","n","Object","prototype","toString","slice","constructor","name","from","test","done","value","TypeError","sourceFragment","ShaderFactory","registerInclude"],"mappings":"sVAAA,SAASA,EAAqBC,CAAG,CAAEC,CAAG,EAC9BA,CAAAA,AAAO,MAAPA,GAAeA,EAAMD,EAAIE,MAAM,AAAN,GAAQD,CAAAA,EAAMD,EAAIE,MAAM,EAErD,IAAK,IAAIC,EAAI,EAAGC,EAAO,AAAIC,MAAMJ,GAAME,EAAIF,EAAKE,IAAKC,CAAI,CAACD,EAAE,CAAGH,CAAG,CAACG,EAAE,CAErE,OAAOC,CACX,CCWME,IAAAA,EAAAA,EAAAA,CAAAA,MAAAA,CAAAA,CACJ,CAAEC,6pHAAoBC,WAAY,iBAAkB,EACpD,CAAED,oqGAAgBC,WAAY,aAAc,EAC5C,CAAED,ymBAAaC,WAAY,UAAW,EACtC,CAAED,8zFAAeC,WAAY,YAAa,EAC1C,CAAED,g9BAAgBC,WAAY,aAAc,EAC5C,CAAED,8zHAA0BC,WAAY,uBAAwB,EAChE,CAAED,qhMAAgBC,WAAY,aAAc,EAC5C,CAAED,ySAAmBC,WAAY,gBAAiB,EAClD,CAAED,uzCAAcC,WAAY,WAAY,EAErCC,CChBU,CACb,CAAEF,uiFAAwBC,WAAY,qBAAsB,EAC5D,CAAED,utCAAuBC,WAAY,oBAAqB,EAC1D,CAAED,+fAAqBC,WAAY,kBAAmB,EACtD,CAAED,+0RAAqBC,WAAY,kBAAmB,EACtD,CAAED,giKAAwBC,WAAY,qBAAsB,EAC5D,CAAED,oqHAA0BC,WAAY,uBAAwB,EAChE,CAAED,wyDAAmBC,WAAY,gBAAiB,EAClD,CAAED,o9CAAgCC,WAAY,6BAA8B,EAC5E,CAAED,goDAAwBC,WAAY,qBAAsB,EAC5D,CAAED,wuBAAoBC,WAAY,iBAAkB,EACpD,CAAED,01VAAcC,WAAY,WAAY,EACzC,ECrBGE,EAAoB,CAAA,szHAEjB,WACL,IAAIA,GAEJ,IAAA,IAA2CC,EAA3CC,EAAAC,ACNF,SAA8CC,CAAC,CAAEC,CAAc,EAC3D,IAAIC,EAAK,AAAkB,aAAlB,OAAOC,QAA0BH,CAAC,CAACG,OAAOC,QAAQ,CAAC,EAAIJ,CAAC,CAAC,aAAa,CAE/E,GAAIE,EAAI,MAAO,AAACA,CAAAA,EAAKA,EAAGG,IAAI,CAACL,EAAC,EAAGM,IAAI,CAACC,IAAI,CAACL,GAE3C,GAAIX,MAAMiB,OAAO,CAACR,IAAOE,CAAAA,EAAKO,ACLlC,SAAwCT,CAAC,CAAEU,CAAM,EAC7C,GAAKV,GACL,GAAI,AAAa,UAAb,OAAOA,EAAgB,OAAOf,EAAqBe,EAFhBU,KAAAA,GAIvC,IAAIC,EAAIC,OAAOC,SAAS,CAACC,QAAQ,CAACT,IAAI,CAACL,GAAGe,KAAK,CAAC,EAAG,IAGnD,GADU,WAANJ,GAAkBX,EAAEgB,WAAW,EAAEL,CAAAA,EAAIX,EAAEgB,WAAW,CAACC,IAAI,EACvDN,AAAM,QAANA,GAAeA,AAAM,QAANA,EAAa,OAAOpB,MAAM2B,IAAI,CAACP,GAClD,GAAIA,AAAM,cAANA,GAAqB,2CAA2CQ,IAAI,CAACR,GAAI,OAAO1B,EAAqBe,EARlEU,KAAAA,GAS3C,EDJiEV,EAAC,EAA2D,CACjHE,GAAIF,CAAAA,EAAIE,GAEZ,IAAIb,EAAI,EAER,OAAO,kBACH,AAAIA,GAAKW,EAAEZ,MAAM,CAAS,CAAEgC,KAAM,CAAA,GAE3B,CAAEA,KAAM,CAAA,EAAOC,MAAOrB,CAAC,CAACX,IAAI,CAC/C,CACK,CAED,MAAM,AAAIiC,UAAU,wIACxB,EDZ+B9B,GAAc,CAAA,AAAAK,CAAAA,EAAAC,GAAA,EAAAsB,IAAA,EAAA,CAAhCG,IAAAA,EAAAA,EAAAA,KAAAA,CACTC,EAAAA,aAAAA,CAAcC,eAAe,CAACF,EAAe7B,UAAU,CAAE6B,EAAe9B,MAAM,CAChF,CAEAG,EAAoB,CAAA,EACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/engine-shader",
|
|
3
|
-
"version": "1.6.0-beta.
|
|
3
|
+
"version": "1.6.0-beta.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"browser": "dist/browser.js",
|
|
16
16
|
"types": "types/index.d.ts",
|
|
17
17
|
"umd": {
|
|
18
|
-
"name": "Galacean.
|
|
18
|
+
"name": "Galacean.ShaderFragment",
|
|
19
19
|
"globals": {
|
|
20
20
|
"@galacean/engine": "Galacean"
|
|
21
21
|
}
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"types/**/*"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@galacean/engine": "1.6.0-beta.
|
|
28
|
+
"@galacean/engine": "1.6.0-beta.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@galacean/engine": "1.6.0-beta.
|
|
31
|
+
"@galacean/engine": "1.6.0-beta.2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"b:types": "tsc"
|