@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
@@ -2995,6 +2995,12 @@ exports.RenderStateDataKey = void 0;
2995
2995
  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";
2996
2996
  })(exports.StencilOperation || (exports.StencilOperation = {}));
2997
2997
 
2998
+ exports.ShaderPlatformTarget = void 0;
2999
+ (function(ShaderPlatformTarget) {
3000
+ ShaderPlatformTarget[ShaderPlatformTarget["GLES100"] = 0] = "GLES100";
3001
+ ShaderPlatformTarget[ShaderPlatformTarget["GLES300"] = 1] = "GLES300";
3002
+ })(exports.ShaderPlatformTarget || (exports.ShaderPlatformTarget = {}));
3003
+
2998
3004
  /**
2999
3005
  * Shader macro。
3000
3006
  */ var ShaderMacro = /*#__PURE__*/ function() {
@@ -3024,14 +3030,14 @@ exports.RenderStateDataKey = void 0;
3024
3030
  maskMap.length++;
3025
3031
  maskMap[index] = new Array(32);
3026
3032
  }
3027
- maskMap[index][bit] = key;
3033
+ maskMap[index][bit] = macro;
3028
3034
  ShaderMacro._macroCounter++;
3029
3035
  }
3030
3036
  return macro;
3031
3037
  };
3032
3038
  /**
3033
3039
  * @internal
3034
- */ ShaderMacro._getNamesByMacros = function _getNamesByMacros(macros, out) {
3040
+ */ ShaderMacro._getMacrosElements = function _getMacrosElements(macros, out) {
3035
3041
  var maskMap = ShaderMacro._macroMaskMap;
3036
3042
  var mask = macros._mask;
3037
3043
  out.length = 0;
@@ -3214,15 +3220,6 @@ exports.RenderStateDataKey = void 0;
3214
3220
  return ShaderMacroCollection;
3215
3221
  }();
3216
3222
 
3217
- /**
3218
- * Pipeline stage.
3219
- */ exports.PipelineStage = void 0;
3220
- (function(PipelineStage) {
3221
- PipelineStage[/** DepthOnly stage. */ "DepthOnly"] = "DepthOnly";
3222
- PipelineStage[/** Shadow caster stage. */ "ShadowCaster"] = "ShadowCaster";
3223
- PipelineStage[/** Forward shading stage. */ "Forward"] = "Forward";
3224
- })(exports.PipelineStage || (exports.PipelineStage = {}));
3225
-
3226
3223
  function _extends() {
3227
3224
  _extends = Object.assign || function assign(target) {
3228
3225
  for (var i = 1; i < arguments.length; i++) {
@@ -3236,6 +3233,15 @@ function _extends() {
3236
3233
  return _extends.apply(this, arguments);
3237
3234
  }
3238
3235
 
3236
+ /**
3237
+ * Pipeline stage.
3238
+ */ exports.PipelineStage = void 0;
3239
+ (function(PipelineStage) {
3240
+ PipelineStage[/** DepthOnly stage. */ "DepthOnly"] = "DepthOnly";
3241
+ PipelineStage[/** Shadow caster stage. */ "ShadowCaster"] = "ShadowCaster";
3242
+ PipelineStage[/** Forward shading stage. */ "Forward"] = "Forward";
3243
+ })(exports.PipelineStage || (exports.PipelineStage = {}));
3244
+
3239
3245
  var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;"; // eslint-disable-line
3240
3246
 
3241
3247
  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
@@ -3324,13 +3330,13 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
3324
3330
 
3325
3331
  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
3326
3332
 
3327
- 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
3333
+ 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
3328
3334
 
3329
3335
  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
3330
3336
 
3331
3337
  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
3332
3338
 
3333
- 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
3339
+ 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
3334
3340
 
3335
3341
  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
3336
3342
 
@@ -3451,7 +3457,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
3451
3457
  function ShaderFactory() {}
3452
3458
  ShaderFactory.parseCustomMacros = function parseCustomMacros(macros) {
3453
3459
  return macros.map(function(m) {
3454
- return "#define " + m + "\n";
3460
+ return "#define " + (m.value ? m.name + " " + m.value : m.name) + "\n";
3455
3461
  }).join("");
3456
3462
  };
3457
3463
  ShaderFactory.registerInclude = function registerInclude(includeName, includeSource) {
@@ -4236,29 +4242,49 @@ var ShaderFactory = /*#__PURE__*/ function() {
4236
4242
  ShaderProgram._counter = 0;
4237
4243
  })();
4238
4244
 
4245
+ /**
4246
+ * @internal
4247
+ * Shader pass type
4248
+ */ var ShaderType;
4249
+ (function(ShaderType) {
4250
+ ShaderType[ShaderType[/** init by glsl */ "Canonical"] = 0] = "Canonical";
4251
+ ShaderType[ShaderType[/** init by shader-lab */ "ShaderLab"] = 1] = "ShaderLab";
4252
+ })(ShaderType || (ShaderType = {}));
4253
+
4239
4254
  /**
4240
4255
  * Shader pass containing vertex and fragment source.
4241
4256
  */ var ShaderPass = /*#__PURE__*/ function(ShaderPart1) {
4242
4257
  _inherits(ShaderPass, ShaderPart1);
4243
- function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSource, fragmentSourceOrTags, tags) {
4258
+ function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSourceOrCode, fragmentSourceOrTagsOrVertexEntry, fragmentEntryOrTags, tags) {
4244
4259
  var _this;
4245
4260
  _this = ShaderPart1.call(this) || this;
4246
4261
  /** @internal */ _this._shaderPassId = 0;
4247
4262
  /** @internal */ _this._renderStateDataMap = {};
4248
4263
  /** @internal */ _this._shaderProgramPools = [];
4264
+ _this._platformMacros = [];
4249
4265
  _this._shaderPassId = ShaderPass._shaderPassCounter++;
4250
- if (typeof fragmentSourceOrTags === "string") {
4266
+ _this._type = ShaderType.Canonical;
4267
+ if (typeof fragmentEntryOrTags === "string") {
4251
4268
  _this._name = nameOrVertexSource;
4252
- _this._vertexSource = vertexSourceOrFragmentSource;
4253
- _this._fragmentSource = fragmentSourceOrTags;
4254
- tags = tags != null ? tags : {
4269
+ _this._shaderLabSource = vertexSourceOrFragmentSourceOrCode;
4270
+ _this._vertexEntry = fragmentSourceOrTagsOrVertexEntry;
4271
+ _this._fragmentEntry = fragmentEntryOrTags;
4272
+ tags = _extends({
4273
+ pipelineStage: exports.PipelineStage.Forward
4274
+ }, tags);
4275
+ _this._type = ShaderType.ShaderLab;
4276
+ } else if (typeof fragmentSourceOrTagsOrVertexEntry === "string") {
4277
+ _this._name = nameOrVertexSource;
4278
+ _this._vertexSource = vertexSourceOrFragmentSourceOrCode;
4279
+ _this._fragmentSource = fragmentSourceOrTagsOrVertexEntry;
4280
+ tags = fragmentEntryOrTags != null ? fragmentEntryOrTags : {
4255
4281
  pipelineStage: exports.PipelineStage.Forward
4256
4282
  };
4257
4283
  } else {
4258
4284
  _this._name = "Default";
4259
4285
  _this._vertexSource = nameOrVertexSource;
4260
- _this._fragmentSource = vertexSourceOrFragmentSource;
4261
- tags = fragmentSourceOrTags != null ? fragmentSourceOrTags : {
4286
+ _this._fragmentSource = vertexSourceOrFragmentSourceOrCode;
4287
+ tags = fragmentSourceOrTagsOrVertexEntry != null ? fragmentSourceOrTagsOrVertexEntry : {
4262
4288
  pipelineStage: exports.PipelineStage.Forward
4263
4289
  };
4264
4290
  }
@@ -4276,9 +4302,51 @@ var ShaderFactory = /*#__PURE__*/ function() {
4276
4302
  if (shaderProgram) {
4277
4303
  return shaderProgram;
4278
4304
  }
4305
+ if (this._type === ShaderType.Canonical) {
4306
+ shaderProgram = this._getCanonicalShaderProgram(engine, macroCollection);
4307
+ } else {
4308
+ shaderProgram = this._compileShaderProgram(engine, macroCollection, this._vertexEntry, this._fragmentEntry);
4309
+ }
4310
+ shaderProgramPool.cache(shaderProgram);
4311
+ return shaderProgram;
4312
+ };
4313
+ /**
4314
+ * @internal
4315
+ */ _proto._destroy = function _destroy() {
4316
+ var shaderProgramPools = this._shaderProgramPools;
4317
+ for(var i = 0, n = shaderProgramPools.length; i < n; i++){
4318
+ shaderProgramPools[i]._destroy();
4319
+ }
4320
+ shaderProgramPools.length = 0;
4321
+ };
4322
+ /**
4323
+ * Shader Lab compilation
4324
+ */ _proto._compileShaderProgram = function _compileShaderProgram(engine, macroCollection, vertexEntry, fragmentEntry) {
4279
4325
  var isWebGL2 = engine._hardwareRenderer.isWebGL2;
4280
- var macroNameList = [];
4281
- ShaderMacro._getNamesByMacros(macroCollection, macroNameList);
4326
+ var macros = new Array();
4327
+ ShaderMacro._getMacrosElements(macroCollection, macros);
4328
+ this._platformMacros.length = 0;
4329
+ if (engine._hardwareRenderer.canIUse(exports.GLCapabilityType.shaderTextureLod)) {
4330
+ this._platformMacros.push("HAS_TEX_LOD");
4331
+ }
4332
+ if (engine._hardwareRenderer.canIUse(exports.GLCapabilityType.standardDerivatives)) {
4333
+ this._platformMacros.push("HAS_DERIVATIVES");
4334
+ }
4335
+ if (isWebGL2) {
4336
+ this._platformMacros.push("GRAPHICS_API_WEBGL2");
4337
+ } else {
4338
+ this._platformMacros.push("GRAPHICS_API_WEBGL1");
4339
+ }
4340
+ var start = engineMiniprogramAdapter.performance.now();
4341
+ var _Shader__shaderLab__parseShaderPass = Shader._shaderLab._parseShaderPass(this._shaderLabSource, vertexEntry, fragmentEntry, macros, isWebGL2 ? exports.ShaderPlatformTarget.GLES300 : exports.ShaderPlatformTarget.GLES100, this._platformMacros), vertex = _Shader__shaderLab__parseShaderPass.vertex, fragment = _Shader__shaderLab__parseShaderPass.fragment;
4342
+ Logger.info("[ShaderLab compilation] cost time: " + (engineMiniprogramAdapter.performance.now() - start) + "ms");
4343
+ return new ShaderProgram(engine, vertex, fragment);
4344
+ };
4345
+ // TODO: remove it after migrate all shader to `ShaderLab`.
4346
+ _proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
4347
+ var isWebGL2 = engine._hardwareRenderer.isWebGL2;
4348
+ var macroNameList = new Array();
4349
+ ShaderMacro._getMacrosElements(macroCollection, macroNameList);
4282
4350
  var macroNameStr = ShaderFactory.parseCustomMacros(macroNameList);
4283
4351
  var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
4284
4352
  var graphicAPI = isWebGL2 ? "#define GRAPHICS_API_WEBGL2" : "#define GRAPHICS_API_WEBGL1";
@@ -4295,19 +4363,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
4295
4363
  vertexSource = ShaderFactory.convertTo300(vertexSource);
4296
4364
  fragmentSource = ShaderFactory.convertTo300(fragmentSource, true);
4297
4365
  }
4298
- shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
4299
- shaderProgramPool.cache(shaderProgram);
4366
+ var shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
4300
4367
  return shaderProgram;
4301
4368
  };
4302
- /**
4303
- * @internal
4304
- */ _proto._destroy = function _destroy() {
4305
- var shaderProgramPools = this._shaderProgramPools;
4306
- for(var i = 0, n = shaderProgramPools.length; i < n; i++){
4307
- shaderProgramPools[i]._destroy();
4308
- }
4309
- shaderProgramPools.length = 0;
4310
- };
4311
4369
  return ShaderPass;
4312
4370
  }(ShaderPart);
4313
4371
  (function() {
@@ -5011,45 +5069,44 @@ __decorate([
5011
5069
  if (!Shader._shaderLab) {
5012
5070
  throw "ShaderLab has not been set up yet.";
5013
5071
  }
5014
- var shaderInfo = Shader._shaderLab.parseShader(nameOrShaderSource);
5015
- if (shaderMap[shaderInfo.name]) {
5016
- console.error('Shader named "' + shaderInfo.name + '" already exists.');
5072
+ var shaderContent = Shader._shaderLab._parseShaderContent(nameOrShaderSource);
5073
+ if (shaderMap[shaderContent.name]) {
5074
+ console.error('Shader named "' + shaderContent.name + '" already exists.');
5017
5075
  return;
5018
5076
  }
5019
- var subShaderList = shaderInfo.subShaders.map(function(subShaderInfo) {
5020
- var passList = subShaderInfo.passes.map(function(passInfo) {
5021
- if (typeof passInfo === "string") {
5077
+ var subShaderList = shaderContent.subShaders.map(function(subShaderContent) {
5078
+ var passList = subShaderContent.passes.map(function(passInfo) {
5079
+ if (passInfo.isUsePass) {
5022
5080
  var _Shader_find_subShaders_find, _Shader_find;
5023
5081
  // Use pass reference
5024
- var paths = passInfo.split("/");
5082
+ var paths = passInfo.name.split("/");
5025
5083
  return (_Shader_find = Shader.find(paths[0])) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
5026
5084
  return subShader.name === paths[1];
5027
5085
  })) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
5028
5086
  return pass.name === paths[2];
5029
5087
  });
5030
5088
  }
5031
- var shaderPass = new ShaderPass(passInfo.name, passInfo.vertexSource, passInfo.fragmentSource, passInfo.tags);
5089
+ var shaderPassContent = new ShaderPass(passInfo.name, passInfo.contents, passInfo.vertexEntry, passInfo.fragmentEntry, passInfo.tags);
5032
5090
  var renderStates = passInfo.renderStates;
5033
5091
  var renderState = new RenderState();
5034
- shaderPass._renderState = renderState;
5092
+ shaderPassContent._renderState = renderState;
5035
5093
  // Parse const render state
5036
- var constRenderStateInfo = renderStates[0];
5037
- for(var k in constRenderStateInfo){
5038
- Shader._applyConstRenderStates(renderState, parseInt(k), constRenderStateInfo[k]);
5094
+ var constantMap = renderStates.constantMap, variableMap = renderStates.variableMap;
5095
+ for(var k in constantMap){
5096
+ Shader._applyConstRenderStates(renderState, parseInt(k), constantMap[k]);
5039
5097
  }
5040
5098
  // Parse variable render state
5041
- var variableRenderStateInfo = renderStates[1];
5042
5099
  var renderStateDataMap = {};
5043
- for(var k1 in variableRenderStateInfo){
5044
- renderStateDataMap[k1] = ShaderProperty.getByName(variableRenderStateInfo[k1]);
5100
+ for(var k1 in variableMap){
5101
+ renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
5045
5102
  }
5046
- shaderPass._renderStateDataMap = renderStateDataMap;
5047
- return shaderPass;
5103
+ shaderPassContent._renderStateDataMap = renderStateDataMap;
5104
+ return shaderPassContent;
5048
5105
  });
5049
- return new SubShader(shaderInfo.name, passList, subShaderInfo.tags);
5106
+ return new SubShader(subShaderContent.name, passList, subShaderContent.tags);
5050
5107
  });
5051
- shader = new Shader(shaderInfo.name, subShaderList);
5052
- shaderMap[shaderInfo.name] = shader;
5108
+ shader = new Shader(shaderContent.name, subShaderList);
5109
+ shaderMap[shaderContent.name] = shader;
5053
5110
  return shader;
5054
5111
  } else {
5055
5112
  if (shaderMap[nameOrShaderSource]) {
@@ -5262,6 +5319,7 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
5262
5319
  TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
5263
5320
  TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
5264
5321
  TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
5322
+ 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";
5265
5323
  TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
5266
5324
  TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
5267
5325
  TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
@@ -7957,22 +8015,23 @@ var /**
7957
8015
  * @param height - Need texture height
7958
8016
  * @param format - Need texture format
7959
8017
  * @param mipmap - Need texture mipmap
8018
+ * @param textureWrapMode - Texture wrap mode
8019
+ * @param textureFilterMode - Texture filter mode
7960
8020
  * @returns Texture
7961
- */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
8021
+ */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap, textureWrapMode, textureFilterMode) {
7962
8022
  if (currentTexture) {
7963
8023
  if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
7964
8024
  currentTexture.destroy(true);
7965
- var texture = new Texture2D(engine, width, height, format, mipmap);
7966
- texture.isGCIgnored = true;
7967
- return texture;
7968
- } else {
7969
- return currentTexture;
8025
+ currentTexture = new Texture2D(engine, width, height, format, mipmap);
8026
+ currentTexture.isGCIgnored = true;
7970
8027
  }
7971
8028
  } else {
7972
- var texture1 = new Texture2D(engine, width, height, format, mipmap);
7973
- texture1.isGCIgnored = true;
7974
- return texture1;
8029
+ currentTexture = new Texture2D(engine, width, height, format, mipmap);
8030
+ currentTexture.isGCIgnored = true;
7975
8031
  }
8032
+ currentTexture.wrapModeU = currentTexture.wrapModeV = textureWrapMode;
8033
+ currentTexture.filterMode = textureFilterMode;
8034
+ return currentTexture;
7976
8035
  };
7977
8036
  /**
7978
8037
  * Recreate render target if needed.
@@ -7984,15 +8043,17 @@ var /**
7984
8043
  * @param depthFormat - Need render target depth format
7985
8044
  * @param mipmap - Need render target mipmap
7986
8045
  * @param antiAliasing - Need render target anti aliasing
8046
+ * @param textureWrapMode - Texture wrap mode
8047
+ * @param textureFilterMode - Texture filter mode
7987
8048
  * @returns Render target
7988
- */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing) {
8049
+ */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing, textureWrapMode, textureFilterMode) {
7989
8050
  var _currentRenderTarget;
7990
8051
  var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
7991
- var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
8052
+ var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap, textureWrapMode, textureFilterMode) : null;
7992
8053
  if (needDepthTexture) {
7993
8054
  var _currentRenderTarget1;
7994
8055
  var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
7995
- var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
8056
+ var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap, textureWrapMode, textureFilterMode) : null;
7996
8057
  if (currentColorTexture !== colorTexture || currentDepthTexture !== _$needDepthTexture) {
7997
8058
  var _currentRenderTarget2;
7998
8059
  (_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy(true);
@@ -8001,38 +8062,46 @@ var /**
8001
8062
  }
8002
8063
  } else {
8003
8064
  var _currentRenderTarget3;
8004
- var needDepthFormat = depthFormat;
8005
- if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== needDepthFormat) {
8065
+ if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== depthFormat || currentRenderTarget.antiAliasing !== antiAliasing) {
8006
8066
  var _currentRenderTarget4;
8007
8067
  (_currentRenderTarget4 = currentRenderTarget) == null ? void 0 : _currentRenderTarget4.destroy(true);
8008
- currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, needDepthFormat, antiAliasing);
8068
+ currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthFormat, antiAliasing);
8009
8069
  currentRenderTarget.isGCIgnored = true;
8010
8070
  }
8011
8071
  }
8012
8072
  return currentRenderTarget;
8013
8073
  };
8014
8074
  /**
8015
- * Blit texture to destination render target.
8075
+ * Blit texture to destination render target using a triangle.
8016
8076
  * @param engine - Engine
8017
8077
  * @param source - Source texture
8018
8078
  * @param destination - Destination render target
8019
8079
  * @param mipLevel - Mip level to blit
8020
8080
  * @param viewport - Viewport
8021
- */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport) {
8081
+ * @param material - The material to use when blitting
8082
+ * @param passIndex - Pass index to use of the provided material
8083
+ */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex) {
8022
8084
  if (mipLevel === void 0) mipLevel = 0;
8085
+ if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
8086
+ if (material === void 0) material = null;
8087
+ if (passIndex === void 0) passIndex = 0;
8023
8088
  var basicResources = engine._basicResources;
8024
8089
  var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
8025
- var blitMaterial = basicResources.blitMaterial;
8090
+ var blitMaterial = material || basicResources.blitMaterial;
8026
8091
  var rhi = engine._hardwareRenderer;
8027
8092
  var context = engine._renderContext;
8028
8093
  // We not use projection matrix when blit, but we must modify flipProjection to make front face correct
8029
- context.flipProjection = destination ? true : false;
8030
- rhi.activeRenderTarget(destination, viewport != null ? viewport : PipelineUtils.defaultViewport, context.flipProjection, 0);
8094
+ context.flipProjection = !!destination;
8095
+ rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
8031
8096
  var rendererShaderData = PipelineUtils._rendererShaderData;
8032
- var pass = blitMaterial.shader.subShaders[0].passes[0];
8033
- var program = pass._getShaderProgram(engine, Shader._compileMacros);
8034
8097
  rendererShaderData.setTexture(PipelineUtils._blitTextureProperty, source);
8035
8098
  rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
8099
+ PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
8100
+ rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
8101
+ var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
8102
+ var compileMacros = Shader._compileMacros;
8103
+ ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
8104
+ var program = pass._getShaderProgram(engine, compileMacros);
8036
8105
  program.bind();
8037
8106
  program.groupingOtherUniformBlock();
8038
8107
  program.uploadAll(program.rendererUniformBlock, rendererShaderData);
@@ -8049,9 +8118,16 @@ var /**
8049
8118
  (function() {
8050
8119
  PipelineUtils._blitMipLevelProperty = ShaderProperty.getByName("renderer_BlitMipLevel");
8051
8120
  })();
8121
+ (function() {
8122
+ PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
8123
+ ;
8124
+ })();
8052
8125
  (function() {
8053
8126
  PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
8054
8127
  })();
8128
+ (function() {
8129
+ PipelineUtils._texelSize = new miniprogram.Vector4();
8130
+ })();
8055
8131
  (function() {
8056
8132
  PipelineUtils.defaultViewport = new miniprogram.Vector4(0, 0, 1, 1);
8057
8133
  })();
@@ -8120,6 +8196,14 @@ var /**
8120
8196
  MSAASamples[MSAASamples[/** Multi-sample anti-aliasing with 8 samples. */ "EightX"] = 8] = "EightX";
8121
8197
  })(exports.MSAASamples || (exports.MSAASamples = {}));
8122
8198
 
8199
+ /**
8200
+ * The strategy to use when a shader replacement fails.
8201
+ */ exports.ReplacementFailureStrategy = void 0;
8202
+ (function(ReplacementFailureStrategy) {
8203
+ ReplacementFailureStrategy[ReplacementFailureStrategy[/** Keep the original shader. */ "KeepOriginalShader"] = 0] = "KeepOriginalShader";
8204
+ ReplacementFailureStrategy[ReplacementFailureStrategy[/** Do not render. */ "DoNotRender"] = 1] = "DoNotRender";
8205
+ })(exports.ReplacementFailureStrategy || (exports.ReplacementFailureStrategy = {}));
8206
+
8123
8207
  var _Camera;
8124
8208
  var MathTemp = function MathTemp() {
8125
8209
  };
@@ -8169,6 +8253,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8169
8253
  /** @internal */ _this._virtualCamera = new VirtualCamera();
8170
8254
  /** @internal */ _this._replacementShader = null;
8171
8255
  /** @internal */ _this._replacementSubShaderTag = null;
8256
+ /** @internal */ _this._replacementFailureStrategy = null;
8172
8257
  /** @internal */ _this._cameraIndex = -1;
8173
8258
  _this._priority = 0;
8174
8259
  _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
@@ -8182,6 +8267,8 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8182
8267
  _this._renderTarget = null;
8183
8268
  _this._depthBufferParams = new miniprogram.Vector4();
8184
8269
  _this._opaqueTextureEnabled = false;
8270
+ _this._enableHDR = false;
8271
+ _this._enablePostProcess = false;
8185
8272
  _this._viewport = new miniprogram.Vector4(0, 0, 1, 1);
8186
8273
  _this._pixelViewport = new miniprogram.Rect(0, 0, 0, 0);
8187
8274
  _this._inverseProjectionMatrix = new miniprogram.Matrix();
@@ -8346,6 +8433,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8346
8433
  context.virtualCamera = virtualCamera;
8347
8434
  context.replacementShader = this._replacementShader;
8348
8435
  context.replacementTag = this._replacementSubShaderTag;
8436
+ context.replacementFailureStrategy = this._replacementFailureStrategy;
8349
8437
  // compute cull frustum.
8350
8438
  if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
8351
8439
  this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
@@ -8365,15 +8453,18 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8365
8453
  this._renderPipeline.render(context, cubeFace, mipLevel, clearMask);
8366
8454
  this._engine._renderCount++;
8367
8455
  };
8368
- _proto.setReplacementShader = function setReplacementShader(shader, replacementTag) {
8456
+ _proto.setReplacementShader = function setReplacementShader(shader, replacementTag, failureStrategy) {
8457
+ if (failureStrategy === void 0) failureStrategy = exports.ReplacementFailureStrategy.KeepOriginalShader;
8369
8458
  this._replacementShader = shader;
8370
8459
  this._replacementSubShaderTag = typeof replacementTag === "string" ? ShaderTagKey.getByName(replacementTag) : replacementTag;
8460
+ this._replacementFailureStrategy = failureStrategy;
8371
8461
  };
8372
8462
  /**
8373
8463
  * Reset and clear the replacement shader.
8374
8464
  */ _proto.resetReplacementShader = function resetReplacementShader() {
8375
8465
  this._replacementShader = null;
8376
8466
  this._replacementSubShaderTag = null;
8467
+ this._replacementFailureStrategy = null;
8377
8468
  };
8378
8469
  /**
8379
8470
  * @inheritdoc
@@ -8387,6 +8478,11 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8387
8478
  };
8388
8479
  /**
8389
8480
  * @internal
8481
+ */ _proto._getInternalColorTextureFormat = function _getInternalColorTextureFormat() {
8482
+ return this._enableHDR ? this.engine._hardwareRenderer.isWebGL2 ? exports.TextureFormat.R11G11B10_UFloat : exports.TextureFormat.R16G16B16A16 : exports.TextureFormat.R8G8B8A8;
8483
+ };
8484
+ /**
8485
+ * @internal
8390
8486
  * @inheritdoc
8391
8487
  */ _proto._onDestroy = function _onDestroy() {
8392
8488
  var _this__renderPipeline;
@@ -8475,9 +8571,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8475
8571
  }
8476
8572
  return this._inverseProjectionMatrix;
8477
8573
  };
8478
- _proto._forceUseInternalCanvas = function _forceUseInternalCanvas() {
8479
- return this.opaqueTextureEnabled;
8480
- };
8481
8574
  _proto._onPixelViewportChanged = function _onPixelViewportChanged() {
8482
8575
  this._updatePixelViewport();
8483
8576
  var _this__customAspectRatio;
@@ -8485,8 +8578,8 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8485
8578
  this._checkMainCanvasAntialiasWaste();
8486
8579
  };
8487
8580
  _proto._checkMainCanvasAntialiasWaste = function _checkMainCanvasAntialiasWaste() {
8488
- if (this.independentCanvasEnabled && miniprogram.Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
8489
- 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.");
8581
+ if (this._phasedActiveInScene && this.independentCanvasEnabled && miniprogram.Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
8582
+ 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.");
8490
8583
  }
8491
8584
  };
8492
8585
  _create_class(Camera1, [
@@ -8497,7 +8590,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8497
8590
  * If enabled, the opaque texture can be accessed in the shader using `camera_OpaqueTexture`.
8498
8591
  *
8499
8592
  * @defaultValue `false`
8500
- *
8501
8593
  * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8502
8594
  */ function get() {
8503
8595
  return this._opaqueTextureEnabled;
@@ -8516,10 +8608,10 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8516
8608
  *
8517
8609
  * @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
8518
8610
  */ function get() {
8519
- if (this._renderTarget) {
8520
- return false;
8611
+ if (this.enableHDR || this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
8612
+ return true;
8521
8613
  }
8522
- return this._forceUseInternalCanvas();
8614
+ return this.opaqueTextureEnabled && !this._renderTarget;
8523
8615
  }
8524
8616
  },
8525
8617
  {
@@ -8704,13 +8796,38 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8704
8796
  key: "enableHDR",
8705
8797
  get: /**
8706
8798
  * Whether to enable HDR.
8707
- * @todo When render pipeline modification
8799
+ * @defaultValue `false`
8800
+ * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8708
8801
  */ function get() {
8709
- console.log("not implementation");
8710
- return false;
8802
+ return this._enableHDR;
8803
+ },
8804
+ set: function set(value) {
8805
+ if (this.enableHDR !== value) {
8806
+ var rhi = this.engine._hardwareRenderer;
8807
+ var supportHDR = rhi.isWebGL2 || rhi.canIUse(exports.GLCapabilityType.textureHalfFloat);
8808
+ if (value && !supportHDR) {
8809
+ Logger.warn("Can't enable HDR in this device.");
8810
+ return;
8811
+ }
8812
+ this._enableHDR = value;
8813
+ this._checkMainCanvasAntialiasWaste();
8814
+ }
8815
+ }
8816
+ },
8817
+ {
8818
+ key: "enablePostProcess",
8819
+ get: /**
8820
+ * Whether to enable post process.
8821
+ * @defaultValue `false`
8822
+ * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8823
+ */ function get() {
8824
+ return this._enablePostProcess;
8711
8825
  },
8712
8826
  set: function set(value) {
8713
- console.log("not implementation");
8827
+ if (this._enablePostProcess !== value) {
8828
+ this._enablePostProcess = value;
8829
+ this._checkMainCanvasAntialiasWaste();
8830
+ }
8714
8831
  }
8715
8832
  },
8716
8833
  {
@@ -8726,7 +8843,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8726
8843
  value && this._addResourceReferCount(value, 1);
8727
8844
  this._renderTarget = value;
8728
8845
  this._onPixelViewportChanged();
8729
- this._checkMainCanvasAntialiasWaste();
8730
8846
  }
8731
8847
  }
8732
8848
  }
@@ -8811,7 +8927,7 @@ exports.Camera = __decorate([
8811
8927
  /**
8812
8928
  * PipelinePass is a base class for all pipeline passes.
8813
8929
  */ var PipelinePass = function PipelinePass(engine) {
8814
- this._engine = engine;
8930
+ this.engine = engine;
8815
8931
  };
8816
8932
 
8817
8933
  /**
@@ -9687,7 +9803,7 @@ var /**
9687
9803
  this._updateReceiversShaderData(light);
9688
9804
  };
9689
9805
  _proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
9690
- var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
9806
+ var _this = this, engine = _this.engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
9691
9807
  var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue;
9692
9808
  var scene = camera.scene;
9693
9809
  var componentsManager = scene._componentsManager;
@@ -9706,13 +9822,12 @@ var /**
9706
9822
  var renderTarget;
9707
9823
  var shadowTexture;
9708
9824
  if (this._supportDepthTexture) {
9709
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1);
9825
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
9710
9826
  shadowTexture = renderTarget.depthTexture;
9711
9827
  } else {
9712
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1);
9828
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
9713
9829
  shadowTexture = renderTarget.getColorTexture(0);
9714
9830
  }
9715
- shadowTexture.wrapModeU = shadowTexture.wrapModeV = exports.TextureWrapMode.Clamp;
9716
9831
  if (engine._hardwareRenderer._isWebGL2) {
9717
9832
  shadowTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
9718
9833
  }
@@ -9963,22 +10078,17 @@ var /**
9963
10078
  }
9964
10079
  var _proto = DepthOnlyPass.prototype;
9965
10080
  _proto.onConfig = function onConfig(camera) {
9966
- var engine = this._engine;
10081
+ var engine = this.engine;
9967
10082
  var _camera_pixelViewport = camera.pixelViewport, width = _camera_pixelViewport.width, height = _camera_pixelViewport.height;
9968
- var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, exports.TextureFormat.Depth16, true, false, 1);
9969
- var depthTexture = renderTarget.depthTexture;
9970
- depthTexture.wrapModeU = depthTexture.wrapModeV = exports.TextureWrapMode.Clamp;
9971
- depthTexture.filterMode = exports.TextureFilterMode.Point;
10083
+ var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, exports.TextureFormat.Depth16, true, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Point);
9972
10084
  this._renderTarget = renderTarget;
9973
10085
  };
9974
10086
  _proto.onRender = function onRender(context, cullingResults) {
9975
- var engine = this._engine;
10087
+ var engine = this.engine;
9976
10088
  var renderTarget = this._renderTarget;
9977
10089
  var camera = context.camera;
9978
10090
  var rhi = engine._hardwareRenderer;
9979
- rhi.activeRenderTarget(renderTarget, camera.viewport, context.flipProjection, 0);
9980
- rhi.viewport(0, 0, renderTarget.width, renderTarget.height);
9981
- rhi.scissor(0, 0, renderTarget.width, renderTarget.height);
10091
+ rhi.activeRenderTarget(renderTarget, PipelineUtils.defaultViewport, context.flipProjection, 0);
9982
10092
  rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
9983
10093
  engine._renderCount++;
9984
10094
  cullingResults.opaqueQueue.render(context, exports.PipelineStage.DepthOnly);
@@ -10003,14 +10113,11 @@ var /**
10003
10113
  var isNoDownsampling = downsampling === exports.Downsampling.None;
10004
10114
  var viewport = camera.pixelViewport;
10005
10115
  var sizeScale = isNoDownsampling ? 1.0 : downsampling === exports.Downsampling.TwoX ? 0.5 : 0.25;
10006
- var opaqueRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this._engine, this._renderTarget, viewport.width * sizeScale, viewport.height * sizeScale, exports.TextureFormat.R8G8B8A8, null, false, false, 1);
10007
- var colorTexture = opaqueRenderTarget.getColorTexture(0);
10008
- colorTexture.wrapModeU = colorTexture.wrapModeV = exports.TextureWrapMode.Clamp;
10009
- colorTexture.filterMode = isNoDownsampling ? exports.TextureFilterMode.Point : exports.TextureFilterMode.Bilinear;
10116
+ var opaqueRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this.engine, this._renderTarget, viewport.width * sizeScale, viewport.height * sizeScale, camera._getInternalColorTextureFormat(), null, false, false, 1, exports.TextureWrapMode.Clamp, isNoDownsampling ? exports.TextureFilterMode.Point : exports.TextureFilterMode.Bilinear);
10010
10117
  this._renderTarget = opaqueRenderTarget;
10011
10118
  };
10012
- _proto.onRender = function onRender(context, _) {
10013
- PipelineUtils.blitTexture(this._engine, this._cameraColorTexture, this._renderTarget);
10119
+ _proto.onRender = function onRender(context) {
10120
+ PipelineUtils.blitTexture(this.engine, this._cameraColorTexture, this._renderTarget);
10014
10121
  context.camera.shaderData.setTexture(exports.Camera._cameraOpaqueTextureProperty, this._renderTarget.getColorTexture(0));
10015
10122
  };
10016
10123
  return OpaqueTexturePass;
@@ -10073,9 +10180,7 @@ var /**
10073
10180
  var independentCanvasEnabled = camera.independentCanvasEnabled;
10074
10181
  if (independentCanvasEnabled) {
10075
10182
  var viewport = camera.pixelViewport;
10076
- var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, exports.TextureFormat.R8G8B8A8, exports.TextureFormat.Depth24Stencil8, false, false, camera.msaaSamples);
10077
- var colorTexture = internalColorTarget.getColorTexture(0);
10078
- colorTexture.wrapModeU = colorTexture.wrapModeV = exports.TextureWrapMode.Clamp;
10183
+ var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), exports.TextureFormat.Depth24Stencil8, false, false, camera.msaaSamples, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
10079
10184
  this._internalColorTarget = internalColorTarget;
10080
10185
  } else {
10081
10186
  var internalColorTarget1 = this._internalColorTarget;
@@ -10089,17 +10194,16 @@ var /**
10089
10194
  this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
10090
10195
  };
10091
10196
  _proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
10092
- var _colorTarget, _colorTarget1;
10197
+ var _cameraRenderTarget, _cameraRenderTarget1;
10093
10198
  var cullingResults = this._cullingResults;
10094
10199
  var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
10095
10200
  var engine = camera.engine, scene = camera.scene;
10096
10201
  var background = scene.background;
10097
- var internalColorTarget = this._internalColorTarget;
10098
10202
  var rhi = engine._hardwareRenderer;
10099
- var _camera_renderTarget;
10100
- var colorTarget = (_camera_renderTarget = camera.renderTarget) != null ? _camera_renderTarget : internalColorTarget;
10203
+ var internalColorTarget = this._internalColorTarget;
10204
+ var colorTarget = internalColorTarget || camera.renderTarget;
10101
10205
  var colorViewport = internalColorTarget ? PipelineUtils.defaultViewport : camera.viewport;
10102
- var needFlipProjection = camera.renderTarget && cubeFace == undefined || internalColorTarget !== null;
10206
+ var needFlipProjection = !!internalColorTarget || camera.renderTarget && cubeFace == undefined;
10103
10207
  if (context.flipProjection !== needFlipProjection) {
10104
10208
  // Just add projection matrix update type is enough
10105
10209
  context.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
@@ -10126,18 +10230,23 @@ var /**
10126
10230
  colorTarget._blitRenderTarget();
10127
10231
  var opaqueTexturePass = this._opaqueTexturePass;
10128
10232
  opaqueTexturePass.onConfig(camera, colorTarget.getColorTexture(0));
10129
- opaqueTexturePass.onRender(context, cullingResults);
10233
+ opaqueTexturePass.onRender(context);
10130
10234
  // Should revert to original render target
10131
10235
  rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10132
10236
  } else {
10133
10237
  camera.shaderData.setTexture(exports.Camera._cameraOpaqueTextureProperty, null);
10134
10238
  }
10135
10239
  transparentQueue.render(context, exports.PipelineStage.Forward);
10136
- (_colorTarget = colorTarget) == null ? void 0 : _colorTarget._blitRenderTarget();
10137
- (_colorTarget1 = colorTarget) == null ? void 0 : _colorTarget1.generateMipmaps();
10138
- if (internalColorTarget) {
10139
- PipelineUtils.blitTexture(engine, internalColorTarget.getColorTexture(0), null, 0, camera.viewport);
10240
+ var postProcessManager = scene._postProcessManager;
10241
+ var cameraRenderTarget = camera.renderTarget;
10242
+ if (camera.enablePostProcess && postProcessManager.hasActiveEffect) {
10243
+ postProcessManager._render(context, internalColorTarget, cameraRenderTarget);
10244
+ } else if (internalColorTarget) {
10245
+ internalColorTarget._blitRenderTarget();
10246
+ PipelineUtils.blitTexture(engine, internalColorTarget.getColorTexture(0), cameraRenderTarget, 0, camera.viewport);
10140
10247
  }
10248
+ (_cameraRenderTarget = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget._blitRenderTarget();
10249
+ (_cameraRenderTarget1 = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget1.generateMipmaps();
10141
10250
  };
10142
10251
  /**
10143
10252
  * Push render data to render queue.
@@ -10163,6 +10272,7 @@ var /**
10163
10272
  break;
10164
10273
  }
10165
10274
  }
10275
+ context.replacementFailureStrategy === exports.ReplacementFailureStrategy.KeepOriginalShader && this.pushRenderElementByType(renderElement, subRenderElement, materialSubShader.passes, renderStates);
10166
10276
  } else {
10167
10277
  this.pushRenderElementByType(renderElement, subRenderElement, replacementSubShaders[0].passes, renderStates);
10168
10278
  }
@@ -18338,37 +18448,29 @@ __decorate([
18338
18448
  -1,
18339
18449
  0,
18340
18450
  1,
18341
- 1,
18451
+ 3,
18342
18452
  -1,
18343
- 1,
18453
+ 2,
18344
18454
  1,
18345
18455
  -1,
18346
- 1,
18347
- 0,
18456
+ 3,
18348
18457
  0,
18349
- 1,
18350
- 1,
18351
- 1,
18352
- 0
18353
- ]); // right-top
18458
+ -1
18459
+ ]); // left-top
18354
18460
  // prettier-ignore
18355
18461
  var flipYVertices = new Float32Array([
18356
- 1,
18462
+ 3,
18357
18463
  -1,
18358
- 1,
18464
+ 2,
18359
18465
  0,
18360
18466
  -1,
18361
18467
  -1,
18362
18468
  0,
18363
18469
  0,
18364
- 1,
18365
- 1,
18366
- 1,
18367
- 1,
18368
18470
  -1,
18369
- 1,
18471
+ 3,
18370
18472
  0,
18371
- 1
18473
+ 2
18372
18474
  ]); // left-top
18373
18475
  var blitMaterial = new Material(engine, Shader.find("blit"));
18374
18476
  blitMaterial._addReferCount(1);
@@ -18406,7 +18508,7 @@ __decorate([
18406
18508
  new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
18407
18509
  ]);
18408
18510
  mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
18409
- mesh.addSubMesh(0, 4, exports.MeshTopology.TriangleStrip);
18511
+ mesh.addSubMesh(0, 3, exports.MeshTopology.Triangles);
18410
18512
  return mesh;
18411
18513
  };
18412
18514
  _proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel) {
@@ -23315,7 +23417,7 @@ ShaderPool.init();
23315
23417
  */ _proto._initialize = function _initialize(configuration) {
23316
23418
  var _this = this;
23317
23419
  var shaderLab = configuration.shaderLab, physics = configuration.physics;
23318
- if (shaderLab) {
23420
+ if (shaderLab && !Shader._shaderLab) {
23319
23421
  Shader._shaderLab = shaderLab;
23320
23422
  }
23321
23423
  var initializePromises = new Array();
@@ -24861,6 +24963,475 @@ __decorate([
24861
24963
  * */ LightManager._maxLight = 10;
24862
24964
  })();
24863
24965
 
24966
+ 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
24967
+
24968
+ 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
24969
+
24970
+ 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
24971
+
24972
+ 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
24973
+
24974
+ exports.BloomDownScaleMode = void 0;
24975
+ (function(BloomDownScaleMode) {
24976
+ BloomDownScaleMode[BloomDownScaleMode[/**
24977
+ * Use this to select half size as the starting resolution.
24978
+ */ "Half"] = 0] = "Half";
24979
+ BloomDownScaleMode[BloomDownScaleMode[/**
24980
+ * Use this to select quarter size as the starting resolution.
24981
+ */ "Quarter"] = 1] = "Quarter";
24982
+ })(exports.BloomDownScaleMode || (exports.BloomDownScaleMode = {}));
24983
+ var BloomEffect = /*#__PURE__*/ function() {
24984
+ function BloomEffect(_uberMaterial) {
24985
+ this._uberMaterial = _uberMaterial;
24986
+ this._highQualityFiltering = false;
24987
+ this._mipDownRT = [];
24988
+ this._mipUpRT = [];
24989
+ this._maxIterations = 6;
24990
+ this._enabled = false;
24991
+ this./**
24992
+ * Controls the starting resolution that this effect begins processing.
24993
+ */ downScale = 0;
24994
+ var engine = _uberMaterial.engine;
24995
+ var material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
24996
+ var depthState = material.renderState.depthState;
24997
+ depthState.enabled = false;
24998
+ depthState.writeEnabled = false;
24999
+ var bloomShaderData = material.shaderData;
25000
+ var uberShaderData = _uberMaterial.shaderData;
25001
+ bloomShaderData.setVector4(BloomEffect._bloomParams, new miniprogram.Vector4());
25002
+ bloomShaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new miniprogram.Vector4());
25003
+ uberShaderData.setVector4(BloomEffect._bloomIntensityParams, new miniprogram.Vector4(1, 1, 0, 0));
25004
+ uberShaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new miniprogram.Vector4());
25005
+ uberShaderData.setColor(BloomEffect._tintProp, new miniprogram.Color(1, 1, 1, 1));
25006
+ this._bloomMaterial = material;
25007
+ this.threshold = 0.9;
25008
+ this.scatter = 0.7;
25009
+ this.intensity = 1;
25010
+ this.dirtIntensity = 1;
25011
+ }
25012
+ var _proto = BloomEffect.prototype;
25013
+ _proto.onRender = function onRender(context, srcTexture) {
25014
+ var camera = context.camera;
25015
+ var downRes = this.downScale === 0 ? 1 : 2;
25016
+ var pixelViewport = camera.pixelViewport;
25017
+ var tw = pixelViewport.width >> downRes;
25018
+ var th = pixelViewport.height >> downRes;
25019
+ // Determine the iteration count
25020
+ var mipCount = this._calculateMipCount(tw, th);
25021
+ // Prefilter
25022
+ this._prefilter(camera, srcTexture, tw, th, mipCount);
25023
+ // Down sample - gaussian pyramid
25024
+ this._downsample(mipCount);
25025
+ // Up sample (bilinear by default, HQ filtering does bicubic instead
25026
+ this._upsample(mipCount);
25027
+ // Setup bloom on uber
25028
+ this._setupUber(camera);
25029
+ };
25030
+ _proto._calculateMipCount = function _calculateMipCount(tw, th) {
25031
+ var maxSize = Math.max(tw, th);
25032
+ var iterations = Math.floor(Math.log2(maxSize) - 1);
25033
+ return Math.min(Math.max(iterations, 1), this._maxIterations);
25034
+ };
25035
+ _proto._prefilter = function _prefilter(camera, srcTexture, tw, th, mipCount) {
25036
+ var engine = this._uberMaterial.engine;
25037
+ var internalColorTextureFormat = camera._getInternalColorTextureFormat();
25038
+ var mipWidth = tw, mipHeight = th;
25039
+ for(var i = 0; i < mipCount; i++){
25040
+ this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipUpRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
25041
+ this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipDownRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
25042
+ mipWidth = Math.max(1, Math.floor(mipWidth / 2));
25043
+ mipHeight = Math.max(1, Math.floor(mipHeight / 2));
25044
+ }
25045
+ PipelineUtils.blitTexture(engine, srcTexture, this._mipDownRT[0], undefined, undefined, this._bloomMaterial, 0);
25046
+ };
25047
+ _proto._downsample = function _downsample(mipCount) {
25048
+ var material = this._bloomMaterial;
25049
+ var engine = material.engine;
25050
+ var lastDown = this._mipDownRT[0];
25051
+ // Down sample - gaussian pyramid
25052
+ for(var i = 1; i < mipCount; i++){
25053
+ // Classic two pass gaussian blur - use mipUp as a temporary target
25054
+ // First pass does 2x downsampling + 9-tap gaussian
25055
+ // Second pass does 9-tap gaussian using a 5-tap filter + bilinear filtering
25056
+ PipelineUtils.blitTexture(engine, lastDown.getColorTexture(0), this._mipUpRT[i], undefined, undefined, material, 1);
25057
+ PipelineUtils.blitTexture(engine, this._mipUpRT[i].getColorTexture(0), this._mipDownRT[i], undefined, undefined, material, 2);
25058
+ lastDown = this._mipDownRT[i];
25059
+ }
25060
+ };
25061
+ _proto._upsample = function _upsample(mipCount) {
25062
+ var material = this._bloomMaterial;
25063
+ var engine = material.engine;
25064
+ var shaderData = material.shaderData;
25065
+ // Up sample (bilinear by default, HQ filtering does bicubic instead
25066
+ for(var i = mipCount - 2; i >= 0; i--){
25067
+ var lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
25068
+ var highMip = this._mipDownRT[i];
25069
+ var dst = this._mipUpRT[i];
25070
+ shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
25071
+ if (this.highQualityFiltering) {
25072
+ var texelSizeLow = shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
25073
+ texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
25074
+ }
25075
+ PipelineUtils.blitTexture(engine, highMip.getColorTexture(0), dst, undefined, undefined, material, 3);
25076
+ }
25077
+ };
25078
+ _proto._setupUber = function _setupUber(camera) {
25079
+ var shaderData = this._uberMaterial.shaderData;
25080
+ var dirtTexture = this.dirtTexture;
25081
+ if (dirtTexture) {
25082
+ var dirtTilingOffset = shaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
25083
+ var dirtRatio = dirtTexture.width / dirtTexture.height;
25084
+ var screenRatio = camera.aspectRatio;
25085
+ if (dirtRatio > screenRatio) {
25086
+ dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
25087
+ } else if (dirtRatio < screenRatio) {
25088
+ dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
25089
+ } else {
25090
+ dirtTilingOffset.set(1, 1, 0, 0);
25091
+ }
25092
+ }
25093
+ shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
25094
+ };
25095
+ _proto._releaseRenderTargets = function _releaseRenderTargets() {
25096
+ var length = this._mipDownRT.length;
25097
+ for(var i = 0; i < length; i++){
25098
+ var downRT = this._mipDownRT[i];
25099
+ var upRT = this._mipUpRT[i];
25100
+ if (downRT) {
25101
+ downRT.getColorTexture(0).destroy(true);
25102
+ downRT.destroy(true);
25103
+ }
25104
+ if (upRT) {
25105
+ upRT.getColorTexture(0).destroy(true);
25106
+ upRT.destroy(true);
25107
+ }
25108
+ }
25109
+ this._mipDownRT.length = 0;
25110
+ this._mipUpRT.length = 0;
25111
+ };
25112
+ _create_class(BloomEffect, [
25113
+ {
25114
+ key: "enabled",
25115
+ get: /**
25116
+ * Indicates whether the post process effect is enabled.
25117
+ */ function get() {
25118
+ return this._enabled;
25119
+ },
25120
+ set: function set(value) {
25121
+ if (value !== this._enabled) {
25122
+ this._enabled = value;
25123
+ if (value) {
25124
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._enableMacro);
25125
+ } else {
25126
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._enableMacro);
25127
+ this._releaseRenderTargets();
25128
+ }
25129
+ }
25130
+ }
25131
+ },
25132
+ {
25133
+ key: "threshold",
25134
+ get: /**
25135
+ * Set the level of brightness to filter out pixels under this level.
25136
+ * @remarks This value is expressed in gamma-space.
25137
+ */ function get() {
25138
+ return this._threshold;
25139
+ },
25140
+ set: function set(value) {
25141
+ value = Math.max(0, value);
25142
+ if (value !== this._threshold) {
25143
+ this._threshold = value;
25144
+ var threshold = miniprogram.Color.gammaToLinearSpace(value);
25145
+ var thresholdKnee = threshold * 0.5; // Hardcoded soft knee
25146
+ var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
25147
+ params.x = threshold;
25148
+ params.y = thresholdKnee;
25149
+ }
25150
+ }
25151
+ },
25152
+ {
25153
+ key: "scatter",
25154
+ get: /**
25155
+ * Controls the radius of the bloom effect.
25156
+ */ function get() {
25157
+ return this._scatter;
25158
+ },
25159
+ set: function set(value) {
25160
+ value = Math.min(Math.max(0, value), 1);
25161
+ if (value !== this._scatter) {
25162
+ this._scatter = value;
25163
+ var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
25164
+ var scatter = miniprogram.MathUtil.lerp(0.05, 0.95, value);
25165
+ params.z = scatter;
25166
+ }
25167
+ }
25168
+ },
25169
+ {
25170
+ key: "intensity",
25171
+ get: /**
25172
+ * Controls the strength of the bloom effect.
25173
+ */ function get() {
25174
+ return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x;
25175
+ },
25176
+ set: function set(value) {
25177
+ value = Math.max(0, value);
25178
+ this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x = value;
25179
+ }
25180
+ },
25181
+ {
25182
+ key: "tint",
25183
+ get: /**
25184
+ * Specifies the tint of the bloom effect.
25185
+ */ function get() {
25186
+ return this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
25187
+ },
25188
+ set: function set(value) {
25189
+ var tint = this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
25190
+ if (value !== tint) {
25191
+ tint.copyFrom(value);
25192
+ }
25193
+ }
25194
+ },
25195
+ {
25196
+ key: "highQualityFiltering",
25197
+ get: /**
25198
+ * Controls whether to use bicubic sampling instead of bilinear sampling for the upSampling passes.
25199
+ * @remarks This is slightly more expensive but helps getting smoother visuals.
25200
+ */ function get() {
25201
+ return this._highQualityFiltering;
25202
+ },
25203
+ set: function set(value) {
25204
+ if (value !== this._highQualityFiltering) {
25205
+ this._highQualityFiltering = value;
25206
+ if (value) {
25207
+ this._bloomMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
25208
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
25209
+ } else {
25210
+ this._bloomMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
25211
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
25212
+ }
25213
+ }
25214
+ }
25215
+ },
25216
+ {
25217
+ key: "dirtTexture",
25218
+ get: /**
25219
+ * Specifies a Texture to add smudges or dust to the bloom effect.
25220
+ */ function get() {
25221
+ return this._uberMaterial.shaderData.getTexture(BloomEffect._dirtTextureProp);
25222
+ },
25223
+ set: function set(value) {
25224
+ this._uberMaterial.shaderData.setTexture(BloomEffect._dirtTextureProp, value);
25225
+ if (value) {
25226
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._dirtMacro);
25227
+ } else {
25228
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._dirtMacro);
25229
+ }
25230
+ }
25231
+ },
25232
+ {
25233
+ key: "dirtIntensity",
25234
+ get: /**
25235
+ * Controls the strength of the lens dirt.
25236
+ */ function get() {
25237
+ return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y;
25238
+ },
25239
+ set: function set(value) {
25240
+ value = Math.max(0, value);
25241
+ this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y = value;
25242
+ }
25243
+ }
25244
+ ]);
25245
+ return BloomEffect;
25246
+ }();
25247
+ (function() {
25248
+ BloomEffect.SHADER_NAME = "PostProcessEffect Bloom";
25249
+ })();
25250
+ (function() {
25251
+ // Bloom shader properties
25252
+ BloomEffect._hqMacro = ShaderMacro.getByName("BLOOM_HQ");
25253
+ })();
25254
+ (function() {
25255
+ BloomEffect._dirtMacro = ShaderMacro.getByName("BLOOM_DIRT");
25256
+ })();
25257
+ (function() {
25258
+ BloomEffect._bloomParams = ShaderProperty.getByName("material_BloomParams") // x: threshold (linear), y: threshold knee, z: scatter
25259
+ ;
25260
+ })();
25261
+ (function() {
25262
+ BloomEffect._lowMipTextureProp = ShaderProperty.getByName("material_lowMipTexture");
25263
+ })();
25264
+ (function() {
25265
+ BloomEffect._lowMipTexelSizeProp = ShaderProperty.getByName("material_lowMipTexelSize") // x: 1/width, y: 1/height, z: width, w: height
25266
+ ;
25267
+ })();
25268
+ (function() {
25269
+ // Uber shader properties
25270
+ BloomEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_BLOOM");
25271
+ })();
25272
+ (function() {
25273
+ BloomEffect._bloomTextureProp = ShaderProperty.getByName("material_BloomTexture");
25274
+ })();
25275
+ (function() {
25276
+ BloomEffect._dirtTextureProp = ShaderProperty.getByName("material_BloomDirtTexture");
25277
+ })();
25278
+ (function() {
25279
+ BloomEffect._tintProp = ShaderProperty.getByName("material_BloomTint");
25280
+ })();
25281
+ (function() {
25282
+ BloomEffect._bloomIntensityParams = ShaderProperty.getByName("material_BloomIntensityParams") // x: bloom intensity, y: dirt intensity
25283
+ ;
25284
+ })();
25285
+ (function() {
25286
+ BloomEffect._dirtTilingOffsetProp = ShaderProperty.getByName("material_BloomDirtTilingOffset");
25287
+ })();
25288
+ Shader.create(BloomEffect.SHADER_NAME, [
25289
+ new ShaderPass("Bloom Prefilter", blitVs, fragPrefilter),
25290
+ new ShaderPass("Bloom Blur Horizontal", blitVs, fragBlurH),
25291
+ new ShaderPass("Bloom Blur Vertical", blitVs, fragBlurV),
25292
+ new ShaderPass("Bloom Upsample", blitVs, fragUpsample)
25293
+ ]);
25294
+
25295
+ exports.TonemappingMode = void 0;
25296
+ (function(TonemappingMode) {
25297
+ TonemappingMode[TonemappingMode[/**
25298
+ * Neutral tonemapper
25299
+ * @remarks Use this option if you only want range-remapping with minimal impact on color hue and saturation.
25300
+ */ "Neutral"] = 0] = "Neutral";
25301
+ TonemappingMode[TonemappingMode[/**
25302
+ * ACES Filmic reference tonemapper (custom approximation)
25303
+ * @remarks
25304
+ * Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
25305
+ * It is more contrasted than Neutral and has an effect on actual color hue and saturation.
25306
+ */ "ACES"] = 1] = "ACES";
25307
+ })(exports.TonemappingMode || (exports.TonemappingMode = {}));
25308
+ var TonemappingEffect = /*#__PURE__*/ function() {
25309
+ function TonemappingEffect(_uberMaterial) {
25310
+ this._uberMaterial = _uberMaterial;
25311
+ this._enabled = false;
25312
+ this.mode = 0;
25313
+ }
25314
+ _create_class(TonemappingEffect, [
25315
+ {
25316
+ key: "enabled",
25317
+ get: /**
25318
+ * Indicates whether the post process effect is enabled.
25319
+ */ function get() {
25320
+ return this._enabled;
25321
+ },
25322
+ set: function set(value) {
25323
+ if (value !== this._enabled) {
25324
+ this._enabled = value;
25325
+ if (value) {
25326
+ this._uberMaterial.shaderData.enableMacro(TonemappingEffect._enableMacro);
25327
+ } else {
25328
+ this._uberMaterial.shaderData.disableMacro(TonemappingEffect._enableMacro);
25329
+ }
25330
+ }
25331
+ }
25332
+ },
25333
+ {
25334
+ key: "mode",
25335
+ get: /**
25336
+ * Use this to select a tonemapping algorithm to use.
25337
+ */ function get() {
25338
+ return this._mode;
25339
+ },
25340
+ set: function set(value) {
25341
+ if (value !== this._mode) {
25342
+ this._mode = value;
25343
+ this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE", value.toString());
25344
+ }
25345
+ }
25346
+ }
25347
+ ]);
25348
+ return TonemappingEffect;
25349
+ }();
25350
+ (function() {
25351
+ TonemappingEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_TONEMAPPING");
25352
+ })();
25353
+
25354
+ /**
25355
+ * @internal
25356
+ */ var _PostProcessManager = /*#__PURE__*/ function() {
25357
+ function _PostProcessManager(scene) {
25358
+ this.scene = scene;
25359
+ this./**
25360
+ * Whether the post process manager is active.
25361
+ */ isActive = true;
25362
+ var uberShader = Shader.find(_PostProcessManager.UBER_SHADER_NAME);
25363
+ var uberMaterial = new Material(scene.engine, uberShader);
25364
+ var depthState = uberMaterial.renderState.depthState;
25365
+ depthState.enabled = false;
25366
+ depthState.writeEnabled = false;
25367
+ var bloomEffect = new BloomEffect(uberMaterial);
25368
+ var tonemappingEffect = new TonemappingEffect(uberMaterial);
25369
+ this._uberMaterial = uberMaterial;
25370
+ this._bloomEffect = bloomEffect;
25371
+ this._tonemappingEffect = tonemappingEffect;
25372
+ }
25373
+ var _proto = _PostProcessManager.prototype;
25374
+ /**
25375
+ * @internal
25376
+ */ _proto._render = function _render(context, srcTarget, destTarget) {
25377
+ var camera = context.camera;
25378
+ var engine = camera.engine;
25379
+ // Should blit to resolve the MSAA
25380
+ srcTarget._blitRenderTarget();
25381
+ var srcTexture = srcTarget.getColorTexture();
25382
+ var bloomEffect = this._bloomEffect;
25383
+ if (bloomEffect.enabled) {
25384
+ bloomEffect.onRender(context, srcTexture);
25385
+ }
25386
+ // Done with Uber, blit it
25387
+ PipelineUtils.blitTexture(engine, srcTexture, destTarget, 0, camera.viewport, this._uberMaterial);
25388
+ };
25389
+ _create_class(_PostProcessManager, [
25390
+ {
25391
+ key: "hasActiveEffect",
25392
+ get: /**
25393
+ * Whether has active post process effect.
25394
+ */ function get() {
25395
+ return this.isActive && (this._bloomEffect.enabled || this._tonemappingEffect.enabled);
25396
+ }
25397
+ }
25398
+ ]);
25399
+ return _PostProcessManager;
25400
+ }();
25401
+ (function() {
25402
+ _PostProcessManager.UBER_SHADER_NAME = "UberPost";
25403
+ })();
25404
+
25405
+ 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
25406
+
25407
+ 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
25408
+
25409
+ 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
25410
+
25411
+ 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
25412
+
25413
+ 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
25414
+
25415
+ 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
25416
+
25417
+ 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
25418
+
25419
+ 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
25420
+
25421
+ 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
25422
+
25423
+ Object.assign(ShaderLib, {
25424
+ PostCommon: PostCommon,
25425
+ Filtering: Filtering,
25426
+ ODT: ODT,
25427
+ RRT: RRT,
25428
+ Tonescale: Tonescale,
25429
+ ColorTransform: ColorTransform,
25430
+ NeutralTonemapping: NeutralTonemapping,
25431
+ ACESTonemapping: ACESTonemapping
25432
+ });
25433
+ Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
25434
+
24864
25435
  /**
24865
25436
  * Scene.
24866
25437
  */ var Scene = /*#__PURE__*/ function(EngineObject1) {
@@ -24884,6 +25455,7 @@ __decorate([
24884
25455
  /** @internal */ _this._isActiveInEngine = false;
24885
25456
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
24886
25457
  /** @internal */ _this._rootEntities = [];
25458
+ /** @internal */ _this._postProcessManager = new _PostProcessManager(_assert_this_initialized(_this));
24887
25459
  _this._background = new Background(_this._engine);
24888
25460
  _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
24889
25461
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
@@ -27813,7 +28385,8 @@ exports.AnimatorLayerBlendingMode = void 0;
27813
28385
  eventHandler.event = event;
27814
28386
  handlers.length = 0;
27815
28387
  for(var j = scriptCount - 1; j >= 0; j--){
27816
- var handler = scripts[j][funcName];
28388
+ var script = scripts[j];
28389
+ var handler = script[funcName].bind(script);
27817
28390
  handler && handlers.push(handler);
27818
28391
  }
27819
28392
  eventHandlers.push(eventHandler);
@@ -33631,6 +34204,7 @@ exports.BlendShape = BlendShape;
33631
34204
  exports.BlendShapeFrame = BlendShapeFrame;
33632
34205
  exports.BlendState = BlendState;
33633
34206
  exports.BlinnPhongMaterial = BlinnPhongMaterial;
34207
+ exports.BloomEffect = BloomEffect;
33634
34208
  exports.BoolUpdateFlag = BoolUpdateFlag;
33635
34209
  exports.BoxColliderShape = BoxColliderShape;
33636
34210
  exports.BoxShape = BoxShape;
@@ -33747,6 +34321,7 @@ exports.Texture2DArray = Texture2DArray;
33747
34321
  exports.TextureCube = TextureCube;
33748
34322
  exports.TextureSheetAnimationModule = TextureSheetAnimationModule;
33749
34323
  exports.Time = Time;
34324
+ exports.TonemappingEffect = TonemappingEffect;
33750
34325
  exports.TrailMaterial = TrailMaterial;
33751
34326
  exports.TrailRenderer = TrailRenderer;
33752
34327
  exports.Transform = Transform;
@@ -33756,6 +34331,7 @@ exports.VelocityOverLifetimeModule = VelocityOverLifetimeModule;
33756
34331
  exports.VertexBufferBinding = VertexBufferBinding;
33757
34332
  exports.VertexElement = VertexElement;
33758
34333
  exports.XRManager = XRManager;
34334
+ exports._PostProcessManager = _PostProcessManager;
33759
34335
  exports.assignmentClone = assignmentClone;
33760
34336
  exports.deepClone = deepClone;
33761
34337
  exports.dependentComponents = dependentComponents;