@galacean/engine-core 1.6.0-alpha.2 → 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 +136 -178
- package/dist/main.js.map +1 -1
- package/dist/module.js +135 -177
- package/dist/module.js.map +1 -1
- package/package.json +3 -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.";
|
|
@@ -25793,9 +25712,9 @@ ParticleBufferUtils.boundsFloatStride = 8;
|
|
|
25793
25712
|
ParticleBufferUtils.boundsTimeOffset = 6;
|
|
25794
25713
|
ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
|
|
25795
25714
|
|
|
25796
|
-
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
|
|
25797
25716
|
|
|
25798
|
-
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
|
|
25799
25718
|
|
|
25800
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
|
|
25801
25720
|
|
|
@@ -28263,6 +28182,45 @@ Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
|
|
|
28263
28182
|
Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
|
|
28264
28183
|
Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
|
|
28265
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
|
+
|
|
28266
28224
|
/**
|
|
28267
28225
|
* Script class, used for logic writing.
|
|
28268
28226
|
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
@@ -37428,7 +37386,7 @@ exports.RenderQueue = RenderQueue;
|
|
|
37428
37386
|
exports.RenderQueueFlags = RenderQueueFlags;
|
|
37429
37387
|
exports.RenderQueueType = RenderQueueType;
|
|
37430
37388
|
exports.RenderState = RenderState;
|
|
37431
|
-
exports.
|
|
37389
|
+
exports.RenderStateElementKey = RenderStateElementKey;
|
|
37432
37390
|
exports.RenderTarget = RenderTarget;
|
|
37433
37391
|
exports.RenderTargetBlendState = RenderTargetBlendState;
|
|
37434
37392
|
exports.RendererUpdateFlags = RendererUpdateFlags;
|
|
@@ -37445,11 +37403,11 @@ exports.Shader = Shader;
|
|
|
37445
37403
|
exports.ShaderData = ShaderData;
|
|
37446
37404
|
exports.ShaderDataGroup = ShaderDataGroup;
|
|
37447
37405
|
exports.ShaderFactory = ShaderFactory;
|
|
37406
|
+
exports.ShaderLanguage = ShaderLanguage;
|
|
37448
37407
|
exports.ShaderLib = ShaderLib;
|
|
37449
37408
|
exports.ShaderMacro = ShaderMacro;
|
|
37450
37409
|
exports.ShaderMacroCollection = ShaderMacroCollection;
|
|
37451
37410
|
exports.ShaderPass = ShaderPass;
|
|
37452
|
-
exports.ShaderPlatformTarget = ShaderPlatformTarget;
|
|
37453
37411
|
exports.ShaderProperty = ShaderProperty;
|
|
37454
37412
|
exports.ShaderPropertyType = ShaderPropertyType;
|
|
37455
37413
|
exports.ShaderTagKey = ShaderTagKey;
|