@galacean/engine-core 1.3.0-alpha.0 → 1.3.0-alpha.2

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