@galacean/engine-core 1.6.0-alpha.1 → 1.6.0-beta.0
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 +183 -212
- package/dist/main.js.map +1 -1
- package/dist/module.js +182 -211
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Transform.d.ts +5 -3
- package/types/shader/Shader.d.ts +5 -2
- package/types/shader/ShaderPass.d.ts +0 -9
- package/types/shader/enums/ShaderLanguage.d.ts +9 -0
- package/types/shader/index.d.ts +3 -3
- package/types/shader/enums/ShaderPlatformTarget.d.ts +0 -4
- package/types/shader/enums/ShaderType.d.ts +0 -1
package/dist/main.js
CHANGED
|
@@ -4265,6 +4265,15 @@ __decorate([
|
|
|
4265
4265
|
return CullMode;
|
|
4266
4266
|
}({});
|
|
4267
4267
|
|
|
4268
|
+
/**
|
|
4269
|
+
* Render queue type.
|
|
4270
|
+
*/ var RenderQueueType = /*#__PURE__*/ function(RenderQueueType) {
|
|
4271
|
+
/** Opaque queue. */ RenderQueueType[RenderQueueType["Opaque"] = 0] = "Opaque";
|
|
4272
|
+
/** Opaque queue, alpha cutoff. */ RenderQueueType[RenderQueueType["AlphaTest"] = 1] = "AlphaTest";
|
|
4273
|
+
/** Transparent queue, rendering from back to front to ensure correct rendering of transparent objects. */ RenderQueueType[RenderQueueType["Transparent"] = 2] = "Transparent";
|
|
4274
|
+
return RenderQueueType;
|
|
4275
|
+
}({});
|
|
4276
|
+
|
|
4268
4277
|
var RenderStateElementKey = /*#__PURE__*/ function(RenderStateElementKey) {
|
|
4269
4278
|
/** Blend state enabled for target 0 key. */ RenderStateElementKey[RenderStateElementKey["BlendStateEnabled0"] = 0] = "BlendStateEnabled0";
|
|
4270
4279
|
/** Blend state color blend operation for target 0 key. */ RenderStateElementKey[RenderStateElementKey["BlendStateColorBlendOperation0"] = 1] = "BlendStateColorBlendOperation0";
|
|
@@ -4298,15 +4307,6 @@ var RenderStateElementKey = /*#__PURE__*/ function(RenderStateElementKey) {
|
|
|
4298
4307
|
return RenderStateElementKey;
|
|
4299
4308
|
}({});
|
|
4300
4309
|
|
|
4301
|
-
/**
|
|
4302
|
-
* Render queue type.
|
|
4303
|
-
*/ var RenderQueueType = /*#__PURE__*/ function(RenderQueueType) {
|
|
4304
|
-
/** Opaque queue. */ RenderQueueType[RenderQueueType["Opaque"] = 0] = "Opaque";
|
|
4305
|
-
/** Opaque queue, alpha cutoff. */ RenderQueueType[RenderQueueType["AlphaTest"] = 1] = "AlphaTest";
|
|
4306
|
-
/** Transparent queue, rendering from back to front to ensure correct rendering of transparent objects. */ RenderQueueType[RenderQueueType["Transparent"] = 2] = "Transparent";
|
|
4307
|
-
return RenderQueueType;
|
|
4308
|
-
}({});
|
|
4309
|
-
|
|
4310
4310
|
/**
|
|
4311
4311
|
* Shader data grouping.
|
|
4312
4312
|
*/ var ShaderDataGroup = /*#__PURE__*/ function(ShaderDataGroup) {
|
|
@@ -4318,6 +4318,14 @@ var RenderStateElementKey = /*#__PURE__*/ function(RenderStateElementKey) {
|
|
|
4318
4318
|
return ShaderDataGroup;
|
|
4319
4319
|
}({});
|
|
4320
4320
|
|
|
4321
|
+
/**
|
|
4322
|
+
* Shader language belongs to.
|
|
4323
|
+
*/ var ShaderLanguage = /*#__PURE__*/ function(ShaderLanguage) {
|
|
4324
|
+
/** GLSL ES 100. */ ShaderLanguage[ShaderLanguage["GLSLES100"] = 0] = "GLSLES100";
|
|
4325
|
+
/** GLSL ES 300. */ ShaderLanguage[ShaderLanguage["GLSLES300"] = 1] = "GLSLES300";
|
|
4326
|
+
return ShaderLanguage;
|
|
4327
|
+
}({});
|
|
4328
|
+
|
|
4321
4329
|
/**
|
|
4322
4330
|
* Shader Property type.
|
|
4323
4331
|
*/ var ShaderPropertyType = /*#__PURE__*/ function(ShaderPropertyType) {
|
|
@@ -4350,51 +4358,6 @@ var RenderStateElementKey = /*#__PURE__*/ function(RenderStateElementKey) {
|
|
|
4350
4358
|
return StencilOperation;
|
|
4351
4359
|
}({});
|
|
4352
4360
|
|
|
4353
|
-
var ShaderPlatformTarget = /*#__PURE__*/ function(ShaderPlatformTarget) {
|
|
4354
|
-
ShaderPlatformTarget[ShaderPlatformTarget["GLES100"] = 0] = "GLES100";
|
|
4355
|
-
ShaderPlatformTarget[ShaderPlatformTarget["GLES300"] = 1] = "GLES300";
|
|
4356
|
-
return ShaderPlatformTarget;
|
|
4357
|
-
}({});
|
|
4358
|
-
|
|
4359
|
-
function _array_like_to_array(arr, len) {
|
|
4360
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
4361
|
-
|
|
4362
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
4363
|
-
|
|
4364
|
-
return arr2;
|
|
4365
|
-
}
|
|
4366
|
-
|
|
4367
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
4368
|
-
if (!o) return;
|
|
4369
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
4370
|
-
|
|
4371
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4372
|
-
|
|
4373
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4374
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
4375
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
4376
|
-
}
|
|
4377
|
-
|
|
4378
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
4379
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
4380
|
-
|
|
4381
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
4382
|
-
// Fallback for engines without symbol support
|
|
4383
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
4384
|
-
if (it) o = it;
|
|
4385
|
-
|
|
4386
|
-
var i = 0;
|
|
4387
|
-
|
|
4388
|
-
return function() {
|
|
4389
|
-
if (i >= o.length) return { done: true };
|
|
4390
|
-
|
|
4391
|
-
return { done: false, value: o[i++] };
|
|
4392
|
-
};
|
|
4393
|
-
}
|
|
4394
|
-
|
|
4395
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4396
|
-
}
|
|
4397
|
-
|
|
4398
4361
|
/**
|
|
4399
4362
|
* Shader macro。
|
|
4400
4363
|
*/ var ShaderMacro = /*#__PURE__*/ function() {
|
|
@@ -4628,7 +4591,7 @@ function _extends() {
|
|
|
4628
4591
|
|
|
4629
4592
|
var camera_declare = "uniform vec3 camera_Position;\nuniform vec3 camera_Forward; "; // eslint-disable-line
|
|
4630
4593
|
|
|
4631
|
-
var common = "#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats\n#define HALF_EPS 4.8828125e-4 // 2^-11, machine epsilon: 1 + EPS = 1 (half of the ULP for 1.0f)\n\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n\nfloat pow2(float x ) {\n return x * x;\n}\n\nvec4 RGBMToLinear(vec4 value, float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 gammaToLinear(vec4 value){\n return vec4( pow(value.rgb, vec3(2.2)), value.a);\n}\n\nvec4 linearToGamma(vec4 value){\n\tvalue = max(value, 0.0);\n return vec4( pow(value.rgb, vec3(1.0 / 2.2)), value.a);\n}\n\n\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt\nfloat sRGBToLinear(float value){\n float linearRGBLo = value / 12.92;\n float linearRGBHi = pow((value + 0.055) / 1.055, 2.4);\n float linearRGB = (value <= 0.04045) ? linearRGBLo : linearRGBHi;\n return linearRGB;\n}\n\nvec4 sRGBToLinear(vec4 value){\n return vec4(sRGBToLinear(value.r), sRGBToLinear(value.g), sRGBToLinear(value.b), value.a);\n}\n\nfloat linearToSRGB(float value){\n\tvalue = max(value, 0.0);\n return (value <= 0.0031308) ? (value * 12.9232102) : 1.055 * pow(value, 1.0 / 2.4) - 0.055;\n}\n\nvec4 linearToSRGB(vec4 value){\n return vec4(linearToSRGB(value.r), linearToSRGB(value.g), linearToSRGB(value.b), value.a);\n}\n\n// Compatible with devices that do not even support EXT_sRGB in WebGL1.0.\nvec4 texture2DSRGB(sampler2D tex, vec2 uv) {\n\tvec4 color = texture2D(tex, uv);\n\t#ifdef ENGINE_NO_SRGB\n\t\tcolor = sRGBToLinear(color);\n\t#endif\n\treturn color;\n}\n\
|
|
4594
|
+
var common = "#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats\n#define HALF_EPS 4.8828125e-4 // 2^-11, machine epsilon: 1 + EPS = 1 (half of the ULP for 1.0f)\n\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n\nfloat pow2(float x ) {\n return x * x;\n}\n\nvec4 RGBMToLinear(vec4 value, float maxRange ) {\n return vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 gammaToLinear(vec4 value){\n return vec4( pow(value.rgb, vec3(2.2)), value.a);\n}\n\nvec4 linearToGamma(vec4 value){\n\tvalue = max(value, 0.0);\n return vec4( pow(value.rgb, vec3(1.0 / 2.2)), value.a);\n}\n\n\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt\nfloat sRGBToLinear(float value){\n float linearRGBLo = value / 12.92;\n float linearRGBHi = pow((value + 0.055) / 1.055, 2.4);\n float linearRGB = (value <= 0.04045) ? linearRGBLo : linearRGBHi;\n return linearRGB;\n}\n\nvec4 sRGBToLinear(vec4 value){\n return vec4(sRGBToLinear(value.r), sRGBToLinear(value.g), sRGBToLinear(value.b), value.a);\n}\n\nfloat linearToSRGB(float value){\n\tvalue = max(value, 0.0);\n return (value <= 0.0031308) ? (value * 12.9232102) : 1.055 * pow(value, 1.0 / 2.4) - 0.055;\n}\n\nvec4 linearToSRGB(vec4 value){\n return vec4(linearToSRGB(value.r), linearToSRGB(value.g), linearToSRGB(value.b), value.a);\n}\n\n// Compatible with devices that do not even support EXT_sRGB in WebGL1.0.\nvec4 texture2DSRGB(sampler2D tex, vec2 uv) {\n\tvec4 color = texture2D(tex, uv);\n\t#ifdef ENGINE_NO_SRGB\n\t\tcolor = sRGBToLinear(color);\n\t#endif\n\treturn color;\n}\n\nvec4 outputSRGBCorrection(vec4 linearIn){\n #ifdef ENGINE_OUTPUT_SRGB_CORRECT\n \treturn linearToSRGB(linearIn);\n #else \n \treturn linearIn;\n #endif\n}\n\n\nuniform vec4 camera_DepthBufferParams;\nuniform vec4 camera_ProjectionParams;\n\nfloat remapDepthBufferLinear01(float depth){\n\treturn 1.0 / (camera_DepthBufferParams.x * depth + camera_DepthBufferParams.y);\n}\n\nfloat remapDepthBufferEyeDepth(float depth){\n\t#ifdef CAMERA_ORTHOGRAPHIC\n\t\treturn camera_ProjectionParams.y + (camera_ProjectionParams.z - camera_ProjectionParams.y) * depth;\n\t#else\n\t\treturn 1.0 / (camera_DepthBufferParams.z * depth + camera_DepthBufferParams.w);\n\t#endif\n}\n\n// From Next Generation Post Processing in Call of Duty: Advanced Warfare [Jimenez 2014]\n// http://advances.realtimerendering.com/s2014/index.html\n// sampleCoord must not be normalized (e.g. window coordinates)\nfloat interleavedGradientNoise(vec2 sampleCoord)\n{\n\tconst vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\n\treturn fract(magic.z * fract(dot(sampleCoord, magic.xy)));\n}\n\n#ifdef GRAPHICS_API_WEBGL2\n\t#define INVERSE_MAT(mat) inverse(mat)\n#else\n\tmat2 inverseMat(mat2 m) {\n\t\treturn mat2(m[1][1],-m[0][1],\n\t\t\t\t-m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n\t}\n\tmat3 inverseMat(mat3 m) {\n\t\tfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n\t\tfloat a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n\t\tfloat a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n\t\tfloat b01 = a22 * a11 - a12 * a21;\n\t\tfloat b11 = -a22 * a10 + a12 * a20;\n\t\tfloat b21 = a21 * a10 - a11 * a20;\n\n\t\tfloat det = a00 * b01 + a01 * b11 + a02 * b21;\n\n\t\treturn mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n\t\t\t\t\tb11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n\t\t\t\t\tb21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n\t}\n\tmat4 inverseMat(mat4 m) {\n\t\tfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n\t\t\ta10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n\t\t\ta20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n\t\t\ta30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n\t\t\tb00 = a00 * a11 - a01 * a10,\n\t\t\tb01 = a00 * a12 - a02 * a10,\n\t\t\tb02 = a00 * a13 - a03 * a10,\n\t\t\tb03 = a01 * a12 - a02 * a11,\n\t\t\tb04 = a01 * a13 - a03 * a11,\n\t\t\tb05 = a02 * a13 - a03 * a12,\n\t\t\tb06 = a20 * a31 - a21 * a30,\n\t\t\tb07 = a20 * a32 - a22 * a30,\n\t\t\tb08 = a20 * a33 - a23 * a30,\n\t\t\tb09 = a21 * a32 - a22 * a31,\n\t\t\tb10 = a21 * a33 - a23 * a31,\n\t\t\tb11 = a22 * a33 - a23 * a32,\n\n\t\t\tdet = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n\t\treturn mat4(\n\t\t\ta11 * b11 - a12 * b10 + a13 * b09,\n\t\t\ta02 * b10 - a01 * b11 - a03 * b09,\n\t\t\ta31 * b05 - a32 * b04 + a33 * b03,\n\t\t\ta22 * b04 - a21 * b05 - a23 * b03,\n\t\t\ta12 * b08 - a10 * b11 - a13 * b07,\n\t\t\ta00 * b11 - a02 * b08 + a03 * b07,\n\t\t\ta32 * b02 - a30 * b05 - a33 * b01,\n\t\t\ta20 * b05 - a22 * b02 + a23 * b01,\n\t\t\ta10 * b10 - a11 * b08 + a13 * b06,\n\t\t\ta01 * b08 - a00 * b10 - a03 * b06,\n\t\t\ta30 * b04 - a31 * b02 + a33 * b00,\n\t\t\ta21 * b02 - a20 * b04 - a23 * b00,\n\t\t\ta11 * b07 - a10 * b09 - a12 * b06,\n\t\t\ta00 * b09 - a01 * b07 + a02 * b06,\n\t\t\ta31 * b01 - a30 * b03 - a32 * b00,\n\t\t\ta20 * b03 - a21 * b01 + a22 * b00) / det;\n\t}\n\n\t#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n\n\nvec3 safeNormalize(vec3 inVec) {\n float dp3 = max(float(HALF_MIN), dot(inVec, inVec));\n return inVec * inversesqrt(dp3);\n}\n"; // eslint-disable-line
|
|
4632
4595
|
|
|
4633
4596
|
var common_vert = "attribute vec3 POSITION;\n\n#ifdef RENDERER_HAS_UV\n attribute vec2 TEXCOORD_0;\n#endif\n\n#ifdef RENDERER_HAS_UV1\n attribute vec2 TEXCOORD_1;\n#endif\n\n#ifdef RENDERER_HAS_SKIN\n attribute vec4 JOINTS_0;\n attribute vec4 WEIGHTS_0;\n\n #ifdef RENDERER_USE_JOINT_TEXTURE\n uniform sampler2D renderer_JointSampler;\n uniform float renderer_JointCount;\n\n mat4 getJointMatrix(sampler2D smp, float index)\n {\n float base = index / renderer_JointCount;\n float hf = 0.5 / renderer_JointCount;\n float v = base + hf;\n\n vec4 m0 = texture2D(smp, vec2(0.125, v ));\n vec4 m1 = texture2D(smp, vec2(0.375, v ));\n vec4 m2 = texture2D(smp, vec2(0.625, v ));\n vec4 m3 = texture2D(smp, vec2(0.875, v ));\n\n return mat4(m0, m1, m2, m3);\n\n }\n\n #else\n uniform mat4 renderer_JointMatrix[ RENDERER_JOINTS_NUM ];\n #endif\n#endif\n\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n#endif\n\n\n#include <transform_declare>\n#include <camera_declare>\n\nuniform vec4 material_TilingOffset;\n\n\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n attribute vec3 NORMAL;\n #endif\n\n #ifdef RENDERER_HAS_TANGENT\n attribute vec4 TANGENT;\n #endif\n#endif"; // eslint-disable-line
|
|
4634
4597
|
|
|
@@ -4891,11 +4854,11 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4891
4854
|
shader = shader.replace(/\bvarying\b/g, isFrag ? "in" : "out");
|
|
4892
4855
|
shader = shader.replace(/\btexture(2D|Cube)\b/g, "texture");
|
|
4893
4856
|
shader = shader.replace(/\btexture2DProj\b/g, "textureProj");
|
|
4857
|
+
shader = shader.replace(/\btexture(2D|Cube)LodEXT\b/g, "textureLod");
|
|
4858
|
+
shader = shader.replace(/\btexture(2D|Cube)GradEXT\b/g, "textureGrad");
|
|
4859
|
+
shader = shader.replace(/\btexture2DProjLodEXT\b/g, "textureProjLod");
|
|
4860
|
+
shader = shader.replace(/\btexture2DProjGradEXT\b/g, "textureProjGrad");
|
|
4894
4861
|
if (isFrag) {
|
|
4895
|
-
shader = shader.replace(/\btexture(2D|Cube)LodEXT\b/g, "textureLod");
|
|
4896
|
-
shader = shader.replace(/\btexture(2D|Cube)GradEXT\b/g, "textureGrad");
|
|
4897
|
-
shader = shader.replace(/\btexture2DProjLodEXT\b/g, "textureProjLod");
|
|
4898
|
-
shader = shader.replace(/\btexture2DProjGradEXT\b/g, "textureProjGrad");
|
|
4899
4862
|
shader = shader.replace(/\bgl_FragDepthEXT\b/g, "gl_FragDepth");
|
|
4900
4863
|
if (!ShaderFactory._has300Output(shader)) {
|
|
4901
4864
|
var isMRT = /\bgl_FragData\[.+?\]/g.test(shader);
|
|
@@ -4904,7 +4867,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4904
4867
|
var result = shader.match(/\bgl_FragData\[.+?\]/g);
|
|
4905
4868
|
shader = this._replaceMRTShader(shader, result);
|
|
4906
4869
|
} else {
|
|
4907
|
-
shader =
|
|
4870
|
+
shader = "out vec4 glFragColor;\n" + shader;
|
|
4908
4871
|
shader = shader.replace(/\bgl_FragColor\b/g, "glFragColor");
|
|
4909
4872
|
}
|
|
4910
4873
|
}
|
|
@@ -5601,47 +5564,29 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
5601
5564
|
}();
|
|
5602
5565
|
ShaderProgram._counter = 0;
|
|
5603
5566
|
|
|
5604
|
-
|
|
5605
|
-
* @internal
|
|
5606
|
-
* Shader pass type
|
|
5607
|
-
*/ var ShaderType = /*#__PURE__*/ function(ShaderType) {
|
|
5608
|
-
/** init by glsl */ ShaderType[ShaderType["Canonical"] = 0] = "Canonical";
|
|
5609
|
-
/** init by shader-lab */ ShaderType[ShaderType["ShaderLab"] = 1] = "ShaderLab";
|
|
5610
|
-
return ShaderType;
|
|
5611
|
-
}({});
|
|
5612
|
-
|
|
5567
|
+
var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";
|
|
5613
5568
|
/**
|
|
5614
5569
|
* Shader pass containing vertex and fragment source.
|
|
5615
5570
|
*/ var ShaderPass = /*#__PURE__*/ function(ShaderPart) {
|
|
5616
5571
|
_inherits(ShaderPass, ShaderPart);
|
|
5617
|
-
function ShaderPass(nameOrVertexSource,
|
|
5572
|
+
function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSource, fragmentSourceOrTags, tags) {
|
|
5618
5573
|
var _this;
|
|
5619
|
-
_this = ShaderPart.call(this) || this, /** @internal */ _this._shaderPassId = 0, /** @internal */ _this._renderStateDataMap = {}, /** @internal */ _this._shaderProgramPools = []
|
|
5574
|
+
_this = ShaderPart.call(this) || this, /** @internal */ _this._shaderPassId = 0, /** @internal */ _this._renderStateDataMap = {}, /** @internal */ _this._shaderProgramPools = [];
|
|
5620
5575
|
_this._shaderPassId = ShaderPass._shaderPassCounter++;
|
|
5621
|
-
|
|
5622
|
-
if (typeof fragmentEntryOrTags === "string") {
|
|
5576
|
+
if (typeof fragmentSourceOrTags === "string") {
|
|
5623
5577
|
_this._name = nameOrVertexSource;
|
|
5624
|
-
_this.
|
|
5625
|
-
_this.
|
|
5626
|
-
_this._fragmentEntry = fragmentEntryOrTags;
|
|
5578
|
+
_this._vertexSource = vertexSourceOrFragmentSource;
|
|
5579
|
+
_this._fragmentSource = fragmentSourceOrTags;
|
|
5627
5580
|
tags = _extends({
|
|
5628
5581
|
pipelineStage: PipelineStage.Forward
|
|
5629
5582
|
}, tags);
|
|
5630
|
-
_this._type = ShaderType.ShaderLab;
|
|
5631
|
-
} else if (typeof fragmentSourceOrTagsOrVertexEntry === "string") {
|
|
5632
|
-
_this._name = nameOrVertexSource;
|
|
5633
|
-
_this._vertexSource = vertexSourceOrFragmentSourceOrCode;
|
|
5634
|
-
_this._fragmentSource = fragmentSourceOrTagsOrVertexEntry;
|
|
5635
|
-
tags = fragmentEntryOrTags != null ? fragmentEntryOrTags : {
|
|
5636
|
-
pipelineStage: PipelineStage.Forward
|
|
5637
|
-
};
|
|
5638
5583
|
} else {
|
|
5639
5584
|
_this._name = "Default";
|
|
5640
5585
|
_this._vertexSource = nameOrVertexSource;
|
|
5641
|
-
_this._fragmentSource =
|
|
5642
|
-
tags =
|
|
5586
|
+
_this._fragmentSource = vertexSourceOrFragmentSource;
|
|
5587
|
+
tags = _extends({
|
|
5643
5588
|
pipelineStage: PipelineStage.Forward
|
|
5644
|
-
};
|
|
5589
|
+
}, fragmentSourceOrTags);
|
|
5645
5590
|
}
|
|
5646
5591
|
for(var key in tags){
|
|
5647
5592
|
_this.setTag(key, tags[key]);
|
|
@@ -5657,11 +5602,7 @@ ShaderProgram._counter = 0;
|
|
|
5657
5602
|
if (shaderProgram) {
|
|
5658
5603
|
return shaderProgram;
|
|
5659
5604
|
}
|
|
5660
|
-
|
|
5661
|
-
shaderProgram = this._getCanonicalShaderProgram(engine, macroCollection);
|
|
5662
|
-
} else {
|
|
5663
|
-
shaderProgram = this._compileShaderProgram(engine, macroCollection, this._vertexEntry, this._fragmentEntry);
|
|
5664
|
-
}
|
|
5605
|
+
shaderProgram = this._getCanonicalShaderProgram(engine, macroCollection);
|
|
5665
5606
|
shaderProgramPool.cache(shaderProgram);
|
|
5666
5607
|
return shaderProgram;
|
|
5667
5608
|
};
|
|
@@ -5677,55 +5618,37 @@ ShaderProgram._counter = 0;
|
|
|
5677
5618
|
// Clear array storing multiple engine shader program pools
|
|
5678
5619
|
shaderProgramPools.length = 0;
|
|
5679
5620
|
};
|
|
5680
|
-
|
|
5681
|
-
* Shader Lab compilation
|
|
5682
|
-
*/ _proto._compileShaderProgram = function _compileShaderProgram(engine, macroCollection, vertexEntry, fragmentEntry) {
|
|
5683
|
-
var _this = this, path = _this._path, platformMacros = _this._platformMacros;
|
|
5621
|
+
_proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
|
|
5684
5622
|
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
5685
|
-
var
|
|
5686
|
-
ShaderMacro._getMacrosElements(macroCollection,
|
|
5687
|
-
|
|
5623
|
+
var shaderMacroList = new Array();
|
|
5624
|
+
ShaderMacro._getMacrosElements(macroCollection, shaderMacroList);
|
|
5625
|
+
shaderMacroList.push(ShaderMacro.getByName(isWebGL2 ? "GRAPHICS_API_WEBGL2" : "GRAPHICS_API_WEBGL1"));
|
|
5688
5626
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.shaderTextureLod)) {
|
|
5689
|
-
|
|
5627
|
+
shaderMacroList.push(ShaderMacro.getByName("HAS_TEX_LOD"));
|
|
5690
5628
|
}
|
|
5691
5629
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
|
|
5692
|
-
|
|
5693
|
-
}
|
|
5694
|
-
|
|
5695
|
-
|
|
5630
|
+
shaderMacroList.push(ShaderMacro.getByName("HAS_DERIVATIVES"));
|
|
5631
|
+
}
|
|
5632
|
+
// Compatible with non-shaderlab syntax
|
|
5633
|
+
var noIncludeVertex = ShaderFactory.parseIncludes(this._vertexSource);
|
|
5634
|
+
var noIncludeFrag = ShaderFactory.parseIncludes(this._fragmentSource);
|
|
5635
|
+
// Parse macros when use shaderlab
|
|
5636
|
+
if (this._platformTarget != undefined) {
|
|
5637
|
+
noIncludeVertex = Shader._shaderLab._parseMacros(noIncludeVertex, shaderMacroList);
|
|
5638
|
+
noIncludeFrag = Shader._shaderLab._parseMacros(noIncludeFrag, shaderMacroList);
|
|
5696
5639
|
} else {
|
|
5697
|
-
|
|
5640
|
+
var macroNameStr = ShaderFactory.parseCustomMacros(shaderMacroList);
|
|
5641
|
+
noIncludeVertex = macroNameStr + noIncludeVertex;
|
|
5642
|
+
noIncludeFrag = macroNameStr + noIncludeFrag;
|
|
5698
5643
|
}
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
return new ShaderProgram(engine, shaderProgramSource.vertex, shaderProgramSource.fragment);
|
|
5704
|
-
} else {
|
|
5705
|
-
return new ShaderProgram(engine, "", "");
|
|
5644
|
+
// Need to convert to 300 es when the target is GLSL ES 100 or unkdown
|
|
5645
|
+
if (isWebGL2 && (this._platformTarget == undefined || this._platformTarget === ShaderLanguage.GLSLES100)) {
|
|
5646
|
+
noIncludeVertex = ShaderFactory.convertTo300(noIncludeVertex);
|
|
5647
|
+
noIncludeFrag = ShaderFactory.convertTo300(noIncludeFrag, true);
|
|
5706
5648
|
}
|
|
5707
|
-
};
|
|
5708
|
-
// TODO: remove it after migrate all shader to `ShaderLab`.
|
|
5709
|
-
_proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
|
|
5710
|
-
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
5711
|
-
var macroNameList = new Array();
|
|
5712
|
-
ShaderMacro._getMacrosElements(macroCollection, macroNameList);
|
|
5713
|
-
var macroNameStr = ShaderFactory.parseCustomMacros(macroNameList);
|
|
5714
5649
|
var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
|
|
5715
|
-
var
|
|
5716
|
-
var
|
|
5717
|
-
if (engine._hardwareRenderer.canIUse(GLCapabilityType.shaderTextureLod)) {
|
|
5718
|
-
precisionStr += "#define HAS_TEX_LOD\n";
|
|
5719
|
-
}
|
|
5720
|
-
if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
|
|
5721
|
-
precisionStr += "#define HAS_DERIVATIVES\n";
|
|
5722
|
-
}
|
|
5723
|
-
var vertexSource = " " + versionStr + "\n " + graphicAPI + "\n " + macroNameStr + "\n " + ShaderFactory.parseIncludes(this._vertexSource);
|
|
5724
|
-
var fragmentSource = " " + versionStr + "\n " + graphicAPI + "\n " + (isWebGL2 ? "" : ShaderFactory._shaderExtension) + "\n " + precisionStr + "\n " + macroNameStr + "\n " + ShaderFactory.parseIncludes(this._fragmentSource);
|
|
5725
|
-
if (isWebGL2) {
|
|
5726
|
-
vertexSource = ShaderFactory.convertTo300(vertexSource);
|
|
5727
|
-
fragmentSource = ShaderFactory.convertTo300(fragmentSource, true);
|
|
5728
|
-
}
|
|
5650
|
+
var vertexSource = " " + versionStr + " \n " + noIncludeVertex + "\n ";
|
|
5651
|
+
var fragmentSource = " " + versionStr + "\n " + (isWebGL2 ? "" : ShaderFactory._shaderExtension) + "\n " + precisionStr + "\n " + noIncludeFrag + "\n ";
|
|
5729
5652
|
var shaderProgram = new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
5730
5653
|
return shaderProgram;
|
|
5731
5654
|
};
|
|
@@ -6407,18 +6330,6 @@ __decorate([
|
|
|
6407
6330
|
}
|
|
6408
6331
|
var _proto = Shader.prototype;
|
|
6409
6332
|
/**
|
|
6410
|
-
* @internal
|
|
6411
|
-
* path should follow the specifications of [URL.origin](https://developer.mozilla.org/en-US/docs/Web/API/URL/origin), like: `shaders://root/`
|
|
6412
|
-
*/ _proto._registerPath = function _registerPath(path) {
|
|
6413
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this._subShaders), _step; !(_step = _iterator()).done;){
|
|
6414
|
-
var subShader = _step.value;
|
|
6415
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(subShader.passes), _step1; !(_step1 = _iterator1()).done;){
|
|
6416
|
-
var shaderPass = _step1.value;
|
|
6417
|
-
shaderPass._path = path;
|
|
6418
|
-
}
|
|
6419
|
-
}
|
|
6420
|
-
};
|
|
6421
|
-
/**
|
|
6422
6333
|
* Compile shader variant by macro name list.
|
|
6423
6334
|
*
|
|
6424
6335
|
* @remarks
|
|
@@ -6474,74 +6385,82 @@ __decorate([
|
|
|
6474
6385
|
*/ _proto._addReferCount = function _addReferCount(value) {
|
|
6475
6386
|
this._refCount += value;
|
|
6476
6387
|
};
|
|
6477
|
-
Shader.create = function create(nameOrShaderSource,
|
|
6388
|
+
Shader.create = function create(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, fragmentSourceOrPath) {
|
|
6478
6389
|
var shader;
|
|
6479
6390
|
var shaderMap = Shader._shaderMap;
|
|
6480
|
-
if (
|
|
6481
|
-
|
|
6391
|
+
if (vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget == undefined) {
|
|
6392
|
+
vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget = ShaderLanguage.GLSLES100;
|
|
6393
|
+
}
|
|
6394
|
+
if (typeof vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget === "number") {
|
|
6395
|
+
var shaderLab = Shader._shaderLab;
|
|
6396
|
+
if (!shaderLab) {
|
|
6482
6397
|
throw "ShaderLab has not been set up yet.";
|
|
6483
6398
|
}
|
|
6484
|
-
var
|
|
6485
|
-
if (shaderMap[
|
|
6486
|
-
console.error('Shader named "' +
|
|
6399
|
+
var shaderSource = shaderLab._parseShaderSource(nameOrShaderSource);
|
|
6400
|
+
if (shaderMap[shaderSource.name]) {
|
|
6401
|
+
console.error('Shader named "' + shaderSource.name + '" already exists.');
|
|
6487
6402
|
return;
|
|
6488
6403
|
}
|
|
6489
|
-
var subShaderList =
|
|
6490
|
-
var passList =
|
|
6491
|
-
if (
|
|
6404
|
+
var subShaderList = shaderSource.subShaders.map(function(subShaderSource) {
|
|
6405
|
+
var passList = subShaderSource.passes.map(function(passSource) {
|
|
6406
|
+
if (passSource.isUsePass) {
|
|
6492
6407
|
var _Shader_find_subShaders_find, _Shader_find;
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
return subShader.name === paths[1];
|
|
6408
|
+
var _passSource_name_split = passSource.name.split("/"), shaderName = _passSource_name_split[0], subShaderName = _passSource_name_split[1], passName = _passSource_name_split[2];
|
|
6409
|
+
return (_Shader_find = Shader.find(shaderName)) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
|
|
6410
|
+
return subShader.name === subShaderName;
|
|
6497
6411
|
})) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
|
|
6498
|
-
return pass.name ===
|
|
6412
|
+
return pass.name === passName;
|
|
6499
6413
|
});
|
|
6500
6414
|
}
|
|
6501
|
-
var
|
|
6502
|
-
|
|
6415
|
+
var shaderPassSource = Shader._shaderLab._parseShaderPass(passSource.contents, passSource.vertexEntry, passSource.fragmentEntry, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, new URL(fragmentSourceOrPath != null ? fragmentSourceOrPath : "", ShaderPass._shaderRootPath).href);
|
|
6416
|
+
if (!shaderPassSource) {
|
|
6417
|
+
throw 'Shader pass "' + shaderSource.name + "." + subShaderSource.name + "." + passSource.name + '" parse failed, please check the shader source code.';
|
|
6418
|
+
}
|
|
6419
|
+
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.vertex, shaderPassSource.fragment, passSource.tags);
|
|
6420
|
+
shaderPass._platformTarget = vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget;
|
|
6421
|
+
var _passSource_renderStates = passSource.renderStates, constantMap = _passSource_renderStates.constantMap, variableMap = _passSource_renderStates.variableMap;
|
|
6503
6422
|
// Compatible shader lab no render state use material `renderState` to modify render state
|
|
6504
6423
|
if (Object.keys(constantMap).length > 0 || Object.keys(variableMap).length > 0) {
|
|
6505
6424
|
// Parse const render state
|
|
6506
6425
|
var renderState = new RenderState();
|
|
6507
|
-
shaderPassContent._renderState = renderState;
|
|
6508
6426
|
for(var k in constantMap){
|
|
6509
|
-
Shader._applyConstRenderStates(renderState,
|
|
6427
|
+
Shader._applyConstRenderStates(renderState, +k, constantMap[k]);
|
|
6510
6428
|
}
|
|
6429
|
+
shaderPass._renderState = renderState;
|
|
6511
6430
|
// Parse variable render state
|
|
6512
6431
|
var renderStateDataMap = {};
|
|
6513
6432
|
for(var k1 in variableMap){
|
|
6514
6433
|
renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
|
|
6515
6434
|
}
|
|
6516
|
-
|
|
6435
|
+
shaderPass._renderStateDataMap = renderStateDataMap;
|
|
6517
6436
|
}
|
|
6518
|
-
return
|
|
6437
|
+
return shaderPass;
|
|
6519
6438
|
});
|
|
6520
|
-
return new SubShader(
|
|
6439
|
+
return new SubShader(subShaderSource.name, passList, subShaderSource.tags);
|
|
6521
6440
|
});
|
|
6522
|
-
shader = new Shader(
|
|
6523
|
-
shaderMap[
|
|
6441
|
+
shader = new Shader(shaderSource.name, subShaderList);
|
|
6442
|
+
shaderMap[shaderSource.name] = shader;
|
|
6524
6443
|
return shader;
|
|
6525
6444
|
} else {
|
|
6526
6445
|
if (shaderMap[nameOrShaderSource]) {
|
|
6527
6446
|
console.error('Shader named "' + nameOrShaderSource + '" already exists.');
|
|
6528
6447
|
return;
|
|
6529
6448
|
}
|
|
6530
|
-
if (typeof
|
|
6531
|
-
var shaderPass = new ShaderPass(
|
|
6449
|
+
if (typeof vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget === "string") {
|
|
6450
|
+
var shaderPass = new ShaderPass(vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, fragmentSourceOrPath);
|
|
6532
6451
|
shader = new Shader(nameOrShaderSource, [
|
|
6533
6452
|
new SubShader("Default", [
|
|
6534
6453
|
shaderPass
|
|
6535
6454
|
])
|
|
6536
6455
|
]);
|
|
6537
6456
|
} else {
|
|
6538
|
-
if (
|
|
6539
|
-
if (
|
|
6457
|
+
if (vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget.length > 0) {
|
|
6458
|
+
if (vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget[0].constructor === ShaderPass) {
|
|
6540
6459
|
shader = new Shader(nameOrShaderSource, [
|
|
6541
|
-
new SubShader("Default",
|
|
6460
|
+
new SubShader("Default", vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget)
|
|
6542
6461
|
]);
|
|
6543
6462
|
} else {
|
|
6544
|
-
shader = new Shader(nameOrShaderSource,
|
|
6463
|
+
shader = new Shader(nameOrShaderSource, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget.slice());
|
|
6545
6464
|
}
|
|
6546
6465
|
} else {
|
|
6547
6466
|
throw "SubShader or ShaderPass count must large than 0.";
|
|
@@ -7648,7 +7567,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
|
|
|
7648
7567
|
_inherits(Transform, Component);
|
|
7649
7568
|
function Transform(entity) {
|
|
7650
7569
|
var _this;
|
|
7651
|
-
_this = Component.call(this, entity) || this, _this._position = new engineMath.Vector3(), _this._rotation = new engineMath.Vector3(), _this._rotationQuaternion = new engineMath.Quaternion(), _this._scale = new engineMath.Vector3(1, 1, 1), _this._localUniformScaling = true, _this._worldPosition = new engineMath.Vector3(), _this._worldRotation = new engineMath.Vector3(), _this._worldRotationQuaternion = new engineMath.Quaternion(), _this._worldUniformScaling = true, _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1), _this._localMatrix = new engineMath.Matrix(), _this._worldMatrix = new engineMath.Matrix(), _this._worldForward = null, _this._worldRight = null, _this._worldUp = null, _this._isParentDirty = true, _this._parentTransformCache = null, _this._dirtyFlag =
|
|
7570
|
+
_this = Component.call(this, entity) || this, _this._position = new engineMath.Vector3(), _this._rotation = new engineMath.Vector3(), _this._rotationQuaternion = new engineMath.Quaternion(), _this._scale = new engineMath.Vector3(1, 1, 1), _this._localUniformScaling = true, _this._worldPosition = new engineMath.Vector3(), _this._worldRotation = new engineMath.Vector3(), _this._worldRotationQuaternion = new engineMath.Quaternion(), _this._worldUniformScaling = true, _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1), _this._localMatrix = new engineMath.Matrix(), _this._worldMatrix = new engineMath.Matrix(), _this._worldForward = null, _this._worldRight = null, _this._worldUp = null, _this._isParentDirty = true, _this._parentTransformCache = null, _this._dirtyFlag = 510;
|
|
7652
7571
|
_this._onPositionChanged = _this._onPositionChanged.bind(_this);
|
|
7653
7572
|
_this._onWorldPositionChanged = _this._onWorldPositionChanged.bind(_this);
|
|
7654
7573
|
_this._onRotationChanged = _this._onRotationChanged.bind(_this);
|
|
@@ -7813,11 +7732,23 @@ function dependentComponents(componentOrComponents, dependentMode) {
|
|
|
7813
7732
|
/**
|
|
7814
7733
|
* @internal
|
|
7815
7734
|
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
7816
|
-
target._position.
|
|
7817
|
-
|
|
7818
|
-
|
|
7735
|
+
var position = target._position, rotation = target._rotation, scale = target._scale;
|
|
7736
|
+
// @ts-ignore
|
|
7737
|
+
position._onValueChanged = rotation._onValueChanged = scale._onValueChanged = null;
|
|
7738
|
+
position.copyFrom(this.position);
|
|
7739
|
+
rotation.copyFrom(this.rotation);
|
|
7740
|
+
scale.copyFrom(this.scale);
|
|
7741
|
+
// @ts-ignore
|
|
7742
|
+
position._onValueChanged = target._onPositionChanged;
|
|
7743
|
+
// @ts-ignore
|
|
7744
|
+
rotation._onValueChanged = target._onRotationChanged;
|
|
7745
|
+
// @ts-ignore
|
|
7746
|
+
scale._onValueChanged = target._onScaleChanged;
|
|
7747
|
+
};
|
|
7748
|
+
_proto._onLocalMatrixChanging = function _onLocalMatrixChanging() {
|
|
7749
|
+
this._setDirtyFlagFalse(64);
|
|
7819
7750
|
};
|
|
7820
|
-
_proto.
|
|
7751
|
+
_proto._onWorldMatrixChanging = function _onWorldMatrixChanging() {
|
|
7821
7752
|
this._setDirtyFlagFalse(128);
|
|
7822
7753
|
};
|
|
7823
7754
|
_proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
|
|
@@ -8267,9 +8198,9 @@ function dependentComponents(componentOrComponents, dependentMode) {
|
|
|
8267
8198
|
// @ts-ignore
|
|
8268
8199
|
position._onValueChanged = rotationQuaternion._onValueChanged = scale._onValueChanged = null;
|
|
8269
8200
|
value.decompose(position, rotationQuaternion, scale);
|
|
8270
|
-
this._onLocalMatrixChanging
|
|
8201
|
+
this._onLocalMatrixChanging();
|
|
8271
8202
|
this._setDirtyFlagTrue(1);
|
|
8272
|
-
this._setDirtyFlagFalse(
|
|
8203
|
+
this._setDirtyFlagFalse(2);
|
|
8273
8204
|
// @ts-ignore
|
|
8274
8205
|
position._onValueChanged = this._onPositionChanged;
|
|
8275
8206
|
// @ts-ignore
|
|
@@ -8314,7 +8245,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
|
|
|
8314
8245
|
this._localMatrix.copyFrom(value);
|
|
8315
8246
|
}
|
|
8316
8247
|
this.localMatrix = this._localMatrix;
|
|
8317
|
-
this.
|
|
8248
|
+
this._onWorldMatrixChanging();
|
|
8318
8249
|
}
|
|
8319
8250
|
},
|
|
8320
8251
|
{
|
|
@@ -8363,40 +8294,40 @@ Transform._tempMat32 = new engineMath.Matrix3x3();
|
|
|
8363
8294
|
Transform._tempMat41 = new engineMath.Matrix();
|
|
8364
8295
|
Transform._tempMat42 = new engineMath.Matrix();
|
|
8365
8296
|
__decorate([
|
|
8366
|
-
|
|
8297
|
+
ignoreClone
|
|
8367
8298
|
], Transform.prototype, "_position", void 0);
|
|
8368
8299
|
__decorate([
|
|
8369
|
-
|
|
8300
|
+
ignoreClone
|
|
8370
8301
|
], Transform.prototype, "_rotation", void 0);
|
|
8371
8302
|
__decorate([
|
|
8372
|
-
|
|
8303
|
+
ignoreClone
|
|
8373
8304
|
], Transform.prototype, "_rotationQuaternion", void 0);
|
|
8374
8305
|
__decorate([
|
|
8375
|
-
|
|
8306
|
+
ignoreClone
|
|
8376
8307
|
], Transform.prototype, "_scale", void 0);
|
|
8377
8308
|
__decorate([
|
|
8378
8309
|
assignmentClone
|
|
8379
8310
|
], Transform.prototype, "_localUniformScaling", void 0);
|
|
8380
8311
|
__decorate([
|
|
8381
|
-
|
|
8312
|
+
ignoreClone
|
|
8382
8313
|
], Transform.prototype, "_worldPosition", void 0);
|
|
8383
8314
|
__decorate([
|
|
8384
|
-
|
|
8315
|
+
ignoreClone
|
|
8385
8316
|
], Transform.prototype, "_worldRotation", void 0);
|
|
8386
8317
|
__decorate([
|
|
8387
|
-
|
|
8318
|
+
ignoreClone
|
|
8388
8319
|
], Transform.prototype, "_worldRotationQuaternion", void 0);
|
|
8389
8320
|
__decorate([
|
|
8390
|
-
|
|
8321
|
+
ignoreClone
|
|
8391
8322
|
], Transform.prototype, "_worldUniformScaling", void 0);
|
|
8392
8323
|
__decorate([
|
|
8393
|
-
|
|
8324
|
+
ignoreClone
|
|
8394
8325
|
], Transform.prototype, "_lossyWorldScale", void 0);
|
|
8395
8326
|
__decorate([
|
|
8396
|
-
|
|
8327
|
+
ignoreClone
|
|
8397
8328
|
], Transform.prototype, "_localMatrix", void 0);
|
|
8398
8329
|
__decorate([
|
|
8399
|
-
|
|
8330
|
+
ignoreClone
|
|
8400
8331
|
], Transform.prototype, "_worldMatrix", void 0);
|
|
8401
8332
|
__decorate([
|
|
8402
8333
|
ignoreClone
|
|
@@ -8413,6 +8344,9 @@ __decorate([
|
|
|
8413
8344
|
__decorate([
|
|
8414
8345
|
ignoreClone
|
|
8415
8346
|
], Transform.prototype, "_parentTransformCache", void 0);
|
|
8347
|
+
__decorate([
|
|
8348
|
+
ignoreClone
|
|
8349
|
+
], Transform.prototype, "_dirtyFlag", void 0);
|
|
8416
8350
|
__decorate([
|
|
8417
8351
|
ignoreClone
|
|
8418
8352
|
], Transform.prototype, "_onPositionChanged", null);
|
|
@@ -8457,6 +8391,7 @@ __decorate([
|
|
|
8457
8391
|
/** WorldMatrix | WorldPosition | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWpWs"] = 164] = "WmWpWs";
|
|
8458
8392
|
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWs"] = 188] = "WmWpWeWqWs";
|
|
8459
8393
|
/** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWsWus"] = 444] = "WmWpWeWqWsWus";
|
|
8394
|
+
/** LocalQuat | LocalMatrix | WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["LqLmWmWpWeWqWsWus"] = 510] = "LqLmWmWpWeWqWsWus";
|
|
8460
8395
|
return TransformModifyFlags;
|
|
8461
8396
|
}({});
|
|
8462
8397
|
|
|
@@ -10935,9 +10870,9 @@ var scalableAmbientOcclusionFS = "// Ambient Occlusion, largely inspired from:\n
|
|
|
10935
10870
|
// projection[0][0] is at index 0 (X scaling)
|
|
10936
10871
|
// projection[1][1] is at index 5 (Y scaling)
|
|
10937
10872
|
// The inverse values we need are:
|
|
10938
|
-
var
|
|
10873
|
+
var invProjectionScaleX = 1.0 / projectionScaleX;
|
|
10939
10874
|
var invProjectionScaleY = 1.0 / projectionScaleY;
|
|
10940
|
-
var invProjScaleXY = this._invProjScaleXY.set(
|
|
10875
|
+
var invProjScaleXY = this._invProjScaleXY.set(invProjectionScaleX * 2.0, invProjectionScaleY * 2.0);
|
|
10941
10876
|
shaderData.setVector2(ScalableAmbientObscurancePass._invProjScaleXYProp, invProjScaleXY);
|
|
10942
10877
|
var quality = ambientOcclusion.quality, radius = ambientOcclusion.radius;
|
|
10943
10878
|
this._updateBlurKernel(shaderData, quality);
|
|
@@ -10983,9 +10918,6 @@ var scalableAmbientOcclusionFS = "// Ambient Occlusion, largely inspired from:\n
|
|
|
10983
10918
|
this._blurRenderTarget = null;
|
|
10984
10919
|
}
|
|
10985
10920
|
this._depthRenderTarget = null;
|
|
10986
|
-
var material = this._material;
|
|
10987
|
-
material._addReferCount(-1);
|
|
10988
|
-
material.destroy();
|
|
10989
10921
|
};
|
|
10990
10922
|
_proto._updateBlurKernel = function _updateBlurKernel(blurShaderData, quality) {
|
|
10991
10923
|
if (quality === this._quality) {
|
|
@@ -19099,7 +19031,7 @@ var BlendShapeFrameDirty = /*#__PURE__*/ function(BlendShapeFrameDirty) {
|
|
|
19099
19031
|
continue;
|
|
19100
19032
|
}
|
|
19101
19033
|
if (material.destroyed || material.shader.destroyed) {
|
|
19102
|
-
material = this.engine.
|
|
19034
|
+
material = this.engine._basicResources.meshMagentaMaterial;
|
|
19103
19035
|
}
|
|
19104
19036
|
var subRenderElement = subRenderElementPool.get();
|
|
19105
19037
|
subRenderElement.set(this, material, mesh._primitive, subMeshes[i1]);
|
|
@@ -23089,6 +23021,8 @@ __decorate([
|
|
|
23089
23021
|
this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
|
|
23090
23022
|
this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
|
|
23091
23023
|
this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
|
|
23024
|
+
this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
|
|
23025
|
+
this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
|
|
23092
23026
|
}
|
|
23093
23027
|
var _proto = BasicResources.prototype;
|
|
23094
23028
|
/**
|
|
@@ -23194,6 +23128,12 @@ __decorate([
|
|
|
23194
23128
|
material.isGCIgnored = true;
|
|
23195
23129
|
return material;
|
|
23196
23130
|
};
|
|
23131
|
+
_proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
|
|
23132
|
+
var material = new Material(engine, Shader.find(shaderName));
|
|
23133
|
+
material.isGCIgnored = true;
|
|
23134
|
+
material.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
23135
|
+
return material;
|
|
23136
|
+
};
|
|
23197
23137
|
_proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
|
|
23198
23138
|
var material = new Material(engine, Shader.find("SpriteMask"));
|
|
23199
23139
|
material.isGCIgnored = true;
|
|
@@ -25772,9 +25712,9 @@ ParticleBufferUtils.boundsFloatStride = 8;
|
|
|
25772
25712
|
ParticleBufferUtils.boundsTimeOffset = 6;
|
|
25773
25713
|
ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
|
|
25774
25714
|
|
|
25775
|
-
var blitFs = "#include <common>\n\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\n\tuniform float renderer_BlitMipLevel;\n#endif\n\nuniform vec4 renderer_SourceScaleOffset;\n\nvarying vec2 v_uv;\n\nvoid main() {\n\tvec2 uv = v_uv;\n\tuv = uv * renderer_SourceScaleOffset.xy + renderer_SourceScaleOffset.zw;\n\n\t#ifdef HAS_TEX_LOD\n\t\tgl_FragColor = texture2DLodSRGB( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n\t#else\n\t\tgl_FragColor = texture2DSRGB( renderer_BlitTexture, uv );\n\t#endif\n}\n\n"; // eslint-disable-line
|
|
25715
|
+
var blitFs = "#include <common>\n\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\n\tuniform float renderer_BlitMipLevel;\n#endif\n\nuniform vec4 renderer_SourceScaleOffset;\n\nvarying vec2 v_uv;\n\n#ifdef HAS_TEX_LOD\n\tvec4 texture2DLodSRGB(sampler2D tex, vec2 uv, float lod) {\n\t\tvec4 color = texture2DLodEXT(tex, uv, lod);\n\t\t#ifdef ENGINE_NO_SRGB\n\t\t\tcolor = sRGBToLinear(color);\n\t\t#endif\n\t\treturn color;\n\t}\n#endif\n\nvoid main() {\n\tvec2 uv = v_uv;\n\tuv = uv * renderer_SourceScaleOffset.xy + renderer_SourceScaleOffset.zw;\n\n\t#ifdef HAS_TEX_LOD\n\t\tgl_FragColor = texture2DLodSRGB( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n\t#else\n\t\tgl_FragColor = texture2DSRGB( renderer_BlitTexture, uv );\n\t#endif\n}\n\n"; // eslint-disable-line
|
|
25776
25716
|
|
|
25777
|
-
var blitScreenFs = "#include <common>\n\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\n\tuniform float renderer_BlitMipLevel;\n#endif\n\nvarying vec2 v_uv;\n\nvoid main() {\n\tvec2 uv = v_uv;\n\t// Screen uv is flipped\n\tuv.y = 1.0 - uv.y;\n\n\t#ifdef HAS_TEX_LOD\n\t\tgl_FragColor = texture2DLodSRGB( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n\t#else\n\t\tgl_FragColor = texture2D( renderer_BlitTexture, uv );\n\t#endif\n\n\t// Color space in screen is in gamma space but without sRGB texture, so we need to convert it to linear space manually\n\tgl_FragColor = sRGBToLinear(gl_FragColor);\n}\n\n"; // eslint-disable-line
|
|
25717
|
+
var blitScreenFs = "#include <common>\n\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\n\tuniform float renderer_BlitMipLevel;\n#endif\n\nvarying vec2 v_uv;\n\n#ifdef HAS_TEX_LOD\n\tvec4 texture2DLodSRGB(sampler2D tex, vec2 uv, float lod) {\n\t\tvec4 color = texture2DLodEXT(tex, uv, lod);\n\t\t#ifdef ENGINE_NO_SRGB\n\t\t\tcolor = sRGBToLinear(color);\n\t\t#endif\n\t\treturn color;\n\t}\n#endif\n\nvoid main() {\n\tvec2 uv = v_uv;\n\t// Screen uv is flipped\n\tuv.y = 1.0 - uv.y;\n\n\t#ifdef HAS_TEX_LOD\n\t\tgl_FragColor = texture2DLodSRGB( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n\t#else\n\t\tgl_FragColor = texture2D( renderer_BlitTexture, uv );\n\t#endif\n\n\t// Color space in screen is in gamma space but without sRGB texture, so we need to convert it to linear space manually\n\tgl_FragColor = sRGBToLinear(gl_FragColor);\n}\n\n"; // eslint-disable-line
|
|
25778
25718
|
|
|
25779
25719
|
var skyProceduralFs = "// This code uses the Unity skybox-Procedural shader algorithm, developed by Unity and licensed under the Unity Companion License. \n// The original implementation can be found at unity build-in shader(DefaultResourcesExtra/Skybox-Procedural.shader)\n\n#include <common>\n\nconst float MIE_G = -0.990;\nconst float MIE_G2 = 0.9801;\nconst float SKY_GROUND_THRESHOLD = 0.02;\n\nuniform float material_SunSize;\nuniform float material_SunSizeConvergence;\nuniform vec4 scene_SunlightColor;\nuniform vec3 scene_SunlightDirection;\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n#ifdef MATERIAL_SUN_HIGH_QUALITY\n\tvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\n\tvarying vec3 v_RayDir;\n#else\n\tvarying float v_SkyGroundFactor;\n#endif\n\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\n\tvarying vec3 v_SunColor;\n#endif\n\n// Calculates the Mie phase function\nfloat getMiePhase(float eyeCos, float eyeCos2) {\n\tfloat temp = 1.0 + MIE_G2 - 2.0 * MIE_G * eyeCos;\n\ttemp = pow(temp, pow(material_SunSize,0.65) * 10.0);\n\ttemp = max(temp,1.0e-4); // prevent division by zero, esp. in half precision\n\ttemp = 1.5 * ((1.0 - MIE_G2) / (2.0 + MIE_G2)) * (1.0 + eyeCos2) / temp;\n\treturn temp;\n}\n\n// Calculates the sun shape\nfloat calcSunAttenuation(vec3 lightPos, vec3 ray) {\n\t#ifdef MATERIAL_SUN_HIGH_QUALITY\n\t\tfloat focusedEyeCos = pow(clamp(dot(lightPos, ray),0.0,1.0), material_SunSizeConvergence);\n\t\treturn getMiePhase(-focusedEyeCos, focusedEyeCos * focusedEyeCos);\n\t#else //MATERIAL_SUN_SIMPLE\n\t\tvec3 delta = lightPos - ray;\n\t\tfloat dist = length(delta);\n\t\tfloat spot = 1.0 - smoothstep(0.0, material_SunSize, dist);\n\t\treturn spot * spot;\n\t#endif\n}\n\nvoid main() {\n\t// if y > 1 [eyeRay.y < -SKY_GROUND_THRESHOLD] - ground\n\t// if y >= 0 and < 1 [eyeRay.y <= 0 and > -SKY_GROUND_THRESHOLD] - horizon\n\t// if y < 0 [eyeRay.y > 0] - sky\n\tvec3 col = vec3(0.0, 0.0, 0.0);\n\n\t#ifdef MATERIAL_SUN_HIGH_QUALITY\n\t\tvec3 ray = normalize(v_Vertex);\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\n\t#elif defined(MATERIAL_SUN_SIMPLE) \n\t\tvec3 ray = v_RayDir;\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\t\n\t#else\n\t\tfloat y = v_SkyGroundFactor;\n\t#endif\n\n\t// if we did precalculate color in vprog: just do lerp between them\n\tcol = mix(v_SkyColor, v_GroundColor, clamp(y,0.0,1.0));\n\n\t#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\n\t\tif (y < 0.0)\n\t\t\tcol += v_SunColor * calcSunAttenuation(-scene_SunlightDirection, -ray);\n\t#endif\n\n\n\tgl_FragColor = vec4(col, 1.0);\n}\n\n"; // eslint-disable-line
|
|
25780
25720
|
|
|
@@ -26102,14 +26042,6 @@ ShaderPool.init();
|
|
|
26102
26042
|
if (!hardwareRenderer.canIUse(GLCapabilityType.sRGB)) {
|
|
26103
26043
|
_this._macroCollection.enable(Engine._noSRGBSupportMacro);
|
|
26104
26044
|
}
|
|
26105
|
-
var meshMagentaMaterial = new Material(_this, Shader.find("unlit"));
|
|
26106
|
-
meshMagentaMaterial.isGCIgnored = true;
|
|
26107
|
-
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
26108
|
-
_this._meshMagentaMaterial = meshMagentaMaterial;
|
|
26109
|
-
var particleMagentaMaterial = new Material(_this, Shader.find("particle-shader"));
|
|
26110
|
-
particleMagentaMaterial.isGCIgnored = true;
|
|
26111
|
-
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
26112
|
-
_this._particleMagentaMaterial = particleMagentaMaterial;
|
|
26113
26045
|
_this._basicResources = new BasicResources(_this);
|
|
26114
26046
|
_this._particleBufferUtils = new ParticleBufferUtils(_this);
|
|
26115
26047
|
var uberPass = new PostProcessUberPass(_this);
|
|
@@ -28250,6 +28182,45 @@ Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
|
|
|
28250
28182
|
Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
|
|
28251
28183
|
Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
|
|
28252
28184
|
|
|
28185
|
+
function _array_like_to_array(arr, len) {
|
|
28186
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
28187
|
+
|
|
28188
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
28189
|
+
|
|
28190
|
+
return arr2;
|
|
28191
|
+
}
|
|
28192
|
+
|
|
28193
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
28194
|
+
if (!o) return;
|
|
28195
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
28196
|
+
|
|
28197
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
28198
|
+
|
|
28199
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
28200
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
28201
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
28202
|
+
}
|
|
28203
|
+
|
|
28204
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
28205
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
28206
|
+
|
|
28207
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
28208
|
+
// Fallback for engines without symbol support
|
|
28209
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
28210
|
+
if (it) o = it;
|
|
28211
|
+
|
|
28212
|
+
var i = 0;
|
|
28213
|
+
|
|
28214
|
+
return function() {
|
|
28215
|
+
if (i >= o.length) return { done: true };
|
|
28216
|
+
|
|
28217
|
+
return { done: false, value: o[i++] };
|
|
28218
|
+
};
|
|
28219
|
+
}
|
|
28220
|
+
|
|
28221
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
28222
|
+
}
|
|
28223
|
+
|
|
28253
28224
|
/**
|
|
28254
28225
|
* Script class, used for logic writing.
|
|
28255
28226
|
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
@@ -32455,7 +32426,7 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
|
|
|
32455
32426
|
return;
|
|
32456
32427
|
}
|
|
32457
32428
|
if (material.destroyed || material.shader.destroyed) {
|
|
32458
|
-
material = this.engine.
|
|
32429
|
+
material = this.engine._basicResources.particleMagentaMaterial;
|
|
32459
32430
|
}
|
|
32460
32431
|
var engine = this._engine;
|
|
32461
32432
|
var renderElement = engine._renderElementPool.get();
|
|
@@ -37415,7 +37386,7 @@ exports.RenderQueue = RenderQueue;
|
|
|
37415
37386
|
exports.RenderQueueFlags = RenderQueueFlags;
|
|
37416
37387
|
exports.RenderQueueType = RenderQueueType;
|
|
37417
37388
|
exports.RenderState = RenderState;
|
|
37418
|
-
exports.
|
|
37389
|
+
exports.RenderStateElementKey = RenderStateElementKey;
|
|
37419
37390
|
exports.RenderTarget = RenderTarget;
|
|
37420
37391
|
exports.RenderTargetBlendState = RenderTargetBlendState;
|
|
37421
37392
|
exports.RendererUpdateFlags = RendererUpdateFlags;
|
|
@@ -37432,11 +37403,11 @@ exports.Shader = Shader;
|
|
|
37432
37403
|
exports.ShaderData = ShaderData;
|
|
37433
37404
|
exports.ShaderDataGroup = ShaderDataGroup;
|
|
37434
37405
|
exports.ShaderFactory = ShaderFactory;
|
|
37406
|
+
exports.ShaderLanguage = ShaderLanguage;
|
|
37435
37407
|
exports.ShaderLib = ShaderLib;
|
|
37436
37408
|
exports.ShaderMacro = ShaderMacro;
|
|
37437
37409
|
exports.ShaderMacroCollection = ShaderMacroCollection;
|
|
37438
37410
|
exports.ShaderPass = ShaderPass;
|
|
37439
|
-
exports.ShaderPlatformTarget = ShaderPlatformTarget;
|
|
37440
37411
|
exports.ShaderProperty = ShaderProperty;
|
|
37441
37412
|
exports.ShaderPropertyType = ShaderPropertyType;
|
|
37442
37413
|
exports.ShaderTagKey = ShaderTagKey;
|