@galacean/engine-core 1.0.0-beta.7 → 1.0.0-beta.9
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 +242 -101
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +242 -101
- package/dist/module.js +242 -101
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/2d/sprite/Sprite.d.ts +12 -2
- package/types/2d/sprite/SpriteMask.d.ts +15 -4
- package/types/2d/sprite/SpriteRenderer.d.ts +15 -4
- package/types/mesh/MeshRenderer.d.ts +7 -1
package/dist/module.js
CHANGED
|
@@ -7877,8 +7877,9 @@ var DynamicColliderConstraints;
|
|
|
7877
7877
|
}
|
|
7878
7878
|
var _proto = Light.prototype;
|
|
7879
7879
|
/**
|
|
7880
|
+
* Light Color, include intensity.
|
|
7880
7881
|
* @internal
|
|
7881
|
-
*/ _proto.
|
|
7882
|
+
*/ _proto._getLightIntensityColor = function _getLightIntensityColor() {
|
|
7882
7883
|
this._lightColor.r = this.color.r * this.intensity;
|
|
7883
7884
|
this._lightColor.g = this.color.g * this.intensity;
|
|
7884
7885
|
this._lightColor.b = this.color.b * this.intensity;
|
|
@@ -7948,15 +7949,21 @@ __decorate([
|
|
|
7948
7949
|
var cullingMaskStart = lightIndex * 2;
|
|
7949
7950
|
var colorStart = lightIndex * 3;
|
|
7950
7951
|
var directionStart = lightIndex * 3;
|
|
7951
|
-
var lightColor = this.
|
|
7952
|
+
var lightColor = this._getLightIntensityColor();
|
|
7952
7953
|
var direction = this.direction;
|
|
7953
7954
|
var data = DirectLight._combinedData;
|
|
7954
7955
|
var cullingMask = this.cullingMask;
|
|
7955
7956
|
data.cullingMask[cullingMaskStart] = cullingMask & 65535;
|
|
7956
7957
|
data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7958
|
+
if (this.engine.settings.colorSpace === ColorSpace.Linear) {
|
|
7959
|
+
data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
|
|
7960
|
+
data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
|
|
7961
|
+
data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
|
|
7962
|
+
} else {
|
|
7963
|
+
data.color[colorStart] = lightColor.r;
|
|
7964
|
+
data.color[colorStart + 1] = lightColor.g;
|
|
7965
|
+
data.color[colorStart + 2] = lightColor.b;
|
|
7966
|
+
}
|
|
7960
7967
|
data.direction[directionStart] = direction.x;
|
|
7961
7968
|
data.direction[directionStart + 1] = direction.y;
|
|
7962
7969
|
data.direction[directionStart + 2] = direction.z;
|
|
@@ -8045,15 +8052,21 @@ __decorate([
|
|
|
8045
8052
|
var colorStart = lightIndex * 3;
|
|
8046
8053
|
var positionStart = lightIndex * 3;
|
|
8047
8054
|
var distanceStart = lightIndex;
|
|
8048
|
-
var lightColor = this.
|
|
8055
|
+
var lightColor = this._getLightIntensityColor();
|
|
8049
8056
|
var lightPosition = this.position;
|
|
8050
8057
|
var data = PointLight._combinedData;
|
|
8051
8058
|
var cullingMask = this.cullingMask;
|
|
8052
8059
|
data.cullingMask[cullingMaskStart] = cullingMask & 65535;
|
|
8053
8060
|
data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8061
|
+
if (this.engine.settings.colorSpace === ColorSpace.Linear) {
|
|
8062
|
+
data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
|
|
8063
|
+
data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
|
|
8064
|
+
data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
|
|
8065
|
+
} else {
|
|
8066
|
+
data.color[colorStart] = lightColor.r;
|
|
8067
|
+
data.color[colorStart + 1] = lightColor.g;
|
|
8068
|
+
data.color[colorStart + 2] = lightColor.b;
|
|
8069
|
+
}
|
|
8057
8070
|
data.position[positionStart] = lightPosition.x;
|
|
8058
8071
|
data.position[positionStart + 1] = lightPosition.y;
|
|
8059
8072
|
data.position[positionStart + 2] = lightPosition.z;
|
|
@@ -8146,16 +8159,22 @@ __decorate([
|
|
|
8146
8159
|
var distanceStart = lightIndex;
|
|
8147
8160
|
var penumbraCosStart = lightIndex;
|
|
8148
8161
|
var angleCosStart = lightIndex;
|
|
8149
|
-
var
|
|
8162
|
+
var lightColor = this._getLightIntensityColor();
|
|
8150
8163
|
var position = this.position;
|
|
8151
8164
|
var direction = this.direction;
|
|
8152
8165
|
var data = SpotLight._combinedData;
|
|
8153
8166
|
var cullingMask = this.cullingMask;
|
|
8154
8167
|
data.cullingMask[cullingMaskStart] = cullingMask & 65535;
|
|
8155
8168
|
data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8169
|
+
if (this.engine.settings.colorSpace === ColorSpace.Linear) {
|
|
8170
|
+
data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
|
|
8171
|
+
data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
|
|
8172
|
+
data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
|
|
8173
|
+
} else {
|
|
8174
|
+
data.color[colorStart] = lightColor.r;
|
|
8175
|
+
data.color[colorStart + 1] = lightColor.g;
|
|
8176
|
+
data.color[colorStart + 2] = lightColor.b;
|
|
8177
|
+
}
|
|
8159
8178
|
data.position[positionStart] = position.x;
|
|
8160
8179
|
data.position[positionStart + 1] = position.y;
|
|
8161
8180
|
data.position[positionStart + 2] = position.z;
|
|
@@ -9513,11 +9532,11 @@ var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // esli
|
|
|
9513
9532
|
|
|
9514
9533
|
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);}\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
|
|
9515
9534
|
|
|
9516
|
-
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
|
|
9535
|
+
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
|
|
9517
9536
|
|
|
9518
9537
|
var transform_declare = "#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;"; // eslint-disable-line
|
|
9519
9538
|
|
|
9520
|
-
var color_share = "#define GLSLIFY 1\n#ifdef
|
|
9539
|
+
var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
|
|
9521
9540
|
|
|
9522
9541
|
var FogFragmentDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n"; // eslint-disable-line
|
|
9523
9542
|
|
|
@@ -9537,7 +9556,7 @@ var blendShape_input = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifde
|
|
|
9537
9556
|
|
|
9538
9557
|
var blendShape_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n"; // eslint-disable-line
|
|
9539
9558
|
|
|
9540
|
-
var color_vert = "#define GLSLIFY 1\n#ifdef
|
|
9559
|
+
var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n"; // eslint-disable-line
|
|
9541
9560
|
|
|
9542
9561
|
var FogVertex = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n"; // eslint-disable-line
|
|
9543
9562
|
|
|
@@ -9557,11 +9576,11 @@ var light_frag_define = "#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstr
|
|
|
9557
9576
|
|
|
9558
9577
|
var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n"; // eslint-disable-line
|
|
9559
9578
|
|
|
9560
|
-
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef
|
|
9579
|
+
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;"; // eslint-disable-line
|
|
9561
9580
|
|
|
9562
9581
|
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n"; // eslint-disable-line
|
|
9563
9582
|
|
|
9564
|
-
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN();vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv);\n#else\nvec3 N=getNormal();\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(scene_ShadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}\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]))continue;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}\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]))continue;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];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
9583
|
+
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(scene_ShadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}\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]))continue;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}\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]))continue;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];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
9565
9584
|
|
|
9566
9585
|
var noise_cellular = "#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n"; // eslint-disable-line
|
|
9567
9586
|
|
|
@@ -9597,7 +9616,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
|
|
|
9597
9616
|
|
|
9598
9617
|
var pbr_frag_define = "#define GLSLIFY 1\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;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\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\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\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};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
9599
9618
|
|
|
9600
|
-
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 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\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);\n#else\ngeometry.clearCoatNormal=getNormal();\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in 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));\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
|
|
9619
|
+
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 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\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}void initMaterial(out Material material,const in 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));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(F0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
9601
9620
|
|
|
9602
9621
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+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);}float 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);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
9603
9622
|
|
|
@@ -9605,7 +9624,7 @@ var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragment
|
|
|
9605
9624
|
|
|
9606
9625
|
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 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,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
|
|
9607
9626
|
|
|
9608
|
-
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);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.viewDir,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.viewDir,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(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
|
|
9627
|
+
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.viewDir,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.viewDir,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(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
|
|
9609
9628
|
|
|
9610
9629
|
var PBRShaderLib = {
|
|
9611
9630
|
pbr_frag_define: pbr_frag_define,
|
|
@@ -9634,7 +9653,7 @@ var ShadowLib = {
|
|
|
9634
9653
|
ShadowVertex: ShadowVertex
|
|
9635
9654
|
};
|
|
9636
9655
|
|
|
9637
|
-
var normal_get = "#define GLSLIFY 1\nvec3 getNormal(){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(
|
|
9656
|
+
var normal_get = "#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"; // eslint-disable-line
|
|
9638
9657
|
|
|
9639
9658
|
var ShaderLib = _extends({
|
|
9640
9659
|
common: common,
|
|
@@ -11172,8 +11191,10 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11172
11191
|
_this = Renderer.call(this, entity) || this;
|
|
11173
11192
|
/** The mask layers the sprite mask influence to. */ _this.influenceLayers = SpriteMaskLayer.Everything;
|
|
11174
11193
|
_this._sprite = null;
|
|
11175
|
-
_this.
|
|
11176
|
-
_this.
|
|
11194
|
+
_this._automaticWidth = 0;
|
|
11195
|
+
_this._automaticHeight = 0;
|
|
11196
|
+
_this._customWidth = undefined;
|
|
11197
|
+
_this._customHeight = undefined;
|
|
11177
11198
|
_this._flipX = false;
|
|
11178
11199
|
_this._flipY = false;
|
|
11179
11200
|
_this._alphaCutoff = 0.5;
|
|
@@ -11193,12 +11214,11 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11193
11214
|
/**
|
|
11194
11215
|
* @internal
|
|
11195
11216
|
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
11196
|
-
|
|
11197
|
-
|
|
11217
|
+
if (this.sprite) {
|
|
11218
|
+
SimpleSpriteAssembler.updatePositions(this);
|
|
11219
|
+
} else {
|
|
11198
11220
|
worldBounds.min.set(0, 0, 0);
|
|
11199
11221
|
worldBounds.max.set(0, 0, 0);
|
|
11200
|
-
} else {
|
|
11201
|
-
SimpleSpriteAssembler.updatePositions(this);
|
|
11202
11222
|
}
|
|
11203
11223
|
};
|
|
11204
11224
|
/**
|
|
@@ -11209,12 +11229,12 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11209
11229
|
if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
|
|
11210
11230
|
return;
|
|
11211
11231
|
}
|
|
11212
|
-
// Update position
|
|
11232
|
+
// Update position
|
|
11213
11233
|
if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
|
|
11214
11234
|
SimpleSpriteAssembler.updatePositions(this);
|
|
11215
11235
|
this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
|
|
11216
11236
|
}
|
|
11217
|
-
// Update uv
|
|
11237
|
+
// Update uv
|
|
11218
11238
|
if (this._dirtyUpdateFlag & 0x2) {
|
|
11219
11239
|
SimpleSpriteAssembler.updateUVs(this);
|
|
11220
11240
|
this._dirtyUpdateFlag &= ~0x2;
|
|
@@ -11237,11 +11257,27 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11237
11257
|
this._sprite = null;
|
|
11238
11258
|
this._verticesData = null;
|
|
11239
11259
|
};
|
|
11260
|
+
_proto._calDefaultSize = function _calDefaultSize() {
|
|
11261
|
+
var sprite = this._sprite;
|
|
11262
|
+
if (sprite) {
|
|
11263
|
+
this._automaticWidth = sprite.width;
|
|
11264
|
+
this._automaticHeight = sprite.height;
|
|
11265
|
+
} else {
|
|
11266
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
11267
|
+
}
|
|
11268
|
+
this._dirtyUpdateFlag &= ~0x4;
|
|
11269
|
+
};
|
|
11240
11270
|
_proto._onSpriteChange = function _onSpriteChange(type) {
|
|
11241
11271
|
switch(type){
|
|
11242
11272
|
case SpriteModifyFlags.texture:
|
|
11243
11273
|
this.shaderData.setTexture(SpriteMask._textureProperty, this.sprite.texture);
|
|
11244
11274
|
break;
|
|
11275
|
+
case SpriteModifyFlags.size:
|
|
11276
|
+
this._dirtyUpdateFlag |= 0x4;
|
|
11277
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
11278
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11279
|
+
}
|
|
11280
|
+
break;
|
|
11245
11281
|
case SpriteModifyFlags.region:
|
|
11246
11282
|
case SpriteModifyFlags.atlasRegionOffset:
|
|
11247
11283
|
this._dirtyUpdateFlag |= 0x3;
|
|
@@ -11249,22 +11285,31 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11249
11285
|
case SpriteModifyFlags.atlasRegion:
|
|
11250
11286
|
this._dirtyUpdateFlag |= 0x2;
|
|
11251
11287
|
break;
|
|
11288
|
+
case SpriteModifyFlags.pivot:
|
|
11289
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11290
|
+
break;
|
|
11252
11291
|
}
|
|
11253
11292
|
};
|
|
11254
11293
|
_create_class(SpriteMask, [
|
|
11255
11294
|
{
|
|
11256
11295
|
key: "width",
|
|
11257
11296
|
get: /**
|
|
11258
|
-
* Render width.
|
|
11297
|
+
* Render width (in world coordinates).
|
|
11298
|
+
*
|
|
11299
|
+
* @remarks
|
|
11300
|
+
* If width is set, return the set value,
|
|
11301
|
+
* otherwise return `SpriteMask.sprite.width`.
|
|
11259
11302
|
*/ function get() {
|
|
11260
|
-
if (this.
|
|
11261
|
-
|
|
11303
|
+
if (this._customWidth !== undefined) {
|
|
11304
|
+
return this._customWidth;
|
|
11305
|
+
} else {
|
|
11306
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
11307
|
+
return this._automaticWidth;
|
|
11262
11308
|
}
|
|
11263
|
-
return this._width;
|
|
11264
11309
|
},
|
|
11265
11310
|
set: function set(value) {
|
|
11266
|
-
if (this.
|
|
11267
|
-
this.
|
|
11311
|
+
if (this._customWidth !== value) {
|
|
11312
|
+
this._customWidth = value;
|
|
11268
11313
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11269
11314
|
}
|
|
11270
11315
|
}
|
|
@@ -11272,16 +11317,22 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11272
11317
|
{
|
|
11273
11318
|
key: "height",
|
|
11274
11319
|
get: /**
|
|
11275
|
-
* Render height.
|
|
11320
|
+
* Render height (in world coordinates).
|
|
11321
|
+
*
|
|
11322
|
+
* @remarks
|
|
11323
|
+
* If height is set, return the set value,
|
|
11324
|
+
* otherwise return `SpriteMask.sprite.height`.
|
|
11276
11325
|
*/ function get() {
|
|
11277
|
-
if (this.
|
|
11278
|
-
|
|
11326
|
+
if (this._customHeight !== undefined) {
|
|
11327
|
+
return this._customHeight;
|
|
11328
|
+
} else {
|
|
11329
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
11330
|
+
return this._automaticHeight;
|
|
11279
11331
|
}
|
|
11280
|
-
return this._height;
|
|
11281
11332
|
},
|
|
11282
11333
|
set: function set(value) {
|
|
11283
|
-
if (this.
|
|
11284
|
-
this.
|
|
11334
|
+
if (this._customHeight !== value) {
|
|
11335
|
+
this._customHeight = value;
|
|
11285
11336
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11286
11337
|
}
|
|
11287
11338
|
}
|
|
@@ -11325,9 +11376,9 @@ SimpleSpriteAssembler = __decorate([
|
|
|
11325
11376
|
var lastSprite = this._sprite;
|
|
11326
11377
|
if (lastSprite !== value) {
|
|
11327
11378
|
lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
11379
|
+
this._dirtyUpdateFlag |= 0x7;
|
|
11328
11380
|
if (value) {
|
|
11329
11381
|
value._updateFlagManager.addListener(this._onSpriteChange);
|
|
11330
|
-
this._dirtyUpdateFlag |= 0x3;
|
|
11331
11382
|
this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
|
|
11332
11383
|
} else {
|
|
11333
11384
|
this.shaderData.setTexture(SpriteMask._textureProperty, null);
|
|
@@ -11367,10 +11418,16 @@ __decorate([
|
|
|
11367
11418
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
11368
11419
|
__decorate([
|
|
11369
11420
|
ignoreClone
|
|
11370
|
-
], SpriteMask.prototype, "
|
|
11421
|
+
], SpriteMask.prototype, "_automaticWidth", void 0);
|
|
11371
11422
|
__decorate([
|
|
11372
11423
|
ignoreClone
|
|
11373
|
-
], SpriteMask.prototype, "
|
|
11424
|
+
], SpriteMask.prototype, "_automaticHeight", void 0);
|
|
11425
|
+
__decorate([
|
|
11426
|
+
assignmentClone
|
|
11427
|
+
], SpriteMask.prototype, "_customWidth", void 0);
|
|
11428
|
+
__decorate([
|
|
11429
|
+
assignmentClone
|
|
11430
|
+
], SpriteMask.prototype, "_customHeight", void 0);
|
|
11374
11431
|
__decorate([
|
|
11375
11432
|
assignmentClone
|
|
11376
11433
|
], SpriteMask.prototype, "_flipX", void 0);
|
|
@@ -11388,7 +11445,9 @@ var /**
|
|
|
11388
11445
|
*/ SpriteMaskUpdateFlags;
|
|
11389
11446
|
(function(SpriteMaskUpdateFlags) {
|
|
11390
11447
|
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
|
|
11391
|
-
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/**
|
|
11448
|
+
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
|
|
11449
|
+
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
|
|
11450
|
+
SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x7] = "All";
|
|
11392
11451
|
})(SpriteMaskUpdateFlags || (SpriteMaskUpdateFlags = {}));
|
|
11393
11452
|
|
|
11394
11453
|
/**
|
|
@@ -12195,6 +12254,7 @@ var MeshModifyFlags;
|
|
|
12195
12254
|
var subDataDirtyFlags = this._subDataDirtyFlags;
|
|
12196
12255
|
var blendShapeFloatStride = this._vertexElementCount * 3;
|
|
12197
12256
|
var blendShapeByteStride = blendShapeFloatStride * 4;
|
|
12257
|
+
var bufferOffset = this._bufferBindingOffset;
|
|
12198
12258
|
// @todo: should fix bug when dataChangedFlag is true
|
|
12199
12259
|
for(var i = 0, n = blendShapes.length; i < n; i++){
|
|
12200
12260
|
var dataChangedFlag = subDataDirtyFlags[i];
|
|
@@ -12212,7 +12272,7 @@ var MeshModifyFlags;
|
|
|
12212
12272
|
var offset = indexInBuffer * blendShapeFloatStride;
|
|
12213
12273
|
var storeInfo = storeInfos[i];
|
|
12214
12274
|
storeInfo || (storeInfos[i] = storeInfo = new Vector2());
|
|
12215
|
-
storeInfo.set(
|
|
12275
|
+
storeInfo.set(bufferOffset + bufferIndex, indexInBuffer * blendShapeByteStride); // BufferOffset is mesh vertexBuffer offset
|
|
12216
12276
|
var deltaPositions = endFrame.deltaPositions;
|
|
12217
12277
|
for(var j = 0; j < vertexCount; j++){
|
|
12218
12278
|
var start = offset + bufferFloatStride * j;
|
|
@@ -13489,6 +13549,7 @@ var VertexChangedFlags;
|
|
|
13489
13549
|
function MeshRenderer(entity) {
|
|
13490
13550
|
var _this;
|
|
13491
13551
|
_this = Renderer.call(this, entity) || this;
|
|
13552
|
+
_this._enableVertexColor = false;
|
|
13492
13553
|
_this._onMeshChanged = _this._onMeshChanged.bind(_assert_this_initialized(_this));
|
|
13493
13554
|
return _this;
|
|
13494
13555
|
}
|
|
@@ -13533,7 +13594,7 @@ var VertexChangedFlags;
|
|
|
13533
13594
|
shaderData.disableMacro(MeshRenderer._uv1Macro);
|
|
13534
13595
|
shaderData.disableMacro(MeshRenderer._normalMacro);
|
|
13535
13596
|
shaderData.disableMacro(MeshRenderer._tangentMacro);
|
|
13536
|
-
shaderData.disableMacro(MeshRenderer.
|
|
13597
|
+
shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
|
|
13537
13598
|
for(var i = 0, n = vertexElements.length; i < n; i++){
|
|
13538
13599
|
switch(vertexElements[i].semantic){
|
|
13539
13600
|
case "TEXCOORD_0":
|
|
@@ -13549,7 +13610,7 @@ var VertexChangedFlags;
|
|
|
13549
13610
|
shaderData.enableMacro(MeshRenderer._tangentMacro);
|
|
13550
13611
|
break;
|
|
13551
13612
|
case "COLOR_0":
|
|
13552
|
-
shaderData.enableMacro(MeshRenderer.
|
|
13613
|
+
this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
|
|
13553
13614
|
break;
|
|
13554
13615
|
}
|
|
13555
13616
|
}
|
|
@@ -13600,6 +13661,20 @@ var VertexChangedFlags;
|
|
|
13600
13661
|
this._setMesh(value);
|
|
13601
13662
|
}
|
|
13602
13663
|
}
|
|
13664
|
+
},
|
|
13665
|
+
{
|
|
13666
|
+
key: "enableVertexColor",
|
|
13667
|
+
get: /**
|
|
13668
|
+
* Whether enable vertex color.
|
|
13669
|
+
*/ function get() {
|
|
13670
|
+
return this._enableVertexColor;
|
|
13671
|
+
},
|
|
13672
|
+
set: function set(value) {
|
|
13673
|
+
if (value !== this._enableVertexColor) {
|
|
13674
|
+
this._dirtyUpdateFlag |= 0x2;
|
|
13675
|
+
this._enableVertexColor = value;
|
|
13676
|
+
}
|
|
13677
|
+
}
|
|
13603
13678
|
}
|
|
13604
13679
|
]);
|
|
13605
13680
|
return MeshRenderer;
|
|
@@ -13617,7 +13692,7 @@ var VertexChangedFlags;
|
|
|
13617
13692
|
MeshRenderer._tangentMacro = ShaderMacro.getByName("RENDERER_HAS_TANGENT");
|
|
13618
13693
|
})();
|
|
13619
13694
|
(function() {
|
|
13620
|
-
MeshRenderer.
|
|
13695
|
+
MeshRenderer._enableVertexColorMacro = ShaderMacro.getByName("RENDERER_ENABLE_VERTEXCOLOR");
|
|
13621
13696
|
})();
|
|
13622
13697
|
__decorate([
|
|
13623
13698
|
ignoreClone
|
|
@@ -16118,7 +16193,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
|
|
|
16118
16193
|
var sunLightIndex = lightManager._getSunLightIndex();
|
|
16119
16194
|
if (sunLightIndex !== -1) {
|
|
16120
16195
|
var sunlight = lightManager._directLights.get(sunLightIndex);
|
|
16121
|
-
shaderData.setColor(Scene._sunlightColorProperty, sunlight.
|
|
16196
|
+
shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
|
|
16122
16197
|
shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
|
|
16123
16198
|
this._sunLight = sunlight;
|
|
16124
16199
|
}
|
|
@@ -20393,8 +20468,10 @@ var TextVerticalAlignment;
|
|
|
20393
20468
|
if (name === void 0) name = null;
|
|
20394
20469
|
var _this;
|
|
20395
20470
|
_this = ReferResource.call(this, engine) || this;
|
|
20396
|
-
_this.
|
|
20397
|
-
_this.
|
|
20471
|
+
_this._automaticWidth = 0;
|
|
20472
|
+
_this._automaticHeight = 0;
|
|
20473
|
+
_this._customWidth = undefined;
|
|
20474
|
+
_this._customHeight = undefined;
|
|
20398
20475
|
_this._positions = [
|
|
20399
20476
|
new Vector2(),
|
|
20400
20477
|
new Vector2(),
|
|
@@ -20415,7 +20492,7 @@ var TextVerticalAlignment;
|
|
|
20415
20492
|
_this._region = new Rect(0, 0, 1, 1);
|
|
20416
20493
|
_this._pivot = new Vector2(0.5, 0.5);
|
|
20417
20494
|
_this._border = new Vector4(0, 0, 0, 0);
|
|
20418
|
-
_this._dirtyUpdateFlag =
|
|
20495
|
+
_this._dirtyUpdateFlag = 0x7;
|
|
20419
20496
|
/** @internal */ _this._updateFlagManager = new UpdateFlagManager();
|
|
20420
20497
|
_this._texture = texture;
|
|
20421
20498
|
region && _this._region.copyFrom(region);
|
|
@@ -20463,9 +20540,12 @@ var TextVerticalAlignment;
|
|
|
20463
20540
|
if (this._texture) {
|
|
20464
20541
|
var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
|
|
20465
20542
|
var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
|
|
20466
|
-
this.
|
|
20467
|
-
this.
|
|
20543
|
+
this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
|
|
20544
|
+
this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
|
|
20545
|
+
} else {
|
|
20546
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
20468
20547
|
}
|
|
20548
|
+
this._dirtyUpdateFlag &= ~0x4;
|
|
20469
20549
|
};
|
|
20470
20550
|
_proto._updatePositions = function _updatePositions() {
|
|
20471
20551
|
var blank = this._atlasRegionOffset;
|
|
@@ -20519,11 +20599,16 @@ var TextVerticalAlignment;
|
|
|
20519
20599
|
};
|
|
20520
20600
|
_proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
|
|
20521
20601
|
switch(type){
|
|
20602
|
+
case SpriteModifyFlags.texture:
|
|
20603
|
+
this._dirtyUpdateFlag |= 0x4;
|
|
20604
|
+
break;
|
|
20522
20605
|
case SpriteModifyFlags.atlasRegionOffset:
|
|
20523
20606
|
case SpriteModifyFlags.region:
|
|
20524
|
-
this._dirtyUpdateFlag |=
|
|
20607
|
+
this._dirtyUpdateFlag |= 0x7;
|
|
20525
20608
|
break;
|
|
20526
20609
|
case SpriteModifyFlags.atlasRegion:
|
|
20610
|
+
this._dirtyUpdateFlag |= 0x4 | 0x2;
|
|
20611
|
+
break;
|
|
20527
20612
|
case SpriteModifyFlags.border:
|
|
20528
20613
|
this._dirtyUpdateFlag |= 0x2;
|
|
20529
20614
|
break;
|
|
@@ -20542,7 +20627,9 @@ var TextVerticalAlignment;
|
|
|
20542
20627
|
if (this._texture !== value) {
|
|
20543
20628
|
this._texture = value;
|
|
20544
20629
|
this._dispatchSpriteChange(SpriteModifyFlags.texture);
|
|
20545
|
-
(this.
|
|
20630
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20631
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20632
|
+
}
|
|
20546
20633
|
}
|
|
20547
20634
|
}
|
|
20548
20635
|
},
|
|
@@ -20550,13 +20637,21 @@ var TextVerticalAlignment;
|
|
|
20550
20637
|
key: "width",
|
|
20551
20638
|
get: /**
|
|
20552
20639
|
* The width of the sprite (in world coordinates).
|
|
20640
|
+
*
|
|
20641
|
+
* @remarks
|
|
20642
|
+
* If width is set, return the set value,
|
|
20643
|
+
* otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
|
|
20553
20644
|
*/ function get() {
|
|
20554
|
-
this.
|
|
20555
|
-
|
|
20645
|
+
if (this._customWidth !== undefined) {
|
|
20646
|
+
return this._customWidth;
|
|
20647
|
+
} else {
|
|
20648
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
20649
|
+
return this._automaticWidth;
|
|
20650
|
+
}
|
|
20556
20651
|
},
|
|
20557
20652
|
set: function set(value) {
|
|
20558
|
-
if (this.
|
|
20559
|
-
this.
|
|
20653
|
+
if (this._customWidth !== value) {
|
|
20654
|
+
this._customWidth = value;
|
|
20560
20655
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20561
20656
|
}
|
|
20562
20657
|
}
|
|
@@ -20565,13 +20660,21 @@ var TextVerticalAlignment;
|
|
|
20565
20660
|
key: "height",
|
|
20566
20661
|
get: /**
|
|
20567
20662
|
* The height of the sprite (in world coordinates).
|
|
20663
|
+
*
|
|
20664
|
+
* @remarks
|
|
20665
|
+
* If height is set, return the set value,
|
|
20666
|
+
* otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
|
|
20568
20667
|
*/ function get() {
|
|
20569
|
-
this.
|
|
20570
|
-
|
|
20668
|
+
if (this._customHeight !== undefined) {
|
|
20669
|
+
return this._customHeight;
|
|
20670
|
+
} else {
|
|
20671
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
20672
|
+
return this._automaticHeight;
|
|
20673
|
+
}
|
|
20571
20674
|
},
|
|
20572
20675
|
set: function set(value) {
|
|
20573
|
-
if (this.
|
|
20574
|
-
this.
|
|
20676
|
+
if (this._customHeight !== value) {
|
|
20677
|
+
this._customHeight = value;
|
|
20575
20678
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20576
20679
|
}
|
|
20577
20680
|
}
|
|
@@ -20601,7 +20704,9 @@ var TextVerticalAlignment;
|
|
|
20601
20704
|
var y = MathUtil$1.clamp(value.y, 0, 1);
|
|
20602
20705
|
this._atlasRegion.set(x, y, MathUtil$1.clamp(value.width, 0, 1 - x), MathUtil$1.clamp(value.height, 0, 1 - y));
|
|
20603
20706
|
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
|
|
20604
|
-
(this.
|
|
20707
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20708
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20709
|
+
}
|
|
20605
20710
|
}
|
|
20606
20711
|
},
|
|
20607
20712
|
{
|
|
@@ -20616,7 +20721,9 @@ var TextVerticalAlignment;
|
|
|
20616
20721
|
var y = MathUtil$1.clamp(value.y, 0, 1);
|
|
20617
20722
|
this._atlasRegionOffset.set(x, y, MathUtil$1.clamp(value.z, 0, 1 - x), MathUtil$1.clamp(value.w, 0, 1 - y));
|
|
20618
20723
|
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
|
|
20619
|
-
(this.
|
|
20724
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20725
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20726
|
+
}
|
|
20620
20727
|
}
|
|
20621
20728
|
},
|
|
20622
20729
|
{
|
|
@@ -20632,7 +20739,9 @@ var TextVerticalAlignment;
|
|
|
20632
20739
|
var y = MathUtil$1.clamp(value.y, 0, 1);
|
|
20633
20740
|
region.set(x, y, MathUtil$1.clamp(value.width, 0, 1 - x), MathUtil$1.clamp(value.height, 0, 1 - y));
|
|
20634
20741
|
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
20635
|
-
(this.
|
|
20742
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
20743
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
20744
|
+
}
|
|
20636
20745
|
}
|
|
20637
20746
|
},
|
|
20638
20747
|
{
|
|
@@ -20682,7 +20791,8 @@ var SpriteUpdateFlags;
|
|
|
20682
20791
|
(function(SpriteUpdateFlags) {
|
|
20683
20792
|
SpriteUpdateFlags[SpriteUpdateFlags["positions"] = 0x1] = "positions";
|
|
20684
20793
|
SpriteUpdateFlags[SpriteUpdateFlags["uvs"] = 0x2] = "uvs";
|
|
20685
|
-
SpriteUpdateFlags[SpriteUpdateFlags["
|
|
20794
|
+
SpriteUpdateFlags[SpriteUpdateFlags["automaticSize"] = 0x4] = "automaticSize";
|
|
20795
|
+
SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x7] = "all";
|
|
20686
20796
|
})(SpriteUpdateFlags || (SpriteUpdateFlags = {}));
|
|
20687
20797
|
|
|
20688
20798
|
var _SlicedSpriteAssembler;
|
|
@@ -21174,8 +21284,10 @@ var TiledType;
|
|
|
21174
21284
|
_this._tiledAdaptiveThreshold = 0.5;
|
|
21175
21285
|
_this._color = new Color$1(1, 1, 1, 1);
|
|
21176
21286
|
_this._sprite = null;
|
|
21177
|
-
_this.
|
|
21178
|
-
_this.
|
|
21287
|
+
_this._automaticWidth = 0;
|
|
21288
|
+
_this._automaticHeight = 0;
|
|
21289
|
+
_this._customWidth = undefined;
|
|
21290
|
+
_this._customHeight = undefined;
|
|
21179
21291
|
_this._flipX = false;
|
|
21180
21292
|
_this._flipY = false;
|
|
21181
21293
|
_this._maskLayer = SpriteMaskLayer.Layer0;
|
|
@@ -21192,6 +21304,7 @@ var TiledType;
|
|
|
21192
21304
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
21193
21305
|
target._assembler.resetData(target);
|
|
21194
21306
|
target.sprite = this._sprite;
|
|
21307
|
+
target.drawMode = this._drawMode;
|
|
21195
21308
|
};
|
|
21196
21309
|
/**
|
|
21197
21310
|
* @internal
|
|
@@ -21202,12 +21315,11 @@ var TiledType;
|
|
|
21202
21315
|
/**
|
|
21203
21316
|
* @internal
|
|
21204
21317
|
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
21205
|
-
|
|
21206
|
-
|
|
21318
|
+
if (this.sprite) {
|
|
21319
|
+
this._assembler.updatePositions(this);
|
|
21320
|
+
} else {
|
|
21207
21321
|
worldBounds.min.set(0, 0, 0);
|
|
21208
21322
|
worldBounds.max.set(0, 0, 0);
|
|
21209
|
-
} else {
|
|
21210
|
-
this._assembler.updatePositions(this);
|
|
21211
21323
|
}
|
|
21212
21324
|
};
|
|
21213
21325
|
/**
|
|
@@ -21217,17 +21329,17 @@ var TiledType;
|
|
|
21217
21329
|
if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
|
|
21218
21330
|
return;
|
|
21219
21331
|
}
|
|
21220
|
-
// Update position
|
|
21332
|
+
// Update position
|
|
21221
21333
|
if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
|
|
21222
21334
|
this._assembler.updatePositions(this);
|
|
21223
21335
|
this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
|
|
21224
21336
|
}
|
|
21225
|
-
// Update uv
|
|
21337
|
+
// Update uv
|
|
21226
21338
|
if (this._dirtyUpdateFlag & 0x2) {
|
|
21227
21339
|
this._assembler.updateUVs(this);
|
|
21228
21340
|
this._dirtyUpdateFlag &= ~0x2;
|
|
21229
21341
|
}
|
|
21230
|
-
// Push
|
|
21342
|
+
// Push primitive
|
|
21231
21343
|
var material = this.getMaterial();
|
|
21232
21344
|
var texture = this.sprite.texture;
|
|
21233
21345
|
var renderData = this._engine._spriteRenderDataPool.getFromPool();
|
|
@@ -21245,6 +21357,16 @@ var TiledType;
|
|
|
21245
21357
|
this._assembler = null;
|
|
21246
21358
|
this._verticesData = null;
|
|
21247
21359
|
};
|
|
21360
|
+
_proto._calDefaultSize = function _calDefaultSize() {
|
|
21361
|
+
var sprite = this._sprite;
|
|
21362
|
+
if (sprite) {
|
|
21363
|
+
this._automaticWidth = sprite.width;
|
|
21364
|
+
this._automaticHeight = sprite.height;
|
|
21365
|
+
} else {
|
|
21366
|
+
this._automaticWidth = this._automaticHeight = 0;
|
|
21367
|
+
}
|
|
21368
|
+
this._dirtyUpdateFlag &= ~0x4;
|
|
21369
|
+
};
|
|
21248
21370
|
_proto._updateStencilState = function _updateStencilState() {
|
|
21249
21371
|
// Update stencil.
|
|
21250
21372
|
var material = this.getInstanceMaterial();
|
|
@@ -21271,22 +21393,21 @@ var TiledType;
|
|
|
21271
21393
|
break;
|
|
21272
21394
|
case SpriteModifyFlags.size:
|
|
21273
21395
|
var _this = this, drawMode = _this._drawMode;
|
|
21274
|
-
|
|
21396
|
+
this._dirtyUpdateFlag |= 0x4;
|
|
21397
|
+
if (this._drawMode === SpriteDrawMode.Sliced) {
|
|
21275
21398
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21276
21399
|
} else if (drawMode === SpriteDrawMode.Tiled) {
|
|
21277
21400
|
this._dirtyUpdateFlag |= 0x3;
|
|
21278
21401
|
} else {
|
|
21279
21402
|
// When the width and height of `SpriteRenderer` are `undefined`,
|
|
21280
21403
|
// the `size` of `Sprite` will affect the position of `SpriteRenderer`.
|
|
21281
|
-
if (this.
|
|
21404
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
21282
21405
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21283
21406
|
}
|
|
21284
21407
|
}
|
|
21285
21408
|
break;
|
|
21286
21409
|
case SpriteModifyFlags.border:
|
|
21287
|
-
|
|
21288
|
-
this._dirtyUpdateFlag |= 0x3;
|
|
21289
|
-
}
|
|
21410
|
+
this._drawMode === SpriteDrawMode.Sliced && (this._dirtyUpdateFlag |= 0x3);
|
|
21290
21411
|
break;
|
|
21291
21412
|
case SpriteModifyFlags.region:
|
|
21292
21413
|
case SpriteModifyFlags.atlasRegionOffset:
|
|
@@ -21371,9 +21492,9 @@ var TiledType;
|
|
|
21371
21492
|
var lastSprite = this._sprite;
|
|
21372
21493
|
if (lastSprite !== value) {
|
|
21373
21494
|
lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
|
|
21495
|
+
this._dirtyUpdateFlag |= 0x7;
|
|
21374
21496
|
if (value) {
|
|
21375
21497
|
value._updateFlagManager.addListener(this._onSpriteChange);
|
|
21376
|
-
this._dirtyUpdateFlag |= 0x3;
|
|
21377
21498
|
this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
|
|
21378
21499
|
} else {
|
|
21379
21500
|
this.shaderData.setTexture(SpriteRenderer._textureProperty, null);
|
|
@@ -21398,16 +21519,22 @@ var TiledType;
|
|
|
21398
21519
|
{
|
|
21399
21520
|
key: "width",
|
|
21400
21521
|
get: /**
|
|
21401
|
-
* Render width.
|
|
21522
|
+
* Render width (in world coordinates).
|
|
21523
|
+
*
|
|
21524
|
+
* @remarks
|
|
21525
|
+
* If width is set, return the set value,
|
|
21526
|
+
* otherwise return `SpriteRenderer.sprite.width`.
|
|
21402
21527
|
*/ function get() {
|
|
21403
|
-
|
|
21404
|
-
|
|
21528
|
+
if (this._customWidth !== undefined) {
|
|
21529
|
+
return this._customWidth;
|
|
21530
|
+
} else {
|
|
21531
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
21532
|
+
return this._automaticWidth;
|
|
21533
|
+
}
|
|
21405
21534
|
},
|
|
21406
21535
|
set: function set(value) {
|
|
21407
|
-
|
|
21408
|
-
|
|
21409
|
-
if (this._width !== value) {
|
|
21410
|
-
this._width = value;
|
|
21536
|
+
if (this._customWidth !== value) {
|
|
21537
|
+
this._customWidth = value;
|
|
21411
21538
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21412
21539
|
}
|
|
21413
21540
|
}
|
|
@@ -21415,16 +21542,22 @@ var TiledType;
|
|
|
21415
21542
|
{
|
|
21416
21543
|
key: "height",
|
|
21417
21544
|
get: /**
|
|
21418
|
-
* Render height.
|
|
21545
|
+
* Render height (in world coordinates).
|
|
21546
|
+
*
|
|
21547
|
+
* @remarks
|
|
21548
|
+
* If height is set, return the set value,
|
|
21549
|
+
* otherwise return `SpriteRenderer.sprite.height`.
|
|
21419
21550
|
*/ function get() {
|
|
21420
|
-
|
|
21421
|
-
|
|
21551
|
+
if (this._customHeight !== undefined) {
|
|
21552
|
+
return this._customHeight;
|
|
21553
|
+
} else {
|
|
21554
|
+
this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
|
|
21555
|
+
return this._automaticHeight;
|
|
21556
|
+
}
|
|
21422
21557
|
},
|
|
21423
21558
|
set: function set(value) {
|
|
21424
|
-
|
|
21425
|
-
|
|
21426
|
-
if (this._height !== value) {
|
|
21427
|
-
this._height = value;
|
|
21559
|
+
if (this._customHeight !== value) {
|
|
21560
|
+
this._customHeight = value;
|
|
21428
21561
|
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
21429
21562
|
}
|
|
21430
21563
|
}
|
|
@@ -21511,10 +21644,16 @@ __decorate([
|
|
|
21511
21644
|
], SpriteRenderer.prototype, "_sprite", void 0);
|
|
21512
21645
|
__decorate([
|
|
21513
21646
|
ignoreClone
|
|
21514
|
-
], SpriteRenderer.prototype, "
|
|
21647
|
+
], SpriteRenderer.prototype, "_automaticWidth", void 0);
|
|
21515
21648
|
__decorate([
|
|
21516
21649
|
ignoreClone
|
|
21517
|
-
], SpriteRenderer.prototype, "
|
|
21650
|
+
], SpriteRenderer.prototype, "_automaticHeight", void 0);
|
|
21651
|
+
__decorate([
|
|
21652
|
+
assignmentClone
|
|
21653
|
+
], SpriteRenderer.prototype, "_customWidth", void 0);
|
|
21654
|
+
__decorate([
|
|
21655
|
+
assignmentClone
|
|
21656
|
+
], SpriteRenderer.prototype, "_customHeight", void 0);
|
|
21518
21657
|
__decorate([
|
|
21519
21658
|
assignmentClone
|
|
21520
21659
|
], SpriteRenderer.prototype, "_flipX", void 0);
|
|
@@ -21535,7 +21674,9 @@ var /**
|
|
|
21535
21674
|
*/ SpriteRendererUpdateFlags;
|
|
21536
21675
|
(function(SpriteRendererUpdateFlags) {
|
|
21537
21676
|
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
|
|
21538
|
-
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/**
|
|
21677
|
+
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
|
|
21678
|
+
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
|
|
21679
|
+
SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x7] = "All";
|
|
21539
21680
|
})(SpriteRendererUpdateFlags || (SpriteRendererUpdateFlags = {}));
|
|
21540
21681
|
|
|
21541
21682
|
/**
|