@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 +590 -88
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +590 -88
- package/dist/module.js +588 -89
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Camera.d.ts +11 -3
- package/types/RenderPipeline/PipelinePass.d.ts +1 -1
- package/types/RenderPipeline/enums/RenderBufferStoreAction.d.ts +13 -0
- package/types/RenderPipeline/index.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/postProcess/PostProcessEffect.d.ts +13 -0
- package/types/postProcess/PostProcessManager.d.ts +1 -0
- package/types/postProcess/PostProcessPass.d.ts +55 -0
- package/types/postProcess/effects/BloomEffect.d.ts +94 -0
- package/types/postProcess/effects/TonemappingEffect.d.ts +35 -0
- package/types/postProcess/effects/index.d.ts +2 -0
- package/types/postProcess/index.d.ts +3 -0
- package/types/shader/enums/ShaderPlatformTarget.d.ts +4 -0
- package/types/shader/enums/ShaderType.d.ts +1 -0
- package/types/texture/enums/TextureFormat.d.ts +2 -0
package/dist/module.js
CHANGED
|
@@ -3319,7 +3319,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
|
|
|
3319
3319
|
|
|
3320
3320
|
var pbr_frag_define = "#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
3321
3321
|
|
|
3322
|
-
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return
|
|
3322
|
+
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.roughness+getAARoughnessFactor(geometry.normal),1.0));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.clearCoatRoughness+getAARoughnessFactor(geometry.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
3323
3323
|
|
|
3324
3324
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
3325
3325
|
|
|
@@ -5257,6 +5257,7 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
|
|
|
5257
5257
|
TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
|
|
5258
5258
|
TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
|
|
5259
5259
|
TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
|
|
5260
|
+
TextureFormat[TextureFormat[/** RGB unsigned float format, 11 bits in R channel, 11 bits in G channel, 10 bits in B channel. */ "R11G11B10_UFloat"] = 35] = "R11G11B10_UFloat";
|
|
5260
5261
|
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
|
|
5261
5262
|
TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
|
|
5262
5263
|
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
|
|
@@ -7952,22 +7953,23 @@ var /**
|
|
|
7952
7953
|
* @param height - Need texture height
|
|
7953
7954
|
* @param format - Need texture format
|
|
7954
7955
|
* @param mipmap - Need texture mipmap
|
|
7956
|
+
* @param textureWrapMode - Texture wrap mode
|
|
7957
|
+
* @param textureFilterMode - Texture filter mode
|
|
7955
7958
|
* @returns Texture
|
|
7956
|
-
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
7959
|
+
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap, textureWrapMode, textureFilterMode) {
|
|
7957
7960
|
if (currentTexture) {
|
|
7958
7961
|
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
7959
7962
|
currentTexture.destroy(true);
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
return texture;
|
|
7963
|
-
} else {
|
|
7964
|
-
return currentTexture;
|
|
7963
|
+
currentTexture = new Texture2D(engine, width, height, format, mipmap);
|
|
7964
|
+
currentTexture.isGCIgnored = true;
|
|
7965
7965
|
}
|
|
7966
7966
|
} else {
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
return texture1;
|
|
7967
|
+
currentTexture = new Texture2D(engine, width, height, format, mipmap);
|
|
7968
|
+
currentTexture.isGCIgnored = true;
|
|
7970
7969
|
}
|
|
7970
|
+
currentTexture.wrapModeU = currentTexture.wrapModeV = textureWrapMode;
|
|
7971
|
+
currentTexture.filterMode = textureFilterMode;
|
|
7972
|
+
return currentTexture;
|
|
7971
7973
|
};
|
|
7972
7974
|
/**
|
|
7973
7975
|
* Recreate render target if needed.
|
|
@@ -7979,15 +7981,17 @@ var /**
|
|
|
7979
7981
|
* @param depthFormat - Need render target depth format
|
|
7980
7982
|
* @param mipmap - Need render target mipmap
|
|
7981
7983
|
* @param antiAliasing - Need render target anti aliasing
|
|
7984
|
+
* @param textureWrapMode - Texture wrap mode
|
|
7985
|
+
* @param textureFilterMode - Texture filter mode
|
|
7982
7986
|
* @returns Render target
|
|
7983
|
-
*/ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing) {
|
|
7987
|
+
*/ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, antiAliasing, textureWrapMode, textureFilterMode) {
|
|
7984
7988
|
var _currentRenderTarget;
|
|
7985
7989
|
var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
|
|
7986
|
-
var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
|
|
7990
|
+
var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap, textureWrapMode, textureFilterMode) : null;
|
|
7987
7991
|
if (needDepthTexture) {
|
|
7988
7992
|
var _currentRenderTarget1;
|
|
7989
7993
|
var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
|
|
7990
|
-
var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
7994
|
+
var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap, textureWrapMode, textureFilterMode) : null;
|
|
7991
7995
|
if (currentColorTexture !== colorTexture || currentDepthTexture !== _$needDepthTexture) {
|
|
7992
7996
|
var _currentRenderTarget2;
|
|
7993
7997
|
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy(true);
|
|
@@ -7996,38 +8000,46 @@ var /**
|
|
|
7996
8000
|
}
|
|
7997
8001
|
} else {
|
|
7998
8002
|
var _currentRenderTarget3;
|
|
7999
|
-
|
|
8000
|
-
if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== needDepthFormat) {
|
|
8003
|
+
if (currentColorTexture !== colorTexture || ((_currentRenderTarget3 = currentRenderTarget) == null ? void 0 : _currentRenderTarget3._depthFormat) !== depthFormat || currentRenderTarget.antiAliasing !== antiAliasing) {
|
|
8001
8004
|
var _currentRenderTarget4;
|
|
8002
8005
|
(_currentRenderTarget4 = currentRenderTarget) == null ? void 0 : _currentRenderTarget4.destroy(true);
|
|
8003
|
-
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture,
|
|
8006
|
+
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthFormat, antiAliasing);
|
|
8004
8007
|
currentRenderTarget.isGCIgnored = true;
|
|
8005
8008
|
}
|
|
8006
8009
|
}
|
|
8007
8010
|
return currentRenderTarget;
|
|
8008
8011
|
};
|
|
8009
8012
|
/**
|
|
8010
|
-
* Blit texture to destination render target.
|
|
8013
|
+
* Blit texture to destination render target using a triangle.
|
|
8011
8014
|
* @param engine - Engine
|
|
8012
8015
|
* @param source - Source texture
|
|
8013
8016
|
* @param destination - Destination render target
|
|
8014
8017
|
* @param mipLevel - Mip level to blit
|
|
8015
8018
|
* @param viewport - Viewport
|
|
8016
|
-
|
|
8019
|
+
* @param material - The material to use when blitting
|
|
8020
|
+
* @param passIndex - Pass index to use of the provided material
|
|
8021
|
+
*/ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex) {
|
|
8017
8022
|
if (mipLevel === void 0) mipLevel = 0;
|
|
8023
|
+
if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
|
|
8024
|
+
if (material === void 0) material = null;
|
|
8025
|
+
if (passIndex === void 0) passIndex = 0;
|
|
8018
8026
|
var basicResources = engine._basicResources;
|
|
8019
8027
|
var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
|
|
8020
|
-
var blitMaterial = basicResources.blitMaterial;
|
|
8028
|
+
var blitMaterial = material || basicResources.blitMaterial;
|
|
8021
8029
|
var rhi = engine._hardwareRenderer;
|
|
8022
8030
|
var context = engine._renderContext;
|
|
8023
8031
|
// We not use projection matrix when blit, but we must modify flipProjection to make front face correct
|
|
8024
|
-
context.flipProjection = destination
|
|
8025
|
-
rhi.activeRenderTarget(destination, viewport
|
|
8032
|
+
context.flipProjection = !!destination;
|
|
8033
|
+
rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
|
|
8026
8034
|
var rendererShaderData = PipelineUtils._rendererShaderData;
|
|
8027
|
-
var pass = blitMaterial.shader.subShaders[0].passes[0];
|
|
8028
|
-
var program = pass._getShaderProgram(engine, Shader._compileMacros);
|
|
8029
8035
|
rendererShaderData.setTexture(PipelineUtils._blitTextureProperty, source);
|
|
8030
8036
|
rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
|
|
8037
|
+
PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
|
|
8038
|
+
rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
|
|
8039
|
+
var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
|
|
8040
|
+
var compileMacros = Shader._compileMacros;
|
|
8041
|
+
ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
|
|
8042
|
+
var program = pass._getShaderProgram(engine, compileMacros);
|
|
8031
8043
|
program.bind();
|
|
8032
8044
|
program.groupingOtherUniformBlock();
|
|
8033
8045
|
program.uploadAll(program.rendererUniformBlock, rendererShaderData);
|
|
@@ -8044,9 +8056,16 @@ var /**
|
|
|
8044
8056
|
(function() {
|
|
8045
8057
|
PipelineUtils._blitMipLevelProperty = ShaderProperty.getByName("renderer_BlitMipLevel");
|
|
8046
8058
|
})();
|
|
8059
|
+
(function() {
|
|
8060
|
+
PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
|
|
8061
|
+
;
|
|
8062
|
+
})();
|
|
8047
8063
|
(function() {
|
|
8048
8064
|
PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
|
|
8049
8065
|
})();
|
|
8066
|
+
(function() {
|
|
8067
|
+
PipelineUtils._texelSize = new Vector4();
|
|
8068
|
+
})();
|
|
8050
8069
|
(function() {
|
|
8051
8070
|
PipelineUtils.defaultViewport = new Vector4(0, 0, 1, 1);
|
|
8052
8071
|
})();
|
|
@@ -8177,6 +8196,8 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8177
8196
|
_this._renderTarget = null;
|
|
8178
8197
|
_this._depthBufferParams = new Vector4();
|
|
8179
8198
|
_this._opaqueTextureEnabled = false;
|
|
8199
|
+
_this._enableHDR = false;
|
|
8200
|
+
_this._enablePostProcess = false;
|
|
8180
8201
|
_this._viewport = new Vector4(0, 0, 1, 1);
|
|
8181
8202
|
_this._pixelViewport = new Rect(0, 0, 0, 0);
|
|
8182
8203
|
_this._inverseProjectionMatrix = new Matrix();
|
|
@@ -8382,6 +8403,11 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8382
8403
|
};
|
|
8383
8404
|
/**
|
|
8384
8405
|
* @internal
|
|
8406
|
+
*/ _proto._getInternalColorTextureFormat = function _getInternalColorTextureFormat() {
|
|
8407
|
+
return this._enableHDR ? this.engine._hardwareRenderer.isWebGL2 ? TextureFormat.R11G11B10_UFloat : TextureFormat.R16G16B16A16 : TextureFormat.R8G8B8A8;
|
|
8408
|
+
};
|
|
8409
|
+
/**
|
|
8410
|
+
* @internal
|
|
8385
8411
|
* @inheritdoc
|
|
8386
8412
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
8387
8413
|
var _this__renderPipeline;
|
|
@@ -8470,9 +8496,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8470
8496
|
}
|
|
8471
8497
|
return this._inverseProjectionMatrix;
|
|
8472
8498
|
};
|
|
8473
|
-
_proto._forceUseInternalCanvas = function _forceUseInternalCanvas() {
|
|
8474
|
-
return this.opaqueTextureEnabled;
|
|
8475
|
-
};
|
|
8476
8499
|
_proto._onPixelViewportChanged = function _onPixelViewportChanged() {
|
|
8477
8500
|
this._updatePixelViewport();
|
|
8478
8501
|
var _this__customAspectRatio;
|
|
@@ -8481,7 +8504,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8481
8504
|
};
|
|
8482
8505
|
_proto._checkMainCanvasAntialiasWaste = function _checkMainCanvasAntialiasWaste() {
|
|
8483
8506
|
if (this.independentCanvasEnabled && Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
|
|
8484
|
-
|
|
8507
|
+
Logger.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.");
|
|
8485
8508
|
}
|
|
8486
8509
|
};
|
|
8487
8510
|
_create_class(Camera1, [
|
|
@@ -8492,7 +8515,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8492
8515
|
* If enabled, the opaque texture can be accessed in the shader using `camera_OpaqueTexture`.
|
|
8493
8516
|
*
|
|
8494
8517
|
* @defaultValue `false`
|
|
8495
|
-
*
|
|
8496
8518
|
* @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
|
|
8497
8519
|
*/ function get() {
|
|
8498
8520
|
return this._opaqueTextureEnabled;
|
|
@@ -8511,10 +8533,10 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8511
8533
|
*
|
|
8512
8534
|
* @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
|
|
8513
8535
|
*/ function get() {
|
|
8514
|
-
if (this.
|
|
8515
|
-
return
|
|
8536
|
+
if (this.enableHDR || this.enablePostProcess && this.scene._postProcessManager.hasActiveEffect) {
|
|
8537
|
+
return true;
|
|
8516
8538
|
}
|
|
8517
|
-
return this.
|
|
8539
|
+
return this.opaqueTextureEnabled && !this._renderTarget;
|
|
8518
8540
|
}
|
|
8519
8541
|
},
|
|
8520
8542
|
{
|
|
@@ -8699,13 +8721,38 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8699
8721
|
key: "enableHDR",
|
|
8700
8722
|
get: /**
|
|
8701
8723
|
* Whether to enable HDR.
|
|
8702
|
-
* @
|
|
8724
|
+
* @defaultValue `false`
|
|
8725
|
+
* @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
|
|
8703
8726
|
*/ function get() {
|
|
8704
|
-
|
|
8705
|
-
|
|
8727
|
+
return this._enableHDR;
|
|
8728
|
+
},
|
|
8729
|
+
set: function set(value) {
|
|
8730
|
+
if (this.enableHDR !== value) {
|
|
8731
|
+
var rhi = this.engine._hardwareRenderer;
|
|
8732
|
+
var supportHDR = rhi.isWebGL2 || rhi.canIUse(GLCapabilityType.textureHalfFloat);
|
|
8733
|
+
if (value && !supportHDR) {
|
|
8734
|
+
Logger.warn("Can't enable HDR in this device.");
|
|
8735
|
+
return;
|
|
8736
|
+
}
|
|
8737
|
+
this._enableHDR = value;
|
|
8738
|
+
this._checkMainCanvasAntialiasWaste();
|
|
8739
|
+
}
|
|
8740
|
+
}
|
|
8741
|
+
},
|
|
8742
|
+
{
|
|
8743
|
+
key: "enablePostProcess",
|
|
8744
|
+
get: /**
|
|
8745
|
+
* Whether to enable post process.
|
|
8746
|
+
* @defaultValue `false`
|
|
8747
|
+
* @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
|
|
8748
|
+
*/ function get() {
|
|
8749
|
+
return this._enablePostProcess;
|
|
8706
8750
|
},
|
|
8707
8751
|
set: function set(value) {
|
|
8708
|
-
|
|
8752
|
+
if (this._enablePostProcess !== value) {
|
|
8753
|
+
this._enablePostProcess = value;
|
|
8754
|
+
this._checkMainCanvasAntialiasWaste();
|
|
8755
|
+
}
|
|
8709
8756
|
}
|
|
8710
8757
|
},
|
|
8711
8758
|
{
|
|
@@ -8721,7 +8768,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
8721
8768
|
value && this._addResourceReferCount(value, 1);
|
|
8722
8769
|
this._renderTarget = value;
|
|
8723
8770
|
this._onPixelViewportChanged();
|
|
8724
|
-
this._checkMainCanvasAntialiasWaste();
|
|
8725
8771
|
}
|
|
8726
8772
|
}
|
|
8727
8773
|
}
|
|
@@ -8806,7 +8852,7 @@ Camera = __decorate([
|
|
|
8806
8852
|
/**
|
|
8807
8853
|
* PipelinePass is a base class for all pipeline passes.
|
|
8808
8854
|
*/ var PipelinePass = function PipelinePass(engine) {
|
|
8809
|
-
this.
|
|
8855
|
+
this.engine = engine;
|
|
8810
8856
|
};
|
|
8811
8857
|
|
|
8812
8858
|
/**
|
|
@@ -9682,7 +9728,7 @@ var /**
|
|
|
9682
9728
|
this._updateReceiversShaderData(light);
|
|
9683
9729
|
};
|
|
9684
9730
|
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
|
|
9685
|
-
var _this = this, engine = _this.
|
|
9731
|
+
var _this = this, engine = _this.engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
|
|
9686
9732
|
var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue;
|
|
9687
9733
|
var scene = camera.scene;
|
|
9688
9734
|
var componentsManager = scene._componentsManager;
|
|
@@ -9701,13 +9747,12 @@ var /**
|
|
|
9701
9747
|
var renderTarget;
|
|
9702
9748
|
var shadowTexture;
|
|
9703
9749
|
if (this._supportDepthTexture) {
|
|
9704
|
-
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1);
|
|
9750
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, true, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
|
|
9705
9751
|
shadowTexture = renderTarget.depthTexture;
|
|
9706
9752
|
} else {
|
|
9707
|
-
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1);
|
|
9753
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
|
|
9708
9754
|
shadowTexture = renderTarget.getColorTexture(0);
|
|
9709
9755
|
}
|
|
9710
|
-
shadowTexture.wrapModeU = shadowTexture.wrapModeV = TextureWrapMode.Clamp;
|
|
9711
9756
|
if (engine._hardwareRenderer._isWebGL2) {
|
|
9712
9757
|
shadowTexture.depthCompareFunction = TextureDepthCompareFunction.Less;
|
|
9713
9758
|
}
|
|
@@ -9958,22 +10003,17 @@ var /**
|
|
|
9958
10003
|
}
|
|
9959
10004
|
var _proto = DepthOnlyPass.prototype;
|
|
9960
10005
|
_proto.onConfig = function onConfig(camera) {
|
|
9961
|
-
var engine = this.
|
|
10006
|
+
var engine = this.engine;
|
|
9962
10007
|
var _camera_pixelViewport = camera.pixelViewport, width = _camera_pixelViewport.width, height = _camera_pixelViewport.height;
|
|
9963
|
-
var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, TextureFormat.Depth16, true, false, 1);
|
|
9964
|
-
var depthTexture = renderTarget.depthTexture;
|
|
9965
|
-
depthTexture.wrapModeU = depthTexture.wrapModeV = TextureWrapMode.Clamp;
|
|
9966
|
-
depthTexture.filterMode = TextureFilterMode.Point;
|
|
10008
|
+
var renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, TextureFormat.Depth16, true, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Point);
|
|
9967
10009
|
this._renderTarget = renderTarget;
|
|
9968
10010
|
};
|
|
9969
10011
|
_proto.onRender = function onRender(context, cullingResults) {
|
|
9970
|
-
var engine = this.
|
|
10012
|
+
var engine = this.engine;
|
|
9971
10013
|
var renderTarget = this._renderTarget;
|
|
9972
10014
|
var camera = context.camera;
|
|
9973
10015
|
var rhi = engine._hardwareRenderer;
|
|
9974
|
-
rhi.activeRenderTarget(renderTarget,
|
|
9975
|
-
rhi.viewport(0, 0, renderTarget.width, renderTarget.height);
|
|
9976
|
-
rhi.scissor(0, 0, renderTarget.width, renderTarget.height);
|
|
10016
|
+
rhi.activeRenderTarget(renderTarget, PipelineUtils.defaultViewport, context.flipProjection, 0);
|
|
9977
10017
|
rhi.clearRenderTarget(engine, CameraClearFlags.Depth, null);
|
|
9978
10018
|
engine._renderCount++;
|
|
9979
10019
|
cullingResults.opaqueQueue.render(context, PipelineStage.DepthOnly);
|
|
@@ -9998,14 +10038,11 @@ var /**
|
|
|
9998
10038
|
var isNoDownsampling = downsampling === Downsampling.None;
|
|
9999
10039
|
var viewport = camera.pixelViewport;
|
|
10000
10040
|
var sizeScale = isNoDownsampling ? 1.0 : downsampling === Downsampling.TwoX ? 0.5 : 0.25;
|
|
10001
|
-
var opaqueRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this.
|
|
10002
|
-
var colorTexture = opaqueRenderTarget.getColorTexture(0);
|
|
10003
|
-
colorTexture.wrapModeU = colorTexture.wrapModeV = TextureWrapMode.Clamp;
|
|
10004
|
-
colorTexture.filterMode = isNoDownsampling ? TextureFilterMode.Point : TextureFilterMode.Bilinear;
|
|
10041
|
+
var opaqueRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this.engine, this._renderTarget, viewport.width * sizeScale, viewport.height * sizeScale, camera._getInternalColorTextureFormat(), null, false, false, 1, TextureWrapMode.Clamp, isNoDownsampling ? TextureFilterMode.Point : TextureFilterMode.Bilinear);
|
|
10005
10042
|
this._renderTarget = opaqueRenderTarget;
|
|
10006
10043
|
};
|
|
10007
|
-
_proto.onRender = function onRender(context
|
|
10008
|
-
PipelineUtils.blitTexture(this.
|
|
10044
|
+
_proto.onRender = function onRender(context) {
|
|
10045
|
+
PipelineUtils.blitTexture(this.engine, this._cameraColorTexture, this._renderTarget);
|
|
10009
10046
|
context.camera.shaderData.setTexture(Camera._cameraOpaqueTextureProperty, this._renderTarget.getColorTexture(0));
|
|
10010
10047
|
};
|
|
10011
10048
|
return OpaqueTexturePass;
|
|
@@ -10068,9 +10105,7 @@ var /**
|
|
|
10068
10105
|
var independentCanvasEnabled = camera.independentCanvasEnabled;
|
|
10069
10106
|
if (independentCanvasEnabled) {
|
|
10070
10107
|
var viewport = camera.pixelViewport;
|
|
10071
|
-
var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height,
|
|
10072
|
-
var colorTexture = internalColorTarget.getColorTexture(0);
|
|
10073
|
-
colorTexture.wrapModeU = colorTexture.wrapModeV = TextureWrapMode.Clamp;
|
|
10108
|
+
var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), TextureFormat.Depth24Stencil8, false, false, camera.msaaSamples, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
|
|
10074
10109
|
this._internalColorTarget = internalColorTarget;
|
|
10075
10110
|
} else {
|
|
10076
10111
|
var internalColorTarget1 = this._internalColorTarget;
|
|
@@ -10084,17 +10119,16 @@ var /**
|
|
|
10084
10119
|
this._drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear);
|
|
10085
10120
|
};
|
|
10086
10121
|
_proto._drawRenderPass = function _drawRenderPass(context, camera, cubeFace, mipLevel, ignoreClear) {
|
|
10087
|
-
var
|
|
10122
|
+
var _cameraRenderTarget, _cameraRenderTarget1;
|
|
10088
10123
|
var cullingResults = this._cullingResults;
|
|
10089
10124
|
var opaqueQueue = cullingResults.opaqueQueue, alphaTestQueue = cullingResults.alphaTestQueue, transparentQueue = cullingResults.transparentQueue;
|
|
10090
10125
|
var engine = camera.engine, scene = camera.scene;
|
|
10091
10126
|
var background = scene.background;
|
|
10092
|
-
var internalColorTarget = this._internalColorTarget;
|
|
10093
10127
|
var rhi = engine._hardwareRenderer;
|
|
10094
|
-
var
|
|
10095
|
-
var colorTarget =
|
|
10128
|
+
var internalColorTarget = this._internalColorTarget;
|
|
10129
|
+
var colorTarget = internalColorTarget || camera.renderTarget;
|
|
10096
10130
|
var colorViewport = internalColorTarget ? PipelineUtils.defaultViewport : camera.viewport;
|
|
10097
|
-
var needFlipProjection = camera.renderTarget && cubeFace == undefined
|
|
10131
|
+
var needFlipProjection = !!internalColorTarget || camera.renderTarget && cubeFace == undefined;
|
|
10098
10132
|
if (context.flipProjection !== needFlipProjection) {
|
|
10099
10133
|
// Just add projection matrix update type is enough
|
|
10100
10134
|
context.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
|
|
@@ -10121,18 +10155,23 @@ var /**
|
|
|
10121
10155
|
colorTarget._blitRenderTarget();
|
|
10122
10156
|
var opaqueTexturePass = this._opaqueTexturePass;
|
|
10123
10157
|
opaqueTexturePass.onConfig(camera, colorTarget.getColorTexture(0));
|
|
10124
|
-
opaqueTexturePass.onRender(context
|
|
10158
|
+
opaqueTexturePass.onRender(context);
|
|
10125
10159
|
// Should revert to original render target
|
|
10126
10160
|
rhi.activeRenderTarget(colorTarget, colorViewport, context.flipProjection, mipLevel, cubeFace);
|
|
10127
10161
|
} else {
|
|
10128
10162
|
camera.shaderData.setTexture(Camera._cameraOpaqueTextureProperty, null);
|
|
10129
10163
|
}
|
|
10130
10164
|
transparentQueue.render(context, PipelineStage.Forward);
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
if (
|
|
10134
|
-
|
|
10165
|
+
var postProcessManager = scene._postProcessManager;
|
|
10166
|
+
var cameraRenderTarget = camera.renderTarget;
|
|
10167
|
+
if (camera.enablePostProcess && postProcessManager.hasActiveEffect) {
|
|
10168
|
+
postProcessManager._render(context, internalColorTarget, cameraRenderTarget);
|
|
10169
|
+
} else if (internalColorTarget) {
|
|
10170
|
+
internalColorTarget._blitRenderTarget();
|
|
10171
|
+
PipelineUtils.blitTexture(engine, internalColorTarget.getColorTexture(0), cameraRenderTarget, 0, camera.viewport);
|
|
10135
10172
|
}
|
|
10173
|
+
(_cameraRenderTarget = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget._blitRenderTarget();
|
|
10174
|
+
(_cameraRenderTarget1 = cameraRenderTarget) == null ? void 0 : _cameraRenderTarget1.generateMipmaps();
|
|
10136
10175
|
};
|
|
10137
10176
|
/**
|
|
10138
10177
|
* Push render data to render queue.
|
|
@@ -18333,37 +18372,29 @@ __decorate([
|
|
|
18333
18372
|
-1,
|
|
18334
18373
|
0,
|
|
18335
18374
|
1,
|
|
18336
|
-
|
|
18375
|
+
3,
|
|
18337
18376
|
-1,
|
|
18338
|
-
|
|
18377
|
+
2,
|
|
18339
18378
|
1,
|
|
18340
18379
|
-1,
|
|
18341
|
-
|
|
18342
|
-
0,
|
|
18380
|
+
3,
|
|
18343
18381
|
0,
|
|
18344
|
-
1
|
|
18345
|
-
|
|
18346
|
-
1,
|
|
18347
|
-
0
|
|
18348
|
-
]); // right-top
|
|
18382
|
+
-1
|
|
18383
|
+
]); // left-top
|
|
18349
18384
|
// prettier-ignore
|
|
18350
18385
|
var flipYVertices = new Float32Array([
|
|
18351
|
-
|
|
18386
|
+
3,
|
|
18352
18387
|
-1,
|
|
18353
|
-
|
|
18388
|
+
2,
|
|
18354
18389
|
0,
|
|
18355
18390
|
-1,
|
|
18356
18391
|
-1,
|
|
18357
18392
|
0,
|
|
18358
18393
|
0,
|
|
18359
|
-
1,
|
|
18360
|
-
1,
|
|
18361
|
-
1,
|
|
18362
|
-
1,
|
|
18363
18394
|
-1,
|
|
18364
|
-
|
|
18395
|
+
3,
|
|
18365
18396
|
0,
|
|
18366
|
-
|
|
18397
|
+
2
|
|
18367
18398
|
]); // left-top
|
|
18368
18399
|
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
18369
18400
|
blitMaterial._addReferCount(1);
|
|
@@ -18401,7 +18432,7 @@ __decorate([
|
|
|
18401
18432
|
new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
|
|
18402
18433
|
]);
|
|
18403
18434
|
mesh.setVertexBufferBinding(new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static), 16);
|
|
18404
|
-
mesh.addSubMesh(0,
|
|
18435
|
+
mesh.addSubMesh(0, 3, MeshTopology.Triangles);
|
|
18405
18436
|
return mesh;
|
|
18406
18437
|
};
|
|
18407
18438
|
_proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel) {
|
|
@@ -24856,6 +24887,472 @@ __decorate([
|
|
|
24856
24887
|
* */ LightManager._maxLight = 10;
|
|
24857
24888
|
})();
|
|
24858
24889
|
|
|
24890
|
+
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
|
|
24891
|
+
|
|
24892
|
+
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
|
|
24893
|
+
|
|
24894
|
+
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
|
|
24895
|
+
|
|
24896
|
+
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
|
|
24897
|
+
|
|
24898
|
+
var BloomDownScaleMode;
|
|
24899
|
+
(function(BloomDownScaleMode) {
|
|
24900
|
+
BloomDownScaleMode[BloomDownScaleMode[/**
|
|
24901
|
+
* Use this to select half size as the starting resolution.
|
|
24902
|
+
*/ "Half"] = 0] = "Half";
|
|
24903
|
+
BloomDownScaleMode[BloomDownScaleMode[/**
|
|
24904
|
+
* Use this to select quarter size as the starting resolution.
|
|
24905
|
+
*/ "Quarter"] = 1] = "Quarter";
|
|
24906
|
+
})(BloomDownScaleMode || (BloomDownScaleMode = {}));
|
|
24907
|
+
var BloomEffect = /*#__PURE__*/ function() {
|
|
24908
|
+
function BloomEffect(_uberMaterial) {
|
|
24909
|
+
this._uberMaterial = _uberMaterial;
|
|
24910
|
+
this._highQualityFiltering = false;
|
|
24911
|
+
this._mipDownRT = [];
|
|
24912
|
+
this._mipUpRT = [];
|
|
24913
|
+
this._maxIterations = 6;
|
|
24914
|
+
this._enabled = false;
|
|
24915
|
+
this./**
|
|
24916
|
+
* Controls the starting resolution that this effect begins processing.
|
|
24917
|
+
*/ downScale = 0;
|
|
24918
|
+
var engine = _uberMaterial.engine;
|
|
24919
|
+
var material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
|
|
24920
|
+
var depthState = material.renderState.depthState;
|
|
24921
|
+
depthState.enabled = false;
|
|
24922
|
+
depthState.writeEnabled = false;
|
|
24923
|
+
var bloomShaderData = material.shaderData;
|
|
24924
|
+
var uberShaderData = _uberMaterial.shaderData;
|
|
24925
|
+
bloomShaderData.setVector4(BloomEffect._bloomParams, new Vector4());
|
|
24926
|
+
bloomShaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
|
|
24927
|
+
uberShaderData.setVector4(BloomEffect._bloomIntensityParams, new Vector4(1, 1, 0, 0));
|
|
24928
|
+
uberShaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
|
|
24929
|
+
uberShaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));
|
|
24930
|
+
this._bloomMaterial = material;
|
|
24931
|
+
this.threshold = 0.9;
|
|
24932
|
+
this.scatter = 0.7;
|
|
24933
|
+
this.intensity = 1;
|
|
24934
|
+
this.dirtIntensity = 1;
|
|
24935
|
+
}
|
|
24936
|
+
var _proto = BloomEffect.prototype;
|
|
24937
|
+
_proto.onRender = function onRender(context, srcTexture) {
|
|
24938
|
+
var camera = context.camera;
|
|
24939
|
+
var downRes = this.downScale === 0 ? 1 : 2;
|
|
24940
|
+
var pixelViewport = camera.pixelViewport;
|
|
24941
|
+
var tw = pixelViewport.width >> downRes;
|
|
24942
|
+
var th = pixelViewport.height >> downRes;
|
|
24943
|
+
// Determine the iteration count
|
|
24944
|
+
var mipCount = this._calculateMipCount(tw, th);
|
|
24945
|
+
// Prefilter
|
|
24946
|
+
this._prefilter(camera, srcTexture, tw, th, mipCount);
|
|
24947
|
+
// Down sample - gaussian pyramid
|
|
24948
|
+
this._downsample(mipCount);
|
|
24949
|
+
// Up sample (bilinear by default, HQ filtering does bicubic instead
|
|
24950
|
+
this._upsample(mipCount);
|
|
24951
|
+
// Setup bloom on uber
|
|
24952
|
+
this._setupUber(camera);
|
|
24953
|
+
};
|
|
24954
|
+
_proto._calculateMipCount = function _calculateMipCount(tw, th) {
|
|
24955
|
+
var maxSize = Math.max(tw, th);
|
|
24956
|
+
var iterations = Math.floor(Math.log2(maxSize) - 1);
|
|
24957
|
+
return Math.min(Math.max(iterations, 1), this._maxIterations);
|
|
24958
|
+
};
|
|
24959
|
+
_proto._prefilter = function _prefilter(camera, srcTexture, tw, th, mipCount) {
|
|
24960
|
+
var engine = this._uberMaterial.engine;
|
|
24961
|
+
var internalColorTextureFormat = camera._getInternalColorTextureFormat();
|
|
24962
|
+
var mipWidth = tw, mipHeight = th;
|
|
24963
|
+
for(var i = 0; i < mipCount; i++){
|
|
24964
|
+
this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipUpRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
|
|
24965
|
+
this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipDownRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
|
|
24966
|
+
mipWidth = Math.max(1, Math.floor(mipWidth / 2));
|
|
24967
|
+
mipHeight = Math.max(1, Math.floor(mipHeight / 2));
|
|
24968
|
+
}
|
|
24969
|
+
PipelineUtils.blitTexture(engine, srcTexture, this._mipDownRT[0], undefined, undefined, this._bloomMaterial, 0);
|
|
24970
|
+
};
|
|
24971
|
+
_proto._downsample = function _downsample(mipCount) {
|
|
24972
|
+
var material = this._bloomMaterial;
|
|
24973
|
+
var engine = material.engine;
|
|
24974
|
+
var lastDown = this._mipDownRT[0];
|
|
24975
|
+
// Down sample - gaussian pyramid
|
|
24976
|
+
for(var i = 1; i < mipCount; i++){
|
|
24977
|
+
// Classic two pass gaussian blur - use mipUp as a temporary target
|
|
24978
|
+
// First pass does 2x downsampling + 9-tap gaussian
|
|
24979
|
+
// Second pass does 9-tap gaussian using a 5-tap filter + bilinear filtering
|
|
24980
|
+
PipelineUtils.blitTexture(engine, lastDown.getColorTexture(0), this._mipUpRT[i], undefined, undefined, material, 1);
|
|
24981
|
+
PipelineUtils.blitTexture(engine, this._mipUpRT[i].getColorTexture(0), this._mipDownRT[i], undefined, undefined, material, 2);
|
|
24982
|
+
lastDown = this._mipDownRT[i];
|
|
24983
|
+
}
|
|
24984
|
+
};
|
|
24985
|
+
_proto._upsample = function _upsample(mipCount) {
|
|
24986
|
+
var material = this._bloomMaterial;
|
|
24987
|
+
var engine = material.engine;
|
|
24988
|
+
var shaderData = material.shaderData;
|
|
24989
|
+
// Up sample (bilinear by default, HQ filtering does bicubic instead
|
|
24990
|
+
for(var i = mipCount - 2; i >= 0; i--){
|
|
24991
|
+
var lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
|
|
24992
|
+
var highMip = this._mipDownRT[i];
|
|
24993
|
+
var dst = this._mipUpRT[i];
|
|
24994
|
+
shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
|
|
24995
|
+
if (this.highQualityFiltering) {
|
|
24996
|
+
var texelSizeLow = shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
|
|
24997
|
+
texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
|
|
24998
|
+
}
|
|
24999
|
+
PipelineUtils.blitTexture(engine, highMip.getColorTexture(0), dst, undefined, undefined, material, 3);
|
|
25000
|
+
}
|
|
25001
|
+
};
|
|
25002
|
+
_proto._setupUber = function _setupUber(camera) {
|
|
25003
|
+
var shaderData = this._uberMaterial.shaderData;
|
|
25004
|
+
var dirtTexture = this.dirtTexture;
|
|
25005
|
+
if (dirtTexture) {
|
|
25006
|
+
var dirtTilingOffset = shaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
|
|
25007
|
+
var dirtRatio = dirtTexture.width / dirtTexture.height;
|
|
25008
|
+
var screenRatio = camera.aspectRatio;
|
|
25009
|
+
if (dirtRatio > screenRatio) {
|
|
25010
|
+
dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
|
|
25011
|
+
} else if (dirtRatio < screenRatio) {
|
|
25012
|
+
dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
|
|
25013
|
+
} else {
|
|
25014
|
+
dirtTilingOffset.set(1, 1, 0, 0);
|
|
25015
|
+
}
|
|
25016
|
+
}
|
|
25017
|
+
shaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
|
|
25018
|
+
};
|
|
25019
|
+
_proto._releaseRenderTargets = function _releaseRenderTargets() {
|
|
25020
|
+
var length = this._mipDownRT.length;
|
|
25021
|
+
for(var i = 0; i < length; i++){
|
|
25022
|
+
var downRT = this._mipDownRT[i];
|
|
25023
|
+
var upRT = this._mipUpRT[i];
|
|
25024
|
+
if (downRT) {
|
|
25025
|
+
downRT.getColorTexture(0).destroy(true);
|
|
25026
|
+
downRT.destroy(true);
|
|
25027
|
+
}
|
|
25028
|
+
if (upRT) {
|
|
25029
|
+
upRT.getColorTexture(0).destroy(true);
|
|
25030
|
+
upRT.destroy(true);
|
|
25031
|
+
}
|
|
25032
|
+
}
|
|
25033
|
+
this._mipDownRT.length = 0;
|
|
25034
|
+
this._mipUpRT.length = 0;
|
|
25035
|
+
};
|
|
25036
|
+
_create_class(BloomEffect, [
|
|
25037
|
+
{
|
|
25038
|
+
key: "enabled",
|
|
25039
|
+
get: /**
|
|
25040
|
+
* Indicates whether the post process effect is enabled.
|
|
25041
|
+
*/ function get() {
|
|
25042
|
+
return this._enabled;
|
|
25043
|
+
},
|
|
25044
|
+
set: function set(value) {
|
|
25045
|
+
if (value !== this._enabled) {
|
|
25046
|
+
this._enabled = value;
|
|
25047
|
+
if (value) {
|
|
25048
|
+
this._uberMaterial.shaderData.enableMacro(BloomEffect._enableMacro);
|
|
25049
|
+
} else {
|
|
25050
|
+
this._uberMaterial.shaderData.disableMacro(BloomEffect._enableMacro);
|
|
25051
|
+
this._releaseRenderTargets();
|
|
25052
|
+
}
|
|
25053
|
+
}
|
|
25054
|
+
}
|
|
25055
|
+
},
|
|
25056
|
+
{
|
|
25057
|
+
key: "threshold",
|
|
25058
|
+
get: /**
|
|
25059
|
+
* Set the level of brightness to filter out pixels under this level.
|
|
25060
|
+
* @remarks This value is expressed in gamma-space.
|
|
25061
|
+
*/ function get() {
|
|
25062
|
+
return this._threshold;
|
|
25063
|
+
},
|
|
25064
|
+
set: function set(value) {
|
|
25065
|
+
value = Math.max(0, value);
|
|
25066
|
+
if (value !== this._threshold) {
|
|
25067
|
+
this._threshold = value;
|
|
25068
|
+
var threshold = Color.gammaToLinearSpace(value);
|
|
25069
|
+
var thresholdKnee = threshold * 0.5; // Hardcoded soft knee
|
|
25070
|
+
var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
|
|
25071
|
+
params.x = threshold;
|
|
25072
|
+
params.y = thresholdKnee;
|
|
25073
|
+
}
|
|
25074
|
+
}
|
|
25075
|
+
},
|
|
25076
|
+
{
|
|
25077
|
+
key: "scatter",
|
|
25078
|
+
get: /**
|
|
25079
|
+
* Controls the radius of the bloom effect.
|
|
25080
|
+
*/ function get() {
|
|
25081
|
+
return this._scatter;
|
|
25082
|
+
},
|
|
25083
|
+
set: function set(value) {
|
|
25084
|
+
value = Math.min(Math.max(0, value), 1);
|
|
25085
|
+
if (value !== this._scatter) {
|
|
25086
|
+
this._scatter = value;
|
|
25087
|
+
var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
|
|
25088
|
+
var scatter = MathUtil.lerp(0.05, 0.95, value);
|
|
25089
|
+
params.z = scatter;
|
|
25090
|
+
}
|
|
25091
|
+
}
|
|
25092
|
+
},
|
|
25093
|
+
{
|
|
25094
|
+
key: "intensity",
|
|
25095
|
+
get: /**
|
|
25096
|
+
* Controls the strength of the bloom effect.
|
|
25097
|
+
*/ function get() {
|
|
25098
|
+
return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x;
|
|
25099
|
+
},
|
|
25100
|
+
set: function set(value) {
|
|
25101
|
+
value = Math.max(0, value);
|
|
25102
|
+
this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x = value;
|
|
25103
|
+
}
|
|
25104
|
+
},
|
|
25105
|
+
{
|
|
25106
|
+
key: "tint",
|
|
25107
|
+
get: /**
|
|
25108
|
+
* Specifies the tint of the bloom effect.
|
|
25109
|
+
*/ function get() {
|
|
25110
|
+
return this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
|
|
25111
|
+
},
|
|
25112
|
+
set: function set(value) {
|
|
25113
|
+
var tint = this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
|
|
25114
|
+
if (value !== tint) {
|
|
25115
|
+
tint.copyFrom(value);
|
|
25116
|
+
}
|
|
25117
|
+
}
|
|
25118
|
+
},
|
|
25119
|
+
{
|
|
25120
|
+
key: "highQualityFiltering",
|
|
25121
|
+
get: /**
|
|
25122
|
+
* Controls whether to use bicubic sampling instead of bilinear sampling for the upSampling passes.
|
|
25123
|
+
* @remarks This is slightly more expensive but helps getting smoother visuals.
|
|
25124
|
+
*/ function get() {
|
|
25125
|
+
return this._highQualityFiltering;
|
|
25126
|
+
},
|
|
25127
|
+
set: function set(value) {
|
|
25128
|
+
if (value !== this._highQualityFiltering) {
|
|
25129
|
+
this._highQualityFiltering = value;
|
|
25130
|
+
if (value) {
|
|
25131
|
+
this._bloomMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
|
|
25132
|
+
this._uberMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
|
|
25133
|
+
} else {
|
|
25134
|
+
this._bloomMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
|
|
25135
|
+
this._uberMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
|
|
25136
|
+
}
|
|
25137
|
+
}
|
|
25138
|
+
}
|
|
25139
|
+
},
|
|
25140
|
+
{
|
|
25141
|
+
key: "dirtTexture",
|
|
25142
|
+
get: /**
|
|
25143
|
+
* Specifies a Texture to add smudges or dust to the bloom effect.
|
|
25144
|
+
*/ function get() {
|
|
25145
|
+
return this._uberMaterial.shaderData.getTexture(BloomEffect._dirtTextureProp);
|
|
25146
|
+
},
|
|
25147
|
+
set: function set(value) {
|
|
25148
|
+
this._uberMaterial.shaderData.setTexture(BloomEffect._dirtTextureProp, value);
|
|
25149
|
+
if (value) {
|
|
25150
|
+
this._uberMaterial.shaderData.enableMacro(BloomEffect._dirtMacro);
|
|
25151
|
+
} else {
|
|
25152
|
+
this._uberMaterial.shaderData.disableMacro(BloomEffect._dirtMacro);
|
|
25153
|
+
}
|
|
25154
|
+
}
|
|
25155
|
+
},
|
|
25156
|
+
{
|
|
25157
|
+
key: "dirtIntensity",
|
|
25158
|
+
get: /**
|
|
25159
|
+
* Controls the strength of the lens dirt.
|
|
25160
|
+
*/ function get() {
|
|
25161
|
+
return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y;
|
|
25162
|
+
},
|
|
25163
|
+
set: function set(value) {
|
|
25164
|
+
value = Math.max(0, value);
|
|
25165
|
+
this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y = value;
|
|
25166
|
+
}
|
|
25167
|
+
}
|
|
25168
|
+
]);
|
|
25169
|
+
return BloomEffect;
|
|
25170
|
+
}();
|
|
25171
|
+
(function() {
|
|
25172
|
+
BloomEffect.SHADER_NAME = "PostProcessEffect Bloom";
|
|
25173
|
+
})();
|
|
25174
|
+
(function() {
|
|
25175
|
+
// Bloom shader properties
|
|
25176
|
+
BloomEffect._hqMacro = ShaderMacro.getByName("BLOOM_HQ");
|
|
25177
|
+
})();
|
|
25178
|
+
(function() {
|
|
25179
|
+
BloomEffect._dirtMacro = ShaderMacro.getByName("BLOOM_DIRT");
|
|
25180
|
+
})();
|
|
25181
|
+
(function() {
|
|
25182
|
+
BloomEffect._bloomParams = ShaderProperty.getByName("material_BloomParams") // x: threshold (linear), y: threshold knee, z: scatter
|
|
25183
|
+
;
|
|
25184
|
+
})();
|
|
25185
|
+
(function() {
|
|
25186
|
+
BloomEffect._lowMipTextureProp = ShaderProperty.getByName("material_lowMipTexture");
|
|
25187
|
+
})();
|
|
25188
|
+
(function() {
|
|
25189
|
+
BloomEffect._lowMipTexelSizeProp = ShaderProperty.getByName("material_lowMipTexelSize") // x: 1/width, y: 1/height, z: width, w: height
|
|
25190
|
+
;
|
|
25191
|
+
})();
|
|
25192
|
+
(function() {
|
|
25193
|
+
// Uber shader properties
|
|
25194
|
+
BloomEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_BLOOM");
|
|
25195
|
+
})();
|
|
25196
|
+
(function() {
|
|
25197
|
+
BloomEffect._bloomTextureProp = ShaderProperty.getByName("material_BloomTexture");
|
|
25198
|
+
})();
|
|
25199
|
+
(function() {
|
|
25200
|
+
BloomEffect._dirtTextureProp = ShaderProperty.getByName("material_BloomDirtTexture");
|
|
25201
|
+
})();
|
|
25202
|
+
(function() {
|
|
25203
|
+
BloomEffect._tintProp = ShaderProperty.getByName("material_BloomTint");
|
|
25204
|
+
})();
|
|
25205
|
+
(function() {
|
|
25206
|
+
BloomEffect._bloomIntensityParams = ShaderProperty.getByName("material_BloomIntensityParams") // x: bloom intensity, y: dirt intensity
|
|
25207
|
+
;
|
|
25208
|
+
})();
|
|
25209
|
+
(function() {
|
|
25210
|
+
BloomEffect._dirtTilingOffsetProp = ShaderProperty.getByName("material_BloomDirtTilingOffset");
|
|
25211
|
+
})();
|
|
25212
|
+
Shader.create(BloomEffect.SHADER_NAME, [
|
|
25213
|
+
new ShaderPass("Bloom Prefilter", blitVs, fragPrefilter),
|
|
25214
|
+
new ShaderPass("Bloom Blur Horizontal", blitVs, fragBlurH),
|
|
25215
|
+
new ShaderPass("Bloom Blur Vertical", blitVs, fragBlurV),
|
|
25216
|
+
new ShaderPass("Bloom Upsample", blitVs, fragUpsample)
|
|
25217
|
+
]);
|
|
25218
|
+
|
|
25219
|
+
var TonemappingMode;
|
|
25220
|
+
(function(TonemappingMode) {
|
|
25221
|
+
TonemappingMode[TonemappingMode[/**
|
|
25222
|
+
* Neutral tonemapper
|
|
25223
|
+
* @remarks Use this option if you only want range-remapping with minimal impact on color hue and saturation.
|
|
25224
|
+
*/ "Neutral"] = 0] = "Neutral";
|
|
25225
|
+
TonemappingMode[TonemappingMode[/**
|
|
25226
|
+
* ACES Filmic reference tonemapper (custom approximation)
|
|
25227
|
+
* @remarks
|
|
25228
|
+
* Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
|
|
25229
|
+
* It is more contrasted than Neutral and has an effect on actual color hue and saturation.
|
|
25230
|
+
*/ "ACES"] = 1] = "ACES";
|
|
25231
|
+
})(TonemappingMode || (TonemappingMode = {}));
|
|
25232
|
+
var TonemappingEffect = /*#__PURE__*/ function() {
|
|
25233
|
+
function TonemappingEffect(_uberMaterial) {
|
|
25234
|
+
this._uberMaterial = _uberMaterial;
|
|
25235
|
+
this._enabled = false;
|
|
25236
|
+
this.mode = 0;
|
|
25237
|
+
}
|
|
25238
|
+
_create_class(TonemappingEffect, [
|
|
25239
|
+
{
|
|
25240
|
+
key: "enabled",
|
|
25241
|
+
get: /**
|
|
25242
|
+
* Indicates whether the post process effect is enabled.
|
|
25243
|
+
*/ function get() {
|
|
25244
|
+
return this._enabled;
|
|
25245
|
+
},
|
|
25246
|
+
set: function set(value) {
|
|
25247
|
+
if (value !== this._enabled) {
|
|
25248
|
+
this._enabled = value;
|
|
25249
|
+
if (value) {
|
|
25250
|
+
this._uberMaterial.shaderData.enableMacro(TonemappingEffect._enableMacro);
|
|
25251
|
+
} else {
|
|
25252
|
+
this._uberMaterial.shaderData.disableMacro(TonemappingEffect._enableMacro);
|
|
25253
|
+
}
|
|
25254
|
+
}
|
|
25255
|
+
}
|
|
25256
|
+
},
|
|
25257
|
+
{
|
|
25258
|
+
key: "mode",
|
|
25259
|
+
get: /**
|
|
25260
|
+
* Use this to select a tonemapping algorithm to use.
|
|
25261
|
+
*/ function get() {
|
|
25262
|
+
return this._mode;
|
|
25263
|
+
},
|
|
25264
|
+
set: function set(value) {
|
|
25265
|
+
if (value !== this._mode) {
|
|
25266
|
+
this._mode = value;
|
|
25267
|
+
this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE", value.toString());
|
|
25268
|
+
}
|
|
25269
|
+
}
|
|
25270
|
+
}
|
|
25271
|
+
]);
|
|
25272
|
+
return TonemappingEffect;
|
|
25273
|
+
}();
|
|
25274
|
+
(function() {
|
|
25275
|
+
TonemappingEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_TONEMAPPING");
|
|
25276
|
+
})();
|
|
25277
|
+
|
|
25278
|
+
/**
|
|
25279
|
+
* @internal
|
|
25280
|
+
*/ var _PostProcessManager = /*#__PURE__*/ function() {
|
|
25281
|
+
function _PostProcessManager(scene) {
|
|
25282
|
+
this.scene = scene;
|
|
25283
|
+
var uberShader = Shader.find(_PostProcessManager.UBER_SHADER_NAME);
|
|
25284
|
+
var uberMaterial = new Material(scene.engine, uberShader);
|
|
25285
|
+
var depthState = uberMaterial.renderState.depthState;
|
|
25286
|
+
depthState.enabled = false;
|
|
25287
|
+
depthState.writeEnabled = false;
|
|
25288
|
+
var bloomEffect = new BloomEffect(uberMaterial);
|
|
25289
|
+
var tonemappingEffect = new TonemappingEffect(uberMaterial);
|
|
25290
|
+
this._uberMaterial = uberMaterial;
|
|
25291
|
+
this._bloomEffect = bloomEffect;
|
|
25292
|
+
this._tonemappingEffect = tonemappingEffect;
|
|
25293
|
+
}
|
|
25294
|
+
var _proto = _PostProcessManager.prototype;
|
|
25295
|
+
/**
|
|
25296
|
+
* @internal
|
|
25297
|
+
*/ _proto._render = function _render(context, srcTarget, destTarget) {
|
|
25298
|
+
var camera = context.camera;
|
|
25299
|
+
var engine = camera.engine;
|
|
25300
|
+
// Should blit to resolve the MSAA
|
|
25301
|
+
srcTarget._blitRenderTarget();
|
|
25302
|
+
var srcTexture = srcTarget.getColorTexture();
|
|
25303
|
+
var bloomEffect = this._bloomEffect;
|
|
25304
|
+
if (bloomEffect.enabled) {
|
|
25305
|
+
bloomEffect.onRender(context, srcTexture);
|
|
25306
|
+
}
|
|
25307
|
+
// Done with Uber, blit it
|
|
25308
|
+
PipelineUtils.blitTexture(engine, srcTexture, destTarget, 0, camera.viewport, this._uberMaterial);
|
|
25309
|
+
};
|
|
25310
|
+
_create_class(_PostProcessManager, [
|
|
25311
|
+
{
|
|
25312
|
+
key: "hasActiveEffect",
|
|
25313
|
+
get: /**
|
|
25314
|
+
* Whether has active post process effect.
|
|
25315
|
+
*/ function get() {
|
|
25316
|
+
return this._bloomEffect.enabled || this._tonemappingEffect.enabled;
|
|
25317
|
+
}
|
|
25318
|
+
}
|
|
25319
|
+
]);
|
|
25320
|
+
return _PostProcessManager;
|
|
25321
|
+
}();
|
|
25322
|
+
(function() {
|
|
25323
|
+
_PostProcessManager.UBER_SHADER_NAME = "UberPost";
|
|
25324
|
+
})();
|
|
25325
|
+
|
|
25326
|
+
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
|
|
25327
|
+
|
|
25328
|
+
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
|
|
25329
|
+
|
|
25330
|
+
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
|
|
25331
|
+
|
|
25332
|
+
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
|
|
25333
|
+
|
|
25334
|
+
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
|
|
25335
|
+
|
|
25336
|
+
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
|
|
25337
|
+
|
|
25338
|
+
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
|
|
25339
|
+
|
|
25340
|
+
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
|
|
25341
|
+
|
|
25342
|
+
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
|
|
25343
|
+
|
|
25344
|
+
Object.assign(ShaderLib, {
|
|
25345
|
+
PostCommon: PostCommon,
|
|
25346
|
+
Filtering: Filtering,
|
|
25347
|
+
ODT: ODT,
|
|
25348
|
+
RRT: RRT,
|
|
25349
|
+
Tonescale: Tonescale,
|
|
25350
|
+
ColorTransform: ColorTransform,
|
|
25351
|
+
NeutralTonemapping: NeutralTonemapping,
|
|
25352
|
+
ACESTonemapping: ACESTonemapping
|
|
25353
|
+
});
|
|
25354
|
+
Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
|
|
25355
|
+
|
|
24859
25356
|
/**
|
|
24860
25357
|
* Scene.
|
|
24861
25358
|
*/ var Scene = /*#__PURE__*/ function(EngineObject1) {
|
|
@@ -24879,6 +25376,7 @@ __decorate([
|
|
|
24879
25376
|
/** @internal */ _this._isActiveInEngine = false;
|
|
24880
25377
|
/** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
|
|
24881
25378
|
/** @internal */ _this._rootEntities = [];
|
|
25379
|
+
/** @internal */ _this._postProcessManager = new _PostProcessManager(_assert_this_initialized(_this));
|
|
24882
25380
|
_this._background = new Background(_this._engine);
|
|
24883
25381
|
_this._shaderData = new ShaderData(ShaderDataGroup.Scene);
|
|
24884
25382
|
_this._shadowCascades = ShadowCascadesMode.NoCascades;
|
|
@@ -27808,7 +28306,8 @@ var AnimatorLayerBlendingMode;
|
|
|
27808
28306
|
eventHandler.event = event;
|
|
27809
28307
|
handlers.length = 0;
|
|
27810
28308
|
for(var j = scriptCount - 1; j >= 0; j--){
|
|
27811
|
-
var
|
|
28309
|
+
var script = scripts[j];
|
|
28310
|
+
var handler = script[funcName].bind(script);
|
|
27812
28311
|
handler && handlers.push(handler);
|
|
27813
28312
|
}
|
|
27814
28313
|
eventHandlers.push(eventHandler);
|
|
@@ -33606,5 +34105,5 @@ var cacheDir = new Vector3();
|
|
|
33606
34105
|
return CubeProbe;
|
|
33607
34106
|
}(Probe);
|
|
33608
34107
|
|
|
33609
|
-
export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraType, Canvas, CapsuleColliderShape, CharacterController, CircleShape, ClearableObjectPool, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
|
|
34108
|
+
export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraType, Canvas, CapsuleColliderShape, CharacterController, CircleShape, ClearableObjectPool, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, _PostProcessManager, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
|
|
33610
34109
|
//# sourceMappingURL=module.js.map
|