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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -3323,7 +3323,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
3323
3323
 
3324
3324
  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
3325
 
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
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 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
3327
 
3328
3328
  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
3329
 
@@ -5261,6 +5261,7 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
5261
5261
  TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
5262
5262
  TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
5263
5263
  TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
5264
+ 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
5265
  TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
5265
5266
  TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
5266
5267
  TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
@@ -7956,22 +7957,23 @@ var /**
7956
7957
  * @param height - Need texture height
7957
7958
  * @param format - Need texture format
7958
7959
  * @param mipmap - Need texture mipmap
7960
+ * @param textureWrapMode - Texture wrap mode
7961
+ * @param textureFilterMode - Texture filter mode
7959
7962
  * @returns Texture
7960
- */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
7963
+ */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap, textureWrapMode, textureFilterMode) {
7961
7964
  if (currentTexture) {
7962
7965
  if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
7963
7966
  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;
7967
+ currentTexture = new Texture2D(engine, width, height, format, mipmap);
7968
+ currentTexture.isGCIgnored = true;
7969
7969
  }
7970
7970
  } else {
7971
- var texture1 = new Texture2D(engine, width, height, format, mipmap);
7972
- texture1.isGCIgnored = true;
7973
- return texture1;
7971
+ currentTexture = new Texture2D(engine, width, height, format, mipmap);
7972
+ currentTexture.isGCIgnored = true;
7974
7973
  }
7974
+ currentTexture.wrapModeU = currentTexture.wrapModeV = textureWrapMode;
7975
+ currentTexture.filterMode = textureFilterMode;
7976
+ return currentTexture;
7975
7977
  };
7976
7978
  /**
7977
7979
  * Recreate render target if needed.
@@ -7983,15 +7985,17 @@ var /**
7983
7985
  * @param depthFormat - Need render target depth format
7984
7986
  * @param mipmap - Need render target mipmap
7985
7987
  * @param antiAliasing - Need render target anti aliasing
7988
+ * @param textureWrapMode - Texture wrap mode
7989
+ * @param textureFilterMode - Texture filter mode
7986
7990
  * @returns Render target
7987
- */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing) {
7991
+ */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing, textureWrapMode, textureFilterMode) {
7988
7992
  var _currentRenderTarget;
7989
7993
  var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
7990
- var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
7994
+ var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap, textureWrapMode, textureFilterMode) : null;
7991
7995
  if (needDepthTexture) {
7992
7996
  var _currentRenderTarget1;
7993
7997
  var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
7994
- var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
7998
+ var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap, textureWrapMode, textureFilterMode) : null;
7995
7999
  if (currentColorTexture !== colorTexture || currentDepthTexture !== _$needDepthTexture) {
7996
8000
  var _currentRenderTarget2;
7997
8001
  (_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy(true);
@@ -8000,38 +8004,46 @@ var /**
8000
8004
  }
8001
8005
  } else {
8002
8006
  var _currentRenderTarget3;
8003
- var needDepthFormat = depthFormat;
8004
- if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== needDepthFormat) {
8007
+ if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== depthFormat || currentRenderTarget.antiAliasing !== antiAliasing) {
8005
8008
  var _currentRenderTarget4;
8006
8009
  (_currentRenderTarget4 = currentRenderTarget) == null ? void 0 : _currentRenderTarget4.destroy(true);
8007
- currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, needDepthFormat, antiAliasing);
8010
+ currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthFormat, antiAliasing);
8008
8011
  currentRenderTarget.isGCIgnored = true;
8009
8012
  }
8010
8013
  }
8011
8014
  return currentRenderTarget;
8012
8015
  };
8013
8016
  /**
8014
- * Blit texture to destination render target.
8017
+ * Blit texture to destination render target using a triangle.
8015
8018
  * @param engine - Engine
8016
8019
  * @param source - Source texture
8017
8020
  * @param destination - Destination render target
8018
8021
  * @param mipLevel - Mip level to blit
8019
8022
  * @param viewport - Viewport
8020
- */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport) {
8023
+ * @param material - The material to use when blitting
8024
+ * @param passIndex - Pass index to use of the provided material
8025
+ */ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex) {
8021
8026
  if (mipLevel === void 0) mipLevel = 0;
8027
+ if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
8028
+ if (material === void 0) material = null;
8029
+ if (passIndex === void 0) passIndex = 0;
8022
8030
  var basicResources = engine._basicResources;
8023
8031
  var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
8024
- var blitMaterial = basicResources.blitMaterial;
8032
+ var blitMaterial = material || basicResources.blitMaterial;
8025
8033
  var rhi = engine._hardwareRenderer;
8026
8034
  var context = engine._renderContext;
8027
8035
  // 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);
8036
+ context.flipProjection = !!destination;
8037
+ rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
8030
8038
  var rendererShaderData = PipelineUtils._rendererShaderData;
8031
- var pass = blitMaterial.shader.subShaders[0].passes[0];
8032
- var program = pass._getShaderProgram(engine, Shader._compileMacros);
8033
8039
  rendererShaderData.setTexture(PipelineUtils._blitTextureProperty, source);
8034
8040
  rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
8041
+ PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
8042
+ rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
8043
+ var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
8044
+ var compileMacros = Shader._compileMacros;
8045
+ ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
8046
+ var program = pass._getShaderProgram(engine, compileMacros);
8035
8047
  program.bind();
8036
8048
  program.groupingOtherUniformBlock();
8037
8049
  program.uploadAll(program.rendererUniformBlock, rendererShaderData);
@@ -8048,9 +8060,16 @@ var /**
8048
8060
  (function() {
8049
8061
  PipelineUtils._blitMipLevelProperty = ShaderProperty.getByName("renderer_BlitMipLevel");
8050
8062
  })();
8063
+ (function() {
8064
+ PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
8065
+ ;
8066
+ })();
8051
8067
  (function() {
8052
8068
  PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
8053
8069
  })();
8070
+ (function() {
8071
+ PipelineUtils._texelSize = new engineMath.Vector4();
8072
+ })();
8054
8073
  (function() {
8055
8074
  PipelineUtils.defaultViewport = new engineMath.Vector4(0, 0, 1, 1);
8056
8075
  })();
@@ -8181,6 +8200,8 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8181
8200
  _this._renderTarget = null;
8182
8201
  _this._depthBufferParams = new engineMath.Vector4();
8183
8202
  _this._opaqueTextureEnabled = false;
8203
+ _this._enableHDR = false;
8204
+ _this._enablePostProcess = false;
8184
8205
  _this._viewport = new engineMath.Vector4(0, 0, 1, 1);
8185
8206
  _this._pixelViewport = new engineMath.Rect(0, 0, 0, 0);
8186
8207
  _this._inverseProjectionMatrix = new engineMath.Matrix();
@@ -8386,6 +8407,11 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8386
8407
  };
8387
8408
  /**
8388
8409
  * @internal
8410
+ */ _proto._getInternalColorTextureFormat = function _getInternalColorTextureFormat() {
8411
+ return this._enableHDR ? this.engine._hardwareRenderer.isWebGL2 ? exports.TextureFormat.R11G11B10_UFloat : exports.TextureFormat.R16G16B16A16 : exports.TextureFormat.R8G8B8A8;
8412
+ };
8413
+ /**
8414
+ * @internal
8389
8415
  * @inheritdoc
8390
8416
  */ _proto._onDestroy = function _onDestroy() {
8391
8417
  var _this__renderPipeline;
@@ -8474,9 +8500,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8474
8500
  }
8475
8501
  return this._inverseProjectionMatrix;
8476
8502
  };
8477
- _proto._forceUseInternalCanvas = function _forceUseInternalCanvas() {
8478
- return this.opaqueTextureEnabled;
8479
- };
8480
8503
  _proto._onPixelViewportChanged = function _onPixelViewportChanged() {
8481
8504
  this._updatePixelViewport();
8482
8505
  var _this__customAspectRatio;
@@ -8485,7 +8508,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8485
8508
  };
8486
8509
  _proto._checkMainCanvasAntialiasWaste = function _checkMainCanvasAntialiasWaste() {
8487
8510
  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.");
8511
+ 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
8512
  }
8490
8513
  };
8491
8514
  _create_class(Camera1, [
@@ -8496,7 +8519,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8496
8519
  * If enabled, the opaque texture can be accessed in the shader using `camera_OpaqueTexture`.
8497
8520
  *
8498
8521
  * @defaultValue `false`
8499
- *
8500
8522
  * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8501
8523
  */ function get() {
8502
8524
  return this._opaqueTextureEnabled;
@@ -8515,10 +8537,10 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8515
8537
  *
8516
8538
  * @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
8517
8539
  */ function get() {
8518
- if (this._renderTarget) {
8519
- return false;
8540
+ if (this.enableHDR || this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
8541
+ return true;
8520
8542
  }
8521
- return this._forceUseInternalCanvas();
8543
+ return this.opaqueTextureEnabled && !this._renderTarget;
8522
8544
  }
8523
8545
  },
8524
8546
  {
@@ -8703,13 +8725,38 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8703
8725
  key: "enableHDR",
8704
8726
  get: /**
8705
8727
  * Whether to enable HDR.
8706
- * @todo When render pipeline modification
8728
+ * @defaultValue `false`
8729
+ * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8707
8730
  */ function get() {
8708
- console.log("not implementation");
8709
- return false;
8731
+ return this._enableHDR;
8732
+ },
8733
+ set: function set(value) {
8734
+ if (this.enableHDR !== value) {
8735
+ var rhi = this.engine._hardwareRenderer;
8736
+ var supportHDR = rhi.isWebGL2 || rhi.canIUse(exports.GLCapabilityType.textureHalfFloat);
8737
+ if (value && !supportHDR) {
8738
+ Logger.warn("Can't enable HDR in this device.");
8739
+ return;
8740
+ }
8741
+ this._enableHDR = value;
8742
+ this._checkMainCanvasAntialiasWaste();
8743
+ }
8744
+ }
8745
+ },
8746
+ {
8747
+ key: "enablePostProcess",
8748
+ get: /**
8749
+ * Whether to enable post process.
8750
+ * @defaultValue `false`
8751
+ * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
8752
+ */ function get() {
8753
+ return this._enablePostProcess;
8710
8754
  },
8711
8755
  set: function set(value) {
8712
- console.log("not implementation");
8756
+ if (this._enablePostProcess !== value) {
8757
+ this._enablePostProcess = value;
8758
+ this._checkMainCanvasAntialiasWaste();
8759
+ }
8713
8760
  }
8714
8761
  },
8715
8762
  {
@@ -8725,7 +8772,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8725
8772
  value && this._addResourceReferCount(value, 1);
8726
8773
  this._renderTarget = value;
8727
8774
  this._onPixelViewportChanged();
8728
- this._checkMainCanvasAntialiasWaste();
8729
8775
  }
8730
8776
  }
8731
8777
  }
@@ -8810,7 +8856,7 @@ exports.Camera = __decorate([
8810
8856
  /**
8811
8857
  * PipelinePass is a base class for all pipeline passes.
8812
8858
  */ var PipelinePass = function PipelinePass(engine) {
8813
- this._engine = engine;
8859
+ this.engine = engine;
8814
8860
  };
8815
8861
 
8816
8862
  /**
@@ -9686,7 +9732,7 @@ var /**
9686
9732
  this._updateReceiversShaderData(light);
9687
9733
  };
9688
9734
  _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;
9735
+ var _this = this, engine = _this.engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
9690
9736
  var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue;
9691
9737
  var scene = camera.scene;
9692
9738
  var componentsManager = scene._componentsManager;
@@ -9705,13 +9751,12 @@ var /**
9705
9751
  var renderTarget;
9706
9752
  var shadowTexture;
9707
9753
  if (this._supportDepthTexture) {
9708
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1);
9754
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
9709
9755
  shadowTexture = renderTarget.depthTexture;
9710
9756
  } else {
9711
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1);
9757
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
9712
9758
  shadowTexture = renderTarget.getColorTexture(0);
9713
9759
  }
9714
- shadowTexture.wrapModeU = shadowTexture.wrapModeV = exports.TextureWrapMode.Clamp;
9715
9760
  if (engine._hardwareRenderer._isWebGL2) {
9716
9761
  shadowTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
9717
9762
  }
@@ -9962,22 +10007,17 @@ var /**
9962
10007
  }
9963
10008
  var _proto = DepthOnlyPass.prototype;
9964
10009
  _proto.onConfig = function onConfig(camera) {
9965
- var engine = this._engine;
10010
+ var engine = this.engine;
9966
10011
  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;
10012
+ var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, exports.TextureFormat.Depth16, true, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Point);
9971
10013
  this._renderTarget = renderTarget;
9972
10014
  };
9973
10015
  _proto.onRender = function onRender(context, cullingResults) {
9974
- var engine = this._engine;
10016
+ var engine = this.engine;
9975
10017
  var renderTarget = this._renderTarget;
9976
10018
  var camera = context.camera;
9977
10019
  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);
10020
+ rhi.activeRenderTarget(renderTarget, PipelineUtils.defaultViewport, context.flipProjection, 0);
9981
10021
  rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
9982
10022
  engine._renderCount++;
9983
10023
  cullingResults.opaqueQueue.render(context, exports.PipelineStage.DepthOnly);
@@ -10002,14 +10042,11 @@ var /**
10002
10042
  var isNoDownsampling = downsampling === exports.Downsampling.None;
10003
10043
  var viewport = camera.pixelViewport;
10004
10044
  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;
10045
+ 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
10046
  this._renderTarget = opaqueRenderTarget;
10010
10047
  };
10011
- _proto.onRender = function onRender(context, _) {
10012
- PipelineUtils.blitTexture(this._engine, this._cameraColorTexture, this._renderTarget);
10048
+ _proto.onRender = function onRender(context) {
10049
+ PipelineUtils.blitTexture(this.engine, this._cameraColorTexture, this._renderTarget);
10013
10050
  context.camera.shaderData.setTexture(exports.Camera._cameraOpaqueTextureProperty, this._renderTarget.getColorTexture(0));
10014
10051
  };
10015
10052
  return OpaqueTexturePass;
@@ -10072,9 +10109,7 @@ var /**
10072
10109
  var independentCanvasEnabled = camera.independentCanvasEnabled;
10073
10110
  if (independentCanvasEnabled) {
10074
10111
  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;
10112
+ 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
10113
  this._internalColorTarget = internalColorTarget;
10079
10114
  } else {
10080
10115
  var internalColorTarget1 = this._internalColorTarget;
@@ -10088,17 +10123,16 @@ var /**
10088
10123
  this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
10089
10124
  };
10090
10125
  _proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
10091
- var _colorTarget, _colorTarget1;
10126
+ var _cameraRenderTarget, _cameraRenderTarget1;
10092
10127
  var cullingResults = this._cullingResults;
10093
10128
  var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
10094
10129
  var engine = camera.engine, scene = camera.scene;
10095
10130
  var background = scene.background;
10096
- var internalColorTarget = this._internalColorTarget;
10097
10131
  var rhi = engine._hardwareRenderer;
10098
- var _camera_renderTarget;
10099
- var colorTarget = (_camera_renderTarget = camera.renderTarget) != null ? _camera_renderTarget : internalColorTarget;
10132
+ var internalColorTarget = this._internalColorTarget;
10133
+ var colorTarget = internalColorTarget || camera.renderTarget;
10100
10134
  var colorViewport = internalColorTarget ? PipelineUtils.defaultViewport : camera.viewport;
10101
- var needFlipProjection = camera.renderTarget && cubeFace == undefined || internalColorTarget !== null;
10135
+ var needFlipProjection = !!internalColorTarget || camera.renderTarget && cubeFace == undefined;
10102
10136
  if (context.flipProjection !== needFlipProjection) {
10103
10137
  // Just add projection matrix update type is enough
10104
10138
  context.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
@@ -10125,18 +10159,23 @@ var /**
10125
10159
  colorTarget._blitRenderTarget();
10126
10160
  var opaqueTexturePass = this._opaqueTexturePass;
10127
10161
  opaqueTexturePass.onConfig(camera, colorTarget.getColorTexture(0));
10128
- opaqueTexturePass.onRender(context, cullingResults);
10162
+ opaqueTexturePass.onRender(context);
10129
10163
  // Should revert to original render target
10130
10164
  rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
10131
10165
  } else {
10132
10166
  camera.shaderData.setTexture(exports.Camera._cameraOpaqueTextureProperty, null);
10133
10167
  }
10134
10168
  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);
10169
+ var postProcessManager = scene._postProcessManager;
10170
+ var cameraRenderTarget = camera.renderTarget;
10171
+ if (camera.enablePostProcess && postProcessManager.hasActiveEffect) {
10172
+ postProcessManager._render(context, internalColorTarget, cameraRenderTarget);
10173
+ } else if (internalColorTarget) {
10174
+ internalColorTarget._blitRenderTarget();
10175
+ PipelineUtils.blitTexture(engine, internalColorTarget.getColorTexture(0), cameraRenderTarget, 0, camera.viewport);
10139
10176
  }
10177
+ (_cameraRenderTarget = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget._blitRenderTarget();
10178
+ (_cameraRenderTarget1 = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget1.generateMipmaps();
10140
10179
  };
10141
10180
  /**
10142
10181
  * Push render data to render queue.
@@ -18337,37 +18376,29 @@ __decorate([
18337
18376
  -1,
18338
18377
  0,
18339
18378
  1,
18340
- 1,
18379
+ 3,
18341
18380
  -1,
18342
- 1,
18381
+ 2,
18343
18382
  1,
18344
18383
  -1,
18345
- 1,
18346
- 0,
18384
+ 3,
18347
18385
  0,
18348
- 1,
18349
- 1,
18350
- 1,
18351
- 0
18352
- ]); // right-top
18386
+ -1
18387
+ ]); // left-top
18353
18388
  // prettier-ignore
18354
18389
  var flipYVertices = new Float32Array([
18355
- 1,
18390
+ 3,
18356
18391
  -1,
18357
- 1,
18392
+ 2,
18358
18393
  0,
18359
18394
  -1,
18360
18395
  -1,
18361
18396
  0,
18362
18397
  0,
18363
- 1,
18364
- 1,
18365
- 1,
18366
- 1,
18367
18398
  -1,
18368
- 1,
18399
+ 3,
18369
18400
  0,
18370
- 1
18401
+ 2
18371
18402
  ]); // left-top
18372
18403
  var blitMaterial = new Material(engine, Shader.find("blit"));
18373
18404
  blitMaterial._addReferCount(1);
@@ -18405,7 +18436,7 @@ __decorate([
18405
18436
  new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
18406
18437
  ]);
18407
18438
  mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
18408
- mesh.addSubMesh(0, 4, exports.MeshTopology.TriangleStrip);
18439
+ mesh.addSubMesh(0, 3, exports.MeshTopology.Triangles);
18409
18440
  return mesh;
18410
18441
  };
18411
18442
  _proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel) {
@@ -24860,6 +24891,472 @@ __decorate([
24860
24891
  * */ LightManager._maxLight = 10;
24861
24892
  })();
24862
24893
 
24894
+ 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
24895
+
24896
+ 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
24897
+
24898
+ 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
24899
+
24900
+ 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
24901
+
24902
+ exports.BloomDownScaleMode = void 0;
24903
+ (function(BloomDownScaleMode) {
24904
+ BloomDownScaleMode[BloomDownScaleMode[/**
24905
+ * Use this to select half size as the starting resolution.
24906
+ */ "Half"] = 0] = "Half";
24907
+ BloomDownScaleMode[BloomDownScaleMode[/**
24908
+ * Use this to select quarter size as the starting resolution.
24909
+ */ "Quarter"] = 1] = "Quarter";
24910
+ })(exports.BloomDownScaleMode || (exports.BloomDownScaleMode = {}));
24911
+ var BloomEffect = /*#__PURE__*/ function() {
24912
+ function BloomEffect(_uberMaterial) {
24913
+ this._uberMaterial = _uberMaterial;
24914
+ this._highQualityFiltering = false;
24915
+ this._mipDownRT = [];
24916
+ this._mipUpRT = [];
24917
+ this._maxIterations = 6;
24918
+ this._enabled = false;
24919
+ this./**
24920
+ * Controls the starting resolution that this effect begins processing.
24921
+ */ downScale = 0;
24922
+ var engine = _uberMaterial.engine;
24923
+ var material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
24924
+ var depthState = material.renderState.depthState;
24925
+ depthState.enabled = false;
24926
+ depthState.writeEnabled = false;
24927
+ var bloomShaderData = material.shaderData;
24928
+ var uberShaderData = _uberMaterial.shaderData;
24929
+ bloomShaderData.setVector4(BloomEffect._bloomParams, new engineMath.Vector4());
24930
+ bloomShaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new engineMath.Vector4());
24931
+ uberShaderData.setVector4(BloomEffect._bloomIntensityParams, new engineMath.Vector4(1, 1, 0, 0));
24932
+ uberShaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new engineMath.Vector4());
24933
+ uberShaderData.setColor(BloomEffect._tintProp, new engineMath.Color(1, 1, 1, 1));
24934
+ this._bloomMaterial = material;
24935
+ this.threshold = 0.9;
24936
+ this.scatter = 0.7;
24937
+ this.intensity = 1;
24938
+ this.dirtIntensity = 1;
24939
+ }
24940
+ var _proto = BloomEffect.prototype;
24941
+ _proto.onRender = function onRender(context, srcTexture) {
24942
+ var camera = context.camera;
24943
+ var downRes = this.downScale === 0 ? 1 : 2;
24944
+ var pixelViewport = camera.pixelViewport;
24945
+ var tw = pixelViewport.width >> downRes;
24946
+ var th = pixelViewport.height >> downRes;
24947
+ // Determine the iteration count
24948
+ var mipCount = this._calculateMipCount(tw, th);
24949
+ // Prefilter
24950
+ this._prefilter(camera, srcTexture, tw, th, mipCount);
24951
+ // Down sample - gaussian pyramid
24952
+ this._downsample(mipCount);
24953
+ // Up sample (bilinear by default, HQ filtering does bicubic instead
24954
+ this._upsample(mipCount);
24955
+ // Setup bloom on uber
24956
+ this._setupUber(camera);
24957
+ };
24958
+ _proto._calculateMipCount = function _calculateMipCount(tw, th) {
24959
+ var maxSize = Math.max(tw, th);
24960
+ var iterations = Math.floor(Math.log2(maxSize) - 1);
24961
+ return Math.min(Math.max(iterations, 1), this._maxIterations);
24962
+ };
24963
+ _proto._prefilter = function _prefilter(camera, srcTexture, tw, th, mipCount) {
24964
+ var engine = this._uberMaterial.engine;
24965
+ var internalColorTextureFormat = camera._getInternalColorTextureFormat();
24966
+ var mipWidth = tw, mipHeight = th;
24967
+ for(var i = 0; i < mipCount; i++){
24968
+ this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipUpRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
24969
+ this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipDownRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, exports.TextureWrapMode.Clamp, exports.TextureFilterMode.Bilinear);
24970
+ mipWidth = Math.max(1, Math.floor(mipWidth / 2));
24971
+ mipHeight = Math.max(1, Math.floor(mipHeight / 2));
24972
+ }
24973
+ PipelineUtils.blitTexture(engine, srcTexture, this._mipDownRT[0], undefined, undefined, this._bloomMaterial, 0);
24974
+ };
24975
+ _proto._downsample = function _downsample(mipCount) {
24976
+ var material = this._bloomMaterial;
24977
+ var engine = material.engine;
24978
+ var lastDown = this._mipDownRT[0];
24979
+ // Down sample - gaussian pyramid
24980
+ for(var i = 1; i < mipCount; i++){
24981
+ // Classic two pass gaussian blur - use mipUp as a temporary target
24982
+ // First pass does 2x downsampling + 9-tap gaussian
24983
+ // Second pass does 9-tap gaussian using a 5-tap filter + bilinear filtering
24984
+ PipelineUtils.blitTexture(engine, lastDown.getColorTexture(0), this._mipUpRT[i], undefined, undefined, material, 1);
24985
+ PipelineUtils.blitTexture(engine, this._mipUpRT[i].getColorTexture(0), this._mipDownRT[i], undefined, undefined, material, 2);
24986
+ lastDown = this._mipDownRT[i];
24987
+ }
24988
+ };
24989
+ _proto._upsample = function _upsample(mipCount) {
24990
+ var material = this._bloomMaterial;
24991
+ var engine = material.engine;
24992
+ var shaderData = material.shaderData;
24993
+ // Up sample (bilinear by default, HQ filtering does bicubic instead
24994
+ for(var i = mipCount - 2; i >= 0; i--){
24995
+ var lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
24996
+ var highMip = this._mipDownRT[i];
24997
+ var dst = this._mipUpRT[i];
24998
+ shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
24999
+ if (this.highQualityFiltering) {
25000
+ var texelSizeLow = shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
25001
+ texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
25002
+ }
25003
+ PipelineUtils.blitTexture(engine, highMip.getColorTexture(0), dst, undefined, undefined, material, 3);
25004
+ }
25005
+ };
25006
+ _proto._setupUber = function _setupUber(camera) {
25007
+ var shaderData = this._uberMaterial.shaderData;
25008
+ var dirtTexture = this.dirtTexture;
25009
+ if (dirtTexture) {
25010
+ var dirtTilingOffset = shaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
25011
+ var dirtRatio = dirtTexture.width / dirtTexture.height;
25012
+ var screenRatio = camera.aspectRatio;
25013
+ if (dirtRatio > screenRatio) {
25014
+ dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
25015
+ } else if (dirtRatio < screenRatio) {
25016
+ dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
25017
+ } else {
25018
+ dirtTilingOffset.set(1, 1, 0, 0);
25019
+ }
25020
+ }
25021
+ shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
25022
+ };
25023
+ _proto._releaseRenderTargets = function _releaseRenderTargets() {
25024
+ var length = this._mipDownRT.length;
25025
+ for(var i = 0; i < length; i++){
25026
+ var downRT = this._mipDownRT[i];
25027
+ var upRT = this._mipUpRT[i];
25028
+ if (downRT) {
25029
+ downRT.getColorTexture(0).destroy(true);
25030
+ downRT.destroy(true);
25031
+ }
25032
+ if (upRT) {
25033
+ upRT.getColorTexture(0).destroy(true);
25034
+ upRT.destroy(true);
25035
+ }
25036
+ }
25037
+ this._mipDownRT.length = 0;
25038
+ this._mipUpRT.length = 0;
25039
+ };
25040
+ _create_class(BloomEffect, [
25041
+ {
25042
+ key: "enabled",
25043
+ get: /**
25044
+ * Indicates whether the post process effect is enabled.
25045
+ */ function get() {
25046
+ return this._enabled;
25047
+ },
25048
+ set: function set(value) {
25049
+ if (value !== this._enabled) {
25050
+ this._enabled = value;
25051
+ if (value) {
25052
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._enableMacro);
25053
+ } else {
25054
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._enableMacro);
25055
+ this._releaseRenderTargets();
25056
+ }
25057
+ }
25058
+ }
25059
+ },
25060
+ {
25061
+ key: "threshold",
25062
+ get: /**
25063
+ * Set the level of brightness to filter out pixels under this level.
25064
+ * @remarks This value is expressed in gamma-space.
25065
+ */ function get() {
25066
+ return this._threshold;
25067
+ },
25068
+ set: function set(value) {
25069
+ value = Math.max(0, value);
25070
+ if (value !== this._threshold) {
25071
+ this._threshold = value;
25072
+ var threshold = engineMath.Color.gammaToLinearSpace(value);
25073
+ var thresholdKnee = threshold * 0.5; // Hardcoded soft knee
25074
+ var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
25075
+ params.x = threshold;
25076
+ params.y = thresholdKnee;
25077
+ }
25078
+ }
25079
+ },
25080
+ {
25081
+ key: "scatter",
25082
+ get: /**
25083
+ * Controls the radius of the bloom effect.
25084
+ */ function get() {
25085
+ return this._scatter;
25086
+ },
25087
+ set: function set(value) {
25088
+ value = Math.min(Math.max(0, value), 1);
25089
+ if (value !== this._scatter) {
25090
+ this._scatter = value;
25091
+ var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
25092
+ var scatter = engineMath.MathUtil.lerp(0.05, 0.95, value);
25093
+ params.z = scatter;
25094
+ }
25095
+ }
25096
+ },
25097
+ {
25098
+ key: "intensity",
25099
+ get: /**
25100
+ * Controls the strength of the bloom effect.
25101
+ */ function get() {
25102
+ return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x;
25103
+ },
25104
+ set: function set(value) {
25105
+ value = Math.max(0, value);
25106
+ this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x = value;
25107
+ }
25108
+ },
25109
+ {
25110
+ key: "tint",
25111
+ get: /**
25112
+ * Specifies the tint of the bloom effect.
25113
+ */ function get() {
25114
+ return this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
25115
+ },
25116
+ set: function set(value) {
25117
+ var tint = this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
25118
+ if (value !== tint) {
25119
+ tint.copyFrom(value);
25120
+ }
25121
+ }
25122
+ },
25123
+ {
25124
+ key: "highQualityFiltering",
25125
+ get: /**
25126
+ * Controls whether to use bicubic sampling instead of bilinear sampling for the upSampling passes.
25127
+ * @remarks This is slightly more expensive but helps getting smoother visuals.
25128
+ */ function get() {
25129
+ return this._highQualityFiltering;
25130
+ },
25131
+ set: function set(value) {
25132
+ if (value !== this._highQualityFiltering) {
25133
+ this._highQualityFiltering = value;
25134
+ if (value) {
25135
+ this._bloomMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
25136
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
25137
+ } else {
25138
+ this._bloomMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
25139
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
25140
+ }
25141
+ }
25142
+ }
25143
+ },
25144
+ {
25145
+ key: "dirtTexture",
25146
+ get: /**
25147
+ * Specifies a Texture to add smudges or dust to the bloom effect.
25148
+ */ function get() {
25149
+ return this._uberMaterial.shaderData.getTexture(BloomEffect._dirtTextureProp);
25150
+ },
25151
+ set: function set(value) {
25152
+ this._uberMaterial.shaderData.setTexture(BloomEffect._dirtTextureProp, value);
25153
+ if (value) {
25154
+ this._uberMaterial.shaderData.enableMacro(BloomEffect._dirtMacro);
25155
+ } else {
25156
+ this._uberMaterial.shaderData.disableMacro(BloomEffect._dirtMacro);
25157
+ }
25158
+ }
25159
+ },
25160
+ {
25161
+ key: "dirtIntensity",
25162
+ get: /**
25163
+ * Controls the strength of the lens dirt.
25164
+ */ function get() {
25165
+ return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y;
25166
+ },
25167
+ set: function set(value) {
25168
+ value = Math.max(0, value);
25169
+ this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y = value;
25170
+ }
25171
+ }
25172
+ ]);
25173
+ return BloomEffect;
25174
+ }();
25175
+ (function() {
25176
+ BloomEffect.SHADER_NAME = "PostProcessEffect Bloom";
25177
+ })();
25178
+ (function() {
25179
+ // Bloom shader properties
25180
+ BloomEffect._hqMacro = ShaderMacro.getByName("BLOOM_HQ");
25181
+ })();
25182
+ (function() {
25183
+ BloomEffect._dirtMacro = ShaderMacro.getByName("BLOOM_DIRT");
25184
+ })();
25185
+ (function() {
25186
+ BloomEffect._bloomParams = ShaderProperty.getByName("material_BloomParams") // x: threshold (linear), y: threshold knee, z: scatter
25187
+ ;
25188
+ })();
25189
+ (function() {
25190
+ BloomEffect._lowMipTextureProp = ShaderProperty.getByName("material_lowMipTexture");
25191
+ })();
25192
+ (function() {
25193
+ BloomEffect._lowMipTexelSizeProp = ShaderProperty.getByName("material_lowMipTexelSize") // x: 1/width, y: 1/height, z: width, w: height
25194
+ ;
25195
+ })();
25196
+ (function() {
25197
+ // Uber shader properties
25198
+ BloomEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_BLOOM");
25199
+ })();
25200
+ (function() {
25201
+ BloomEffect._bloomTextureProp = ShaderProperty.getByName("material_BloomTexture");
25202
+ })();
25203
+ (function() {
25204
+ BloomEffect._dirtTextureProp = ShaderProperty.getByName("material_BloomDirtTexture");
25205
+ })();
25206
+ (function() {
25207
+ BloomEffect._tintProp = ShaderProperty.getByName("material_BloomTint");
25208
+ })();
25209
+ (function() {
25210
+ BloomEffect._bloomIntensityParams = ShaderProperty.getByName("material_BloomIntensityParams") // x: bloom intensity, y: dirt intensity
25211
+ ;
25212
+ })();
25213
+ (function() {
25214
+ BloomEffect._dirtTilingOffsetProp = ShaderProperty.getByName("material_BloomDirtTilingOffset");
25215
+ })();
25216
+ Shader.create(BloomEffect.SHADER_NAME, [
25217
+ new ShaderPass("Bloom Prefilter", blitVs, fragPrefilter),
25218
+ new ShaderPass("Bloom Blur Horizontal", blitVs, fragBlurH),
25219
+ new ShaderPass("Bloom Blur Vertical", blitVs, fragBlurV),
25220
+ new ShaderPass("Bloom Upsample", blitVs, fragUpsample)
25221
+ ]);
25222
+
25223
+ exports.TonemappingMode = void 0;
25224
+ (function(TonemappingMode) {
25225
+ TonemappingMode[TonemappingMode[/**
25226
+ * Neutral tonemapper
25227
+ * @remarks Use this option if you only want range-remapping with minimal impact on color hue and saturation.
25228
+ */ "Neutral"] = 0] = "Neutral";
25229
+ TonemappingMode[TonemappingMode[/**
25230
+ * ACES Filmic reference tonemapper (custom approximation)
25231
+ * @remarks
25232
+ * Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
25233
+ * It is more contrasted than Neutral and has an effect on actual color hue and saturation.
25234
+ */ "ACES"] = 1] = "ACES";
25235
+ })(exports.TonemappingMode || (exports.TonemappingMode = {}));
25236
+ var TonemappingEffect = /*#__PURE__*/ function() {
25237
+ function TonemappingEffect(_uberMaterial) {
25238
+ this._uberMaterial = _uberMaterial;
25239
+ this._enabled = false;
25240
+ this.mode = 0;
25241
+ }
25242
+ _create_class(TonemappingEffect, [
25243
+ {
25244
+ key: "enabled",
25245
+ get: /**
25246
+ * Indicates whether the post process effect is enabled.
25247
+ */ function get() {
25248
+ return this._enabled;
25249
+ },
25250
+ set: function set(value) {
25251
+ if (value !== this._enabled) {
25252
+ this._enabled = value;
25253
+ if (value) {
25254
+ this._uberMaterial.shaderData.enableMacro(TonemappingEffect._enableMacro);
25255
+ } else {
25256
+ this._uberMaterial.shaderData.disableMacro(TonemappingEffect._enableMacro);
25257
+ }
25258
+ }
25259
+ }
25260
+ },
25261
+ {
25262
+ key: "mode",
25263
+ get: /**
25264
+ * Use this to select a tonemapping algorithm to use.
25265
+ */ function get() {
25266
+ return this._mode;
25267
+ },
25268
+ set: function set(value) {
25269
+ if (value !== this._mode) {
25270
+ this._mode = value;
25271
+ this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE", value.toString());
25272
+ }
25273
+ }
25274
+ }
25275
+ ]);
25276
+ return TonemappingEffect;
25277
+ }();
25278
+ (function() {
25279
+ TonemappingEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_TONEMAPPING");
25280
+ })();
25281
+
25282
+ /**
25283
+ * @internal
25284
+ */ var _PostProcessManager = /*#__PURE__*/ function() {
25285
+ function _PostProcessManager(scene) {
25286
+ this.scene = scene;
25287
+ var uberShader = Shader.find(_PostProcessManager.UBER_SHADER_NAME);
25288
+ var uberMaterial = new Material(scene.engine, uberShader);
25289
+ var depthState = uberMaterial.renderState.depthState;
25290
+ depthState.enabled = false;
25291
+ depthState.writeEnabled = false;
25292
+ var bloomEffect = new BloomEffect(uberMaterial);
25293
+ var tonemappingEffect = new TonemappingEffect(uberMaterial);
25294
+ this._uberMaterial = uberMaterial;
25295
+ this._bloomEffect = bloomEffect;
25296
+ this._tonemappingEffect = tonemappingEffect;
25297
+ }
25298
+ var _proto = _PostProcessManager.prototype;
25299
+ /**
25300
+ * @internal
25301
+ */ _proto._render = function _render(context, srcTarget, destTarget) {
25302
+ var camera = context.camera;
25303
+ var engine = camera.engine;
25304
+ // Should blit to resolve the MSAA
25305
+ srcTarget._blitRenderTarget();
25306
+ var srcTexture = srcTarget.getColorTexture();
25307
+ var bloomEffect = this._bloomEffect;
25308
+ if (bloomEffect.enabled) {
25309
+ bloomEffect.onRender(context, srcTexture);
25310
+ }
25311
+ // Done with Uber, blit it
25312
+ PipelineUtils.blitTexture(engine, srcTexture, destTarget, 0, camera.viewport, this._uberMaterial);
25313
+ };
25314
+ _create_class(_PostProcessManager, [
25315
+ {
25316
+ key: "hasActiveEffect",
25317
+ get: /**
25318
+ * Whether has active post process effect.
25319
+ */ function get() {
25320
+ return this._bloomEffect.enabled || this._tonemappingEffect.enabled;
25321
+ }
25322
+ }
25323
+ ]);
25324
+ return _PostProcessManager;
25325
+ }();
25326
+ (function() {
25327
+ _PostProcessManager.UBER_SHADER_NAME = "UberPost";
25328
+ })();
25329
+
25330
+ 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
25331
+
25332
+ 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
25333
+
25334
+ 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
25335
+
25336
+ 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
25337
+
25338
+ 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
25339
+
25340
+ 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
25341
+
25342
+ 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
25343
+
25344
+ 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
25345
+
25346
+ 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
25347
+
25348
+ Object.assign(ShaderLib, {
25349
+ PostCommon: PostCommon,
25350
+ Filtering: Filtering,
25351
+ ODT: ODT,
25352
+ RRT: RRT,
25353
+ Tonescale: Tonescale,
25354
+ ColorTransform: ColorTransform,
25355
+ NeutralTonemapping: NeutralTonemapping,
25356
+ ACESTonemapping: ACESTonemapping
25357
+ });
25358
+ Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
25359
+
24863
25360
  /**
24864
25361
  * Scene.
24865
25362
  */ var Scene = /*#__PURE__*/ function(EngineObject1) {
@@ -24883,6 +25380,7 @@ __decorate([
24883
25380
  /** @internal */ _this._isActiveInEngine = false;
24884
25381
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
24885
25382
  /** @internal */ _this._rootEntities = [];
25383
+ /** @internal */ _this._postProcessManager = new _PostProcessManager(_assert_this_initialized(_this));
24886
25384
  _this._background = new Background(_this._engine);
24887
25385
  _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
24888
25386
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
@@ -27812,7 +28310,8 @@ exports.AnimatorLayerBlendingMode = void 0;
27812
28310
  eventHandler.event = event;
27813
28311
  handlers.length = 0;
27814
28312
  for(var j = scriptCount - 1; j >= 0; j--){
27815
- var handler = scripts[j][funcName];
28313
+ var script = scripts[j];
28314
+ var handler = script[funcName].bind(script);
27816
28315
  handler && handlers.push(handler);
27817
28316
  }
27818
28317
  eventHandlers.push(eventHandler);
@@ -33630,6 +34129,7 @@ exports.BlendShape = BlendShape;
33630
34129
  exports.BlendShapeFrame = BlendShapeFrame;
33631
34130
  exports.BlendState = BlendState;
33632
34131
  exports.BlinnPhongMaterial = BlinnPhongMaterial;
34132
+ exports.BloomEffect = BloomEffect;
33633
34133
  exports.BoolUpdateFlag = BoolUpdateFlag;
33634
34134
  exports.BoxColliderShape = BoxColliderShape;
33635
34135
  exports.BoxShape = BoxShape;
@@ -33746,6 +34246,7 @@ exports.Texture2DArray = Texture2DArray;
33746
34246
  exports.TextureCube = TextureCube;
33747
34247
  exports.TextureSheetAnimationModule = TextureSheetAnimationModule;
33748
34248
  exports.Time = Time;
34249
+ exports.TonemappingEffect = TonemappingEffect;
33749
34250
  exports.TrailMaterial = TrailMaterial;
33750
34251
  exports.TrailRenderer = TrailRenderer;
33751
34252
  exports.Transform = Transform;
@@ -33755,6 +34256,7 @@ exports.VelocityOverLifetimeModule = VelocityOverLifetimeModule;
33755
34256
  exports.VertexBufferBinding = VertexBufferBinding;
33756
34257
  exports.VertexElement = VertexElement;
33757
34258
  exports.XRManager = XRManager;
34259
+ exports._PostProcessManager = _PostProcessManager;
33758
34260
  exports.assignmentClone = assignmentClone;
33759
34261
  exports.deepClone = deepClone;
33760
34262
  exports.dependentComponents = dependentComponents;