@galacean/engine-core 1.6.0-alpha.2 → 1.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +242 -250
- package/dist/main.js.map +1 -1
- package/dist/module.js +241 -249
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/physics/PhysicsScene.d.ts +116 -4
- 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
|
|
|
@@ -4718,7 +4681,7 @@ var noise_simplex_4D = "//\n// Description : Array and textureless GLSL 2D/3D/4D
|
|
|
4718
4681
|
|
|
4719
4682
|
var pbr_frag_define = "#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n\nuniform float material_AlphaCutoff;\nuniform vec4 material_BaseColor;\nuniform float material_Metal;\nuniform float material_Roughness;\nuniform float material_IOR;\nuniform vec3 material_PBRSpecularColor;\nuniform float material_Glossiness;\nuniform vec3 material_EmissiveColor;\nuniform float material_NormalIntensity;\nuniform float material_OcclusionIntensity;\nuniform float material_OcclusionTextureCoord;\n\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n uniform float material_ClearCoat;\n uniform float material_ClearCoatRoughness;\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n uniform sampler2D material_ClearCoatTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n uniform sampler2D material_ClearCoatRoughnessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n uniform sampler2D material_ClearCoatNormalTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n uniform vec3 material_AnisotropyInfo;\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n uniform sampler2D material_AnisotropyTexture;\n #endif\n#endif\n\n// Texture\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\n#ifdef MATERIAL_HAS_NORMALTEXTURE\n uniform sampler2D material_NormalTexture;\n#endif\n\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n uniform sampler2D material_RoughnessMetallicTexture;\n#endif\n\n\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n uniform sampler2D material_SpecularGlossinessTexture;\n#endif\n\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n uniform sampler2D material_OcclusionTexture;\n#endif\n\n\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform float material_SheenRoughness;\n uniform vec3 material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n uniform sampler2D material_SheenTexture;\n #endif\n\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n uniform sampler2D material_SheenRoughnessTexture;\n #endif\n#endif\n\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n uniform vec4 material_IridescenceInfo;\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n uniform sampler2D material_IridescenceThicknessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n uniform sampler2D material_IridescenceTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION\n uniform float material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n uniform sampler2D material_TransmissionTexture;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n uniform vec3 material_AttenuationColor;\n uniform float material_AttenuationDistance;\n uniform float material_Thickness;\n\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n uniform sampler2D material_ThicknessTexture;\n #endif\n #endif\n#endif\n\n// Runtime\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct Geometry {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n float dotNV;\n \n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatNormal;\n float clearCoatDotNV;\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicT;\n vec3 anisotropicB;\n vec3 anisotropicN;\n float anisotropy;\n #endif\n};\n\nstruct Material {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float opacity;\n float f0;\n float diffuseAO;\n float specularAO;\n vec3 envSpecularDFG;\n float IOR;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float iridescenceIOR;\n float iridescenceFactor;\n float iridescenceThickness;\n vec3 iridescenceSpecularColor;\n #endif\n\n #ifdef MATERIAL_ENABLE_SHEEN\n float sheenRoughness;\n vec3 sheenColor;\n float sheenScaling;\n float approxIBLSheenDG;\n #endif\n\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 absorptionCoefficient;\n float transmission;\n float thickness;\n #endif\n};"; // eslint-disable-line
|
|
4720
4683
|
|
|
4721
|
-
var pbr_helper = "#include <normal_get>\n#include <brdf>\n#include <btdf>\n\n// direct + indirect\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n\nuniform sampler2D camera_AOTexture;\n\nfloat computeSpecularOcclusion(float ambientOcclusion, float roughness, float dotNV ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n\nfloat getAARoughnessFactor(vec3 normal) {\n // Kaplanyan 2016, \"Stable specular highlights\"\n // Tokuyoshi 2017, \"Error Reduction and Simplification for Shading Anti-Aliasing\"\n // Tokuyoshi and Kaplanyan 2019, \"Improved Geometric Specular Antialiasing\"\n #ifdef HAS_DERIVATIVES\n vec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n return max( max(dxy.x, dxy.y), dxy.z );\n #else\n return 0.0;\n #endif\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Aniso Bent Normals\n // Mc Alley https://www.gdcvault.com/play/1022235/Rendering-the-World-of-Far \n vec3 getAnisotropicBentNormal(Geometry geometry, vec3 n, float roughness) {\n vec3 anisotropyDirection = geometry.anisotropy >= 0.0 ? geometry.anisotropicB : geometry.anisotropicT;\n vec3 anisotropicTangent = cross(anisotropyDirection, geometry.viewDir);\n vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\n // reduce stretching for (roughness < 0.2), refer to https://advances.realtimerendering.com/s2018/Siggraph%202018%20HDRP%20talk_with%20notes.pdf 80\n vec3 bentNormal = normalize( mix(n, anisotropicNormal, abs(geometry.anisotropy) * saturate( 5.0 * roughness)) );\n\n return bentNormal;\n }\n#endif\n\nvoid initGeometry(out Geometry geometry, bool isFrontFacing){\n geometry.position = v_pos;\n #ifdef CAMERA_ORTHOGRAPHIC\n geometry.viewDir = -camera_Forward;\n #else\n geometry.viewDir = normalize(camera_Position - v_pos);\n #endif\n #if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\n mat3 tbn = getTBN(isFrontFacing);\n #endif\n\n #ifdef MATERIAL_HAS_NORMALTEXTURE\n geometry.normal = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.normal = getNormal(isFrontFacing);\n #endif\n\n geometry.dotNV = saturate( dot(geometry.normal, geometry.viewDir) );\n\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n geometry.clearCoatNormal = getNormalByNormalTexture(tbn, material_ClearCoatNormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.clearCoatNormal = getNormal(isFrontFacing);\n #endif\n geometry.clearCoatDotNV = saturate( dot(geometry.clearCoatNormal, geometry.viewDir) );\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float anisotropy = material_AnisotropyInfo.z;\n vec3 anisotropicDirection = vec3(material_AnisotropyInfo.xy, 0.0);\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n vec3 anisotropyTextureInfo = texture2D( material_AnisotropyTexture, v_uv ).rgb;\n anisotropy *= anisotropyTextureInfo.b;\n anisotropicDirection.xy *= anisotropyTextureInfo.rg * 2.0 - 1.0;\n #endif\n\n geometry.anisotropy = anisotropy;\n geometry.anisotropicT = normalize(tbn * anisotropicDirection);\n geometry.anisotropicB = normalize(cross(geometry.normal, geometry.anisotropicT));\n #endif\n}\n\nvoid initMaterial(out Material material, inout Geometry geometry){\n vec4 baseColor = material_BaseColor;\n float metal = material_Metal;\n float roughness = material_Roughness;\n vec3 specularColor = material_PBRSpecularColor;\n float glossiness = material_Glossiness;\n float alphaCutoff = material_AlphaCutoff;\n float f0 = pow2( (material_IOR - 1.0) / (material_IOR + 1.0) );\n\n material.f0 = f0;\n material.IOR = material_IOR;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n baseColor *= texture2DSRGB(material_BaseTexture, v_uv);\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n baseColor *= v_color;\n #endif\n\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( baseColor.a < alphaCutoff ) {\n discard;\n }\n #endif\n\n #ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n vec4 metalRoughMapColor = texture2D( material_RoughnessMetallicTexture, v_uv );\n roughness *= metalRoughMapColor.g;\n metal *= metalRoughMapColor.b;\n #endif\n\n #ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n vec4 specularGlossinessColor = texture2DSRGB(material_SpecularGlossinessTexture, v_uv);\n specularColor *= specularGlossinessColor.rgb;\n glossiness *= specularGlossinessColor.a;\n #endif\n\n\n #ifdef IS_METALLIC_WORKFLOW\n material.diffuseColor = baseColor.rgb * ( 1.0 - metal );\n material.specularColor = mix( vec3(f0), baseColor.rgb, metal );\n material.roughness = roughness;\n #else\n float specularStrength = max( max( specularColor.r, specularColor.g ), specularColor.b );\n material.diffuseColor = baseColor.rgb * ( 1.0 - specularStrength );\n material.specularColor = specularColor;\n material.roughness = 1.0 - glossiness;\n #endif\n\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.roughness + getAARoughnessFactor(geometry.normal), 1.0));\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n material.clearCoat = material_ClearCoat;\n material.clearCoatRoughness = material_ClearCoatRoughness;\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n material.clearCoat *= texture2D( material_ClearCoatTexture, v_uv ).r;\n #endif\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n material.clearCoatRoughness *= texture2D( material_ClearCoatRoughnessTexture, v_uv ).g;\n #endif\n material.clearCoat = saturate( material.clearCoat );\n material.clearCoatRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.clearCoatRoughness + getAARoughnessFactor(geometry.clearCoatNormal), 1.0));\n #endif\n\n #ifdef MATERIAL_IS_TRANSPARENT\n material.opacity = baseColor.a;\n #else\n material.opacity = 1.0;\n #endif\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n material.envSpecularDFG = envBRDFApprox(material.specularColor, material.roughness, geometry.dotNV );\n\n // AO\n float diffuseAO = 1.0;\n float specularAO = 1.0;\n\n #ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n vec2 aoUV = v_uv;\n #ifdef RENDERER_HAS_UV1\n if(material_OcclusionTextureCoord == 1.0){\n aoUV = v_uv1;\n }\n #endif\n diffuseAO = ((texture2D(material_OcclusionTexture, aoUV)).r - 1.0) * material_OcclusionIntensity + 1.0;\n #endif\n\n #ifdef SCENE_ENABLE_AMBIENT_OCCLUSION \n float ambientAO = texture2D(camera_AOTexture,(v_PositionCS.xy / v_PositionCS.w) * 0.5 + 0.5).r;\n diffuseAO = min(diffuseAO, ambientAO);\n #endif\n\n #if (defined(MATERIAL_HAS_OCCLUSION_TEXTURE) || defined(SCENE_ENABLE_AMBIENT_OCCLUSION))&& defined(SCENE_USE_SPECULAR_ENV) \n specularAO = saturate( pow( geometry.dotNV + diffuseAO, exp2( - 16.0 * material.roughness - 1.0 ) ) - 1.0 + diffuseAO );\n #endif\n\n material.diffuseAO = diffuseAO;\n material.specularAO = specularAO;\n\n // Sheen\n #ifdef MATERIAL_ENABLE_SHEEN\n vec3 sheenColor = material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n sheenColor *= texture2DSRGB(material_SheenTexture, v_uv).rgb;\n #endif\n material.sheenColor = sheenColor;\n\n material.sheenRoughness = material_SheenRoughness;\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n material.sheenRoughness *= texture2D(material_SheenRoughnessTexture, v_uv).a;\n #endif\n\n material.sheenRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.sheenRoughness + getAARoughnessFactor(geometry.normal), 1.0));\n material.approxIBLSheenDG = prefilteredSheenDFG(geometry.dotNV, material.sheenRoughness);\n material.sheenScaling = 1.0 - material.approxIBLSheenDG * max(max(material.sheenColor.r, material.sheenColor.g), material.sheenColor.b);\n #endif\n\n // Iridescence\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n material.iridescenceFactor = material_IridescenceInfo.x;\n material.iridescenceIOR = material_IridescenceInfo.y;\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n float iridescenceThicknessWeight = texture2D( material_IridescenceThicknessTexture, v_uv).g;\n material.iridescenceThickness = mix(material_IridescenceInfo.z, material_IridescenceInfo.w, iridescenceThicknessWeight);\n #else\n material.iridescenceThickness = material_IridescenceInfo.w;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n material.iridescenceFactor *= texture2D( material_IridescenceTexture, v_uv).r;\n #endif\n \n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float topIOR = 1.0;\n material.iridescenceSpecularColor = evalIridescenceSpecular(topIOR, geometry.dotNV, material.iridescenceIOR, material.specularColor, material.iridescenceThickness); \n #endif\n #endif\n\n // Transmission\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n material.transmission = material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n material.transmission *= texture2D(material_TransmissionTexture, v_uv).r;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n material.absorptionCoefficient = -log(material_AttenuationColor + HALF_EPS) / max(HALF_EPS, material_AttenuationDistance);\n material.thickness = max(material_Thickness, 0.0001);\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n material.thickness *= texture2D( material_ThicknessTexture, v_uv).g;\n #endif\n #endif \n #endif\n\n}\n\n\n"; // eslint-disable-line
|
|
4684
|
+
var pbr_helper = "#include <normal_get>\n#include <brdf>\n#include <btdf>\n\n// direct + indirect\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n\nuniform sampler2D camera_AOTexture;\n\nfloat evaluateAmbientOcclusion(vec2 uv)\n{\n #ifdef MATERIAL_IS_TRANSPARENT\n return 1.0;\n #else\n return texture2D(camera_AOTexture, uv).r;\n #endif\n}\n\n\nfloat computeSpecularOcclusion(float ambientOcclusion, float roughness, float dotNV ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n\nfloat getAARoughnessFactor(vec3 normal) {\n // Kaplanyan 2016, \"Stable specular highlights\"\n // Tokuyoshi 2017, \"Error Reduction and Simplification for Shading Anti-Aliasing\"\n // Tokuyoshi and Kaplanyan 2019, \"Improved Geometric Specular Antialiasing\"\n #ifdef HAS_DERIVATIVES\n vec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n return max( max(dxy.x, dxy.y), dxy.z );\n #else\n return 0.0;\n #endif\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Aniso Bent Normals\n // Mc Alley https://www.gdcvault.com/play/1022235/Rendering-the-World-of-Far \n vec3 getAnisotropicBentNormal(Geometry geometry, vec3 n, float roughness) {\n vec3 anisotropyDirection = geometry.anisotropy >= 0.0 ? geometry.anisotropicB : geometry.anisotropicT;\n vec3 anisotropicTangent = cross(anisotropyDirection, geometry.viewDir);\n vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\n // reduce stretching for (roughness < 0.2), refer to https://advances.realtimerendering.com/s2018/Siggraph%202018%20HDRP%20talk_with%20notes.pdf 80\n vec3 bentNormal = normalize( mix(n, anisotropicNormal, abs(geometry.anisotropy) * saturate( 5.0 * roughness)) );\n\n return bentNormal;\n }\n#endif\n\nvoid initGeometry(out Geometry geometry, bool isFrontFacing){\n geometry.position = v_pos;\n #ifdef CAMERA_ORTHOGRAPHIC\n geometry.viewDir = -camera_Forward;\n #else\n geometry.viewDir = normalize(camera_Position - v_pos);\n #endif\n #if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\n mat3 tbn = getTBN(isFrontFacing);\n #endif\n\n #ifdef MATERIAL_HAS_NORMALTEXTURE\n geometry.normal = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.normal = getNormal(isFrontFacing);\n #endif\n\n geometry.dotNV = saturate( dot(geometry.normal, geometry.viewDir) );\n\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n geometry.clearCoatNormal = getNormalByNormalTexture(tbn, material_ClearCoatNormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.clearCoatNormal = getNormal(isFrontFacing);\n #endif\n geometry.clearCoatDotNV = saturate( dot(geometry.clearCoatNormal, geometry.viewDir) );\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float anisotropy = material_AnisotropyInfo.z;\n vec3 anisotropicDirection = vec3(material_AnisotropyInfo.xy, 0.0);\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n vec3 anisotropyTextureInfo = texture2D( material_AnisotropyTexture, v_uv ).rgb;\n anisotropy *= anisotropyTextureInfo.b;\n anisotropicDirection.xy *= anisotropyTextureInfo.rg * 2.0 - 1.0;\n #endif\n\n geometry.anisotropy = anisotropy;\n geometry.anisotropicT = normalize(tbn * anisotropicDirection);\n geometry.anisotropicB = normalize(cross(geometry.normal, geometry.anisotropicT));\n #endif\n}\n\nvoid initMaterial(out Material material, inout Geometry geometry){\n vec4 baseColor = material_BaseColor;\n float metal = material_Metal;\n float roughness = material_Roughness;\n vec3 specularColor = material_PBRSpecularColor;\n float glossiness = material_Glossiness;\n float alphaCutoff = material_AlphaCutoff;\n float f0 = pow2( (material_IOR - 1.0) / (material_IOR + 1.0) );\n\n material.f0 = f0;\n material.IOR = material_IOR;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n baseColor *= texture2DSRGB(material_BaseTexture, v_uv);\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n baseColor *= v_color;\n #endif\n\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( baseColor.a < alphaCutoff ) {\n discard;\n }\n #endif\n\n #ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n vec4 metalRoughMapColor = texture2D( material_RoughnessMetallicTexture, v_uv );\n roughness *= metalRoughMapColor.g;\n metal *= metalRoughMapColor.b;\n #endif\n\n #ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n vec4 specularGlossinessColor = texture2DSRGB(material_SpecularGlossinessTexture, v_uv);\n specularColor *= specularGlossinessColor.rgb;\n glossiness *= specularGlossinessColor.a;\n #endif\n\n\n #ifdef IS_METALLIC_WORKFLOW\n material.diffuseColor = baseColor.rgb * ( 1.0 - metal );\n material.specularColor = mix( vec3(f0), baseColor.rgb, metal );\n material.roughness = roughness;\n #else\n float specularStrength = max( max( specularColor.r, specularColor.g ), specularColor.b );\n material.diffuseColor = baseColor.rgb * ( 1.0 - specularStrength );\n material.specularColor = specularColor;\n material.roughness = 1.0 - glossiness;\n #endif\n\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.roughness + getAARoughnessFactor(geometry.normal), 1.0));\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n material.clearCoat = material_ClearCoat;\n material.clearCoatRoughness = material_ClearCoatRoughness;\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n material.clearCoat *= texture2D( material_ClearCoatTexture, v_uv ).r;\n #endif\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n material.clearCoatRoughness *= texture2D( material_ClearCoatRoughnessTexture, v_uv ).g;\n #endif\n material.clearCoat = saturate( material.clearCoat );\n material.clearCoatRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.clearCoatRoughness + getAARoughnessFactor(geometry.clearCoatNormal), 1.0));\n #endif\n\n #ifdef MATERIAL_IS_TRANSPARENT\n material.opacity = baseColor.a;\n #else\n material.opacity = 1.0;\n #endif\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n material.envSpecularDFG = envBRDFApprox(material.specularColor, material.roughness, geometry.dotNV );\n\n // AO\n float diffuseAO = 1.0;\n float specularAO = 1.0;\n\n #ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n vec2 aoUV = v_uv;\n #ifdef RENDERER_HAS_UV1\n if(material_OcclusionTextureCoord == 1.0){\n aoUV = v_uv1;\n }\n #endif\n diffuseAO = ((texture2D(material_OcclusionTexture, aoUV)).r - 1.0) * material_OcclusionIntensity + 1.0;\n #endif\n\n #ifdef SCENE_ENABLE_AMBIENT_OCCLUSION\n float ambientAO = evaluateAmbientOcclusion((v_PositionCS.xy / v_PositionCS.w) * 0.5 + 0.5);\n diffuseAO = min(diffuseAO, ambientAO);\n #endif\n\n #if (defined(MATERIAL_HAS_OCCLUSION_TEXTURE) || defined(SCENE_ENABLE_AMBIENT_OCCLUSION))&& defined(SCENE_USE_SPECULAR_ENV) \n specularAO = saturate( pow( geometry.dotNV + diffuseAO, exp2( - 16.0 * material.roughness - 1.0 ) ) - 1.0 + diffuseAO );\n #endif\n\n material.diffuseAO = diffuseAO;\n material.specularAO = specularAO;\n\n // Sheen\n #ifdef MATERIAL_ENABLE_SHEEN\n vec3 sheenColor = material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n sheenColor *= texture2DSRGB(material_SheenTexture, v_uv).rgb;\n #endif\n material.sheenColor = sheenColor;\n\n material.sheenRoughness = material_SheenRoughness;\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n material.sheenRoughness *= texture2D(material_SheenRoughnessTexture, v_uv).a;\n #endif\n\n material.sheenRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.sheenRoughness + getAARoughnessFactor(geometry.normal), 1.0));\n material.approxIBLSheenDG = prefilteredSheenDFG(geometry.dotNV, material.sheenRoughness);\n material.sheenScaling = 1.0 - material.approxIBLSheenDG * max(max(material.sheenColor.r, material.sheenColor.g), material.sheenColor.b);\n #endif\n\n // Iridescence\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n material.iridescenceFactor = material_IridescenceInfo.x;\n material.iridescenceIOR = material_IridescenceInfo.y;\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n float iridescenceThicknessWeight = texture2D( material_IridescenceThicknessTexture, v_uv).g;\n material.iridescenceThickness = mix(material_IridescenceInfo.z, material_IridescenceInfo.w, iridescenceThicknessWeight);\n #else\n material.iridescenceThickness = material_IridescenceInfo.w;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n material.iridescenceFactor *= texture2D( material_IridescenceTexture, v_uv).r;\n #endif\n \n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float topIOR = 1.0;\n material.iridescenceSpecularColor = evalIridescenceSpecular(topIOR, geometry.dotNV, material.iridescenceIOR, material.specularColor, material.iridescenceThickness); \n #endif\n #endif\n\n // Transmission\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n material.transmission = material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n material.transmission *= texture2D(material_TransmissionTexture, v_uv).r;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n material.absorptionCoefficient = -log(material_AttenuationColor + HALF_EPS) / max(HALF_EPS, material_AttenuationDistance);\n material.thickness = max(material_Thickness, 0.0001);\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n material.thickness *= texture2D( material_ThicknessTexture, v_uv).g;\n #endif\n #endif \n #endif\n}\n\n\n\n"; // eslint-disable-line
|
|
4722
4685
|
|
|
4723
4686
|
var brdf = "\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform sampler2D scene_PrefilteredDFG;\n#endif\n\nfloat F_Schlick(float f0, float dotLH) {\n\treturn f0 + 0.96 * (pow(1.0 - dotLH, 5.0));\n}\n\nvec3 F_Schlick(vec3 specularColor, float dotLH ) {\n\n\t// Original approximation by Christophe Schlick '94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH '13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n}\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated(float alpha, float dotNL, float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Heitz 2014, \"Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs\"\n // Heitz http://jcgt.org/published/0003/02/03/paper.pdf\n float G_GGX_SmithCorrelated_Anisotropic(float at, float ab, float ToV, float BoV, float ToL, float BoL, float NoV, float NoL) {\n float lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\n float lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\n return 0.5 / max(lambdaV + lambdaL, EPSILON);\n }\n#endif\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat D_GGX(float alpha, float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n#ifdef MATERIAL_ENABLE_SHEEN\n // http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf\n float D_Charlie(float roughness, float dotNH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = dotNH * dotNH;\n float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n }\n\n // Neubelt and Pettineo 2013, \"Crafting a Next-gen Material Pipeline for The Order: 1886\".\n float V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n }\n\n vec3 sheenBRDF(vec3 incidentDirection, Geometry geometry, vec3 sheenColor, float sheenRoughness) {\n vec3 halfDir = normalize(incidentDirection + geometry.viewDir);\n float dotNL = saturate(dot(geometry.normal, incidentDirection));\n float dotNH = saturate(dot(geometry.normal, halfDir));\n float D = D_Charlie(sheenRoughness, dotNH);\n float V = V_Neubelt(geometry.dotNV, dotNL);\n vec3 F = sheenColor;\n return D * V * F;\n }\n\n float prefilteredSheenDFG(float dotNV, float sheenRoughness) {\n #ifdef HAS_TEX_LOD\n return texture2DLodEXT(scene_PrefilteredDFG, vec2(dotNV, sheenRoughness), 0.0).b;\n #else\n return texture2D(scene_PrefilteredDFG, vec2(dotNV, sheenRoughness),0.0).b;\n #endif \n }\n#endif\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // GGX Distribution Anisotropic\n // https://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf Addenda\n float D_GGX_Anisotropic(float at, float ab, float ToH, float BoH, float NoH) {\n float a2 = at * ab;\n vec3 d = vec3(ab * ToH, at * BoH, a2 * NoH);\n float d2 = dot(d, d);\n float b2 = a2 / d2;\n return a2 * b2 * b2 * RECIPROCAL_PI;\n }\n#endif\n\nfloat DG_GGX(float alpha, float dotNV, float dotNL, float dotNH) {\n\tfloat D = D_GGX( alpha, dotNH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n return G * D;\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n float DG_GGX_anisotropic(vec3 h, vec3 l, Geometry geometry, float alpha, float dotNV, float dotNL, float dotNH) {\n vec3 t = geometry.anisotropicT;\n vec3 b = geometry.anisotropicB;\n vec3 v = geometry.viewDir;\n\n float dotTV = dot(t, v);\n float dotBV = dot(b, v);\n float dotTL = dot(t, l);\n float dotBL = dot(b, l);\n float dotTH = dot(t, h);\n float dotBH = dot(b, h);\n\n // Aniso parameter remapping\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf page 24\n float at = max(alpha * (1.0 + geometry.anisotropy), MIN_ROUGHNESS);\n float ab = max(alpha * (1.0 - geometry.anisotropy), MIN_ROUGHNESS);\n\n // specular anisotropic BRDF\n float D = D_GGX_Anisotropic(at, ab, dotTH, dotBH, dotNH);\n float G = G_GGX_SmithCorrelated_Anisotropic(at, ab, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL);\n\n return G * D;\n }\n#endif\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n vec3 iorToFresnel0(vec3 transmittedIOR, float incidentIOR) {\n return pow((transmittedIOR - incidentIOR) / (transmittedIOR + incidentIOR),vec3(2.0));\n } \n\n float iorToFresnel0(float transmittedIOR, float incidentIOR) {\n return pow((transmittedIOR - incidentIOR) / (transmittedIOR + incidentIOR),2.0);\n } \n\n // Assume air interface for top\n // Note: We don't handle the case fresnel0 == 1\n vec3 fresnelToIOR(vec3 f0){\n vec3 sqrtF0 = sqrt(f0);\n return (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);\n }\n\n // Fresnel equations for dielectric/dielectric interfaces.\n // Ref: https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html\n // Evaluation XYZ sensitivity curves in Fourier space\n vec3 evalSensitivity(float opd, vec3 shift){\n // Use Gaussian fits, given by 3 parameters: val, pos and var\n float phase = 2.0 * PI * opd * 1.0e-9;\n const vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n const vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);\n const vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);\n vec3 xyz = val * sqrt(2.0 * PI * var) * cos(pos * phase + shift) * exp(-var * pow2(phase));\n xyz.x += 9.7470e-14 * sqrt(2.0 * PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(-4.5282e+09 * pow2(phase));\n xyz /= 1.0685e-7;\n // XYZ to RGB color space\n const mat3 XYZ_TO_RGB = mat3( 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252);\n vec3 rgb = XYZ_TO_RGB * xyz;\n return rgb;\n }\n\n vec3 evalIridescenceSpecular(float outsideIOR, float dotNV, float thinIOR, vec3 baseF0,float iridescenceThickness){ \n vec3 iridescence = vec3(1.0);\n // Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0\n float iridescenceIOR = mix( outsideIOR, thinIOR, smoothstep( 0.0, 0.03, iridescenceThickness ) );\n // Evaluate the cosTheta on the base layer (Snell law)\n float sinTheta2Sq = pow( outsideIOR / iridescenceIOR, 2.0) * (1.0 - pow( dotNV, 2.0));\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n // Handle total internal reflection\n if (cosTheta2Sq < 0.0) {\n return iridescence;\n }\n float cosTheta2 = sqrt(cosTheta2Sq);\n \n // First interface\n float f0 = iorToFresnel0(iridescenceIOR, outsideIOR);\n float reflectance = F_Schlick(f0, dotNV);\n float t121 = 1.0 - reflectance;\n float phi12 = 0.0;\n // iridescenceIOR has limited greater than 1.0\n // if (iridescenceIOR < outsideIOR) {phi12 = PI;} \n float phi21 = PI - phi12;\n \n // Second interface\n vec3 baseIOR = fresnelToIOR(clamp(baseF0, 0.0, 0.9999)); // guard against 1.0\n vec3 r1 = iorToFresnel0(baseIOR, iridescenceIOR);\n vec3 r23 = F_Schlick(r1, cosTheta2);\n vec3 phi23 =vec3(0.0);\n if (baseIOR[0] < iridescenceIOR) {phi23[0] = PI;}\n if (baseIOR[1] < iridescenceIOR) {phi23[1] = PI;}\n if (baseIOR[2] < iridescenceIOR) {phi23[2] = PI;}\n \n // Phase shift\n float opd = 2.0 * iridescenceIOR * iridescenceThickness * cosTheta2;\n vec3 phi = vec3(phi21) + phi23;\n \n // Compound terms\n vec3 r123 = clamp(reflectance * r23, 1e-5, 0.9999);\n vec3 sr123 = sqrt(r123);\n vec3 rs = pow2(t121) * r23 / (vec3(1.0) - r123);\n // Reflectance term for m = 0 (DC term amplitude)\n vec3 c0 = reflectance + rs;\n iridescence = c0;\n // Reflectance term for m > 0 (pairs of diracs)\n vec3 cm = rs - t121;\n for (int m = 1; m <= 2; ++m) {\n cm *= sr123;\n vec3 sm = 2.0 * evalSensitivity(float(m) * opd, float(m) * phi);\n iridescence += cm * sm;\n }\n return iridescence = max(iridescence, vec3(0.0)); \n }\n#endif\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX(vec3 incidentDirection, Geometry geometry, Material material, vec3 normal, vec3 specularColor, float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4's roughness\n\n\tvec3 halfDir = normalize( incidentDirection + geometry.viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentDirection ) );\n\tfloat dotNV = saturate( dot( normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentDirection, halfDir ) );\n\n vec3 F = F_Schlick( specularColor, dotLH );\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n F = mix(F, material.iridescenceSpecularColor, material.iridescenceFactor);\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float GD = DG_GGX_anisotropic(halfDir, incidentDirection, geometry, alpha, dotNV, dotNL, dotNH);\n #else\n float GD = DG_GGX(alpha, dotNV, dotNL, dotNH);\n #endif\n\n return F * GD;\n}\n\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\n"; // eslint-disable-line
|
|
4724
4687
|
|
|
@@ -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.";
|
|
@@ -9473,6 +9392,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
|
|
|
9473
9392
|
var shaderData = _this.shaderData;
|
|
9474
9393
|
shaderData.setFloat(BaseMaterial._alphaCutoffProp, 0);
|
|
9475
9394
|
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.Opaque);
|
|
9395
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, RenderQueueType.Opaque);
|
|
9476
9396
|
return _this;
|
|
9477
9397
|
}
|
|
9478
9398
|
var _proto = BaseMaterial.prototype;
|
|
@@ -9565,44 +9485,48 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
|
|
|
9565
9485
|
};
|
|
9566
9486
|
_proto._seIsTransparent = function _seIsTransparent(value) {
|
|
9567
9487
|
if (value !== this._isTransparent) {
|
|
9488
|
+
// Forward pass
|
|
9568
9489
|
this.setIsTransparent(0, value);
|
|
9490
|
+
// Shadow caster pass and depth only pass
|
|
9569
9491
|
var shaderData = this.shaderData;
|
|
9570
9492
|
if (value) {
|
|
9571
|
-
//
|
|
9493
|
+
// Shadow caster render queue, use alpha test queue to simulate transparent shadow
|
|
9572
9494
|
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
9495
|
+
// Depth only render queue
|
|
9496
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, RenderQueueType.Transparent);
|
|
9573
9497
|
} else {
|
|
9574
9498
|
var alphaCutoff = shaderData.getFloat(BaseMaterial._alphaCutoffProp);
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9499
|
+
var renderQueueType = alphaCutoff ? RenderQueueType.AlphaTest : RenderQueueType.Opaque;
|
|
9500
|
+
// Shadow caster render queue
|
|
9501
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, renderQueueType);
|
|
9502
|
+
// Depth only render queue
|
|
9503
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, renderQueueType);
|
|
9580
9504
|
}
|
|
9581
9505
|
this._isTransparent = value;
|
|
9582
9506
|
}
|
|
9583
9507
|
};
|
|
9584
9508
|
_proto._setAlphaCutoff = function _setAlphaCutoff(value) {
|
|
9585
|
-
var shaderData =
|
|
9509
|
+
var _this = this, shaderData = _this.shaderData, isTransparent = _this._isTransparent;
|
|
9586
9510
|
if (shaderData.getFloat(BaseMaterial._alphaCutoffProp) !== value) {
|
|
9587
9511
|
if (value) {
|
|
9588
9512
|
shaderData.enableMacro(BaseMaterial._alphaCutoffMacro);
|
|
9513
|
+
// Forward render queue
|
|
9514
|
+
var forwardQueue = isTransparent ? RenderQueueType.Transparent : RenderQueueType.AlphaTest;
|
|
9515
|
+
this.renderStates[0].renderQueueType = forwardQueue;
|
|
9516
|
+
// Shadow caster render queue
|
|
9589
9517
|
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
9518
|
+
// Depth only render queue
|
|
9519
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, forwardQueue);
|
|
9590
9520
|
} else {
|
|
9591
9521
|
shaderData.disableMacro(BaseMaterial._alphaCutoffMacro);
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
var renderState = renderStates[i];
|
|
9601
|
-
if (value > 0) {
|
|
9602
|
-
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.AlphaTest;
|
|
9603
|
-
} else {
|
|
9604
|
-
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.Opaque;
|
|
9605
|
-
}
|
|
9522
|
+
// Forward render queue
|
|
9523
|
+
var forwardQueue1 = isTransparent ? RenderQueueType.Transparent : RenderQueueType.Opaque;
|
|
9524
|
+
this.renderStates[0].renderQueueType = forwardQueue1;
|
|
9525
|
+
// Shadow caster render queue
|
|
9526
|
+
var shadowCasterQueue = isTransparent ? RenderQueueType.AlphaTest : RenderQueueType.Opaque;
|
|
9527
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, shadowCasterQueue);
|
|
9528
|
+
// Depth only render queue
|
|
9529
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, forwardQueue1);
|
|
9606
9530
|
}
|
|
9607
9531
|
shaderData.setFloat(BaseMaterial._alphaCutoffProp, value);
|
|
9608
9532
|
}
|
|
@@ -9698,6 +9622,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
|
|
|
9698
9622
|
return BaseMaterial;
|
|
9699
9623
|
}(Material);
|
|
9700
9624
|
/** @internal */ BaseMaterial._shadowCasterRenderQueueProp = ShaderProperty.getByName("material_ShadowCasterRenderQueue");
|
|
9625
|
+
/** @internal */ BaseMaterial._depthOnlyRenderQueueProp = ShaderProperty.getByName("material_DepthOnlyRenderQueue");
|
|
9701
9626
|
BaseMaterial._baseTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_BASETEXTURE");
|
|
9702
9627
|
BaseMaterial._normalTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_NORMALTEXTURE");
|
|
9703
9628
|
BaseMaterial._emissiveTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_EMISSIVETEXTURE");
|
|
@@ -12632,65 +12557,91 @@ __decorate([
|
|
|
12632
12557
|
}
|
|
12633
12558
|
return result;
|
|
12634
12559
|
};
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
if (
|
|
12647
|
-
|
|
12648
|
-
if (
|
|
12560
|
+
_proto.boxCast = function boxCast(center, halfExtents, direction, orientationOrDistanceOrResult, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
12561
|
+
var hitResult;
|
|
12562
|
+
var orientation = PhysicsScene._identityQuaternion;
|
|
12563
|
+
var distance = Number.MAX_VALUE;
|
|
12564
|
+
var layerMask = Layer.Everything;
|
|
12565
|
+
// Parse parameters based on new overload patterns
|
|
12566
|
+
if (typeof orientationOrDistanceOrResult === "number") {
|
|
12567
|
+
distance = orientationOrDistanceOrResult;
|
|
12568
|
+
if ((distanceOrResult == null ? void 0 : distanceOrResult.constructor) === HitResult) {
|
|
12569
|
+
hitResult = distanceOrResult;
|
|
12570
|
+
}
|
|
12571
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === HitResult) {
|
|
12572
|
+
hitResult = orientationOrDistanceOrResult;
|
|
12573
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === engineMath.Quaternion) {
|
|
12574
|
+
orientation = orientationOrDistanceOrResult;
|
|
12575
|
+
if (typeof distanceOrResult === "number") {
|
|
12576
|
+
distance = distanceOrResult;
|
|
12577
|
+
if (typeof layerMaskOrResult === "number") {
|
|
12578
|
+
layerMask = layerMaskOrResult;
|
|
12579
|
+
}
|
|
12580
|
+
}
|
|
12581
|
+
}
|
|
12582
|
+
if (outHitResult) {
|
|
12583
|
+
hitResult = outHitResult;
|
|
12584
|
+
}
|
|
12649
12585
|
var preFilter = this._createPreFilter(layerMask);
|
|
12650
|
-
var result = this._nativePhysicsScene.boxCast(center, orientation, halfExtents, direction, distance, preFilter,
|
|
12651
|
-
if (!result &&
|
|
12652
|
-
this._clearHitResult(
|
|
12586
|
+
var result = this._nativePhysicsScene.boxCast(center, orientation, halfExtents, direction, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
|
|
12587
|
+
if (!result && hitResult) {
|
|
12588
|
+
this._clearHitResult(hitResult);
|
|
12653
12589
|
}
|
|
12654
12590
|
return result;
|
|
12655
12591
|
};
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12592
|
+
_proto.sphereCast = function sphereCast(center, radius, direction, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
12593
|
+
var hitResult;
|
|
12594
|
+
var distance = Number.MAX_VALUE;
|
|
12595
|
+
var layerMask = Layer.Everything;
|
|
12596
|
+
// Parse parameters based on new overload patterns
|
|
12597
|
+
if (typeof distanceOrResult === "number") {
|
|
12598
|
+
distance = distanceOrResult;
|
|
12599
|
+
if ((layerMaskOrResult == null ? void 0 : layerMaskOrResult.constructor) === HitResult) {
|
|
12600
|
+
hitResult = layerMaskOrResult;
|
|
12601
|
+
} else if (typeof layerMaskOrResult === "number") {
|
|
12602
|
+
layerMask = layerMaskOrResult;
|
|
12603
|
+
}
|
|
12604
|
+
} else if ((distanceOrResult == null ? void 0 : distanceOrResult.constructor) === HitResult) {
|
|
12605
|
+
hitResult = distanceOrResult;
|
|
12606
|
+
}
|
|
12607
|
+
if (outHitResult) {
|
|
12608
|
+
hitResult = outHitResult;
|
|
12609
|
+
}
|
|
12668
12610
|
var preFilter = this._createPreFilter(layerMask);
|
|
12669
|
-
var result = this._nativePhysicsScene.sphereCast(center, radius, direction, distance, preFilter,
|
|
12670
|
-
if (!result &&
|
|
12671
|
-
this._clearHitResult(
|
|
12611
|
+
var result = this._nativePhysicsScene.sphereCast(center, radius, direction, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
|
|
12612
|
+
if (!result && hitResult) {
|
|
12613
|
+
this._clearHitResult(hitResult);
|
|
12672
12614
|
}
|
|
12673
12615
|
return result;
|
|
12674
12616
|
};
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
if (
|
|
12688
|
-
|
|
12689
|
-
|
|
12617
|
+
_proto.capsuleCast = function capsuleCast(center, radius, height, direction, orientationOrDistanceOrResult, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
12618
|
+
var hitResult;
|
|
12619
|
+
var orientation = PhysicsScene._identityQuaternion;
|
|
12620
|
+
var distance = Number.MAX_VALUE;
|
|
12621
|
+
var layerMask = Layer.Everything;
|
|
12622
|
+
if (typeof orientationOrDistanceOrResult === "number") {
|
|
12623
|
+
distance = orientationOrDistanceOrResult;
|
|
12624
|
+
if ((distanceOrResult == null ? void 0 : distanceOrResult.constructor) === HitResult) {
|
|
12625
|
+
hitResult = distanceOrResult;
|
|
12626
|
+
}
|
|
12627
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === HitResult) {
|
|
12628
|
+
hitResult = orientationOrDistanceOrResult;
|
|
12629
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === engineMath.Quaternion) {
|
|
12630
|
+
orientation = orientationOrDistanceOrResult;
|
|
12631
|
+
if (typeof distanceOrResult === "number") {
|
|
12632
|
+
distance = distanceOrResult;
|
|
12633
|
+
if (typeof layerMaskOrResult === "number") {
|
|
12634
|
+
layerMask = layerMaskOrResult;
|
|
12635
|
+
}
|
|
12636
|
+
}
|
|
12637
|
+
}
|
|
12638
|
+
if (outHitResult) {
|
|
12639
|
+
hitResult = outHitResult;
|
|
12640
|
+
}
|
|
12690
12641
|
var preFilter = this._createPreFilter(layerMask);
|
|
12691
|
-
var result = this._nativePhysicsScene.capsuleCast(center, radius, height, orientation, direction, distance, preFilter,
|
|
12692
|
-
if (!result &&
|
|
12693
|
-
this._clearHitResult(
|
|
12642
|
+
var result = this._nativePhysicsScene.capsuleCast(center, radius, height, orientation, direction, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
|
|
12643
|
+
if (!result && hitResult) {
|
|
12644
|
+
this._clearHitResult(hitResult);
|
|
12694
12645
|
}
|
|
12695
12646
|
return result;
|
|
12696
12647
|
};
|
|
@@ -25793,9 +25744,9 @@ ParticleBufferUtils.boundsFloatStride = 8;
|
|
|
25793
25744
|
ParticleBufferUtils.boundsTimeOffset = 6;
|
|
25794
25745
|
ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
|
|
25795
25746
|
|
|
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
|
|
25747
|
+
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
25748
|
|
|
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
|
|
25749
|
+
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
25750
|
|
|
25800
25751
|
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
25752
|
|
|
@@ -25861,6 +25812,8 @@ var unlitVs = "#include <common>\n#include <common_vert>\n#include <blendShape_i
|
|
|
25861
25812
|
var depthOnlyPass = new ShaderPass("DepthOnly", depthOnlyVs, depthOnlyFs, {
|
|
25862
25813
|
pipelineStage: PipelineStage.DepthOnly
|
|
25863
25814
|
});
|
|
25815
|
+
depthOnlyPass._renderState = new RenderState();
|
|
25816
|
+
depthOnlyPass._renderStateDataMap[RenderStateElementKey.RenderQueueType] = BaseMaterial._depthOnlyRenderQueueProp;
|
|
25864
25817
|
var basePasses = [
|
|
25865
25818
|
shadowCasterPass,
|
|
25866
25819
|
depthOnlyPass
|
|
@@ -28263,6 +28216,45 @@ Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
|
|
|
28263
28216
|
Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
|
|
28264
28217
|
Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
|
|
28265
28218
|
|
|
28219
|
+
function _array_like_to_array(arr, len) {
|
|
28220
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
28221
|
+
|
|
28222
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
28223
|
+
|
|
28224
|
+
return arr2;
|
|
28225
|
+
}
|
|
28226
|
+
|
|
28227
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
28228
|
+
if (!o) return;
|
|
28229
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
28230
|
+
|
|
28231
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
28232
|
+
|
|
28233
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
28234
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
28235
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
28236
|
+
}
|
|
28237
|
+
|
|
28238
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
28239
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
28240
|
+
|
|
28241
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
28242
|
+
// Fallback for engines without symbol support
|
|
28243
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
28244
|
+
if (it) o = it;
|
|
28245
|
+
|
|
28246
|
+
var i = 0;
|
|
28247
|
+
|
|
28248
|
+
return function() {
|
|
28249
|
+
if (i >= o.length) return { done: true };
|
|
28250
|
+
|
|
28251
|
+
return { done: false, value: o[i++] };
|
|
28252
|
+
};
|
|
28253
|
+
}
|
|
28254
|
+
|
|
28255
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
28256
|
+
}
|
|
28257
|
+
|
|
28266
28258
|
/**
|
|
28267
28259
|
* Script class, used for logic writing.
|
|
28268
28260
|
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
@@ -37428,7 +37420,7 @@ exports.RenderQueue = RenderQueue;
|
|
|
37428
37420
|
exports.RenderQueueFlags = RenderQueueFlags;
|
|
37429
37421
|
exports.RenderQueueType = RenderQueueType;
|
|
37430
37422
|
exports.RenderState = RenderState;
|
|
37431
|
-
exports.
|
|
37423
|
+
exports.RenderStateElementKey = RenderStateElementKey;
|
|
37432
37424
|
exports.RenderTarget = RenderTarget;
|
|
37433
37425
|
exports.RenderTargetBlendState = RenderTargetBlendState;
|
|
37434
37426
|
exports.RendererUpdateFlags = RendererUpdateFlags;
|
|
@@ -37445,11 +37437,11 @@ exports.Shader = Shader;
|
|
|
37445
37437
|
exports.ShaderData = ShaderData;
|
|
37446
37438
|
exports.ShaderDataGroup = ShaderDataGroup;
|
|
37447
37439
|
exports.ShaderFactory = ShaderFactory;
|
|
37440
|
+
exports.ShaderLanguage = ShaderLanguage;
|
|
37448
37441
|
exports.ShaderLib = ShaderLib;
|
|
37449
37442
|
exports.ShaderMacro = ShaderMacro;
|
|
37450
37443
|
exports.ShaderMacroCollection = ShaderMacroCollection;
|
|
37451
37444
|
exports.ShaderPass = ShaderPass;
|
|
37452
|
-
exports.ShaderPlatformTarget = ShaderPlatformTarget;
|
|
37453
37445
|
exports.ShaderProperty = ShaderProperty;
|
|
37454
37446
|
exports.ShaderPropertyType = ShaderPropertyType;
|
|
37455
37447
|
exports.ShaderTagKey = ShaderTagKey;
|