@galacean/engine-core 1.3.0-alpha.0 → 1.3.0-alpha.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.
Files changed (47) hide show
  1. package/dist/main.js +720 -144
  2. package/dist/main.js.map +1 -1
  3. package/dist/miniprogram.js +720 -144
  4. package/dist/module.js +718 -145
  5. package/dist/module.js.map +1 -1
  6. package/package.json +3 -3
  7. package/types/Camera.d.ts +18 -7
  8. package/types/RenderPipeline/PipelinePass.d.ts +1 -1
  9. package/types/RenderPipeline/index.d.ts +1 -1
  10. package/types/enums/ReplacementFailureStrategy.d.ts +9 -0
  11. package/types/index.d.ts +2 -0
  12. package/types/postProcess/effects/BloomEffect.d.ts +94 -0
  13. package/types/postProcess/effects/TonemappingEffect.d.ts +35 -0
  14. package/types/postProcess/effects/index.d.ts +2 -0
  15. package/types/postProcess/index.d.ts +3 -0
  16. package/types/shader/ShaderPass.d.ts +10 -0
  17. package/types/shader/enums/ShaderPlatformTarget.d.ts +4 -0
  18. package/types/shader/index.d.ts +1 -0
  19. package/types/shaderlib/ShaderFactory.d.ts +2 -1
  20. package/types/texture/enums/TextureFormat.d.ts +2 -0
  21. package/types/2d/text/CharRenderData.d.ts +0 -1
  22. package/types/2d/text/CharRenderDataPool.d.ts +0 -1
  23. package/types/Deprecated.d.ts +0 -101
  24. package/types/RenderPipeline/Basic2DBatcher.d.ts +0 -19
  25. package/types/RenderPipeline/Chunk.d.ts +0 -1
  26. package/types/RenderPipeline/ClassPool.d.ts +0 -19
  27. package/types/RenderPipeline/DynamicGeometryData.d.ts +0 -1
  28. package/types/RenderPipeline/DynamicGeometryDataManager.d.ts +0 -1
  29. package/types/RenderPipeline/IPoolElement.d.ts +0 -3
  30. package/types/RenderPipeline/RenderData.d.ts +0 -14
  31. package/types/RenderPipeline/RenderData2D.d.ts +0 -14
  32. package/types/RenderPipeline/RenderPass.d.ts +0 -55
  33. package/types/RenderPipeline/SpriteBatcher.d.ts +0 -1
  34. package/types/RenderPipeline/SpriteMaskBatcher.d.ts +0 -11
  35. package/types/RenderPipeline/SpriteMaskManager.d.ts +0 -1
  36. package/types/RenderPipeline/SpriteMaskRenderData.d.ts +0 -12
  37. package/types/RenderPipeline/SpriteRenderData.d.ts +0 -14
  38. package/types/RenderPipeline/TextRenderData.d.ts +0 -8
  39. package/types/RenderPipeline/batcher/MeshBuffer.d.ts +0 -1
  40. package/types/RenderPipeline/enums/ForceUploadShaderDataFlag.d.ts +0 -15
  41. package/types/RenderPipeline/enums/RenderDataUsage.d.ts +0 -13
  42. package/types/animation/AnimatorTransition.d.ts +0 -14
  43. package/types/renderingHardwareInterface/IHardwareRenderer.d.ts +0 -6
  44. package/types/texture/enums/PixelFormat.d.ts +0 -73
  45. package/types/utils/Pool.d.ts +0 -12
  46. /package/types/{2d/assembler/IAssembler.d.ts → postProcess/PostProcessManager.d.ts} +0 -0
  47. /package/types/{2d/data/VertexData2D.d.ts → shader/enums/ShaderType.d.ts} +0 -0
package/dist/module.js CHANGED
@@ -2990,6 +2990,12 @@ var RenderStateElementKey;
2990
2990
  StencilOperation[StencilOperation[/** Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of 0. */ "DecrementWrap"] = 7] = "DecrementWrap";
2991
2991
  })(StencilOperation || (StencilOperation = {}));
2992
2992
 
2993
+ var ShaderPlatformTarget;
2994
+ (function(ShaderPlatformTarget) {
2995
+ ShaderPlatformTarget[ShaderPlatformTarget["GLES100"] = 0] = "GLES100";
2996
+ ShaderPlatformTarget[ShaderPlatformTarget["GLES300"] = 1] = "GLES300";
2997
+ })(ShaderPlatformTarget || (ShaderPlatformTarget = {}));
2998
+
2993
2999
  /**
2994
3000
  * Shader macro。
2995
3001
  */ var ShaderMacro = /*#__PURE__*/ function() {
@@ -3019,14 +3025,14 @@ var RenderStateElementKey;
3019
3025
  maskMap.length++;
3020
3026
  maskMap[index] = new Array(32);
3021
3027
  }
3022
- maskMap[index][bit] = key;
3028
+ maskMap[index][bit] = macro;
3023
3029
  ShaderMacro._macroCounter++;
3024
3030
  }
3025
3031
  return macro;
3026
3032
  };
3027
3033
  /**
3028
3034
  * @internal
3029
- */ ShaderMacro._getNamesByMacros = function _getNamesByMacros(macros, out) {
3035
+ */ ShaderMacro._getMacrosElements = function _getMacrosElements(macros, out) {
3030
3036
  var maskMap = ShaderMacro._macroMaskMap;
3031
3037
  var mask = macros._mask;
3032
3038
  out.length = 0;
@@ -3209,15 +3215,6 @@ var RenderStateElementKey;
3209
3215
  return ShaderMacroCollection;
3210
3216
  }();
3211
3217
 
3212
- /**
3213
- * Pipeline stage.
3214
- */ var PipelineStage;
3215
- (function(PipelineStage) {
3216
- PipelineStage[/** DepthOnly stage. */ "DepthOnly"] = "DepthOnly";
3217
- PipelineStage[/** Shadow caster stage. */ "ShadowCaster"] = "ShadowCaster";
3218
- PipelineStage[/** Forward shading stage. */ "Forward"] = "Forward";
3219
- })(PipelineStage || (PipelineStage = {}));
3220
-
3221
3218
  function _extends() {
3222
3219
  _extends = Object.assign || function assign(target) {
3223
3220
  for (var i = 1; i < arguments.length; i++) {
@@ -3231,6 +3228,15 @@ function _extends() {
3231
3228
  return _extends.apply(this, arguments);
3232
3229
  }
3233
3230
 
3231
+ /**
3232
+ * Pipeline stage.
3233
+ */ var PipelineStage;
3234
+ (function(PipelineStage) {
3235
+ PipelineStage[/** DepthOnly stage. */ "DepthOnly"] = "DepthOnly";
3236
+ PipelineStage[/** Shadow caster stage. */ "ShadowCaster"] = "ShadowCaster";
3237
+ PipelineStage[/** Forward shading stage. */ "Forward"] = "Forward";
3238
+ })(PipelineStage || (PipelineStage = {}));
3239
+
3234
3240
  var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;"; // eslint-disable-line
3235
3241
 
3236
3242
  var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\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 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform 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\n"; // eslint-disable-line
@@ -3319,13 +3325,13 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
3319
3325
 
3320
3326
  var pbr_frag_define = "#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
3321
3327
 
3322
- var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\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,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
3328
+ var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}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}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\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,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.roughness+getAARoughnessFactor(geometry.normal),1.0));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.clearCoatRoughness+getAARoughnessFactor(geometry.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
3323
3329
 
3324
3330
  var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}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;vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.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+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);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 F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
3325
3331
 
3326
3332
  var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.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 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){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];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}"; // eslint-disable-line
3327
3333
 
3328
- var ibl_frag_define = "#define GLSLIFY 1\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));}vec3 envBRDFApprox(vec3 specularColor,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 specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\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#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
3334
+ var ibl_frag_define = "#define GLSLIFY 1\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));}vec3 envBRDFApprox(vec3 specularColor,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 max(specularColor*AB.x+AB.y,0.0);}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\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#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
3329
3335
 
3330
3336
  var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
3331
3337
 
@@ -3446,7 +3452,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
3446
3452
  function ShaderFactory() {}
3447
3453
  ShaderFactory.parseCustomMacros = function parseCustomMacros(macros) {
3448
3454
  return macros.map(function(m) {
3449
- return "#define " + m + "\n";
3455
+ return "#define " + (m.value ? m.name + " " + m.value : m.name) + "\n";
3450
3456
  }).join("");
3451
3457
  };
3452
3458
  ShaderFactory.registerInclude = function registerInclude(includeName, includeSource) {
@@ -4231,29 +4237,49 @@ var ShaderFactory = /*#__PURE__*/ function() {
4231
4237
  ShaderProgram._counter = 0;
4232
4238
  })();
4233
4239
 
4240
+ /**
4241
+ * @internal
4242
+ * Shader pass type
4243
+ */ var ShaderType;
4244
+ (function(ShaderType) {
4245
+ ShaderType[ShaderType[/** init by glsl */ "Canonical"] = 0] = "Canonical";
4246
+ ShaderType[ShaderType[/** init by shader-lab */ "ShaderLab"] = 1] = "ShaderLab";
4247
+ })(ShaderType || (ShaderType = {}));
4248
+
4234
4249
  /**
4235
4250
  * Shader pass containing vertex and fragment source.
4236
4251
  */ var ShaderPass = /*#__PURE__*/ function(ShaderPart1) {
4237
4252
  _inherits(ShaderPass, ShaderPart1);
4238
- function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSource, fragmentSourceOrTags, tags) {
4253
+ function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSourceOrCode, fragmentSourceOrTagsOrVertexEntry, fragmentEntryOrTags, tags) {
4239
4254
  var _this;
4240
4255
  _this = ShaderPart1.call(this) || this;
4241
4256
  /** @internal */ _this._shaderPassId = 0;
4242
4257
  /** @internal */ _this._renderStateDataMap = {};
4243
4258
  /** @internal */ _this._shaderProgramPools = [];
4259
+ _this._platformMacros = [];
4244
4260
  _this._shaderPassId = ShaderPass._shaderPassCounter++;
4245
- if (typeof fragmentSourceOrTags === "string") {
4261
+ _this._type = ShaderType.Canonical;
4262
+ if (typeof fragmentEntryOrTags === "string") {
4246
4263
  _this._name = nameOrVertexSource;
4247
- _this._vertexSource = vertexSourceOrFragmentSource;
4248
- _this._fragmentSource = fragmentSourceOrTags;
4249
- tags = tags != null ? tags : {
4264
+ _this._shaderLabSource = vertexSourceOrFragmentSourceOrCode;
4265
+ _this._vertexEntry = fragmentSourceOrTagsOrVertexEntry;
4266
+ _this._fragmentEntry = fragmentEntryOrTags;
4267
+ tags = _extends({
4268
+ pipelineStage: PipelineStage.Forward
4269
+ }, tags);
4270
+ _this._type = ShaderType.ShaderLab;
4271
+ } else if (typeof fragmentSourceOrTagsOrVertexEntry === "string") {
4272
+ _this._name = nameOrVertexSource;
4273
+ _this._vertexSource = vertexSourceOrFragmentSourceOrCode;
4274
+ _this._fragmentSource = fragmentSourceOrTagsOrVertexEntry;
4275
+ tags = fragmentEntryOrTags != null ? fragmentEntryOrTags : {
4250
4276
  pipelineStage: PipelineStage.Forward
4251
4277
  };
4252
4278
  } else {
4253
4279
  _this._name = "Default";
4254
4280
  _this._vertexSource = nameOrVertexSource;
4255
- _this._fragmentSource = vertexSourceOrFragmentSource;
4256
- tags = fragmentSourceOrTags != null ? fragmentSourceOrTags : {
4281
+ _this._fragmentSource = vertexSourceOrFragmentSourceOrCode;
4282
+ tags = fragmentSourceOrTagsOrVertexEntry != null ? fragmentSourceOrTagsOrVertexEntry : {
4257
4283
  pipelineStage: PipelineStage.Forward
4258
4284
  };
4259
4285
  }
@@ -4271,9 +4297,51 @@ var ShaderFactory = /*#__PURE__*/ function() {
4271
4297
  if (shaderProgram) {
4272
4298
  return shaderProgram;
4273
4299
  }
4300
+ if (this._type === ShaderType.Canonical) {
4301
+ shaderProgram = this._getCanonicalShaderProgram(engine, macroCollection);
4302
+ } else {
4303
+ shaderProgram = this._compileShaderProgram(engine, macroCollection, this._vertexEntry, this._fragmentEntry);
4304
+ }
4305
+ shaderProgramPool.cache(shaderProgram);
4306
+ return shaderProgram;
4307
+ };
4308
+ /**
4309
+ * @internal
4310
+ */ _proto._destroy = function _destroy() {
4311
+ var shaderProgramPools = this._shaderProgramPools;
4312
+ for(var i = 0, n = shaderProgramPools.length; i < n; i++){
4313
+ shaderProgramPools[i]._destroy();
4314
+ }
4315
+ shaderProgramPools.length = 0;
4316
+ };
4317
+ /**
4318
+ * Shader Lab compilation
4319
+ */ _proto._compileShaderProgram = function _compileShaderProgram(engine, macroCollection, vertexEntry, fragmentEntry) {
4274
4320
  var isWebGL2 = engine._hardwareRenderer.isWebGL2;
4275
- var macroNameList = [];
4276
- ShaderMacro._getNamesByMacros(macroCollection, macroNameList);
4321
+ var macros = new Array();
4322
+ ShaderMacro._getMacrosElements(macroCollection, macros);
4323
+ this._platformMacros.length = 0;
4324
+ if (engine._hardwareRenderer.canIUse(GLCapabilityType.shaderTextureLod)) {
4325
+ this._platformMacros.push("HAS_TEX_LOD");
4326
+ }
4327
+ if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
4328
+ this._platformMacros.push("HAS_DERIVATIVES");
4329
+ }
4330
+ if (isWebGL2) {
4331
+ this._platformMacros.push("GRAPHICS_API_WEBGL2");
4332
+ } else {
4333
+ this._platformMacros.push("GRAPHICS_API_WEBGL1");
4334
+ }
4335
+ var start = performance.now();
4336
+ var _Shader__shaderLab__parseShaderPass = Shader._shaderLab._parseShaderPass(this._shaderLabSource, vertexEntry, fragmentEntry, macros, isWebGL2 ? ShaderPlatformTarget.GLES300 : ShaderPlatformTarget.GLES100, this._platformMacros), vertex = _Shader__shaderLab__parseShaderPass.vertex, fragment = _Shader__shaderLab__parseShaderPass.fragment;
4337
+ Logger.info("[ShaderLab compilation] cost time: " + (performance.now() - start) + "ms");
4338
+ return new ShaderProgram(engine, vertex, fragment);
4339
+ };
4340
+ // TODO: remove it after migrate all shader to `ShaderLab`.
4341
+ _proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
4342
+ var isWebGL2 = engine._hardwareRenderer.isWebGL2;
4343
+ var macroNameList = new Array();
4344
+ ShaderMacro._getMacrosElements(macroCollection, macroNameList);
4277
4345
  var macroNameStr = ShaderFactory.parseCustomMacros(macroNameList);
4278
4346
  var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
4279
4347
  var graphicAPI = isWebGL2 ? "#define GRAPHICS_API_WEBGL2" : "#define GRAPHICS_API_WEBGL1";
@@ -4290,19 +4358,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
4290
4358
  vertexSource = ShaderFactory.convertTo300(vertexSource);
4291
4359
  fragmentSource = ShaderFactory.convertTo300(fragmentSource, true);
4292
4360
  }
4293
- shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
4294
- shaderProgramPool.cache(shaderProgram);
4361
+ var shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
4295
4362
  return shaderProgram;
4296
4363
  };
4297
- /**
4298
- * @internal
4299
- */ _proto._destroy = function _destroy() {
4300
- var shaderProgramPools = this._shaderProgramPools;
4301
- for(var i = 0, n = shaderProgramPools.length; i < n; i++){
4302
- shaderProgramPools[i]._destroy();
4303
- }
4304
- shaderProgramPools.length = 0;
4305
- };
4306
4364
  return ShaderPass;
4307
4365
  }(ShaderPart);
4308
4366
  (function() {
@@ -5006,45 +5064,44 @@ __decorate([
5006
5064
  if (!Shader._shaderLab) {
5007
5065
  throw "ShaderLab has not been set up yet.";
5008
5066
  }
5009
- var shaderInfo = Shader._shaderLab.parseShader(nameOrShaderSource);
5010
- if (shaderMap[shaderInfo.name]) {
5011
- console.error('Shader named "' + shaderInfo.name + '" already exists.');
5067
+ var shaderContent = Shader._shaderLab._parseShaderContent(nameOrShaderSource);
5068
+ if (shaderMap[shaderContent.name]) {
5069
+ console.error('Shader named "' + shaderContent.name + '" already exists.');
5012
5070
  return;
5013
5071
  }
5014
- var subShaderList = shaderInfo.subShaders.map(function(subShaderInfo) {
5015
- var passList = subShaderInfo.passes.map(function(passInfo) {
5016
- if (typeof passInfo === "string") {
5072
+ var subShaderList = shaderContent.subShaders.map(function(subShaderContent) {
5073
+ var passList = subShaderContent.passes.map(function(passInfo) {
5074
+ if (passInfo.isUsePass) {
5017
5075
  var _Shader_find_subShaders_find, _Shader_find;
5018
5076
  // Use pass reference
5019
- var paths = passInfo.split("/");
5077
+ var paths = passInfo.name.split("/");
5020
5078
  return (_Shader_find = Shader.find(paths[0])) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
5021
5079
  return subShader.name === paths[1];
5022
5080
  })) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
5023
5081
  return pass.name === paths[2];
5024
5082
  });
5025
5083
  }
5026
- var shaderPass = new ShaderPass(passInfo.name, passInfo.vertexSource, passInfo.fragmentSource, passInfo.tags);
5084
+ var shaderPassContent = new ShaderPass(passInfo.name, passInfo.contents, passInfo.vertexEntry, passInfo.fragmentEntry, passInfo.tags);
5027
5085
  var renderStates = passInfo.renderStates;
5028
5086
  var renderState = new RenderState();
5029
- shaderPass._renderState = renderState;
5087
+ shaderPassContent._renderState = renderState;
5030
5088
  // Parse const render state
5031
- var constRenderStateInfo = renderStates[0];
5032
- for(var k in constRenderStateInfo){
5033
- Shader._applyConstRenderStates(renderState, parseInt(k), constRenderStateInfo[k]);
5089
+ var constantMap = renderStates.constantMap, variableMap = renderStates.variableMap;
5090
+ for(var k in constantMap){
5091
+ Shader._applyConstRenderStates(renderState, parseInt(k), constantMap[k]);
5034
5092
  }
5035
5093
  // Parse variable render state
5036
- var variableRenderStateInfo = renderStates[1];
5037
5094
  var renderStateDataMap = {};
5038
- for(var k1 in variableRenderStateInfo){
5039
- renderStateDataMap[k1] = ShaderProperty.getByName(variableRenderStateInfo[k1]);
5095
+ for(var k1 in variableMap){
5096
+ renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
5040
5097
  }
5041
- shaderPass._renderStateDataMap = renderStateDataMap;
5042
- return shaderPass;
5098
+ shaderPassContent._renderStateDataMap = renderStateDataMap;
5099
+ return shaderPassContent;
5043
5100
  });
5044
- return new SubShader(shaderInfo.name, passList, subShaderInfo.tags);
5101
+ return new SubShader(subShaderContent.name, passList, subShaderContent.tags);
5045
5102
  });
5046
- shader = new Shader(shaderInfo.name, subShaderList);
5047
- shaderMap[shaderInfo.name] = shader;
5103
+ shader = new Shader(shaderContent.name, subShaderList);
5104
+ shaderMap[shaderContent.name] = shader;
5048
5105
  return shader;
5049
5106
  } else {
5050
5107
  if (shaderMap[nameOrShaderSource]) {
@@ -5257,6 +5314,7 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
5257
5314
  TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
5258
5315
  TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
5259
5316
  TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
5317
+ TextureFormat[TextureFormat[/** RGB unsigned float format, 11 bits in R channel, 11 bits in G channel, 10 bits in B channel. */ "R11G11B10_UFloat"] = 35] = "R11G11B10_UFloat";
5260
5318
  TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
5261
5319
  TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
5262
5320
  TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
@@ -7952,22 +8010,23 @@ var /**
7952
8010
  * @param height - Need texture height
7953
8011
  * @param format - Need texture format
7954
8012
  * @param mipmap - Need texture mipmap
8013
+ * @param textureWrapMode - Texture wrap mode
8014
+ * @param textureFilterMode - Texture filter mode
7955
8015
  * @returns Texture
7956
- */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
8016
+ */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap, textureWrapMode, textureFilterMode) {
7957
8017
  if (currentTexture) {
7958
8018
  if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
7959
8019
  currentTexture.destroy(true);
7960
- var texture = new Texture2D(engine, width, height, format, mipmap);
7961
- texture.isGCIgnored = true;
7962
- return texture;
7963
- } else {
7964
- return currentTexture;
8020
+ currentTexture = new Texture2D(engine, width, height, format, mipmap);
8021
+ currentTexture.isGCIgnored = true;
7965
8022
  }
7966
8023
  } else {
7967
- var texture1 = new Texture2D(engine, width, height, format, mipmap);
7968
- texture1.isGCIgnored = true;
7969
- return texture1;
8024
+ currentTexture = new Texture2D(engine, width, height, format, mipmap);
8025
+ currentTexture.isGCIgnored = true;
7970
8026
  }
8027
+ currentTexture.wrapModeU = currentTexture.wrapModeV = textureWrapMode;
8028
+ currentTexture.filterMode = textureFilterMode;
8029
+ return currentTexture;
7971
8030
  };
7972
8031
  /**
7973
8032
  * Recreate render target if needed.
@@ -7979,15 +8038,17 @@ var /**
7979
8038
  * @param depthFormat - Need render target depth format
7980
8039
  * @param mipmap - Need render target mipmap
7981
8040
  * @param antiAliasing - Need render target anti aliasing
8041
+ * @param textureWrapMode - Texture wrap mode
8042
+ * @param textureFilterMode - Texture filter mode
7982
8043
  * @returns Render target
7983
- */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing) {
8044
+ */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing, textureWrapMode, textureFilterMode) {
7984
8045
  var _currentRenderTarget;
7985
8046
  var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
7986
- var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
8047
+ var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap, textureWrapMode, textureFilterMode) : null;
7987
8048
  if (needDepthTexture) {
7988
8049
  var _currentRenderTarget1;
7989
8050
  var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
7990
- var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
8051
+ var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap, textureWrapMode, textureFilterMode) : null;
7991
8052
  if (currentColorTexture !== colorTexture || currentDepthTexture !== _$needDepthTexture) {
7992
8053
  var _currentRenderTarget2;
7993
8054
  (_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy(true);
@@ -7996,38 +8057,46 @@ var /**
7996
8057
  }
7997
8058
  } else {
7998
8059
  var _currentRenderTarget3;
7999
- var needDepthFormat = depthFormat;
8000
- if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== needDepthFormat) {
8060
+ if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== depthFormat || currentRenderTarget.antiAliasing !== antiAliasing) {
8001
8061
  var _currentRenderTarget4;
8002
8062
  (_currentRenderTarget4 = currentRenderTarget) == null ? void 0 : _currentRenderTarget4.destroy(true);
8003
- currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, needDepthFormat, antiAliasing);
8063
+ currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthFormat, antiAliasing);
8004
8064
  currentRenderTarget.isGCIgnored = true;
8005
8065
  }
8006
8066
  }
8007
8067
  return currentRenderTarget;
8008
8068
  };
8009
8069
  /**
8010
- * Blit texture to destination render target.
8070
+ * Blit texture to destination render target using a triangle.
8011
8071
  * @param engine - Engine
8012
8072
  * @param source - Source texture
8013
8073
  * @param destination - Destination render target
8014
8074
  * @param mipLevel - Mip level to blit
8015
8075
  * @param viewport - Viewport
8016
- */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport) {
8076
+ * @param material - The material to use when blitting
8077
+ * @param passIndex - Pass index to use of the provided material
8078
+ */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex) {
8017
8079
  if (mipLevel === void 0) mipLevel = 0;
8080
+ if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
8081
+ if (material === void 0) material = null;
8082
+ if (passIndex === void 0) passIndex = 0;
8018
8083
  var basicResources = engine._basicResources;
8019
8084
  var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
8020
- var blitMaterial = basicResources.blitMaterial;
8085
+ var blitMaterial = material || basicResources.blitMaterial;
8021
8086
  var rhi = engine._hardwareRenderer;
8022
8087
  var context = engine._renderContext;
8023
8088
  // We not use projection matrix when blit, but we must modify flipProjection to make front face correct
8024
- context.flipProjection = destination ? true : false;
8025
- rhi.activeRenderTarget(destination, viewport != null ? viewport : PipelineUtils.defaultViewport, context.flipProjection, 0);
8089
+ context.flipProjection = !!destination;
8090
+ rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
8026
8091
  var rendererShaderData = PipelineUtils._rendererShaderData;
8027
- var pass = blitMaterial.shader.subShaders[0].passes[0];
8028
- var program = pass._getShaderProgram(engine, Shader._compileMacros);
8029
8092
  rendererShaderData.setTexture(PipelineUtils._blitTextureProperty, source);
8030
8093
  rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
8094
+ PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
8095
+ rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
8096
+ var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
8097
+ var compileMacros = Shader._compileMacros;
8098
+ ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
8099
+ var program = pass._getShaderProgram(engine, compileMacros);
8031
8100
  program.bind();
8032
8101
  program.groupingOtherUniformBlock();
8033
8102
  program.uploadAll(program.rendererUniformBlock, rendererShaderData);
@@ -8044,9 +8113,16 @@ var /**
8044
8113
  (function() {
8045
8114
  PipelineUtils._blitMipLevelProperty = ShaderProperty.getByName("renderer_BlitMipLevel");
8046
8115
  })();
8116
+ (function() {
8117
+ PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
8118
+ ;
8119
+ })();
8047
8120
  (function() {
8048
8121
  PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
8049
8122
  })();
8123
+ (function() {
8124
+ PipelineUtils._texelSize = new Vector4();
8125
+ })();
8050
8126
  (function() {
8051
8127
  PipelineUtils.defaultViewport = new Vector4(0, 0, 1, 1);
8052
8128
  })();
@@ -8115,6 +8191,14 @@ var /**
8115
8191
  MSAASamples[MSAASamples[/** Multi-sample anti-aliasing with 8 samples. */ "EightX"] = 8] = "EightX";
8116
8192
  })(MSAASamples || (MSAASamples = {}));
8117
8193
 
8194
+ /**
8195
+ * The strategy to use when a shader replacement fails.
8196
+ */ var ReplacementFailureStrategy;
8197
+ (function(ReplacementFailureStrategy) {
8198
+ ReplacementFailureStrategy[ReplacementFailureStrategy[/** Keep the original shader. */ "KeepOriginalShader"] = 0] = "KeepOriginalShader";
8199
+ ReplacementFailureStrategy[ReplacementFailureStrategy[/** Do not render. */ "DoNotRender"] = 1] = "DoNotRender";
8200
+ })(ReplacementFailureStrategy || (ReplacementFailureStrategy = {}));
8201
+
8118
8202
  var _Camera;
8119
8203
  var MathTemp = function MathTemp() {
8120
8204
  };
@@ -8164,6 +8248,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8164
8248
  /** @internal */ _this._virtualCamera = new VirtualCamera();
8165
8249
  /** @internal */ _this._replacementShader = null;
8166
8250
  /** @internal */ _this._replacementSubShaderTag = null;
8251
+ /** @internal */ _this._replacementFailureStrategy = null;
8167
8252
  /** @internal */ _this._cameraIndex = -1;
8168
8253
  _this._priority = 0;
8169
8254
  _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
@@ -8177,6 +8262,8 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8177
8262
  _this._renderTarget = null;
8178
8263
  _this._depthBufferParams = new Vector4();
8179
8264
  _this._opaqueTextureEnabled = false;
8265
+ _this._enableHDR = false;
8266
+ _this._enablePostProcess = false;
8180
8267
  _this._viewport = new Vector4(0, 0, 1, 1);
8181
8268
  _this._pixelViewport = new Rect(0, 0, 0, 0);
8182
8269
  _this._inverseProjectionMatrix = new Matrix();
@@ -8341,6 +8428,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8341
8428
  context.virtualCamera = virtualCamera;
8342
8429
  context.replacementShader = this._replacementShader;
8343
8430
  context.replacementTag = this._replacementSubShaderTag;
8431
+ context.replacementFailureStrategy = this._replacementFailureStrategy;
8344
8432
  // compute cull frustum.
8345
8433
  if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
8346
8434
  this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
@@ -8360,15 +8448,18 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8360
8448
  this._renderPipeline.render(context, cubeFace, mipLevel, clearMask);
8361
8449
  this._engine._renderCount++;
8362
8450
  };
8363
- _proto.setReplacementShader = function setReplacementShader(shader, replacementTag) {
8451
+ _proto.setReplacementShader = function setReplacementShader(shader, replacementTag, failureStrategy) {
8452
+ if (failureStrategy === void 0) failureStrategy = ReplacementFailureStrategy.KeepOriginalShader;
8364
8453
  this._replacementShader = shader;
8365
8454
  this._replacementSubShaderTag = typeof replacementTag === "string" ? ShaderTagKey.getByName(replacementTag) : replacementTag;
8455
+ this._replacementFailureStrategy = failureStrategy;
8366
8456
  };
8367
8457
  /**
8368
8458
  * Reset and clear the replacement shader.
8369
8459
  */ _proto.resetReplacementShader = function resetReplacementShader() {
8370
8460
  this._replacementShader = null;
8371
8461
  this._replacementSubShaderTag = null;
8462
+ this._replacementFailureStrategy = null;
8372
8463
  };
8373
8464
  /**
8374
8465
  * @inheritdoc
@@ -8382,6 +8473,11 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8382
8473
  };
8383
8474
  /**
8384
8475
  * @internal
8476
+ */ _proto._getInternalColorTextureFormat = function _getInternalColorTextureFormat() {
8477
+ return this._enableHDR ? this.engine._hardwareRenderer.isWebGL2 ? TextureFormat.R11G11B10_UFloat : TextureFormat.R16G16B16A16 : TextureFormat.R8G8B8A8;
8478
+ };
8479
+ /**
8480
+ * @internal
8385
8481
  * @inheritdoc
8386
8482
  */ _proto._onDestroy = function _onDestroy() {
8387
8483
  var _this__renderPipeline;
@@ -8470,9 +8566,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8470
8566
  }
8471
8567
  return this._inverseProjectionMatrix;
8472
8568
  };
8473
- _proto._forceUseInternalCanvas = function _forceUseInternalCanvas() {
8474
- return this.opaqueTextureEnabled;
8475
- };
8476
8569
  _proto._onPixelViewportChanged = function _onPixelViewportChanged() {
8477
8570
  this._updatePixelViewport();
8478
8571
  var _this__customAspectRatio;
@@ -8480,8 +8573,8 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8480
8573
  this._checkMainCanvasAntialiasWaste();
8481
8574
  };
8482
8575
  _proto._checkMainCanvasAntialiasWaste = function _checkMainCanvasAntialiasWaste() {
8483
- if (this.independentCanvasEnabled && Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
8484
- console.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.");
8576
+ if (this._phasedActiveInScene && this.independentCanvasEnabled && Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
8577
+ Logger.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.");
8485
8578
  }
8486
8579
  };
8487
8580
  _create_class(Camera1, [
@@ -8492,7 +8585,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8492
8585
  * If enabled, the opaque texture can be accessed in the shader using `camera_OpaqueTexture`.
8493
8586
  *
8494
8587
  * @defaultValue `false`
8495
- *
8496
8588
  * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8497
8589
  */ function get() {
8498
8590
  return this._opaqueTextureEnabled;
@@ -8511,10 +8603,10 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8511
8603
  *
8512
8604
  * @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
8513
8605
  */ function get() {
8514
- if (this._renderTarget) {
8515
- return false;
8606
+ if (this.enableHDR || this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
8607
+ return true;
8516
8608
  }
8517
- return this._forceUseInternalCanvas();
8609
+ return this.opaqueTextureEnabled && !this._renderTarget;
8518
8610
  }
8519
8611
  },
8520
8612
  {
@@ -8699,13 +8791,38 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8699
8791
  key: "enableHDR",
8700
8792
  get: /**
8701
8793
  * Whether to enable HDR.
8702
- * @todo When render pipeline modification
8794
+ * @defaultValue `false`
8795
+ * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8703
8796
  */ function get() {
8704
- console.log("not implementation");
8705
- return false;
8797
+ return this._enableHDR;
8798
+ },
8799
+ set: function set(value) {
8800
+ if (this.enableHDR !== value) {
8801
+ var rhi = this.engine._hardwareRenderer;
8802
+ var supportHDR = rhi.isWebGL2 || rhi.canIUse(GLCapabilityType.textureHalfFloat);
8803
+ if (value && !supportHDR) {
8804
+ Logger.warn("Can't enable HDR in this device.");
8805
+ return;
8806
+ }
8807
+ this._enableHDR = value;
8808
+ this._checkMainCanvasAntialiasWaste();
8809
+ }
8810
+ }
8811
+ },
8812
+ {
8813
+ key: "enablePostProcess",
8814
+ get: /**
8815
+ * Whether to enable post process.
8816
+ * @defaultValue `false`
8817
+ * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8818
+ */ function get() {
8819
+ return this._enablePostProcess;
8706
8820
  },
8707
8821
  set: function set(value) {
8708
- console.log("not implementation");
8822
+ if (this._enablePostProcess !== value) {
8823
+ this._enablePostProcess = value;
8824
+ this._checkMainCanvasAntialiasWaste();
8825
+ }
8709
8826
  }
8710
8827
  },
8711
8828
  {
@@ -8721,7 +8838,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8721
8838
  value && this._addResourceReferCount(value, 1);
8722
8839
  this._renderTarget = value;
8723
8840
  this._onPixelViewportChanged();
8724
- this._checkMainCanvasAntialiasWaste();
8725
8841
  }
8726
8842
  }
8727
8843
  }
@@ -8806,7 +8922,7 @@ Camera = __decorate([
8806
8922
  /**
8807
8923
  * PipelinePass is a base class for all pipeline passes.
8808
8924
  */ var PipelinePass = function PipelinePass(engine) {
8809
- this._engine = engine;
8925
+ this.engine = engine;
8810
8926
  };
8811
8927
 
8812
8928
  /**
@@ -9682,7 +9798,7 @@ var /**
9682
9798
  this._updateReceiversShaderData(light);
9683
9799
  };
9684
9800
  _proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
9685
- var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
9801
+ var _this = this, engine = _this.engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
9686
9802
  var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue;
9687
9803
  var scene = camera.scene;
9688
9804
  var componentsManager = scene._componentsManager;
@@ -9701,13 +9817,12 @@ var /**
9701
9817
  var renderTarget;
9702
9818
  var shadowTexture;
9703
9819
  if (this._supportDepthTexture) {
9704
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1);
9820
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
9705
9821
  shadowTexture = renderTarget.depthTexture;
9706
9822
  } else {
9707
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1);
9823
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
9708
9824
  shadowTexture = renderTarget.getColorTexture(0);
9709
9825
  }
9710
- shadowTexture.wrapModeU = shadowTexture.wrapModeV = TextureWrapMode.Clamp;
9711
9826
  if (engine._hardwareRenderer._isWebGL2) {
9712
9827
  shadowTexture.depthCompareFunction = TextureDepthCompareFunction.Less;
9713
9828
  }
@@ -9958,22 +10073,17 @@ var /**
9958
10073
  }
9959
10074
  var _proto = DepthOnlyPass.prototype;
9960
10075
  _proto.onConfig = function onConfig(camera) {
9961
- var engine = this._engine;
10076
+ var engine = this.engine;
9962
10077
  var _camera_pixelViewport = camera.pixelViewport, width = _camera_pixelViewport.width, height = _camera_pixelViewport.height;
9963
- var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, TextureFormat.Depth16, true, false, 1);
9964
- var depthTexture = renderTarget.depthTexture;
9965
- depthTexture.wrapModeU = depthTexture.wrapModeV = TextureWrapMode.Clamp;
9966
- depthTexture.filterMode = TextureFilterMode.Point;
10078
+ var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, TextureFormat.Depth16, true, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Point);
9967
10079
  this._renderTarget = renderTarget;
9968
10080
  };
9969
10081
  _proto.onRender = function onRender(context, cullingResults) {
9970
- var engine = this._engine;
10082
+ var engine = this.engine;
9971
10083
  var renderTarget = this._renderTarget;
9972
10084
  var camera = context.camera;
9973
10085
  var rhi = engine._hardwareRenderer;
9974
- rhi.activeRenderTarget(renderTarget, camera.viewport, context.flipProjection, 0);
9975
- rhi.viewport(0, 0, renderTarget.width, renderTarget.height);
9976
- rhi.scissor(0, 0, renderTarget.width, renderTarget.height);
10086
+ rhi.activeRenderTarget(renderTarget, PipelineUtils.defaultViewport, context.flipProjection, 0);
9977
10087
  rhi.clearRenderTarget(engine, CameraClearFlags.Depth, null);
9978
10088
  engine._renderCount++;
9979
10089
  cullingResults.opaqueQueue.render(context, PipelineStage.DepthOnly);
@@ -9998,14 +10108,11 @@ var /**
9998
10108
  var isNoDownsampling = downsampling === Downsampling.None;
9999
10109
  var viewport = camera.pixelViewport;
10000
10110
  var sizeScale = isNoDownsampling ? 1.0 : downsampling === Downsampling.TwoX ? 0.5 : 0.25;
10001
- var opaqueRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this._engine, this._renderTarget, viewport.width * sizeScale, viewport.height * sizeScale, TextureFormat.R8G8B8A8, null, false, false, 1);
10002
- var colorTexture = opaqueRenderTarget.getColorTexture(0);
10003
- colorTexture.wrapModeU = colorTexture.wrapModeV = TextureWrapMode.Clamp;
10004
- colorTexture.filterMode = isNoDownsampling ? TextureFilterMode.Point : TextureFilterMode.Bilinear;
10111
+ var opaqueRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this.engine, this._renderTarget, viewport.width * sizeScale, viewport.height * sizeScale, camera._getInternalColorTextureFormat(), null, false, false, 1, TextureWrapMode.Clamp, isNoDownsampling ? TextureFilterMode.Point : TextureFilterMode.Bilinear);
10005
10112
  this._renderTarget = opaqueRenderTarget;
10006
10113
  };
10007
- _proto.onRender = function onRender(context, _) {
10008
- PipelineUtils.blitTexture(this._engine, this._cameraColorTexture, this._renderTarget);
10114
+ _proto.onRender = function onRender(context) {
10115
+ PipelineUtils.blitTexture(this.engine, this._cameraColorTexture, this._renderTarget);
10009
10116
  context.camera.shaderData.setTexture(Camera._cameraOpaqueTextureProperty, this._renderTarget.getColorTexture(0));
10010
10117
  };
10011
10118
  return OpaqueTexturePass;
@@ -10068,9 +10175,7 @@ var /**
10068
10175
  var independentCanvasEnabled = camera.independentCanvasEnabled;
10069
10176
  if (independentCanvasEnabled) {
10070
10177
  var viewport = camera.pixelViewport;
10071
- var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, TextureFormat.R8G8B8A8, TextureFormat.Depth24Stencil8, false, false, camera.msaaSamples);
10072
- var colorTexture = internalColorTarget.getColorTexture(0);
10073
- colorTexture.wrapModeU = colorTexture.wrapModeV = TextureWrapMode.Clamp;
10178
+ var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), TextureFormat.Depth24Stencil8, false, false, camera.msaaSamples, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
10074
10179
  this._internalColorTarget = internalColorTarget;
10075
10180
  } else {
10076
10181
  var internalColorTarget1 = this._internalColorTarget;
@@ -10084,17 +10189,16 @@ var /**
10084
10189
  this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
10085
10190
  };
10086
10191
  _proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
10087
- var _colorTarget, _colorTarget1;
10192
+ var _cameraRenderTarget, _cameraRenderTarget1;
10088
10193
  var cullingResults = this._cullingResults;
10089
10194
  var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
10090
10195
  var engine = camera.engine, scene = camera.scene;
10091
10196
  var background = scene.background;
10092
- var internalColorTarget = this._internalColorTarget;
10093
10197
  var rhi = engine._hardwareRenderer;
10094
- var _camera_renderTarget;
10095
- var colorTarget = (_camera_renderTarget = camera.renderTarget) != null ? _camera_renderTarget : internalColorTarget;
10198
+ var internalColorTarget = this._internalColorTarget;
10199
+ var colorTarget = internalColorTarget || camera.renderTarget;
10096
10200
  var colorViewport = internalColorTarget ? PipelineUtils.defaultViewport : camera.viewport;
10097
- var needFlipProjection = camera.renderTarget && cubeFace == undefined || internalColorTarget !== null;
10201
+ var needFlipProjection = !!internalColorTarget || camera.renderTarget && cubeFace == undefined;
10098
10202
  if (context.flipProjection !== needFlipProjection) {
10099
10203
  // Just add projection matrix update type is enough
10100
10204
  context.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
@@ -10121,18 +10225,23 @@ var /**
10121
10225
  colorTarget._blitRenderTarget();
10122
10226
  var opaqueTexturePass = this._opaqueTexturePass;
10123
10227
  opaqueTexturePass.onConfig(camera, colorTarget.getColorTexture(0));
10124
- opaqueTexturePass.onRender(context, cullingResults);
10228
+ opaqueTexturePass.onRender(context);
10125
10229
  // Should revert to original render target
10126
10230
  rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10127
10231
  } else {
10128
10232
  camera.shaderData.setTexture(Camera._cameraOpaqueTextureProperty, null);
10129
10233
  }
10130
10234
  transparentQueue.render(context, PipelineStage.Forward);
10131
- (_colorTarget = colorTarget) == null ? void 0 : _colorTarget._blitRenderTarget();
10132
- (_colorTarget1 = colorTarget) == null ? void 0 : _colorTarget1.generateMipmaps();
10133
- if (internalColorTarget) {
10134
- PipelineUtils.blitTexture(engine, internalColorTarget.getColorTexture(0), null, 0, camera.viewport);
10235
+ var postProcessManager = scene._postProcessManager;
10236
+ var cameraRenderTarget = camera.renderTarget;
10237
+ if (camera.enablePostProcess && postProcessManager.hasActiveEffect) {
10238
+ postProcessManager._render(context, internalColorTarget, cameraRenderTarget);
10239
+ } else if (internalColorTarget) {
10240
+ internalColorTarget._blitRenderTarget();
10241
+ PipelineUtils.blitTexture(engine, internalColorTarget.getColorTexture(0), cameraRenderTarget, 0, camera.viewport);
10135
10242
  }
10243
+ (_cameraRenderTarget = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget._blitRenderTarget();
10244
+ (_cameraRenderTarget1 = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget1.generateMipmaps();
10136
10245
  };
10137
10246
  /**
10138
10247
  * Push render data to render queue.
@@ -10158,6 +10267,7 @@ var /**
10158
10267
  break;
10159
10268
  }
10160
10269
  }
10270
+ context.replacementFailureStrategy === ReplacementFailureStrategy.KeepOriginalShader && this.pushRenderElementByType(renderElement, subRenderElement, materialSubShader.passes, renderStates);
10161
10271
  } else {
10162
10272
  this.pushRenderElementByType(renderElement, subRenderElement, replacementSubShaders[0].passes, renderStates);
10163
10273
  }
@@ -18333,37 +18443,29 @@ __decorate([
18333
18443
  -1,
18334
18444
  0,
18335
18445
  1,
18336
- 1,
18446
+ 3,
18337
18447
  -1,
18338
- 1,
18448
+ 2,
18339
18449
  1,
18340
18450
  -1,
18341
- 1,
18342
- 0,
18451
+ 3,
18343
18452
  0,
18344
- 1,
18345
- 1,
18346
- 1,
18347
- 0
18348
- ]); // right-top
18453
+ -1
18454
+ ]); // left-top
18349
18455
  // prettier-ignore
18350
18456
  var flipYVertices = new Float32Array([
18351
- 1,
18457
+ 3,
18352
18458
  -1,
18353
- 1,
18459
+ 2,
18354
18460
  0,
18355
18461
  -1,
18356
18462
  -1,
18357
18463
  0,
18358
18464
  0,
18359
- 1,
18360
- 1,
18361
- 1,
18362
- 1,
18363
18465
  -1,
18364
- 1,
18466
+ 3,
18365
18467
  0,
18366
- 1
18468
+ 2
18367
18469
  ]); // left-top
18368
18470
  var blitMaterial = new Material(engine, Shader.find("blit"));
18369
18471
  blitMaterial._addReferCount(1);
@@ -18401,7 +18503,7 @@ __decorate([
18401
18503
  new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
18402
18504
  ]);
18403
18505
  mesh.setVertexBufferBinding(new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static), 16);
18404
- mesh.addSubMesh(0, 4, MeshTopology.TriangleStrip);
18506
+ mesh.addSubMesh(0, 3, MeshTopology.Triangles);
18405
18507
  return mesh;
18406
18508
  };
18407
18509
  _proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel) {
@@ -23310,7 +23412,7 @@ ShaderPool.init();
23310
23412
  */ _proto._initialize = function _initialize(configuration) {
23311
23413
  var _this = this;
23312
23414
  var shaderLab = configuration.shaderLab, physics = configuration.physics;
23313
- if (shaderLab) {
23415
+ if (shaderLab && !Shader._shaderLab) {
23314
23416
  Shader._shaderLab = shaderLab;
23315
23417
  }
23316
23418
  var initializePromises = new Array();
@@ -24856,6 +24958,475 @@ __decorate([
24856
24958
  * */ LightManager._maxLight = 10;
24857
24959
  })();
24858
24960
 
24961
+ var fragBlurH = "#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy*2.0;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*4.0,0.0));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*3.0,0.0));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*2.0,0.0));mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*1.0,0.0));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c5=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*1.0,0.0));mediump vec4 c6=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*2.0,0.0));mediump vec4 c7=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*3.0,0.0));mediump vec4 c8=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*4.0,0.0));gl_FragColor=c0*0.01621622+c1*0.05405405+c2*0.12162162+c3*0.19459459+c4*0.22702703+c5*0.19459459+c6*0.12162162+c7*0.05405405+c8*0.01621622;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
24962
+
24963
+ var fragBlurV = "#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*3.23076923));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*1.38461538));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*1.38461538));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*3.23076923));gl_FragColor=c0*0.07027027+c1*0.31621622+c2*0.22702703+c3*0.31621622+c4*0.07027027;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
24964
+
24965
+ var fragPrefilter = "#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 material_BloomParams;uniform vec4 renderer_texelSize;void main(){\n#ifdef BLOOM_HQ\nvec2 texelSize=renderer_texelSize.xy;mediump vec4 A=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,-1.0));mediump vec4 B=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,-1.0));mediump vec4 C=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,-1.0));mediump vec4 D=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,-0.5));mediump vec4 E=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,-0.5));mediump vec4 F=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,0.0));mediump vec4 G=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 H=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,0.0));mediump vec4 I=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,0.5));mediump vec4 J=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,0.5));mediump vec4 K=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,1.0));mediump vec4 L=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,1.0));mediump vec4 M=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,1.0));mediump vec2 scale=vec2(0.5,0.125);mediump vec2 div=(1.0/4.0)*scale;mediump vec4 samplerColor=(D+E+I+J)*div.x;samplerColor+=(A+B+G+F)*div.y;samplerColor+=(B+C+H+G)*div.y;samplerColor+=(F+G+L+K)*div.y;samplerColor+=(G+H+M+L)*div.y;\n#else\nmediump vec4 samplerColor=sampleTexture(renderer_BlitTexture,v_uv);\n#endif\nmediump vec3 color=samplerColor.rgb;color=min(color,HALF_MAX);mediump float brightness=max3(color);float threshold=material_BloomParams.x;float thresholdKnee=material_BloomParams.y;mediump float softness=clamp(brightness-threshold+thresholdKnee,0.0,2.0*thresholdKnee);softness=(softness*softness)/(4.0*thresholdKnee+1e-4);mediump float multiplier=max(brightness-threshold,softness)/max(brightness,1e-4);color*=multiplier;color=max(color,0.0);gl_FragColor=vec4(color,samplerColor.a);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
24966
+
24967
+ var fragUpsample = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform sampler2D material_lowMipTexture;uniform vec4 material_BloomParams;uniform vec4 material_lowMipTexelSize;void main(){mediump vec4 highMip=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef BLOOM_HQ\nmediump vec4 lowMip=sampleTexture2DBicubic(material_lowMipTexture,v_uv,material_lowMipTexelSize);\n#else\nmediump vec4 lowMip=sampleTexture(material_lowMipTexture,v_uv);\n#endif\ngl_FragColor=mix(highMip,lowMip,material_BloomParams.z);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
24968
+
24969
+ var BloomDownScaleMode;
24970
+ (function(BloomDownScaleMode) {
24971
+ BloomDownScaleMode[BloomDownScaleMode[/**
24972
+ * Use this to select half size as the starting resolution.
24973
+ */ "Half"] = 0] = "Half";
24974
+ BloomDownScaleMode[BloomDownScaleMode[/**
24975
+ * Use this to select quarter size as the starting resolution.
24976
+ */ "Quarter"] = 1] = "Quarter";
24977
+ })(BloomDownScaleMode || (BloomDownScaleMode = {}));
24978
+ var BloomEffect = /*#__PURE__*/ function() {
24979
+ function BloomEffect(_uberMaterial) {
24980
+ this._uberMaterial = _uberMaterial;
24981
+ this._highQualityFiltering = false;
24982
+ this._mipDownRT = [];
24983
+ this._mipUpRT = [];
24984
+ this._maxIterations = 6;
24985
+ this._enabled = false;
24986
+ this./**
24987
+ * Controls the starting resolution that this effect begins processing.
24988
+ */ downScale = 0;
24989
+ var engine = _uberMaterial.engine;
24990
+ var material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
24991
+ var depthState = material.renderState.depthState;
24992
+ depthState.enabled = false;
24993
+ depthState.writeEnabled = false;
24994
+ var bloomShaderData = material.shaderData;
24995
+ var uberShaderData = _uberMaterial.shaderData;
24996
+ bloomShaderData.setVector4(BloomEffect._bloomParams, new Vector4());
24997
+ bloomShaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
24998
+ uberShaderData.setVector4(BloomEffect._bloomIntensityParams, new Vector4(1, 1, 0, 0));
24999
+ uberShaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
25000
+ uberShaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));
25001
+ this._bloomMaterial = material;
25002
+ this.threshold = 0.9;
25003
+ this.scatter = 0.7;
25004
+ this.intensity = 1;
25005
+ this.dirtIntensity = 1;
25006
+ }
25007
+ var _proto = BloomEffect.prototype;
25008
+ _proto.onRender = function onRender(context, srcTexture) {
25009
+ var camera = context.camera;
25010
+ var downRes = this.downScale === 0 ? 1 : 2;
25011
+ var pixelViewport = camera.pixelViewport;
25012
+ var tw = pixelViewport.width >> downRes;
25013
+ var th = pixelViewport.height >> downRes;
25014
+ // Determine the iteration count
25015
+ var mipCount = this._calculateMipCount(tw, th);
25016
+ // Prefilter
25017
+ this._prefilter(camera, srcTexture, tw, th, mipCount);
25018
+ // Down sample - gaussian pyramid
25019
+ this._downsample(mipCount);
25020
+ // Up sample (bilinear by default, HQ filtering does bicubic instead
25021
+ this._upsample(mipCount);
25022
+ // Setup bloom on uber
25023
+ this._setupUber(camera);
25024
+ };
25025
+ _proto._calculateMipCount = function _calculateMipCount(tw, th) {
25026
+ var maxSize = Math.max(tw, th);
25027
+ var iterations = Math.floor(Math.log2(maxSize) - 1);
25028
+ return Math.min(Math.max(iterations, 1), this._maxIterations);
25029
+ };
25030
+ _proto._prefilter = function _prefilter(camera, srcTexture, tw, th, mipCount) {
25031
+ var engine = this._uberMaterial.engine;
25032
+ var internalColorTextureFormat = camera._getInternalColorTextureFormat();
25033
+ var mipWidth = tw, mipHeight = th;
25034
+ for(var i = 0; i < mipCount; i++){
25035
+ this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipUpRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
25036
+ this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipDownRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
25037
+ mipWidth = Math.max(1, Math.floor(mipWidth / 2));
25038
+ mipHeight = Math.max(1, Math.floor(mipHeight / 2));
25039
+ }
25040
+ PipelineUtils.blitTexture(engine, srcTexture, this._mipDownRT[0], undefined, undefined, this._bloomMaterial, 0);
25041
+ };
25042
+ _proto._downsample = function _downsample(mipCount) {
25043
+ var material = this._bloomMaterial;
25044
+ var engine = material.engine;
25045
+ var lastDown = this._mipDownRT[0];
25046
+ // Down sample - gaussian pyramid
25047
+ for(var i = 1; i < mipCount; i++){
25048
+ // Classic two pass gaussian blur - use mipUp as a temporary target
25049
+ // First pass does 2x downsampling + 9-tap gaussian
25050
+ // Second pass does 9-tap gaussian using a 5-tap filter + bilinear filtering
25051
+ PipelineUtils.blitTexture(engine, lastDown.getColorTexture(0), this._mipUpRT[i], undefined, undefined, material, 1);
25052
+ PipelineUtils.blitTexture(engine, this._mipUpRT[i].getColorTexture(0), this._mipDownRT[i], undefined, undefined, material, 2);
25053
+ lastDown = this._mipDownRT[i];
25054
+ }
25055
+ };
25056
+ _proto._upsample = function _upsample(mipCount) {
25057
+ var material = this._bloomMaterial;
25058
+ var engine = material.engine;
25059
+ var shaderData = material.shaderData;
25060
+ // Up sample (bilinear by default, HQ filtering does bicubic instead
25061
+ for(var i = mipCount - 2; i >= 0; i--){
25062
+ var lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
25063
+ var highMip = this._mipDownRT[i];
25064
+ var dst = this._mipUpRT[i];
25065
+ shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
25066
+ if (this.highQualityFiltering) {
25067
+ var texelSizeLow = shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
25068
+ texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
25069
+ }
25070
+ PipelineUtils.blitTexture(engine, highMip.getColorTexture(0), dst, undefined, undefined, material, 3);
25071
+ }
25072
+ };
25073
+ _proto._setupUber = function _setupUber(camera) {
25074
+ var shaderData = this._uberMaterial.shaderData;
25075
+ var dirtTexture = this.dirtTexture;
25076
+ if (dirtTexture) {
25077
+ var dirtTilingOffset = shaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
25078
+ var dirtRatio = dirtTexture.width / dirtTexture.height;
25079
+ var screenRatio = camera.aspectRatio;
25080
+ if (dirtRatio > screenRatio) {
25081
+ dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
25082
+ } else if (dirtRatio < screenRatio) {
25083
+ dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
25084
+ } else {
25085
+ dirtTilingOffset.set(1, 1, 0, 0);
25086
+ }
25087
+ }
25088
+ shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
25089
+ };
25090
+ _proto._releaseRenderTargets = function _releaseRenderTargets() {
25091
+ var length = this._mipDownRT.length;
25092
+ for(var i = 0; i < length; i++){
25093
+ var downRT = this._mipDownRT[i];
25094
+ var upRT = this._mipUpRT[i];
25095
+ if (downRT) {
25096
+ downRT.getColorTexture(0).destroy(true);
25097
+ downRT.destroy(true);
25098
+ }
25099
+ if (upRT) {
25100
+ upRT.getColorTexture(0).destroy(true);
25101
+ upRT.destroy(true);
25102
+ }
25103
+ }
25104
+ this._mipDownRT.length = 0;
25105
+ this._mipUpRT.length = 0;
25106
+ };
25107
+ _create_class(BloomEffect, [
25108
+ {
25109
+ key: "enabled",
25110
+ get: /**
25111
+ * Indicates whether the post process effect is enabled.
25112
+ */ function get() {
25113
+ return this._enabled;
25114
+ },
25115
+ set: function set(value) {
25116
+ if (value !== this._enabled) {
25117
+ this._enabled = value;
25118
+ if (value) {
25119
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._enableMacro);
25120
+ } else {
25121
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._enableMacro);
25122
+ this._releaseRenderTargets();
25123
+ }
25124
+ }
25125
+ }
25126
+ },
25127
+ {
25128
+ key: "threshold",
25129
+ get: /**
25130
+ * Set the level of brightness to filter out pixels under this level.
25131
+ * @remarks This value is expressed in gamma-space.
25132
+ */ function get() {
25133
+ return this._threshold;
25134
+ },
25135
+ set: function set(value) {
25136
+ value = Math.max(0, value);
25137
+ if (value !== this._threshold) {
25138
+ this._threshold = value;
25139
+ var threshold = Color.gammaToLinearSpace(value);
25140
+ var thresholdKnee = threshold * 0.5; // Hardcoded soft knee
25141
+ var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
25142
+ params.x = threshold;
25143
+ params.y = thresholdKnee;
25144
+ }
25145
+ }
25146
+ },
25147
+ {
25148
+ key: "scatter",
25149
+ get: /**
25150
+ * Controls the radius of the bloom effect.
25151
+ */ function get() {
25152
+ return this._scatter;
25153
+ },
25154
+ set: function set(value) {
25155
+ value = Math.min(Math.max(0, value), 1);
25156
+ if (value !== this._scatter) {
25157
+ this._scatter = value;
25158
+ var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
25159
+ var scatter = MathUtil.lerp(0.05, 0.95, value);
25160
+ params.z = scatter;
25161
+ }
25162
+ }
25163
+ },
25164
+ {
25165
+ key: "intensity",
25166
+ get: /**
25167
+ * Controls the strength of the bloom effect.
25168
+ */ function get() {
25169
+ return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x;
25170
+ },
25171
+ set: function set(value) {
25172
+ value = Math.max(0, value);
25173
+ this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x = value;
25174
+ }
25175
+ },
25176
+ {
25177
+ key: "tint",
25178
+ get: /**
25179
+ * Specifies the tint of the bloom effect.
25180
+ */ function get() {
25181
+ return this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
25182
+ },
25183
+ set: function set(value) {
25184
+ var tint = this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
25185
+ if (value !== tint) {
25186
+ tint.copyFrom(value);
25187
+ }
25188
+ }
25189
+ },
25190
+ {
25191
+ key: "highQualityFiltering",
25192
+ get: /**
25193
+ * Controls whether to use bicubic sampling instead of bilinear sampling for the upSampling passes.
25194
+ * @remarks This is slightly more expensive but helps getting smoother visuals.
25195
+ */ function get() {
25196
+ return this._highQualityFiltering;
25197
+ },
25198
+ set: function set(value) {
25199
+ if (value !== this._highQualityFiltering) {
25200
+ this._highQualityFiltering = value;
25201
+ if (value) {
25202
+ this._bloomMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
25203
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
25204
+ } else {
25205
+ this._bloomMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
25206
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
25207
+ }
25208
+ }
25209
+ }
25210
+ },
25211
+ {
25212
+ key: "dirtTexture",
25213
+ get: /**
25214
+ * Specifies a Texture to add smudges or dust to the bloom effect.
25215
+ */ function get() {
25216
+ return this._uberMaterial.shaderData.getTexture(BloomEffect._dirtTextureProp);
25217
+ },
25218
+ set: function set(value) {
25219
+ this._uberMaterial.shaderData.setTexture(BloomEffect._dirtTextureProp, value);
25220
+ if (value) {
25221
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._dirtMacro);
25222
+ } else {
25223
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._dirtMacro);
25224
+ }
25225
+ }
25226
+ },
25227
+ {
25228
+ key: "dirtIntensity",
25229
+ get: /**
25230
+ * Controls the strength of the lens dirt.
25231
+ */ function get() {
25232
+ return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y;
25233
+ },
25234
+ set: function set(value) {
25235
+ value = Math.max(0, value);
25236
+ this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y = value;
25237
+ }
25238
+ }
25239
+ ]);
25240
+ return BloomEffect;
25241
+ }();
25242
+ (function() {
25243
+ BloomEffect.SHADER_NAME = "PostProcessEffect Bloom";
25244
+ })();
25245
+ (function() {
25246
+ // Bloom shader properties
25247
+ BloomEffect._hqMacro = ShaderMacro.getByName("BLOOM_HQ");
25248
+ })();
25249
+ (function() {
25250
+ BloomEffect._dirtMacro = ShaderMacro.getByName("BLOOM_DIRT");
25251
+ })();
25252
+ (function() {
25253
+ BloomEffect._bloomParams = ShaderProperty.getByName("material_BloomParams") // x: threshold (linear), y: threshold knee, z: scatter
25254
+ ;
25255
+ })();
25256
+ (function() {
25257
+ BloomEffect._lowMipTextureProp = ShaderProperty.getByName("material_lowMipTexture");
25258
+ })();
25259
+ (function() {
25260
+ BloomEffect._lowMipTexelSizeProp = ShaderProperty.getByName("material_lowMipTexelSize") // x: 1/width, y: 1/height, z: width, w: height
25261
+ ;
25262
+ })();
25263
+ (function() {
25264
+ // Uber shader properties
25265
+ BloomEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_BLOOM");
25266
+ })();
25267
+ (function() {
25268
+ BloomEffect._bloomTextureProp = ShaderProperty.getByName("material_BloomTexture");
25269
+ })();
25270
+ (function() {
25271
+ BloomEffect._dirtTextureProp = ShaderProperty.getByName("material_BloomDirtTexture");
25272
+ })();
25273
+ (function() {
25274
+ BloomEffect._tintProp = ShaderProperty.getByName("material_BloomTint");
25275
+ })();
25276
+ (function() {
25277
+ BloomEffect._bloomIntensityParams = ShaderProperty.getByName("material_BloomIntensityParams") // x: bloom intensity, y: dirt intensity
25278
+ ;
25279
+ })();
25280
+ (function() {
25281
+ BloomEffect._dirtTilingOffsetProp = ShaderProperty.getByName("material_BloomDirtTilingOffset");
25282
+ })();
25283
+ Shader.create(BloomEffect.SHADER_NAME, [
25284
+ new ShaderPass("Bloom Prefilter", blitVs, fragPrefilter),
25285
+ new ShaderPass("Bloom Blur Horizontal", blitVs, fragBlurH),
25286
+ new ShaderPass("Bloom Blur Vertical", blitVs, fragBlurV),
25287
+ new ShaderPass("Bloom Upsample", blitVs, fragUpsample)
25288
+ ]);
25289
+
25290
+ var TonemappingMode;
25291
+ (function(TonemappingMode) {
25292
+ TonemappingMode[TonemappingMode[/**
25293
+ * Neutral tonemapper
25294
+ * @remarks Use this option if you only want range-remapping with minimal impact on color hue and saturation.
25295
+ */ "Neutral"] = 0] = "Neutral";
25296
+ TonemappingMode[TonemappingMode[/**
25297
+ * ACES Filmic reference tonemapper (custom approximation)
25298
+ * @remarks
25299
+ * Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
25300
+ * It is more contrasted than Neutral and has an effect on actual color hue and saturation.
25301
+ */ "ACES"] = 1] = "ACES";
25302
+ })(TonemappingMode || (TonemappingMode = {}));
25303
+ var TonemappingEffect = /*#__PURE__*/ function() {
25304
+ function TonemappingEffect(_uberMaterial) {
25305
+ this._uberMaterial = _uberMaterial;
25306
+ this._enabled = false;
25307
+ this.mode = 0;
25308
+ }
25309
+ _create_class(TonemappingEffect, [
25310
+ {
25311
+ key: "enabled",
25312
+ get: /**
25313
+ * Indicates whether the post process effect is enabled.
25314
+ */ function get() {
25315
+ return this._enabled;
25316
+ },
25317
+ set: function set(value) {
25318
+ if (value !== this._enabled) {
25319
+ this._enabled = value;
25320
+ if (value) {
25321
+ this._uberMaterial.shaderData.enableMacro(TonemappingEffect._enableMacro);
25322
+ } else {
25323
+ this._uberMaterial.shaderData.disableMacro(TonemappingEffect._enableMacro);
25324
+ }
25325
+ }
25326
+ }
25327
+ },
25328
+ {
25329
+ key: "mode",
25330
+ get: /**
25331
+ * Use this to select a tonemapping algorithm to use.
25332
+ */ function get() {
25333
+ return this._mode;
25334
+ },
25335
+ set: function set(value) {
25336
+ if (value !== this._mode) {
25337
+ this._mode = value;
25338
+ this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE", value.toString());
25339
+ }
25340
+ }
25341
+ }
25342
+ ]);
25343
+ return TonemappingEffect;
25344
+ }();
25345
+ (function() {
25346
+ TonemappingEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_TONEMAPPING");
25347
+ })();
25348
+
25349
+ /**
25350
+ * @internal
25351
+ */ var _PostProcessManager = /*#__PURE__*/ function() {
25352
+ function _PostProcessManager(scene) {
25353
+ this.scene = scene;
25354
+ this./**
25355
+ * Whether the post process manager is active.
25356
+ */ isActive = true;
25357
+ var uberShader = Shader.find(_PostProcessManager.UBER_SHADER_NAME);
25358
+ var uberMaterial = new Material(scene.engine, uberShader);
25359
+ var depthState = uberMaterial.renderState.depthState;
25360
+ depthState.enabled = false;
25361
+ depthState.writeEnabled = false;
25362
+ var bloomEffect = new BloomEffect(uberMaterial);
25363
+ var tonemappingEffect = new TonemappingEffect(uberMaterial);
25364
+ this._uberMaterial = uberMaterial;
25365
+ this._bloomEffect = bloomEffect;
25366
+ this._tonemappingEffect = tonemappingEffect;
25367
+ }
25368
+ var _proto = _PostProcessManager.prototype;
25369
+ /**
25370
+ * @internal
25371
+ */ _proto._render = function _render(context, srcTarget, destTarget) {
25372
+ var camera = context.camera;
25373
+ var engine = camera.engine;
25374
+ // Should blit to resolve the MSAA
25375
+ srcTarget._blitRenderTarget();
25376
+ var srcTexture = srcTarget.getColorTexture();
25377
+ var bloomEffect = this._bloomEffect;
25378
+ if (bloomEffect.enabled) {
25379
+ bloomEffect.onRender(context, srcTexture);
25380
+ }
25381
+ // Done with Uber, blit it
25382
+ PipelineUtils.blitTexture(engine, srcTexture, destTarget, 0, camera.viewport, this._uberMaterial);
25383
+ };
25384
+ _create_class(_PostProcessManager, [
25385
+ {
25386
+ key: "hasActiveEffect",
25387
+ get: /**
25388
+ * Whether has active post process effect.
25389
+ */ function get() {
25390
+ return this.isActive && (this._bloomEffect.enabled || this._tonemappingEffect.enabled);
25391
+ }
25392
+ }
25393
+ ]);
25394
+ return _PostProcessManager;
25395
+ }();
25396
+ (function() {
25397
+ _PostProcessManager.UBER_SHADER_NAME = "UberPost";
25398
+ })();
25399
+
25400
+ var Filtering = "#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\nvec2 bSpline3MiddleLeft(vec2 x){return 0.16666667+x*(0.5+x*(0.5-x*0.5));}vec2 bSpline3MiddleRight(vec2 x){return 0.66666667+x*(-1.0+0.5*x)*x;}vec2 bSpline3Rightmost(vec2 x){return 0.16666667+x*(-0.5+x*(0.5-x*0.16666667));}void bicubicFilter(vec2 fracCoord,out vec2 weights[2],out vec2 offsets[2]){vec2 r=bSpline3Rightmost(fracCoord);vec2 mr=bSpline3MiddleRight(fracCoord);vec2 ml=bSpline3MiddleLeft(fracCoord);vec2 l=1.0-mr-ml-r;weights[0]=r+mr;weights[1]=ml+l;offsets[0]=-1.0+mr/weights[0];offsets[1]=1.0+l/weights[1];}vec4 sampleTexture2DBicubic(sampler2D tex,vec2 coord,vec4 texSize){vec2 xy=coord*texSize.zw+0.5;vec2 ic=floor(xy);vec2 fc=fract(xy);vec2 weights[2],offsets[2];bicubicFilter(fc,weights,offsets);return weights[0].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[0].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[0].y)-0.5)*texSize.xy))+weights[1].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[1].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[1].y)-0.5)*texSize.xy));}\n#endif\n"; // eslint-disable-line
25401
+
25402
+ var PostCommon = "#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n#include <common>\n#define FLT_MIN 1.175494351e-38\n#define HALF_MIN 6.103515625e-5\n#define HALF_MAX 65504.0\nfloat min3(vec3 val){return min(min(val.x,val.y),val.z);}float max3(vec3 val){return max(max(val.x,val.y),val.z);}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}vec4 sampleTexture(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ncolor=gammaToLinear(color);\n#endif\nreturn color;}\n#endif\n"; // eslint-disable-line
25403
+
25404
+ var ACESTonemapping = "#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\nvec3 ACESTonemap(vec3 color){vec3 aces=sRGB_2_AP0*color;mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(vec3(aces));mediump float centeredHue=center_hue(hue,RRT_RED_HUE);float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);vec3 acescg=max(AP0_2_AP1_MAT*aces,0.0);acescg=mix(vec3(dot(acescg,AP1_RGB2Y)),acescg,RRT_SAT_FACTOR);const float a=0.0245786;const float b=0.000090537;const float c=0.983729;const float d=0.4329510;const float e=0.238081;vec3 rcpAcesCG=1.0/(acescg+FLT_MIN);mediump vec3 rgbPost=(acescg+a-b*rcpAcesCG)/(acescg*c+d+e*rcpAcesCG);vec3 linearCV=darkSurround_to_dimSurround(rgbPost);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;return linearCV;}"; // eslint-disable-line
25405
+
25406
+ var ColorTransform = "#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\nconst mediump mat3 sRGB_2_AP0=mat3(0.4397010,0.0897923,0.0175440,0.3829780,0.8134230,0.1115440,0.1773350,0.0967616,0.8707040);const mediump mat3 AP1_2_AP0_MAT=mat3(vec3(0.6954522414,0.0447945634,-0.0055258826),vec3(0.1406786965,0.8596711185,0.0040252103),vec3(0.1638690622,0.0955343182,1.0015006723));const mediump mat3 AP0_2_AP1_MAT=mat3(vec3(1.4514393161,-0.0765537734,0.0083161484),vec3(-0.2365107469,1.1762296998,-0.0060324498),vec3(-0.2149285693,-0.0996759264,0.9977163014));const mediump mat3 AP1_2_XYZ_MAT=mat3(vec3(0.6624541811,0.2722287168,-0.0055746495),vec3(0.1340042065,0.6740817658,0.0040607335),vec3(0.1561876870,0.0536895174,1.0103391003));const mediump mat3 XYZ_2_AP1_MAT=mat3(vec3(1.6410233797,-0.6636628587,0.0117218943),vec3(-0.3248032942,1.6153315917,-0.0082844420),vec3(-0.2364246952,0.0167563477,0.9883948585));const mediump mat3 D60_2_D65_CAT=mat3(vec3(0.987224,-0.00759836,0.00307257),vec3(-0.00611327,1.00186,-0.00509595),vec3(0.0159533,0.00533002,1.08168));const mediump mat3 XYZ_2_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));const mediump vec3 AP1_RGB2Y=vec3(0.2722287168,0.6740817658,0.0536895174);mediump float rgb_2_saturation(mediump vec3 rgb){const mediump float TINY=1e-4;mediump float mi=min3(rgb);mediump float ma=max3(rgb);return(max(ma,TINY)-max(mi,TINY))/max(ma,1e-2);}mediump float rgb_2_yc(mediump vec3 rgb){const mediump float ycRadiusWeight=1.75;mediump float r=rgb.x;mediump float g=rgb.y;mediump float b=rgb.z;mediump float k=b*(b-g)+g*(g-r)+r*(r-b);k=max(k,0.0);float chroma=k==0.0 ? 0.0 : sqrt(k);return(b+g+r+ycRadiusWeight*chroma)/3.0;}mediump float rgb_2_hue(mediump vec3 rgb){mediump float hue;if(rgb.x==rgb.y&&rgb.y==rgb.z){hue=0.0;}else{hue=(180.0/PI)*atan(sqrt(3.0)*(rgb.y-rgb.z),2.0*rgb.x-rgb.y-rgb.z);}if(hue<0.0){hue=hue+360.0;}return hue;}mediump float center_hue(mediump float hue,mediump float centerH){mediump float hueCentered=hue-centerH;if(hueCentered<-180.0){hueCentered=hueCentered+360.0;}else if(hueCentered>180.0){hueCentered=hueCentered-360.0;}return hueCentered;}\n#endif\n"; // eslint-disable-line
25407
+
25408
+ var ODT = "#define GLSLIFY 1\n#include <Tonescale>\nconst float CINEMA_WHITE=48.0;const float CINEMA_BLACK=0.02;const float ODT_SAT_FACTOR=0.93;mediump vec3 Y_2_linCV(mediump vec3 Y,mediump float Ymax,mediump float Ymin){return(Y-Ymin)/(Ymax-Ymin);}mediump vec3 XYZ_2_xyY(mediump vec3 XYZ){mediump float divisor=max(dot(XYZ,vec3(1.0)),1e-4);return vec3(XYZ.xy/divisor,XYZ.y);}mediump vec3 xyY_2_XYZ(mediump vec3 xyY){mediump float m=xyY.z/max(xyY.y,1e-4);mediump vec3 XYZ=vec3(xyY.xz,(1.0-xyY.x-xyY.y));XYZ.xz*=m;return XYZ;}const mediump float DIM_SURROUND_GAMMA=0.9811;mediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;mediump vec3 xyY=XYZ_2_xyY(XYZ);xyY.z=clamp(xyY.z,0.0,HALF_MAX);xyY.z=pow(xyY.z,DIM_SURROUND_GAMMA);XYZ=xyY_2_XYZ(xyY);return XYZ_2_AP1_MAT*XYZ;}mediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){mediump vec3 rgbPre=AP0_2_AP1_MAT*oces;mediump vec3 rgbPost;rgbPost.r=segmented_spline_c9_fwd(rgbPre.r);rgbPost.g=segmented_spline_c9_fwd(rgbPre.g);rgbPost.b=segmented_spline_c9_fwd(rgbPre.b);mediump vec3 linearCV=Y_2_linCV(rgbPost,CINEMA_WHITE,CINEMA_BLACK);linearCV=darkSurround_to_dimSurround(linearCV);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;linearCV=clamp(linearCV,vec3(0),vec3(1));return linearCV;}"; // eslint-disable-line
25409
+
25410
+ var RRT = "#define GLSLIFY 1\n#include <Tonescale>\nmediump float sigmoid_shaper(mediump float x){mediump float t=max(1.0-abs(x/2.0),0.0);mediump float y=1.0+sign(x)*(1.0-t*t);return y*0.5;}mediump float glow_fwd(mediump float ycIn,mediump float glowGainIn,mediump float glowMid){mediump float glowGainOut;if(ycIn<=2.0/3.0*glowMid){glowGainOut=glowGainIn;}else if(ycIn>=2.0*glowMid){glowGainOut=0.0;}else{glowGainOut=glowGainIn*(glowMid/ycIn-1.0/2.0);}return glowGainOut;}const mediump float RRT_GLOW_GAIN=0.05;const mediump float RRT_GLOW_MID=0.08;const mediump float RRT_RED_SCALE=0.82;const mediump float RRT_RED_PIVOT=0.03;const mediump float RRT_RED_HUE=0.0;const mediump float RRT_RED_WIDTH=135.0;const mediump float RRT_SAT_FACTOR=0.96;mediump vec3 RRT(mediump vec3 aces){mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);mediump float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(aces);mediump float centeredHue=center_hue(hue,RRT_RED_HUE);mediump float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);aces=clamp(aces,0.0,HALF_MAX);mediump vec3 rgbPre=AP0_2_AP1_MAT*aces;rgbPre=clamp(rgbPre,0.0,HALF_MAX);rgbPre=mix(vec3(dot(rgbPre,AP1_RGB2Y)),rgbPre,RRT_SAT_FACTOR);mediump vec3 rgbPost;rgbPost.x=segmented_spline_c5_fwd(rgbPre.x);rgbPost.y=segmented_spline_c5_fwd(rgbPre.y);rgbPost.z=segmented_spline_c5_fwd(rgbPre.z);mediump vec3 outputVal=AP1_2_AP0_MAT*rgbPost;return outputVal;}"; // eslint-disable-line
25411
+
25412
+ var Tonescale = "#define GLSLIFY 1\n#ifndef TONE_SCALE\n#define TONE_SCALE\nconst mediump mat3 M=mat3(vec3(0.5,-1.0,0.5),vec3(-1.0,1.0,0.5),vec3(0.5,0.0,0.0));mediump float segmented_spline_c5_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[6]=float[6](-4.0000000000,-4.0000000000,-3.1573765773,-0.4852499958,1.8477324706,1.8477324706);const mediump float coefsHigh[6]=float[6](-0.7185482425,2.0810307172,3.6681241237,4.0000000000,4.0000000000,4.0000000000);\n#else\nconst mediump float coefsLow_0=-4.0000000000;const mediump float coefsLow_1=-4.0000000000;const mediump float coefsLow_2=-3.1573765773;const mediump float coefsLow_3=-0.4852499958;const mediump float coefsLow_4=1.8477324706;const mediump float coefsLow_5=1.8477324706;const mediump float coefsHigh_0=-0.7185482425;const mediump float coefsHigh_1=2.0810307172;const mediump float coefsHigh_2=3.6681241237;const mediump float coefsHigh_3=4.0000000000;const mediump float coefsHigh_4=4.0000000000;const mediump float coefsHigh_5=4.0000000000;\n#endif\nconst mediump vec2 minPoint=vec2(0.0000054931640625,0.0001);const mediump vec2 midPoint=vec2(0.18,0.48);const mediump vec2 maxPoint=vec2(47185.92,10000.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.0;const int N_KNOTS_LOW=4;const int N_KNOTS_HIGH=4;mediump float logx=log10(max(x,HALF_MIN));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else{cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else{cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}mediump float segmented_spline_c9_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[10]=float[10](-1.6989700043,-1.6989700043,-1.4779000000,-1.2291000000,-0.8648000000,-0.4480000000,0.0051800000,0.4511080334,0.9113744414,0.9113744414);const mediump float coefsHigh[10]=float[10](0.5154386965,0.8470437783,1.1358000000,1.3802000000,1.5197000000,1.5985000000,1.6467000000,1.6746091357,1.6878733390,1.6878733390);\n#else\nconst mediump float coefsLow_0=-1.6989700043;const mediump float coefsLow_1=-1.6989700043;const mediump float coefsLow_2=-1.4779000000;const mediump float coefsLow_3=-1.2291000000;const mediump float coefsLow_4=-0.8648000000;const mediump float coefsLow_5=-0.4480000000;const mediump float coefsLow_6=0.0051800000;const mediump float coefsLow_7=0.4511080334;const mediump float coefsLow_8=0.9113744414;const mediump float coefsLow_9=0.9113744414;const mediump float coefsHigh_0=0.5154386965;const mediump float coefsHigh_1=0.8470437783;const mediump float coefsHigh_2=1.1358000000;const mediump float coefsHigh_3=1.3802000000;const mediump float coefsHigh_4=1.5197000000;const mediump float coefsHigh_5=1.5985000000;const mediump float coefsHigh_6=1.6467000000;const mediump float coefsHigh_7=1.6746091357;const mediump float coefsHigh_8=1.6878733390;const mediump float coefsHigh_9=1.6878733390;\n#endif\nconst mediump vec2 minPoint=vec2(0.0028799,0.02);const mediump vec2 midPoint=vec2(4.799999,4.8);const mediump vec2 maxPoint=vec2(1005.719,48.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.04;const int N_KNOTS_LOW=8;const int N_KNOTS_HIGH=8;mediump float logx=log10(max(x,1e-4));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else if(j==3){cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}else if(j==4){cf=vec3(coefsLow_4,coefsLow_5,coefsLow_6);}else if(j==5){cf=vec3(coefsLow_5,coefsLow_6,coefsLow_7);}else if(j==6){cf=vec3(coefsLow_6,coefsLow_7,coefsLow_8);}else{cf=vec3(coefsLow_7,coefsLow_8,coefsLow_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else if(j==3){cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}else if(j==4){cf=vec3(coefsHigh_4,coefsHigh_5,coefsHigh_6);}else if(j==5){cf=vec3(coefsHigh_5,coefsHigh_6,coefsHigh_7);}else if(j==6){cf=vec3(coefsHigh_6,coefsHigh_7,coefsHigh_8);}else{cf=vec3(coefsHigh_7,coefsHigh_8,coefsHigh_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}\n#endif\n"; // eslint-disable-line
25413
+
25414
+ var NeutralTonemapping = "#define GLSLIFY 1\nvec3 neutralCurve(vec3 x,float a,float b,float c,float d,float e,float f){return vec3(((x*(a*x+c*b)+d*e)/(x*(a*x+b)+d*f))-e/f);}\n#define TONEMAPPING_CLAMP_MAX 435.18712\nvec3 neutralTonemap(vec3 color){const float a=0.2;const float b=0.29;const float c=0.24;const float d=0.272;const float e=0.02;const float f=0.3;\n#ifndef GL_FRAGMENT_PRECISION_HIGH\ncolor=min(color,TONEMAPPING_CLAMP_MAX);\n#endif\nconst float whiteScale=1.31338;color=neutralCurve(color*whiteScale,a,b,c,d,e,f);color*=whiteScale;return color;}"; // eslint-disable-line
25415
+
25416
+ var UberPost = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;\n#ifdef ENABLE_EFFECT_BLOOM\nuniform sampler2D material_BloomTexture;uniform sampler2D material_BloomDirtTexture;uniform vec4 material_BloomTint;uniform vec4 material_BloomDirtTilingOffset;uniform vec4 material_BloomIntensityParams;\n#endif\nvoid main(){mediump vec4 color=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef ENABLE_EFFECT_BLOOM\n#ifdef BLOOM_HQ\nmediump vec4 bloom=sampleTexture2DBicubic(material_BloomTexture,v_uv,renderer_texelSize);\n#else\nmediump vec4 bloom=sampleTexture(material_BloomTexture,v_uv);\n#endif\nbloom*=material_BloomIntensityParams.x;color+=bloom*material_BloomTint;\n#ifdef BLOOM_DIRT\nmediump vec4 dirt=sampleTexture(material_BloomDirtTexture,v_uv*material_BloomDirtTilingOffset.xy+material_BloomDirtTilingOffset.zw);dirt*=material_BloomIntensityParams.y;color+=dirt*bloom;\n#endif\n#endif\n#ifdef ENABLE_EFFECT_TONEMAPPING\n#if TONEMAPPING_MODE == 0\ncolor.rgb=neutralTonemap(color.rgb);\n#elif TONEMAPPING_MODE == 1\ncolor.rgb=ACESTonemap(color.rgb);\n#endif\ncolor.rgb=clamp(color.rgb,vec3(0),vec3(1));\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
25417
+
25418
+ Object.assign(ShaderLib, {
25419
+ PostCommon: PostCommon,
25420
+ Filtering: Filtering,
25421
+ ODT: ODT,
25422
+ RRT: RRT,
25423
+ Tonescale: Tonescale,
25424
+ ColorTransform: ColorTransform,
25425
+ NeutralTonemapping: NeutralTonemapping,
25426
+ ACESTonemapping: ACESTonemapping
25427
+ });
25428
+ Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
25429
+
24859
25430
  /**
24860
25431
  * Scene.
24861
25432
  */ var Scene = /*#__PURE__*/ function(EngineObject1) {
@@ -24879,6 +25450,7 @@ __decorate([
24879
25450
  /** @internal */ _this._isActiveInEngine = false;
24880
25451
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
24881
25452
  /** @internal */ _this._rootEntities = [];
25453
+ /** @internal */ _this._postProcessManager = new _PostProcessManager(_assert_this_initialized(_this));
24882
25454
  _this._background = new Background(_this._engine);
24883
25455
  _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
24884
25456
  _this._shadowCascades = ShadowCascadesMode.NoCascades;
@@ -27808,7 +28380,8 @@ var AnimatorLayerBlendingMode;
27808
28380
  eventHandler.event = event;
27809
28381
  handlers.length = 0;
27810
28382
  for(var j = scriptCount - 1; j >= 0; j--){
27811
- var handler = scripts[j][funcName];
28383
+ var script = scripts[j];
28384
+ var handler = script[funcName].bind(script);
27812
28385
  handler && handlers.push(handler);
27813
28386
  }
27814
28387
  eventHandlers.push(eventHandler);
@@ -33606,5 +34179,5 @@ var cacheDir = new Vector3();
33606
34179
  return CubeProbe;
33607
34180
  }(Probe);
33608
34181
 
33609
- export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraType, Canvas, CapsuleColliderShape, CharacterController, CircleShape, ClearableObjectPool, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
34182
+ export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraType, Canvas, CapsuleColliderShape, CharacterController, CircleShape, ClearableObjectPool, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderPlatformTarget, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, _PostProcessManager, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
33610
34183
  //# sourceMappingURL=module.js.map