@galacean/engine 1.3.0-alpha.1 → 1.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +153 -57
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -7948,6 +7948,11 @@
|
|
|
7948
7948
|
StencilOperation[StencilOperation[/** Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value. */ "IncrementWrap"] = 6] = "IncrementWrap";
|
|
7949
7949
|
StencilOperation[StencilOperation[/** Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of 0. */ "DecrementWrap"] = 7] = "DecrementWrap";
|
|
7950
7950
|
})(exports.StencilOperation || (exports.StencilOperation = {}));
|
|
7951
|
+
exports.ShaderPlatformTarget = void 0;
|
|
7952
|
+
(function(ShaderPlatformTarget) {
|
|
7953
|
+
ShaderPlatformTarget[ShaderPlatformTarget["GLES100"] = 0] = "GLES100";
|
|
7954
|
+
ShaderPlatformTarget[ShaderPlatformTarget["GLES300"] = 1] = "GLES300";
|
|
7955
|
+
})(exports.ShaderPlatformTarget || (exports.ShaderPlatformTarget = {}));
|
|
7951
7956
|
/**
|
|
7952
7957
|
* Shader macro。
|
|
7953
7958
|
*/ var ShaderMacro = /*#__PURE__*/ function() {
|
|
@@ -7977,14 +7982,14 @@
|
|
|
7977
7982
|
maskMap.length++;
|
|
7978
7983
|
maskMap[index] = new Array(32);
|
|
7979
7984
|
}
|
|
7980
|
-
maskMap[index][bit] =
|
|
7985
|
+
maskMap[index][bit] = macro;
|
|
7981
7986
|
ShaderMacro._macroCounter++;
|
|
7982
7987
|
}
|
|
7983
7988
|
return macro;
|
|
7984
7989
|
};
|
|
7985
7990
|
/**
|
|
7986
7991
|
* @internal
|
|
7987
|
-
*/ ShaderMacro.
|
|
7992
|
+
*/ ShaderMacro._getMacrosElements = function _getMacrosElements(macros, out) {
|
|
7988
7993
|
var maskMap = ShaderMacro._macroMaskMap;
|
|
7989
7994
|
var mask = macros._mask;
|
|
7990
7995
|
out.length = 0;
|
|
@@ -8165,14 +8170,6 @@
|
|
|
8165
8170
|
};
|
|
8166
8171
|
return ShaderMacroCollection;
|
|
8167
8172
|
}();
|
|
8168
|
-
/**
|
|
8169
|
-
* Pipeline stage.
|
|
8170
|
-
*/ exports.PipelineStage = void 0;
|
|
8171
|
-
(function(PipelineStage) {
|
|
8172
|
-
PipelineStage[/** DepthOnly stage. */ "DepthOnly"] = "DepthOnly";
|
|
8173
|
-
PipelineStage[/** Shadow caster stage. */ "ShadowCaster"] = "ShadowCaster";
|
|
8174
|
-
PipelineStage[/** Forward shading stage. */ "Forward"] = "Forward";
|
|
8175
|
-
})(exports.PipelineStage || (exports.PipelineStage = {}));
|
|
8176
8173
|
function _extends$2() {
|
|
8177
8174
|
_extends$2 = Object.assign || function assign(target) {
|
|
8178
8175
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -8183,6 +8180,14 @@
|
|
|
8183
8180
|
};
|
|
8184
8181
|
return _extends$2.apply(this, arguments);
|
|
8185
8182
|
}
|
|
8183
|
+
/**
|
|
8184
|
+
* Pipeline stage.
|
|
8185
|
+
*/ exports.PipelineStage = void 0;
|
|
8186
|
+
(function(PipelineStage) {
|
|
8187
|
+
PipelineStage[/** DepthOnly stage. */ "DepthOnly"] = "DepthOnly";
|
|
8188
|
+
PipelineStage[/** Shadow caster stage. */ "ShadowCaster"] = "ShadowCaster";
|
|
8189
|
+
PipelineStage[/** Forward shading stage. */ "Forward"] = "Forward";
|
|
8190
|
+
})(exports.PipelineStage || (exports.PipelineStage = {}));
|
|
8186
8191
|
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;"; // eslint-disable-line
|
|
8187
8192
|
var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n"; // eslint-disable-line
|
|
8188
8193
|
var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n"; // eslint-disable-line
|
|
@@ -8230,7 +8235,7 @@
|
|
|
8230
8235
|
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
|
|
8231
8236
|
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
|
|
8232
8237
|
var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}"; // eslint-disable-line
|
|
8233
|
-
var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
|
|
8238
|
+
var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return max(specularColor*AB.x+AB.y,0.0);}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
|
|
8234
8239
|
var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
|
|
8235
8240
|
var PBRShaderLib = {
|
|
8236
8241
|
pbr_frag_define: pbr_frag_define,
|
|
@@ -8328,7 +8333,7 @@
|
|
|
8328
8333
|
var ShaderFactory = function ShaderFactory() {};
|
|
8329
8334
|
ShaderFactory.parseCustomMacros = function parseCustomMacros(macros) {
|
|
8330
8335
|
return macros.map(function(m) {
|
|
8331
|
-
return "#define " + m + "\n";
|
|
8336
|
+
return "#define " + (m.value ? m.name + " " + m.value : m.name) + "\n";
|
|
8332
8337
|
}).join("");
|
|
8333
8338
|
};
|
|
8334
8339
|
ShaderFactory.registerInclude = function registerInclude(includeName, includeSource) {
|
|
@@ -9105,29 +9110,48 @@
|
|
|
9105
9110
|
(function() {
|
|
9106
9111
|
ShaderProgram._counter = 0;
|
|
9107
9112
|
})();
|
|
9113
|
+
/**
|
|
9114
|
+
* @internal
|
|
9115
|
+
* Shader pass type
|
|
9116
|
+
*/ var ShaderType;
|
|
9117
|
+
(function(ShaderType) {
|
|
9118
|
+
ShaderType[ShaderType[/** init by glsl */ "Canonical"] = 0] = "Canonical";
|
|
9119
|
+
ShaderType[ShaderType[/** init by shader-lab */ "ShaderLab"] = 1] = "ShaderLab";
|
|
9120
|
+
})(ShaderType || (ShaderType = {}));
|
|
9108
9121
|
/**
|
|
9109
9122
|
* Shader pass containing vertex and fragment source.
|
|
9110
9123
|
*/ var ShaderPass = /*#__PURE__*/ function(ShaderPart1) {
|
|
9111
9124
|
_inherits$2(ShaderPass, ShaderPart1);
|
|
9112
|
-
function ShaderPass(nameOrVertexSource,
|
|
9125
|
+
function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSourceOrCode, fragmentSourceOrTagsOrVertexEntry, fragmentEntryOrTags, tags) {
|
|
9113
9126
|
var _this;
|
|
9114
9127
|
_this = ShaderPart1.call(this) || this;
|
|
9115
9128
|
/** @internal */ _this._shaderPassId = 0;
|
|
9116
9129
|
/** @internal */ _this._renderStateDataMap = {};
|
|
9117
9130
|
/** @internal */ _this._shaderProgramPools = [];
|
|
9131
|
+
_this._platformMacros = [];
|
|
9118
9132
|
_this._shaderPassId = ShaderPass._shaderPassCounter++;
|
|
9119
|
-
|
|
9133
|
+
_this._type = ShaderType.Canonical;
|
|
9134
|
+
if (typeof fragmentEntryOrTags === "string") {
|
|
9135
|
+
_this._name = nameOrVertexSource;
|
|
9136
|
+
_this._shaderLabSource = vertexSourceOrFragmentSourceOrCode;
|
|
9137
|
+
_this._vertexEntry = fragmentSourceOrTagsOrVertexEntry;
|
|
9138
|
+
_this._fragmentEntry = fragmentEntryOrTags;
|
|
9139
|
+
tags = _extends$2({
|
|
9140
|
+
pipelineStage: exports.PipelineStage.Forward
|
|
9141
|
+
}, tags);
|
|
9142
|
+
_this._type = ShaderType.ShaderLab;
|
|
9143
|
+
} else if (typeof fragmentSourceOrTagsOrVertexEntry === "string") {
|
|
9120
9144
|
_this._name = nameOrVertexSource;
|
|
9121
|
-
_this._vertexSource =
|
|
9122
|
-
_this._fragmentSource =
|
|
9123
|
-
tags =
|
|
9145
|
+
_this._vertexSource = vertexSourceOrFragmentSourceOrCode;
|
|
9146
|
+
_this._fragmentSource = fragmentSourceOrTagsOrVertexEntry;
|
|
9147
|
+
tags = fragmentEntryOrTags != null ? fragmentEntryOrTags : {
|
|
9124
9148
|
pipelineStage: exports.PipelineStage.Forward
|
|
9125
9149
|
};
|
|
9126
9150
|
} else {
|
|
9127
9151
|
_this._name = "Default";
|
|
9128
9152
|
_this._vertexSource = nameOrVertexSource;
|
|
9129
|
-
_this._fragmentSource =
|
|
9130
|
-
tags =
|
|
9153
|
+
_this._fragmentSource = vertexSourceOrFragmentSourceOrCode;
|
|
9154
|
+
tags = fragmentSourceOrTagsOrVertexEntry != null ? fragmentSourceOrTagsOrVertexEntry : {
|
|
9131
9155
|
pipelineStage: exports.PipelineStage.Forward
|
|
9132
9156
|
};
|
|
9133
9157
|
}
|
|
@@ -9145,9 +9169,51 @@
|
|
|
9145
9169
|
if (shaderProgram) {
|
|
9146
9170
|
return shaderProgram;
|
|
9147
9171
|
}
|
|
9172
|
+
if (this._type === ShaderType.Canonical) {
|
|
9173
|
+
shaderProgram = this._getCanonicalShaderProgram(engine, macroCollection);
|
|
9174
|
+
} else {
|
|
9175
|
+
shaderProgram = this._compileShaderProgram(engine, macroCollection, this._vertexEntry, this._fragmentEntry);
|
|
9176
|
+
}
|
|
9177
|
+
shaderProgramPool.cache(shaderProgram);
|
|
9178
|
+
return shaderProgram;
|
|
9179
|
+
};
|
|
9180
|
+
/**
|
|
9181
|
+
* @internal
|
|
9182
|
+
*/ _proto._destroy = function _destroy() {
|
|
9183
|
+
var shaderProgramPools = this._shaderProgramPools;
|
|
9184
|
+
for(var i = 0, n = shaderProgramPools.length; i < n; i++){
|
|
9185
|
+
shaderProgramPools[i]._destroy();
|
|
9186
|
+
}
|
|
9187
|
+
shaderProgramPools.length = 0;
|
|
9188
|
+
};
|
|
9189
|
+
/**
|
|
9190
|
+
* Shader Lab compilation
|
|
9191
|
+
*/ _proto._compileShaderProgram = function _compileShaderProgram(engine, macroCollection, vertexEntry, fragmentEntry) {
|
|
9148
9192
|
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
9149
|
-
var
|
|
9150
|
-
ShaderMacro.
|
|
9193
|
+
var macros = new Array();
|
|
9194
|
+
ShaderMacro._getMacrosElements(macroCollection, macros);
|
|
9195
|
+
this._platformMacros.length = 0;
|
|
9196
|
+
if (engine._hardwareRenderer.canIUse(exports.GLCapabilityType.shaderTextureLod)) {
|
|
9197
|
+
this._platformMacros.push("HAS_TEX_LOD");
|
|
9198
|
+
}
|
|
9199
|
+
if (engine._hardwareRenderer.canIUse(exports.GLCapabilityType.standardDerivatives)) {
|
|
9200
|
+
this._platformMacros.push("HAS_DERIVATIVES");
|
|
9201
|
+
}
|
|
9202
|
+
if (isWebGL2) {
|
|
9203
|
+
this._platformMacros.push("GRAPHICS_API_WEBGL2");
|
|
9204
|
+
} else {
|
|
9205
|
+
this._platformMacros.push("GRAPHICS_API_WEBGL1");
|
|
9206
|
+
}
|
|
9207
|
+
var start = performance.now();
|
|
9208
|
+
var _Shader__shaderLab__parseShaderPass = Shader._shaderLab._parseShaderPass(this._shaderLabSource, vertexEntry, fragmentEntry, macros, isWebGL2 ? exports.ShaderPlatformTarget.GLES300 : exports.ShaderPlatformTarget.GLES100, this._platformMacros), vertex = _Shader__shaderLab__parseShaderPass.vertex, fragment = _Shader__shaderLab__parseShaderPass.fragment;
|
|
9209
|
+
Logger.info("[ShaderLab compilation] cost time: " + (performance.now() - start) + "ms");
|
|
9210
|
+
return new ShaderProgram(engine, vertex, fragment);
|
|
9211
|
+
};
|
|
9212
|
+
// TODO: remove it after migrate all shader to `ShaderLab`.
|
|
9213
|
+
_proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
|
|
9214
|
+
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
9215
|
+
var macroNameList = new Array();
|
|
9216
|
+
ShaderMacro._getMacrosElements(macroCollection, macroNameList);
|
|
9151
9217
|
var macroNameStr = ShaderFactory.parseCustomMacros(macroNameList);
|
|
9152
9218
|
var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
|
|
9153
9219
|
var graphicAPI = isWebGL2 ? "#define GRAPHICS_API_WEBGL2" : "#define GRAPHICS_API_WEBGL1";
|
|
@@ -9164,19 +9230,9 @@
|
|
|
9164
9230
|
vertexSource = ShaderFactory.convertTo300(vertexSource);
|
|
9165
9231
|
fragmentSource = ShaderFactory.convertTo300(fragmentSource, true);
|
|
9166
9232
|
}
|
|
9167
|
-
shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
9168
|
-
shaderProgramPool.cache(shaderProgram);
|
|
9233
|
+
var shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
9169
9234
|
return shaderProgram;
|
|
9170
9235
|
};
|
|
9171
|
-
/**
|
|
9172
|
-
* @internal
|
|
9173
|
-
*/ _proto._destroy = function _destroy() {
|
|
9174
|
-
var shaderProgramPools = this._shaderProgramPools;
|
|
9175
|
-
for(var i = 0, n = shaderProgramPools.length; i < n; i++){
|
|
9176
|
-
shaderProgramPools[i]._destroy();
|
|
9177
|
-
}
|
|
9178
|
-
shaderProgramPools.length = 0;
|
|
9179
|
-
};
|
|
9180
9236
|
return ShaderPass;
|
|
9181
9237
|
}(ShaderPart);
|
|
9182
9238
|
(function() {
|
|
@@ -9872,45 +9928,44 @@
|
|
|
9872
9928
|
if (!Shader._shaderLab) {
|
|
9873
9929
|
throw "ShaderLab has not been set up yet.";
|
|
9874
9930
|
}
|
|
9875
|
-
var
|
|
9876
|
-
if (shaderMap[
|
|
9877
|
-
console.error('Shader named "' +
|
|
9931
|
+
var shaderContent = Shader._shaderLab._parseShaderContent(nameOrShaderSource);
|
|
9932
|
+
if (shaderMap[shaderContent.name]) {
|
|
9933
|
+
console.error('Shader named "' + shaderContent.name + '" already exists.');
|
|
9878
9934
|
return;
|
|
9879
9935
|
}
|
|
9880
|
-
var subShaderList =
|
|
9881
|
-
var passList =
|
|
9882
|
-
if (
|
|
9936
|
+
var subShaderList = shaderContent.subShaders.map(function(subShaderContent) {
|
|
9937
|
+
var passList = subShaderContent.passes.map(function(passInfo) {
|
|
9938
|
+
if (passInfo.isUsePass) {
|
|
9883
9939
|
var _Shader_find_subShaders_find, _Shader_find;
|
|
9884
9940
|
// Use pass reference
|
|
9885
|
-
var paths = passInfo.split("/");
|
|
9941
|
+
var paths = passInfo.name.split("/");
|
|
9886
9942
|
return (_Shader_find = Shader.find(paths[0])) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
|
|
9887
9943
|
return subShader.name === paths[1];
|
|
9888
9944
|
})) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
|
|
9889
9945
|
return pass.name === paths[2];
|
|
9890
9946
|
});
|
|
9891
9947
|
}
|
|
9892
|
-
var
|
|
9948
|
+
var shaderPassContent = new ShaderPass(passInfo.name, passInfo.contents, passInfo.vertexEntry, passInfo.fragmentEntry, passInfo.tags);
|
|
9893
9949
|
var renderStates = passInfo.renderStates;
|
|
9894
9950
|
var renderState = new RenderState();
|
|
9895
|
-
|
|
9951
|
+
shaderPassContent._renderState = renderState;
|
|
9896
9952
|
// Parse const render state
|
|
9897
|
-
var
|
|
9898
|
-
for(var k in
|
|
9899
|
-
Shader._applyConstRenderStates(renderState, parseInt(k),
|
|
9953
|
+
var constantMap = renderStates.constantMap, variableMap = renderStates.variableMap;
|
|
9954
|
+
for(var k in constantMap){
|
|
9955
|
+
Shader._applyConstRenderStates(renderState, parseInt(k), constantMap[k]);
|
|
9900
9956
|
}
|
|
9901
9957
|
// Parse variable render state
|
|
9902
|
-
var variableRenderStateInfo = renderStates[1];
|
|
9903
9958
|
var renderStateDataMap = {};
|
|
9904
|
-
for(var k1 in
|
|
9905
|
-
renderStateDataMap[k1] = ShaderProperty.getByName(
|
|
9959
|
+
for(var k1 in variableMap){
|
|
9960
|
+
renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
|
|
9906
9961
|
}
|
|
9907
|
-
|
|
9908
|
-
return
|
|
9962
|
+
shaderPassContent._renderStateDataMap = renderStateDataMap;
|
|
9963
|
+
return shaderPassContent;
|
|
9909
9964
|
});
|
|
9910
|
-
return new SubShader(
|
|
9965
|
+
return new SubShader(subShaderContent.name, passList, subShaderContent.tags);
|
|
9911
9966
|
});
|
|
9912
|
-
shader = new Shader(
|
|
9913
|
-
shaderMap[
|
|
9967
|
+
shader = new Shader(shaderContent.name, subShaderList);
|
|
9968
|
+
shaderMap[shaderContent.name] = shader;
|
|
9914
9969
|
return shader;
|
|
9915
9970
|
} else {
|
|
9916
9971
|
if (shaderMap[nameOrShaderSource]) {
|
|
@@ -12969,6 +13024,13 @@
|
|
|
12969
13024
|
MSAASamples[MSAASamples[/** Multi-sample anti-aliasing with 4 samples. */ "FourX"] = 4] = "FourX";
|
|
12970
13025
|
MSAASamples[MSAASamples[/** Multi-sample anti-aliasing with 8 samples. */ "EightX"] = 8] = "EightX";
|
|
12971
13026
|
})(exports.MSAASamples || (exports.MSAASamples = {}));
|
|
13027
|
+
/**
|
|
13028
|
+
* The strategy to use when a shader replacement fails.
|
|
13029
|
+
*/ exports.ReplacementFailureStrategy = void 0;
|
|
13030
|
+
(function(ReplacementFailureStrategy) {
|
|
13031
|
+
ReplacementFailureStrategy[ReplacementFailureStrategy[/** Keep the original shader. */ "KeepOriginalShader"] = 0] = "KeepOriginalShader";
|
|
13032
|
+
ReplacementFailureStrategy[ReplacementFailureStrategy[/** Do not render. */ "DoNotRender"] = 1] = "DoNotRender";
|
|
13033
|
+
})(exports.ReplacementFailureStrategy || (exports.ReplacementFailureStrategy = {}));
|
|
12972
13034
|
var _Camera;
|
|
12973
13035
|
var MathTemp = function MathTemp() {};
|
|
12974
13036
|
(function() {
|
|
@@ -13016,6 +13078,7 @@
|
|
|
13016
13078
|
/** @internal */ _this._virtualCamera = new VirtualCamera();
|
|
13017
13079
|
/** @internal */ _this._replacementShader = null;
|
|
13018
13080
|
/** @internal */ _this._replacementSubShaderTag = null;
|
|
13081
|
+
/** @internal */ _this._replacementFailureStrategy = null;
|
|
13019
13082
|
/** @internal */ _this._cameraIndex = -1;
|
|
13020
13083
|
_this._priority = 0;
|
|
13021
13084
|
_this._shaderData = new ShaderData(ShaderDataGroup.Camera);
|
|
@@ -13196,6 +13259,7 @@
|
|
|
13196
13259
|
context.virtualCamera = virtualCamera;
|
|
13197
13260
|
context.replacementShader = this._replacementShader;
|
|
13198
13261
|
context.replacementTag = this._replacementSubShaderTag;
|
|
13262
|
+
context.replacementFailureStrategy = this._replacementFailureStrategy;
|
|
13199
13263
|
// compute cull frustum.
|
|
13200
13264
|
if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
|
|
13201
13265
|
this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
|
|
@@ -13215,15 +13279,18 @@
|
|
|
13215
13279
|
this._renderPipeline.render(context, cubeFace, mipLevel, clearMask);
|
|
13216
13280
|
this._engine._renderCount++;
|
|
13217
13281
|
};
|
|
13218
|
-
_proto.setReplacementShader = function setReplacementShader(shader, replacementTag) {
|
|
13282
|
+
_proto.setReplacementShader = function setReplacementShader(shader, replacementTag, failureStrategy) {
|
|
13283
|
+
if (failureStrategy === void 0) failureStrategy = exports.ReplacementFailureStrategy.KeepOriginalShader;
|
|
13219
13284
|
this._replacementShader = shader;
|
|
13220
13285
|
this._replacementSubShaderTag = typeof replacementTag === "string" ? ShaderTagKey.getByName(replacementTag) : replacementTag;
|
|
13286
|
+
this._replacementFailureStrategy = failureStrategy;
|
|
13221
13287
|
};
|
|
13222
13288
|
/**
|
|
13223
13289
|
* Reset and clear the replacement shader.
|
|
13224
13290
|
*/ _proto.resetReplacementShader = function resetReplacementShader() {
|
|
13225
13291
|
this._replacementShader = null;
|
|
13226
13292
|
this._replacementSubShaderTag = null;
|
|
13293
|
+
this._replacementFailureStrategy = null;
|
|
13227
13294
|
};
|
|
13228
13295
|
/**
|
|
13229
13296
|
* @inheritdoc
|
|
@@ -13337,7 +13404,7 @@
|
|
|
13337
13404
|
this._checkMainCanvasAntialiasWaste();
|
|
13338
13405
|
};
|
|
13339
13406
|
_proto._checkMainCanvasAntialiasWaste = function _checkMainCanvasAntialiasWaste() {
|
|
13340
|
-
if (this.independentCanvasEnabled && Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
|
|
13407
|
+
if (this._phasedActiveInScene && this.independentCanvasEnabled && Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
|
|
13341
13408
|
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.");
|
|
13342
13409
|
}
|
|
13343
13410
|
};
|
|
@@ -15015,6 +15082,7 @@
|
|
|
15015
15082
|
break;
|
|
15016
15083
|
}
|
|
15017
15084
|
}
|
|
15085
|
+
context.replacementFailureStrategy === exports.ReplacementFailureStrategy.KeepOriginalShader && this.pushRenderElementByType(renderElement, subRenderElement, materialSubShader.passes, renderStates);
|
|
15018
15086
|
} else {
|
|
15019
15087
|
this.pushRenderElementByType(renderElement, subRenderElement, replacementSubShaders[0].passes, renderStates);
|
|
15020
15088
|
}
|
|
@@ -28021,7 +28089,7 @@
|
|
|
28021
28089
|
*/ _proto._initialize = function _initialize(configuration) {
|
|
28022
28090
|
var _this = this;
|
|
28023
28091
|
var shaderLab = configuration.shaderLab, physics = configuration.physics;
|
|
28024
|
-
if (shaderLab) {
|
|
28092
|
+
if (shaderLab && !Shader._shaderLab) {
|
|
28025
28093
|
Shader._shaderLab = shaderLab;
|
|
28026
28094
|
}
|
|
28027
28095
|
var initializePromises = new Array();
|
|
@@ -29941,6 +30009,9 @@
|
|
|
29941
30009
|
*/ var _PostProcessManager = /*#__PURE__*/ function() {
|
|
29942
30010
|
function _PostProcessManager(scene) {
|
|
29943
30011
|
this.scene = scene;
|
|
30012
|
+
this./**
|
|
30013
|
+
* Whether the post process manager is active.
|
|
30014
|
+
*/ isActive = true;
|
|
29944
30015
|
var uberShader = Shader.find(_PostProcessManager.UBER_SHADER_NAME);
|
|
29945
30016
|
var uberMaterial = new Material(scene.engine, uberShader);
|
|
29946
30017
|
var depthState = uberMaterial.renderState.depthState;
|
|
@@ -29974,7 +30045,7 @@
|
|
|
29974
30045
|
get: /**
|
|
29975
30046
|
* Whether has active post process effect.
|
|
29976
30047
|
*/ function get() {
|
|
29977
|
-
return this._bloomEffect.enabled || this._tonemappingEffect.enabled;
|
|
30048
|
+
return this.isActive && (this._bloomEffect.enabled || this._tonemappingEffect.enabled);
|
|
29978
30049
|
}
|
|
29979
30050
|
}
|
|
29980
30051
|
]);
|
|
@@ -38824,6 +38895,7 @@
|
|
|
38824
38895
|
RenderTarget: RenderTarget,
|
|
38825
38896
|
RenderTargetBlendState: RenderTargetBlendState,
|
|
38826
38897
|
get Renderer () { return exports.Renderer; },
|
|
38898
|
+
get ReplacementFailureStrategy () { return exports.ReplacementFailureStrategy; },
|
|
38827
38899
|
ResourceManager: ResourceManager,
|
|
38828
38900
|
ReturnableObjectPool: ReturnableObjectPool,
|
|
38829
38901
|
RotationOverLifetimeModule: RotationOverLifetimeModule,
|
|
@@ -38838,6 +38910,7 @@
|
|
|
38838
38910
|
ShaderMacro: ShaderMacro,
|
|
38839
38911
|
ShaderMacroCollection: ShaderMacroCollection,
|
|
38840
38912
|
ShaderPass: ShaderPass,
|
|
38913
|
+
get ShaderPlatformTarget () { return exports.ShaderPlatformTarget; },
|
|
38841
38914
|
ShaderProperty: ShaderProperty,
|
|
38842
38915
|
get ShaderPropertyType () { return exports.ShaderPropertyType; },
|
|
38843
38916
|
ShaderTagKey: ShaderTagKey,
|
|
@@ -47307,6 +47380,29 @@
|
|
|
47307
47380
|
if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
|
|
47308
47381
|
if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
|
|
47309
47382
|
}
|
|
47383
|
+
// Post Process
|
|
47384
|
+
var postProcessData = data.scene.postProcess;
|
|
47385
|
+
if (postProcessData) {
|
|
47386
|
+
// @ts-ignore
|
|
47387
|
+
var postProcessManager = scene._postProcessManager;
|
|
47388
|
+
var bloomEffect = postProcessManager._bloomEffect;
|
|
47389
|
+
var tonemappingEffect = postProcessManager._tonemappingEffect;
|
|
47390
|
+
postProcessManager.isActive = postProcessData.isActive;
|
|
47391
|
+
bloomEffect.enabled = postProcessData.bloom.enabled;
|
|
47392
|
+
bloomEffect.threshold = postProcessData.bloom.threshold;
|
|
47393
|
+
bloomEffect.scatter = postProcessData.bloom.scatter;
|
|
47394
|
+
bloomEffect.intensity = postProcessData.bloom.intensity;
|
|
47395
|
+
bloomEffect.tint.copyFrom(postProcessData.bloom.tint);
|
|
47396
|
+
bloomEffect.dirtIntensity = postProcessData.bloom.dirtIntensity;
|
|
47397
|
+
tonemappingEffect.enabled = postProcessData.tonemapping.enabled;
|
|
47398
|
+
tonemappingEffect.mode = postProcessData.tonemapping.mode;
|
|
47399
|
+
// @ts-ignore
|
|
47400
|
+
// prettier-ignore
|
|
47401
|
+
var dirtTexturePromise = resourceManager.getResourceByRef(postProcessData.bloom.dirtTexture).then(function(texture) {
|
|
47402
|
+
bloomEffect.dirtTexture = texture;
|
|
47403
|
+
});
|
|
47404
|
+
promises.push(dirtTexturePromise);
|
|
47405
|
+
}
|
|
47310
47406
|
return Promise.all(promises).then(function() {
|
|
47311
47407
|
resolve(scene);
|
|
47312
47408
|
});
|
|
@@ -47696,7 +47792,7 @@
|
|
|
47696
47792
|
], KHR_materials_anisotropy);
|
|
47697
47793
|
|
|
47698
47794
|
//@ts-ignore
|
|
47699
|
-
var version = "1.3.0-alpha.
|
|
47795
|
+
var version = "1.3.0-alpha.2";
|
|
47700
47796
|
console.log("Galacean engine version: " + version);
|
|
47701
47797
|
for(var key in CoreObjects){
|
|
47702
47798
|
Loader.registerClass(key, CoreObjects[key]);
|