@galacean/engine 1.4.0-alpha.1 → 1.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1538 -693
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -8459,55 +8459,55 @@
|
|
|
8459
8459
|
GLCapabilityType["WEBGL_lose_context"] = "WEBGL_lose_context";
|
|
8460
8460
|
return GLCapabilityType;
|
|
8461
8461
|
}({});
|
|
8462
|
-
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position
|
|
8463
|
-
var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x
|
|
8464
|
-
var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\
|
|
8465
|
-
var transform_declare = "#define GLSLIFY 1\nuniform mat4 renderer_LocalMat
|
|
8466
|
-
var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
|
|
8467
|
-
var FogFragmentDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\
|
|
8468
|
-
var FogVertexDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\
|
|
8469
|
-
var normal_share = "#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\
|
|
8470
|
-
var uv_share = "#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\
|
|
8471
|
-
var worldpos_share = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\
|
|
8472
|
-
var begin_normal_vert = "#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\
|
|
8473
|
-
var begin_position_vert = "#define GLSLIFY 1\
|
|
8474
|
-
var blendShape_input = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\
|
|
8475
|
-
var blendShape_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\
|
|
8476
|
-
var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\
|
|
8477
|
-
var FogVertex = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\
|
|
8478
|
-
var normal_vert = "#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\
|
|
8479
|
-
var position_vert = "#define GLSLIFY 1\
|
|
8480
|
-
var skinning_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\
|
|
8481
|
-
var uv_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\
|
|
8482
|
-
var worldpos_vert = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\
|
|
8483
|
-
var FogFragment = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\
|
|
8484
|
-
var light_frag_define = "#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\
|
|
8485
|
-
var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveColor
|
|
8486
|
-
var begin_mobile_frag = "#define GLSLIFY 1\
|
|
8487
|
-
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\
|
|
8488
|
-
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\
|
|
8462
|
+
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;\nuniform vec3 camera_Forward; \nuniform vec4 camera_ProjectionParams;"; // eslint-disable-line
|
|
8463
|
+
var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n\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 srgbIn){\n return vec4( pow(srgbIn.rgb, vec3(2.2)), srgbIn.a);\n}\n\nvec4 linearToGamma(vec4 linearIn){\n\tlinearIn = max(linearIn, 0.0);\n return vec4( pow(linearIn.rgb, vec3(1.0 / 2.2)), linearIn.a);\n}\n\nuniform vec4 camera_DepthBufferParams;\n\nfloat remapDepthBufferLinear01(float z){\n\treturn 1.0/ (camera_DepthBufferParams.x * z + camera_DepthBufferParams.y);\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"; // eslint-disable-line
|
|
8464
|
+
var common_vert = "#define GLSLIFY 1\nattribute 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#include <transform_declare>\n#include <camera_declare>\n\nuniform vec4 material_TilingOffset;\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
|
|
8465
|
+
var transform_declare = "#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;\nuniform mat4 renderer_ModelMat;\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\nuniform mat4 renderer_MVMat;\nuniform mat4 renderer_MVPMat;\nuniform mat4 renderer_NormalMat;"; // eslint-disable-line
|
|
8466
|
+
var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\n\nvarying vec4 v_color;\n\n#endif\n"; // eslint-disable-line
|
|
8467
|
+
var FogFragmentDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n varying vec3 v_positionVS;\n\n uniform vec4 scene_FogColor;\n uniform vec4 scene_FogParams;// (-1/(end-start), end/(end-start), density/ln(2),density/sprt(ln(2)));\n\n float ComputeFogIntensity(float fogDepth){\n #if SCENE_FOG_MODE == 1\n // (end-z) / (end-start) = z * (-1/(end-start)) + (end/(end-start))\n return clamp(fogDepth * scene_FogParams.x + scene_FogParams.y, 0.0, 1.0);\n #elif SCENE_FOG_MODE == 2\n // exp(-z * density) = exp2((-z * density)/ln(2)) = exp2(-z * density/ln(2))\n return clamp(exp2(-fogDepth * scene_FogParams.z), 0.0, 1.0);\n #elif SCENE_FOG_MODE == 3\n // exp(-(z * density)^2) = exp2(-(z * density)^2/ln(2)) = exp2(-(z * density/sprt(ln(2)))^2)\n float factor = fogDepth * scene_FogParams.w;\n return clamp(exp2(-factor * factor), 0.0, 1.0);\n #endif\n }\n#endif\n"; // eslint-disable-line
|
|
8468
|
+
var FogVertexDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n varying vec3 v_positionVS;\n#endif\n"; // eslint-disable-line
|
|
8469
|
+
var normal_share = "#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n varying vec3 v_normal;\n #if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\n varying mat3 v_TBN;\n #endif\n #endif\n#endif"; // eslint-disable-line
|
|
8470
|
+
var uv_share = "#define GLSLIFY 1\nvarying vec2 v_uv;\n\n#ifdef RENDERER_HAS_UV1\n varying vec2 v_uv1;\n#endif"; // eslint-disable-line
|
|
8471
|
+
var worldpos_share = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\n varying vec3 v_pos;\n#endif\n"; // eslint-disable-line
|
|
8472
|
+
var begin_normal_vert = "#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n vec3 normal = vec3( NORMAL );\n #endif\n\n #ifdef RENDERER_HAS_TANGENT\n vec4 tangent = vec4( TANGENT );\n #endif\n#endif"; // eslint-disable-line
|
|
8473
|
+
var begin_position_vert = "#define GLSLIFY 1\n vec4 position = vec4( POSITION , 1.0 );\n"; // eslint-disable-line
|
|
8474
|
+
var blendShape_input = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n\t#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\n\t\tuniform mediump sampler2DArray renderer_BlendShapeTexture;\n\t\tuniform ivec3 renderer_BlendShapeTextureInfo;\n\t\tuniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n\t#else\n\t\tattribute vec3 POSITION_BS0;\n\t\tattribute vec3 POSITION_BS1;\n\t\t#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n\t\t\tattribute vec3 NORMAL_BS0;\n\t\t\tattribute vec3 NORMAL_BS1;\n\t\t\tattribute vec3 TANGENT_BS0;\n\t\t\tattribute vec3 TANGENT_BS1;\n\t\t\tuniform float renderer_BlendShapeWeights[2];\n\t\t#else\n\t\t\t#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n\t\t\t\tattribute vec3 POSITION_BS2;\n\t\t\t\tattribute vec3 POSITION_BS3;\n\t\t\t\t#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\n\t\t\t\t\tattribute vec3 NORMAL_BS0;\n\t\t\t\t\tattribute vec3 NORMAL_BS1;\n\t\t\t\t\tattribute vec3 NORMAL_BS2;\n\t\t\t\t\tattribute vec3 NORMAL_BS3;\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\n\t\t\t\t\tattribute vec3 TANGENT_BS0;\n\t\t\t\t\tattribute vec3 TANGENT_BS1;\n\t\t\t\t\tattribute vec3 TANGENT_BS2;\n\t\t\t\t\tattribute vec3 TANGENT_BS3;\n\t\t\t\t#endif\n\n\t\t\t\tuniform float renderer_BlendShapeWeights[4];\n\t\t\t#else\n\t\t\t\tattribute vec3 POSITION_BS2;\n\t\t\t\tattribute vec3 POSITION_BS3;\n\t\t\t\tattribute vec3 POSITION_BS4;\n\t\t\t\tattribute vec3 POSITION_BS5;\n\t\t\t\tattribute vec3 POSITION_BS6;\n\t\t\t\tattribute vec3 POSITION_BS7;\n\t\t\t\tuniform float renderer_BlendShapeWeights[8];\n\t\t\t#endif\n\t\t#endif\n\t#endif\n\n\t#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\n\t\tvec3 getBlendShapeVertexElement(int blendShapeIndex, int vertexElementIndex)\n\t\t{\t\t\t\n\t\t\tint y = vertexElementIndex / renderer_BlendShapeTextureInfo.y;\n\t\t\tint x = vertexElementIndex - y * renderer_BlendShapeTextureInfo.y;\n\t\t\tivec3 uv = ivec3(x, y , blendShapeIndex);\n\t\t\treturn texelFetch(renderer_BlendShapeTexture, uv, 0).xyz;\n\t\t}\n\t#endif\n#endif\n"; // eslint-disable-line
|
|
8475
|
+
var blendShape_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n\t#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\t\n\t\tint vertexOffset = gl_VertexID * renderer_BlendShapeTextureInfo.x;\n\t\tfor(int i = 0; i < RENDERER_BLENDSHAPE_COUNT; i++){\n\t\t\tint vertexElementOffset = vertexOffset;\n\t\t\tfloat weight = renderer_BlendShapeWeights[i];\n\t\t\t// Warnning: Multiplying by 0 creates weird precision issues, causing rendering anomalies in Ace2 Android13\n\t\t\tif(weight != 0.0){\n\t\t\t\tposition.xyz += getBlendShapeVertexElement(i, vertexElementOffset) * weight;\n\t\n\t\t\t\t#ifndef MATERIAL_OMIT_NORMAL\n\t\t\t\t\t#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\n\t\t\t\t\t\tvertexElementOffset += 1;\n\t\t\t\t\t\tnormal += getBlendShapeVertexElement(i, vertexElementOffset) * weight;\n\t\t\t\t\t#endif\n\t\n\t\t\t\t\t#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n\t\t\t\t\t\tvertexElementOffset += 1;\n\t\t\t\t\t\ttangent.xyz += getBlendShapeVertexElement(i, vertexElementOffset) * weight;\n\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t}\n\t\t\t\n\t\t}\n\t#else\n\t\tposition.xyz += POSITION_BS0 * renderer_BlendShapeWeights[0];\n\t\tposition.xyz += POSITION_BS1 * renderer_BlendShapeWeights[1];\n\n\t\t#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n\t\t\t#ifndef MATERIAL_OMIT_NORMAL\n\t\t\t\t#ifdef RENDERER_HAS_NORMAL\n\t\t\t\t\tnormal += NORMAL_BS0 * renderer_BlendShapeWeights[0];\n\t\t\t\t\tnormal += NORMAL_BS1 * renderer_BlendShapeWeights[1];\n\t\t\t\t#endif\n\t\t\t\t#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n\t\t\t\t\ttangent.xyz += TANGENT_BS0 * renderer_BlendShapeWeights[0];\n\t\t\t\t\ttangent.xyz += TANGENT_BS1 * renderer_BlendShapeWeights[1];\n\t\t\t\t#endif\t\t\t\t\n\t\t\t#endif\n\t\t#else\n\t\t\t#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n\t\t\t\t#ifndef MATERIAL_OMIT_NORMAL\n\t\t\t\t\tposition.xyz += POSITION_BS2 * renderer_BlendShapeWeights[2];\n\t\t\t\t\tposition.xyz += POSITION_BS3 * renderer_BlendShapeWeights[3];\n\n\t\t\t\t\t#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\n\t\t\t\t\t\tnormal += NORMAL_BS0 * renderer_BlendShapeWeights[0];\n\t\t\t\t\t\tnormal += NORMAL_BS1 * renderer_BlendShapeWeights[1];\n\t\t\t\t\t\tnormal += NORMAL_BS2 * renderer_BlendShapeWeights[2];\n\t\t\t\t\t\tnormal += NORMAL_BS3 * renderer_BlendShapeWeights[3];\n\t\t\t\t\t#endif\n\n\t\t\t\t\t#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n\t\t\t\t\t\ttangent.xyz += TANGENT_BS0 * renderer_BlendShapeWeights[0];\n\t\t\t\t\t\ttangent.xyz += TANGENT_BS1 * renderer_BlendShapeWeights[1];\n\t\t\t\t\t\ttangent.xyz += TANGENT_BS2 * renderer_BlendShapeWeights[2];\n\t\t\t\t\t\ttangent.xyz += TANGENT_BS3 * renderer_BlendShapeWeights[3];\n\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t#else\n\t\t\t\tposition.xyz += POSITION_BS2 * renderer_BlendShapeWeights[2];\n\t\t\t\tposition.xyz += POSITION_BS3 * renderer_BlendShapeWeights[3];\n\t\t\t\tposition.xyz += POSITION_BS4 * renderer_BlendShapeWeights[4];\n\t\t\t\tposition.xyz += POSITION_BS5 * renderer_BlendShapeWeights[5];\n\t\t\t\tposition.xyz += POSITION_BS6 * renderer_BlendShapeWeights[6];\n\t\t\t\tposition.xyz += POSITION_BS7 * renderer_BlendShapeWeights[7];\n\t\t\t#endif\n\t\t#endif\n\t#endif\n#endif\n\n"; // eslint-disable-line
|
|
8476
|
+
var color_vert = "#define GLSLIFY 1\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n\n v_color = COLOR_0;\n\n #endif\n"; // eslint-disable-line
|
|
8477
|
+
var FogVertex = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n vec4 positionVS = renderer_MVMat * position;\n v_positionVS = positionVS.xyz / positionVS.w;\n#endif\n"; // eslint-disable-line
|
|
8478
|
+
var normal_vert = "#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n v_normal = normalize( mat3(renderer_NormalMat) * normal );\n\n #if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\n vec3 tangentW = normalize( mat3(renderer_NormalMat) * tangent.xyz );\n vec3 bitangentW = cross( v_normal, tangentW ) * tangent.w;\n\n v_TBN = mat3( tangentW, bitangentW, v_normal );\n #endif\n #endif\n#endif"; // eslint-disable-line
|
|
8479
|
+
var position_vert = "#define GLSLIFY 1\n gl_Position = renderer_MVPMat * position;"; // eslint-disable-line
|
|
8480
|
+
var skinning_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n\n #ifdef RENDERER_USE_JOINT_TEXTURE\n mat4 skinMatrix =\n WEIGHTS_0.x * getJointMatrix(renderer_JointSampler, JOINTS_0.x ) +\n WEIGHTS_0.y * getJointMatrix(renderer_JointSampler, JOINTS_0.y ) +\n WEIGHTS_0.z * getJointMatrix(renderer_JointSampler, JOINTS_0.z ) +\n WEIGHTS_0.w * getJointMatrix(renderer_JointSampler, JOINTS_0.w );\n\n #else\n mat4 skinMatrix =\n WEIGHTS_0.x * renderer_JointMatrix[ int( JOINTS_0.x ) ] +\n WEIGHTS_0.y * renderer_JointMatrix[ int( JOINTS_0.y ) ] +\n WEIGHTS_0.z * renderer_JointMatrix[ int( JOINTS_0.z ) ] +\n WEIGHTS_0.w * renderer_JointMatrix[ int( JOINTS_0.w ) ];\n #endif\n\n position = skinMatrix * position;\n\n #if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\n mat3 skinNormalMatrix = INVERSE_MAT(mat3(skinMatrix));\n normal = normal * skinNormalMatrix;\n #if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\n tangent.xyz = tangent.xyz * skinNormalMatrix;\n #endif\n\n #endif\n\n#endif\n"; // eslint-disable-line
|
|
8481
|
+
var uv_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\n v_uv = TEXCOORD_0;\n#else\n // may need this calculate normal\n v_uv = vec2( 0., 0. );\n#endif\n\n#ifdef RENDERER_HAS_UV1\n v_uv1 = TEXCOORD_1;\n#endif\n\n#ifdef MATERIAL_NEED_TILING_OFFSET\n v_uv = v_uv * material_TilingOffset.xy + material_TilingOffset.zw;\n#endif"; // eslint-disable-line
|
|
8482
|
+
var worldpos_vert = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\n vec4 temp_pos = renderer_ModelMat * position;\n v_pos = temp_pos.xyz / temp_pos.w;\n#endif\n"; // eslint-disable-line
|
|
8483
|
+
var FogFragment = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\n float fogIntensity = ComputeFogIntensity(length(v_positionVS));\n gl_FragColor.rgb = mix(scene_FogColor.rgb, gl_FragColor.rgb, fogIntensity);\n#endif\n"; // eslint-disable-line
|
|
8484
|
+
var light_frag_define = "#define GLSLIFY 1\n// Directional light\n#ifdef SCENE_DIRECT_LIGHT_COUNT\n\n struct DirectLight {\n vec3 color;\n vec3 direction;\n };\n\n uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];\n uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];\n uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n\n#endif\n\n// Point light\n#ifdef SCENE_POINT_LIGHT_COUNT\n\n struct PointLight {\n vec3 color;\n vec3 position;\n float distance;\n };\n\n uniform ivec2 scene_PointLightCullingMask[ SCENE_POINT_LIGHT_COUNT ];\n uniform vec3 scene_PointLightColor[ SCENE_POINT_LIGHT_COUNT ];\n uniform vec3 scene_PointLightPosition[ SCENE_POINT_LIGHT_COUNT ];\n uniform float scene_PointLightDistance[ SCENE_POINT_LIGHT_COUNT ];\n\n#endif\n\n// Spot light\n#ifdef SCENE_SPOT_LIGHT_COUNT\n\n struct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n float distance;\n float angleCos;\n float penumbraCos;\n };\n\n uniform ivec2 scene_SpotLightCullingMask[ SCENE_SPOT_LIGHT_COUNT ];\n uniform vec3 scene_SpotLightColor[ SCENE_SPOT_LIGHT_COUNT ];\n uniform vec3 scene_SpotLightPosition[ SCENE_SPOT_LIGHT_COUNT ];\n uniform vec3 scene_SpotLightDirection[ SCENE_SPOT_LIGHT_COUNT ];\n uniform float scene_SpotLightDistance[ SCENE_SPOT_LIGHT_COUNT ];\n uniform float scene_SpotLightAngleCos[ SCENE_SPOT_LIGHT_COUNT ];\n uniform float scene_SpotLightPenumbraCos[ SCENE_SPOT_LIGHT_COUNT ];\n\n#endif\n\n// Ambient light\nstruct EnvMapLight {\n vec3 diffuse;\n float mipMapLevel;\n float diffuseIntensity;\n float specularIntensity;\n};\n\nuniform EnvMapLight scene_EnvMapLight;\nuniform ivec4 renderer_Layer;\n\n#ifdef SCENE_USE_SH\n uniform vec3 scene_EnvSH[9];\n#endif\n\n#ifdef SCENE_USE_SPECULAR_ENV\n uniform samplerCube scene_EnvSpecularSampler;\n#endif\n\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value, float mask, float bitIndex)\n{\n return mod(floor(value / pow(2.0, bitIndex)), 2.0) == 1.0 && mod(floor(mask / pow(2.0, bitIndex)), 2.0) == 1.0;\n}\n#endif\n\nbool isRendererCulledByLight(ivec2 rendererLayer, ivec2 lightCullingMask)\n{\n #ifdef GRAPHICS_API_WEBGL2\n return !((rendererLayer.x & lightCullingMask.x) != 0 || (rendererLayer.y & lightCullingMask.y) != 0);\n #else\n for (int i = 0; i < 16; i++) {\n if (isBitSet( float(rendererLayer.x), float(lightCullingMask.x), float(i)) || isBitSet( float(rendererLayer.y), float(lightCullingMask.y), float(i))) {\n return false;\n }\n }\n return true;\n #endif\n}\n"; // eslint-disable-line
|
|
8485
|
+
var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;\nuniform vec4 material_BaseColor;\nuniform vec4 material_SpecularColor;\nuniform float material_Shininess;\nuniform float material_NormalIntensity;\nuniform float material_AlphaCutoff;\n\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n uniform sampler2D material_SpecularTexture;\n#endif\n\n#ifdef MATERIAL_HAS_NORMALTEXTURE\n uniform sampler2D material_NormalTexture;\n#endif\n"; // eslint-disable-line
|
|
8486
|
+
var begin_mobile_frag = "#define GLSLIFY 1\n vec4 ambient = vec4(0.0);\n vec4 emission = material_EmissiveColor;\n vec4 diffuse = material_BaseColor;\n vec4 specular = material_SpecularColor;\n\n \n\n #ifdef MATERIAL_HAS_EMISSIVETEXTURE\n vec4 emissiveTextureColor = texture2D(material_EmissiveTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n emissiveTextureColor = gammaToLinear(emissiveTextureColor);\n #endif\n emission *= emissiveTextureColor;\n\n #endif\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 diffuseTextureColor = texture2D(material_BaseTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n diffuseTextureColor = gammaToLinear(diffuseTextureColor);\n #endif\n diffuse *= diffuseTextureColor;\n\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n\n diffuse *= v_color;\n\n #endif\n\n #ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n vec4 specularTextureColor = texture2D(material_SpecularTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n specularTextureColor = gammaToLinear(specularTextureColor);\n #endif\n specular *= specularTextureColor;\n\n #endif\n\n ambient = vec4(scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity, 1.0) * diffuse;"; // eslint-disable-line
|
|
8487
|
+
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\n vec3 V = -camera_Forward;\n#else\n #ifdef MATERIAL_NEED_WORLD_POS\n vec3 V = normalize( camera_Position - v_pos );\n #endif\n#endif"; // eslint-disable-line
|
|
8488
|
+
var mobile_blinnphong_frag = "#define GLSLIFY 1\n #ifdef MATERIAL_HAS_NORMALTEXTURE\n mat3 tbn = getTBN(gl_FrontFacing);\n vec3 N = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, gl_FrontFacing);\n #else\n vec3 N = getNormal(gl_FrontFacing);\n #endif\n\n vec3 lightDiffuse = vec3( 0.0, 0.0, 0.0 );\n vec3 lightSpecular = vec3( 0.0, 0.0, 0.0 );\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n \n float d = max(dot(N, -directionalLight.direction), 0.0);\n lightDiffuse += directionalLight.color * d;\n \n vec3 halfDir = normalize( V - directionalLight.direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess );\n lightSpecular += directionalLight.color * s;\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n PointLight pointLight;\n for( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n vec3 direction = v_pos - pointLight.position;\n float dist = length( direction );\n direction /= dist;\n float decay = clamp(1.0 - pow(dist / pointLight.distance, 4.0), 0.0, 1.0);\n\n float d = max( dot( N, -direction ), 0.0 ) * decay;\n lightDiffuse += pointLight.color * d;\n\n vec3 halfDir = normalize( V - direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess ) * decay;\n lightSpecular += pointLight.color * s;\n }\n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n SpotLight spotLight;\n for( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i++) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n vec3 direction = spotLight.position - v_pos;\n float lightDistance = length( direction );\n direction /= lightDistance;\n float angleCos = dot( direction, -spotLight.direction );\n float decay = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n float spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n float decayTotal = decay * spotEffect;\n float d = max( dot( N, direction ), 0.0 ) * decayTotal;\n lightDiffuse += spotLight.color * d;\n\n vec3 halfDir = normalize( V + direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess ) * decayTotal;\n lightSpecular += spotLight.color * s;\n }\n }\n\n #endif\n\n diffuse *= vec4( lightDiffuse, 1.0 );\n specular *= vec4( lightSpecular, 1.0 );\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( diffuse.a < material_AlphaCutoff ) {\n discard;\n }\n #endif\n"; // eslint-disable-line
|
|
8489
8489
|
var noise_cellular = "#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n"; // eslint-disable-line
|
|
8490
|
-
var noise_cellular_2D = "#define GLSLIFY 1\nvec2 cellular(vec2 P){
|
|
8491
|
-
var noise_cellular_2x2 = "#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){
|
|
8492
|
-
var noise_cellular_2x2x2 = "#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){
|
|
8493
|
-
var noise_cellular_3D = "#define GLSLIFY 1\nvec2 cellular(vec3 P){
|
|
8494
|
-
var noise_common = "#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0
|
|
8490
|
+
var noise_cellular_2D = "#define GLSLIFY 1\n// Cellular noise (\"Worley noise\") in 2D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Standard 3x3 search window for good F1 and F2 values\nvec2 cellular( vec2 P ) {\n\n\tvec2 Pi = mod289( floor( P ) );\n \tvec2 Pf = fract( P );\n\tvec3 oi = vec3( -1.0, 0.0, 1.0);\n\tvec3 of = vec3( -0.5, 0.5, 1.5);\n\tvec3 px = permute( Pi.x + oi );\n\tvec3 p = permute( px.x + Pi.y + oi ); // p11, p12, p13\n\tvec3 ox = fract( p * K ) - Ko;\n\tvec3 oy = mod7( floor( p * K ) ) * K - Ko;\n\tvec3 dx = Pf.x + 0.5 + jitter * ox;\n\tvec3 dy = Pf.y - of + jitter * oy;\n\tvec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared\n\tp = permute( px.y + Pi.y + oi ); // p21, p22, p23\n\tox = fract( p * K ) - Ko;\n\toy = mod7( floor( p * K ) ) * K - Ko;\n\tdx = Pf.x - 0.5 + jitter * ox;\n\tdy = Pf.y - of + jitter * oy;\n\tvec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared\n\tp = permute( px.z + Pi.y + oi ); // p31, p32, p33\n\tox = fract( p * K ) - Ko;\n\toy = mod7( floor( p * K ) ) * K - Ko;\n\tdx = Pf.x - 1.5 + jitter * ox;\n\tdy = Pf.y - of + jitter * oy;\n\tvec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared\n\t// Sort out the two smallest distances (F1, F2)\n\tvec3 d1a = min( d1, d2 );\n\td2 = max( d1, d2 ); // Swap to keep candidates for F2\n\td2 = min( d2, d3 ); // neither F1 nor F2 are now in d3\n\td1 = min( d1a, d2 ); // F1 is now in d1\n\td2 = max( d1a, d2 ); // Swap to keep candidates for F2\n\td1.xy = ( d1.x < d1.y ) ? d1.xy : d1.yx; // Swap if smaller\n\td1.xz = ( d1.x < d1.z ) ? d1.xz : d1.zx; // F1 is in d1.x\n\td1.yz = min( d1.yz, d2.yz ); // F2 is now not in d2.yz\n\td1.y = min( d1.y, d1.z ); // nor in d1.z\n\td1.y = min( d1.y, d2.x ); // F2 is in d1.y, we're done.\n\treturn sqrt( d1.xy );\n\n}\n"; // eslint-disable-line
|
|
8491
|
+
var noise_cellular_2x2 = "#define GLSLIFY 1\n// Cellular noise (\"Worley noise\") in 2D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Speeded up by using 2x2 search window instead of 3x3,\n// at the expense of some strong pattern artifacts.\n// F2 is often wrong and has sharp discontinuities.\n// If you need a smooth F2, use the slower 3x3 version.\n// F1 is sometimes wrong, too, but OK for most purposes.\nvec2 cellular2x2( vec2 P ) {\n\n\tvec2 Pi = mod289( floor( P ) );\n \tvec2 Pf = fract( P );\n\tvec4 Pfx = Pf.x + vec4( -0.5, -1.5, -0.5, -1.5 );\n\tvec4 Pfy = Pf.y + vec4( -0.5, -0.5, -1.5, -1.5 );\n\tvec4 p = permute( Pi.x + vec4( 0.0, 1.0, 0.0, 1.0 ) );\n\tp = permute( p + Pi.y + vec4( 0.0, 0.0, 1.0, 1.0 ) );\n\tvec4 ox = mod7( p ) * K + Kd2;\n\tvec4 oy = mod7( floor( p * K ) ) * K + Kd2;\n\tvec4 dx = Pfx + jitter1 * ox;\n\tvec4 dy = Pfy + jitter1 * oy;\n\tvec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared\n\n\t// Do it right and find both F1 and F2\n\td.xy = ( d.x < d.y ) ? d.xy : d.yx; // Swap if smaller\n\td.xz = ( d.x < d.z ) ? d.xz : d.zx;\n\td.xw = ( d.x < d.w ) ? d.xw : d.wx;\n\td.y = min( d.y, d.z );\n\td.y = min( d.y, d.w );\n\treturn sqrt( d.xy );\n\n}\n"; // eslint-disable-line
|
|
8492
|
+
var noise_cellular_2x2x2 = "#define GLSLIFY 1\n// Cellular noise (\"Worley noise\") in 3D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Speeded up by using 2x2x2 search window instead of 3x3x3,\n// at the expense of some pattern artifacts.\n// F2 is often wrong and has sharp discontinuities.\n// If you need a good F2, use the slower 3x3x3 version.\nvec2 cellular2x2x2(vec3 P) {\n\n\tvec3 Pi = mod289( floor( P ) );\n \tvec3 Pf = fract( P );\n\tvec4 Pfx = Pf.x + vec4( 0.0, -1.0, 0.0, -1.0 );\n\tvec4 Pfy = Pf.y + vec4( 0.0, 0.0, -1.0, -1.0 );\n\tvec4 p = permute( Pi.x + vec4( 0.0, 1.0, 0.0, 1.0 ) );\n\tp = permute( p + Pi.y + vec4( 0.0, 0.0, 1.0, 1.0 ) );\n\tvec4 p1 = permute( p + Pi.z ); // z+0\n\tvec4 p2 = permute( p + Pi.z + vec4( 1.0 ) ); // z+1\n\tvec4 ox1 = fract( p1 * K ) - Ko;\n\tvec4 oy1 = mod7( floor( p1 * K ) ) * K - Ko;\n\tvec4 oz1 = floor( p1 * K2 ) * Kz - Kzo; // p1 < 289 guaranteed\n\tvec4 ox2 = fract( p2 * K ) - Ko;\n\tvec4 oy2 = mod7( floor( p2 * K ) ) * K - Ko;\n\tvec4 oz2 = floor( p2 * K2 ) * Kz - Kzo;\n\tvec4 dx1 = Pfx + jitter1 * ox1;\n\tvec4 dy1 = Pfy + jitter1 * oy1;\n\tvec4 dz1 = Pf.z + jitter1 * oz1;\n\tvec4 dx2 = Pfx + jitter1 * ox2;\n\tvec4 dy2 = Pfy + jitter1 * oy2;\n\tvec4 dz2 = Pf.z - 1.0 + jitter1 * oz2;\n\tvec4 d1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1; // z+0\n\tvec4 d2 = dx2 * dx2 + dy2 * dy2 + dz2 * dz2; // z+1\n\n\t// Do it right and sort out both F1 and F2\n\tvec4 d = min( d1, d2 ); // F1 is now in d\n\td2 = max( d1, d2 ); // Make sure we keep all candidates for F2\n\td.xy = ( d.x < d.y ) ? d.xy : d.yx; // Swap smallest to d.x\n\td.xz = ( d.x < d.z ) ? d.xz : d.zx;\n\td.xw = ( d.x < d.w ) ? d.xw : d.wx; // F1 is now in d.x\n\td.yzw = min( d.yzw, d2.yzw ); // F2 now not in d2.yzw\n\td.y = min( d.y, d.z ); // nor in d.z\n\td.y = min( d.y, d.w ); // nor in d.w\n\td.y = min( d.y, d2.x ); // F2 is now in d.y\n\treturn sqrt( d.xy ); // F1 and F2\n\n}\n"; // eslint-disable-line
|
|
8493
|
+
var noise_cellular_3D = "#define GLSLIFY 1\n// Cellular noise (\"Worley noise\") in 3D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// 3x3x3 search region for good F2 everywhere, but a lot\n// slower than the 2x2x2 version.\n// The code below is a bit scary even to its author,\n// but it has at least half decent performance on a\n// modern GPU. In any case, it beats any software\n// implementation of Worley noise hands down.\n\nvec2 cellular( vec3 P ) {\n\n\tvec3 Pi = mod289( floor( P ) );\n \tvec3 Pf = fract( P ) - 0.5;\n\n\tvec3 Pfx = Pf.x + vec3( 1.0, 0.0, -1.0 );\n\tvec3 Pfy = Pf.y + vec3( 1.0, 0.0, -1.0 );\n\tvec3 Pfz = Pf.z + vec3( 1.0, 0.0, -1.0 );\n\n\tvec3 p = permute( Pi.x + vec3( -1.0, 0.0, 1.0 ) );\n\tvec3 p1 = permute( p + Pi.y - 1.0 );\n\tvec3 p2 = permute( p + Pi.y );\n\tvec3 p3 = permute( p + Pi.y + 1.0 );\n\n\tvec3 p11 = permute( p1 + Pi.z - 1.0 );\n\tvec3 p12 = permute( p1 + Pi.z );\n\tvec3 p13 = permute( p1 + Pi.z + 1.0 );\n\n\tvec3 p21 = permute( p2 + Pi.z - 1.0 );\n\tvec3 p22 = permute( p2 + Pi.z );\n\tvec3 p23 = permute( p2 + Pi.z + 1.0 );\n\n\tvec3 p31 = permute( p3 + Pi.z - 1.0 );\n\tvec3 p32 = permute( p3 + Pi.z );\n\tvec3 p33 = permute( p3 + Pi.z + 1.0 );\n\n\tvec3 ox11 = fract( p11 * K ) - Ko;\n\tvec3 oy11 = mod7( floor( p11 * K ) ) * K - Ko;\n\tvec3 oz11 = floor( p11 * K2 ) * Kz - Kzo; // p11 < 289 guaranteed\n\n\tvec3 ox12 = fract( p12 * K ) - Ko;\n\tvec3 oy12 = mod7( floor( p12 * K ) ) * K - Ko;\n\tvec3 oz12 = floor( p12 * K2 ) * Kz - Kzo;\n\n\tvec3 ox13 = fract( p13 * K ) - Ko;\n\tvec3 oy13 = mod7( floor( p13 * K ) ) * K - Ko;\n\tvec3 oz13 = floor( p13 * K2 ) * Kz - Kzo;\n\n\tvec3 ox21 = fract( p21 * K ) - Ko;\n\tvec3 oy21 = mod7( floor( p21 * K ) ) * K - Ko;\n\tvec3 oz21 = floor( p21 * K2 ) * Kz - Kzo;\n\n\tvec3 ox22 = fract( p22 * K ) - Ko;\n\tvec3 oy22 = mod7( floor( p22 * K ) ) * K - Ko;\n\tvec3 oz22 = floor( p22 * K2 ) * Kz - Kzo;\n\n\tvec3 ox23 = fract( p23 * K ) - Ko;\n\tvec3 oy23 = mod7( floor( p23 * K ) ) * K - Ko;\n\tvec3 oz23 = floor( p23 * K2 ) * Kz - Kzo;\n\n\tvec3 ox31 = fract( p31 * K ) - Ko;\n\tvec3 oy31 = mod7( floor( p31 * K ) ) * K - Ko;\n\tvec3 oz31 = floor( p31 * K2 ) * Kz - Kzo;\n\n\tvec3 ox32 = fract( p32 * K ) - Ko;\n\tvec3 oy32 = mod7( floor( p32 * K ) ) * K - Ko;\n\tvec3 oz32 = floor( p32 * K2 ) * Kz - Kzo;\n\n\tvec3 ox33 = fract( p33 * K ) - Ko;\n\tvec3 oy33 = mod7( floor( p33 * K ) ) * K - Ko;\n\tvec3 oz33 = floor( p33 * K2 ) * Kz - Kzo;\n\n\tvec3 dx11 = Pfx + jitter * ox11;\n\tvec3 dy11 = Pfy.x + jitter * oy11;\n\tvec3 dz11 = Pfz.x + jitter * oz11;\n\n\tvec3 dx12 = Pfx + jitter * ox12;\n\tvec3 dy12 = Pfy.x + jitter * oy12;\n\tvec3 dz12 = Pfz.y + jitter * oz12;\n\n\tvec3 dx13 = Pfx + jitter * ox13;\n\tvec3 dy13 = Pfy.x + jitter * oy13;\n\tvec3 dz13 = Pfz.z + jitter * oz13;\n\n\tvec3 dx21 = Pfx + jitter * ox21;\n\tvec3 dy21 = Pfy.y + jitter * oy21;\n\tvec3 dz21 = Pfz.x + jitter * oz21;\n\n\tvec3 dx22 = Pfx + jitter * ox22;\n\tvec3 dy22 = Pfy.y + jitter * oy22;\n\tvec3 dz22 = Pfz.y + jitter * oz22;\n\n\tvec3 dx23 = Pfx + jitter * ox23;\n\tvec3 dy23 = Pfy.y + jitter * oy23;\n\tvec3 dz23 = Pfz.z + jitter * oz23;\n\n\tvec3 dx31 = Pfx + jitter * ox31;\n\tvec3 dy31 = Pfy.z + jitter * oy31;\n\tvec3 dz31 = Pfz.x + jitter * oz31;\n\n\tvec3 dx32 = Pfx + jitter * ox32;\n\tvec3 dy32 = Pfy.z + jitter * oy32;\n\tvec3 dz32 = Pfz.y + jitter * oz32;\n\n\tvec3 dx33 = Pfx + jitter * ox33;\n\tvec3 dy33 = Pfy.z + jitter * oy33;\n\tvec3 dz33 = Pfz.z + jitter * oz33;\n\n\tvec3 d11 = dx11 * dx11 + dy11 * dy11 + dz11 * dz11;\n\tvec3 d12 = dx12 * dx12 + dy12 * dy12 + dz12 * dz12;\n\tvec3 d13 = dx13 * dx13 + dy13 * dy13 + dz13 * dz13;\n\tvec3 d21 = dx21 * dx21 + dy21 * dy21 + dz21 * dz21;\n\tvec3 d22 = dx22 * dx22 + dy22 * dy22 + dz22 * dz22;\n\tvec3 d23 = dx23 * dx23 + dy23 * dy23 + dz23 * dz23;\n\tvec3 d31 = dx31 * dx31 + dy31 * dy31 + dz31 * dz31;\n\tvec3 d32 = dx32 * dx32 + dy32 * dy32 + dz32 * dz32;\n\tvec3 d33 = dx33 * dx33 + dy33 * dy33 + dz33 * dz33;\n\n\t// Do it right and sort out both F1 and F2\n\tvec3 d1a = min( d11, d12 );\n\td12 = max( d11, d12 );\n\td11 = min( d1a, d13 ); // Smallest now not in d12 or d13\n\td13 = max( d1a, d13 );\n\td12 = min( d12, d13 ); // 2nd smallest now not in d13\n\tvec3 d2a = min( d21, d22 );\n\td22 = max( d21, d22 );\n\td21 = min( d2a, d23 ); // Smallest now not in d22 or d23\n\td23 = max( d2a, d23 );\n\td22 = min( d22, d23 ); // 2nd smallest now not in d23\n\tvec3 d3a = min( d31, d32 );\n\td32 = max( d31, d32 );\n\td31 = min( d3a, d33 ); // Smallest now not in d32 or d33\n\td33 = max( d3a, d33 );\n\td32 = min( d32, d33 ); // 2nd smallest now not in d33\n\tvec3 da = min( d11, d21 );\n\td21 = max( d11, d21 );\n\td11 = min( da, d31 ); // Smallest now in d11\n\td31 = max( da, d31 ); // 2nd smallest now not in d31\n\td11.xy = ( d11.x < d11.y ) ? d11.xy : d11.yx;\n\td11.xz = ( d11.x < d11.z ) ? d11.xz : d11.zx; // d11.x now smallest\n\td12 = min( d12, d21 ); // 2nd smallest now not in d21\n\td12 = min( d12, d22 ); // nor in d22\n\td12 = min( d12, d31 ); // nor in d31\n\td12 = min( d12, d32 ); // nor in d32\n\td11.yz = min( d11.yz, d12.xy ); // nor in d12.yz\n\td11.y = min( d11.y, d12.z ); // Only two more to go\n\td11.y = min( d11.y, d11.z ); // Done! (Phew! )\n\treturn sqrt( d11.xy ); // F1, F2\n\n}\n"; // eslint-disable-line
|
|
8494
|
+
var noise_common = "#define GLSLIFY 1\n// Modulo 289 without a division (only multiplications)\nvec4 mod289( vec4 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nvec3 mod289( vec3 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nvec2 mod289( vec2 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nfloat mod289( float x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\n// Modulo 7 without a division\nvec4 mod7( vec4 x ) {\n\n return x - floor( x * ( 1.0 / 7.0 ) ) * 7.0;\n\n}\n\nvec3 mod7( vec3 x ) {\n\n return x - floor( x * ( 1.0 / 7.0 ) ) * 7.0;\n\n}\n\n// Permutation polynomial: (34x^2 + x) mod 289\nvec4 permute( vec4 x ) {\n\n return mod289( ( 34.0 * x + 1.0 ) * x);\n\n}\n\nvec3 permute( vec3 x ) {\n\n return mod289( ( 34.0 * x + 1.0 ) * x );\n\n}\n\nfloat permute( float x ) {\n\n return mod289( ( ( x * 34.0 ) + 1.0 ) * x );\n\n}\n\nvec4 taylorInvSqrt( vec4 r ) {\n\n return 1.79284291400159 - 0.85373472095314 * r;\n\n}\n\nfloat taylorInvSqrt( float r ) {\n\n return 1.79284291400159 - 0.85373472095314 * r;\n\n}\n\nvec4 fade( vec4 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\nvec3 fade( vec3 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\nvec2 fade( vec2 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\n#define K 0.142857142857 // 1/7\n#define Ko 0.428571428571 // 1/2-K/2\n#define K2 0.020408163265306 // 1/(7*7)\n#define Kd2 0.0714285714285 // K/2\n#define Kz 0.166666666667 // 1/6\n#define Kzo 0.416666666667 // 1/2-1/6*2\n#define jitter 1.0 // smaller jitter gives more regular pattern\n#define jitter1 0.8 // smaller jitter gives less errors in F1 F2\n"; // eslint-disable-line
|
|
8495
8495
|
var noise_perlin = "#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n"; // eslint-disable-line
|
|
8496
|
-
var noise_perlin_2D = "#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0)
|
|
8497
|
-
var noise_perlin_3D = "#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0)
|
|
8498
|
-
var noise_perlin_4D = "#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}"; // eslint-disable-line
|
|
8499
|
-
var noise_psrd_2D = "#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}"; // eslint-disable-line
|
|
8496
|
+
var noise_perlin_2D = "#define GLSLIFY 1\n//\n// GLSL textureless classic 2D noise \"cnoise\",\n// with an RSL-style periodic variant \"pnoise\".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec2 P ) {\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;\n vec4 gy = abs(gx) - 0.5 ;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x,gy.x);\n vec2 g10 = vec2(gx.y,gy.y);\n vec2 g01 = vec2(gx.z,gy.z);\n vec2 g11 = vec2(gx.w,gy.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin( vec2 P, vec2 rep ) {\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;\n vec4 gy = abs(gx) - 0.5 ;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x,gy.x);\n vec2 g10 = vec2(gx.y,gy.y);\n vec2 g01 = vec2(gx.z,gy.z);\n vec2 g11 = vec2(gx.w,gy.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n\n}\n"; // eslint-disable-line
|
|
8497
|
+
var noise_perlin_3D = "#define GLSLIFY 1\n//\n// GLSL textureless classic 3D noise \"cnoise\",\n// with an RSL-style periodic variant \"pnoise\".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-10-11\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec3 P ) {\n\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin( vec3 P, vec3 rep ) {\n\n vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period\n vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n\n}\n"; // eslint-disable-line
|
|
8498
|
+
var noise_perlin_4D = "#define GLSLIFY 1\n//\n// GLSL textureless classic 4D noise \"cnoise\",\n// with an RSL-style periodic variant \"pnoise\".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec4 P ) {\n\n vec4 Pi0 = floor(P); // Integer part for indexing\n vec4 Pi1 = Pi0 + 1.0; // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec4 Pf0 = fract(P); // Fractional part for interpolation\n vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = vec4(Pi0.zzzz);\n vec4 iz1 = vec4(Pi1.zzzz);\n vec4 iw0 = vec4(Pi0.wwww);\n vec4 iw1 = vec4(Pi1.wwww);\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 ixy00 = permute(ixy0 + iw0);\n vec4 ixy01 = permute(ixy0 + iw1);\n vec4 ixy10 = permute(ixy1 + iw0);\n vec4 ixy11 = permute(ixy1 + iw1);\n\n vec4 gx00 = ixy00 * (1.0 / 7.0);\n vec4 gy00 = floor(gx00) * (1.0 / 7.0);\n vec4 gz00 = floor(gy00) * (1.0 / 6.0);\n gx00 = fract(gx00) - 0.5;\n gy00 = fract(gy00) - 0.5;\n gz00 = fract(gz00) - 0.5;\n vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);\n vec4 sw00 = step(gw00, vec4(0.0));\n gx00 -= sw00 * (step(0.0, gx00) - 0.5);\n gy00 -= sw00 * (step(0.0, gy00) - 0.5);\n\n vec4 gx01 = ixy01 * (1.0 / 7.0);\n vec4 gy01 = floor(gx01) * (1.0 / 7.0);\n vec4 gz01 = floor(gy01) * (1.0 / 6.0);\n gx01 = fract(gx01) - 0.5;\n gy01 = fract(gy01) - 0.5;\n gz01 = fract(gz01) - 0.5;\n vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);\n vec4 sw01 = step(gw01, vec4(0.0));\n gx01 -= sw01 * (step(0.0, gx01) - 0.5);\n gy01 -= sw01 * (step(0.0, gy01) - 0.5);\n\n vec4 gx10 = ixy10 * (1.0 / 7.0);\n vec4 gy10 = floor(gx10) * (1.0 / 7.0);\n vec4 gz10 = floor(gy10) * (1.0 / 6.0);\n gx10 = fract(gx10) - 0.5;\n gy10 = fract(gy10) - 0.5;\n gz10 = fract(gz10) - 0.5;\n vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);\n vec4 sw10 = step(gw10, vec4(0.0));\n gx10 -= sw10 * (step(0.0, gx10) - 0.5);\n gy10 -= sw10 * (step(0.0, gy10) - 0.5);\n\n vec4 gx11 = ixy11 * (1.0 / 7.0);\n vec4 gy11 = floor(gx11) * (1.0 / 7.0);\n vec4 gz11 = floor(gy11) * (1.0 / 6.0);\n gx11 = fract(gx11) - 0.5;\n gy11 = fract(gy11) - 0.5;\n gz11 = fract(gz11) - 0.5;\n vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);\n vec4 sw11 = step(gw11, vec4(0.0));\n gx11 -= sw11 * (step(0.0, gx11) - 0.5);\n gy11 -= sw11 * (step(0.0, gy11) - 0.5);\n\n vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);\n vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);\n vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);\n vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);\n vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);\n vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);\n vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);\n vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);\n vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);\n vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);\n vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);\n vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);\n vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);\n vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);\n vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);\n vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);\n\n vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));\n g0000 *= norm00.x;\n g0100 *= norm00.y;\n g1000 *= norm00.z;\n g1100 *= norm00.w;\n\n vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));\n g0001 *= norm01.x;\n g0101 *= norm01.y;\n g1001 *= norm01.z;\n g1101 *= norm01.w;\n\n vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));\n g0010 *= norm10.x;\n g0110 *= norm10.y;\n g1010 *= norm10.z;\n g1110 *= norm10.w;\n\n vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));\n g0011 *= norm11.x;\n g0111 *= norm11.y;\n g1011 *= norm11.z;\n g1111 *= norm11.w;\n\n float n0000 = dot(g0000, Pf0);\n float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));\n float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));\n float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));\n float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));\n float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));\n float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));\n float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));\n float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));\n float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));\n float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));\n float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));\n float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));\n float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));\n float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));\n float n1111 = dot(g1111, Pf1);\n\n vec4 fade_xyzw = fade(Pf0);\n vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);\n vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);\n vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);\n vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);\n float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);\n return 2.2 * n_xyzw;\n\n}\n\n// Classic Perlin noise, periodic version\nfloat perlin( vec4 P, vec4 rep ) {\n\n vec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep\n vec4 Pi1 = mod(Pi0 + 1.0, rep); // Integer part + 1 mod rep\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec4 Pf0 = fract(P); // Fractional part for interpolation\n vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = vec4(Pi0.zzzz);\n vec4 iz1 = vec4(Pi1.zzzz);\n vec4 iw0 = vec4(Pi0.wwww);\n vec4 iw1 = vec4(Pi1.wwww);\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 ixy00 = permute(ixy0 + iw0);\n vec4 ixy01 = permute(ixy0 + iw1);\n vec4 ixy10 = permute(ixy1 + iw0);\n vec4 ixy11 = permute(ixy1 + iw1);\n\n vec4 gx00 = ixy00 * (1.0 / 7.0);\n vec4 gy00 = floor(gx00) * (1.0 / 7.0);\n vec4 gz00 = floor(gy00) * (1.0 / 6.0);\n gx00 = fract(gx00) - 0.5;\n gy00 = fract(gy00) - 0.5;\n gz00 = fract(gz00) - 0.5;\n vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);\n vec4 sw00 = step(gw00, vec4(0.0));\n gx00 -= sw00 * (step(0.0, gx00) - 0.5);\n gy00 -= sw00 * (step(0.0, gy00) - 0.5);\n\n vec4 gx01 = ixy01 * (1.0 / 7.0);\n vec4 gy01 = floor(gx01) * (1.0 / 7.0);\n vec4 gz01 = floor(gy01) * (1.0 / 6.0);\n gx01 = fract(gx01) - 0.5;\n gy01 = fract(gy01) - 0.5;\n gz01 = fract(gz01) - 0.5;\n vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);\n vec4 sw01 = step(gw01, vec4(0.0));\n gx01 -= sw01 * (step(0.0, gx01) - 0.5);\n gy01 -= sw01 * (step(0.0, gy01) - 0.5);\n\n vec4 gx10 = ixy10 * (1.0 / 7.0);\n vec4 gy10 = floor(gx10) * (1.0 / 7.0);\n vec4 gz10 = floor(gy10) * (1.0 / 6.0);\n gx10 = fract(gx10) - 0.5;\n gy10 = fract(gy10) - 0.5;\n gz10 = fract(gz10) - 0.5;\n vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);\n vec4 sw10 = step(gw10, vec4(0.0));\n gx10 -= sw10 * (step(0.0, gx10) - 0.5);\n gy10 -= sw10 * (step(0.0, gy10) - 0.5);\n\n vec4 gx11 = ixy11 * (1.0 / 7.0);\n vec4 gy11 = floor(gx11) * (1.0 / 7.0);\n vec4 gz11 = floor(gy11) * (1.0 / 6.0);\n gx11 = fract(gx11) - 0.5;\n gy11 = fract(gy11) - 0.5;\n gz11 = fract(gz11) - 0.5;\n vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);\n vec4 sw11 = step(gw11, vec4(0.0));\n gx11 -= sw11 * (step(0.0, gx11) - 0.5);\n gy11 -= sw11 * (step(0.0, gy11) - 0.5);\n\n vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);\n vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);\n vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);\n vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);\n vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);\n vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);\n vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);\n vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);\n vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);\n vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);\n vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);\n vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);\n vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);\n vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);\n vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);\n vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);\n\n vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));\n g0000 *= norm00.x;\n g0100 *= norm00.y;\n g1000 *= norm00.z;\n g1100 *= norm00.w;\n\n vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));\n g0001 *= norm01.x;\n g0101 *= norm01.y;\n g1001 *= norm01.z;\n g1101 *= norm01.w;\n\n vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));\n g0010 *= norm10.x;\n g0110 *= norm10.y;\n g1010 *= norm10.z;\n g1110 *= norm10.w;\n\n vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));\n g0011 *= norm11.x;\n g0111 *= norm11.y;\n g1011 *= norm11.z;\n g1111 *= norm11.w;\n\n float n0000 = dot(g0000, Pf0);\n float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));\n float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));\n float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));\n float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));\n float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));\n float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));\n float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));\n float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));\n float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));\n float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));\n float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));\n float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));\n float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));\n float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));\n float n1111 = dot(g1111, Pf1);\n\n vec4 fade_xyzw = fade(Pf0);\n vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);\n vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);\n vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);\n vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);\n float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);\n return 2.2 * n_xyzw;\n\n}\n"; // eslint-disable-line
|
|
8499
|
+
var noise_psrd_2D = "#define GLSLIFY 1\n// Periodic (tiling) 2-D simplex noise (hexagonal lattice gradient noise)\n// with rotating gradients and analytic derivatives.\n// Variants also without the derivative (no \"d\" in the name), without\n// the tiling property (no \"p\" in the name) and without the rotating\n// gradients (no \"r\" in the name).\n//\n// This is (yet) another variation on simplex noise. It's similar to the\n// version presented by Ken Perlin, but the grid is axis-aligned and\n// slightly stretched in the y direction to permit rectangular tiling.\n//\n// The noise can be made to tile seamlessly to any integer period in x and\n// any even integer period in y. Odd periods may be specified for y, but\n// then the actual tiling period will be twice that number.\n//\n// The rotating gradients give the appearance of a swirling motion, and can\n// serve a similar purpose for animation as motion along z in 3-D noise.\n// The rotating gradients in conjunction with the analytic derivatives\n// can make \"flow noise\" effects as presented by Perlin and Neyret.\n//\n// vec3 {p}s{r}dnoise(vec2 pos {, vec2 per} {, float rot})\n// \"pos\" is the input (x,y) coordinate\n// \"per\" is the x and y period, where per.x is a positive integer\n// and per.y is a positive even integer\n// \"rot\" is the angle to rotate the gradients (any float value,\n// where 0.0 is no rotation and 1.0 is one full turn)\n// The first component of the 3-element return vector is the noise value.\n// The second and third components are the x and y partial derivatives.\n//\n// float {p}s{r}noise(vec2 pos {, vec2 per} {, float rot})\n// \"pos\" is the input (x,y) coordinate\n// \"per\" is the x and y period, where per.x is a positive integer\n// and per.y is a positive even integer\n// \"rot\" is the angle to rotate the gradients (any float value,\n// where 0.0 is no rotation and 1.0 is one full turn)\n// The return value is the noise value.\n// Partial derivatives are not computed, making these functions faster.\n//\n// Author: Stefan Gustavson (stefan.gustavson@gmail.com)\n// Version 2016-05-10.\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// idea of using a permutation polynomial.\n//\n// Copyright (c) 2016 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Hashed 2-D gradients with an extra rotation.\n// (The constant 0.0243902439 is 1/41)\nvec2 rgrad2( vec2 p, float rot ) {\n\n // For more isotropic gradients, sin/cos can be used instead.\n float u = permute( permute( p.x ) + p.y ) * 0.0243902439 + rot; // Rotate by shift\n u = fract( u ) * 6.28318530718; // 2*pi\n return vec2( cos( u ), sin( u ));\n\n}\n\n//\n// 2-D tiling simplex noise with rotating gradients and analytical derivative.\n// The first component of the 3-element return vector is the noise value,\n// and the second and third components are the x and y partial derivatives.\n//\nvec3 psrdnoise(vec2 pos, vec2 per, float rot) {\n // Hack: offset y slightly to hide some rare artifacts\n pos.y += 0.01;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Partial derivatives for analytical gradient computation\n vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);\n vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n if (t.x < 0.0) {\n dtdx.x = 0.0;\n dtdy.x = 0.0;\n\tt.x = 0.0;\n }\n if (t.y < 0.0) {\n dtdx.y = 0.0;\n dtdy.y = 0.0;\n\tt.y = 0.0;\n }\n if (t.z < 0.0) {\n dtdx.z = 0.0;\n dtdy.z = 0.0;\n\tt.z = 0.0;\n }\n\n // Fourth power of t (and third power for derivative)\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n vec3 t3 = t2 * t;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Final analytical derivative (gradient of a sum of scalar products)\n vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;\n vec2 dn0 = t4.x * g0 + dt0 * w.x;\n vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;\n vec2 dn1 = t4.y * g1 + dt1 * w.y;\n vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;\n vec2 dn2 = t4.z * g2 + dt2 * w.z;\n\n return 11.0*vec3(n, dn0 + dn1 + dn2);\n}\n\n//\n// 2-D tiling simplex noise with fixed gradients\n// and analytical derivative.\n// This function is implemented as a wrapper to \"psrdnoise\",\n// at the minimal cost of three extra additions.\n//\nvec3 psdnoise(vec2 pos, vec2 per) {\n return psrdnoise(pos, per, 0.0);\n}\n\n//\n// 2-D tiling simplex noise with rotating gradients,\n// but without the analytical derivative.\n//\nfloat psrnoise(vec2 pos, vec2 per, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n t = max(t, 0.0);\n\n // Fourth power of t\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Rescale to cover the range [-1,1] reasonably well\n return 11.0*n;\n}\n\n//\n// 2-D tiling simplex noise with fixed gradients,\n// without the analytical derivative.\n// This function is implemented as a wrapper to \"psrnoise\",\n// at the minimal cost of three extra additions.\n//\nfloat psnoise(vec2 pos, vec2 per) {\n return psrnoise(pos, per, 0.0);\n}\n\n//\n// 2-D non-tiling simplex noise with rotating gradients and analytical derivative.\n// The first component of the 3-element return vector is the noise value,\n// and the second and third components are the x and y partial derivatives.\n//\nvec3 srdnoise(vec2 pos, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n vec3 x = vec3(p0.x, p1.x, p2.x);\n vec3 y = vec3(p0.y, p1.y, p2.y);\n vec3 iuw = x + 0.5 * y;\n vec3 ivw = y;\n\n // Avoid precision issues in permutation\n iuw = mod289(iuw);\n ivw = mod289(ivw);\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Partial derivatives for analytical gradient computation\n vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);\n vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n if (t.x < 0.0) {\n dtdx.x = 0.0;\n dtdy.x = 0.0;\n\tt.x = 0.0;\n }\n if (t.y < 0.0) {\n dtdx.y = 0.0;\n dtdy.y = 0.0;\n\tt.y = 0.0;\n }\n if (t.z < 0.0) {\n dtdx.z = 0.0;\n dtdy.z = 0.0;\n\tt.z = 0.0;\n }\n\n // Fourth power of t (and third power for derivative)\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n vec3 t3 = t2 * t;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Final analytical derivative (gradient of a sum of scalar products)\n vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;\n vec2 dn0 = t4.x * g0 + dt0 * w.x;\n vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;\n vec2 dn1 = t4.y * g1 + dt1 * w.y;\n vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;\n vec2 dn2 = t4.z * g2 + dt2 * w.z;\n\n return 11.0*vec3(n, dn0 + dn1 + dn2);\n}\n\n//\n// 2-D non-tiling simplex noise with fixed gradients and analytical derivative.\n// This function is implemented as a wrapper to \"srdnoise\",\n// at the minimal cost of three extra additions.\n//\nvec3 sdnoise(vec2 pos) {\n return srdnoise(pos, 0.0);\n}\n\n//\n// 2-D non-tiling simplex noise with rotating gradients,\n// without the analytical derivative.\n//\nfloat srnoise(vec2 pos, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 x = vec3(p0.x, p1.x, p2.x);\n vec3 y = vec3(p0.y, p1.y, p2.y);\n vec3 iuw = x + 0.5 * y;\n vec3 ivw = y;\n\n // Avoid precision issues in permutation\n iuw = mod289(iuw);\n ivw = mod289(ivw);\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n t = max(t, 0.0);\n\n // Fourth power of t\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Rescale to cover the range [-1,1] reasonably well\n return 11.0*n;\n}\n\n//\n// 2-D non-tiling simplex noise with fixed gradients,\n// without the analytical derivative.\n// This function is implemented as a wrapper to \"srnoise\",\n// at the minimal cost of three extra additions.\n// Note: if this kind of noise is all you want, there are faster\n// GLSL implementations of non-tiling simplex noise out there.\n// This one is included mainly for completeness and compatibility\n// with the other functions in the file.\n//\nfloat snoise(vec2 pos) {\n return srnoise(pos, 0.0);\n}\n"; // eslint-disable-line
|
|
8500
8500
|
var noise_simplex = "#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"; // eslint-disable-line
|
|
8501
|
-
var noise_simplex_2D = "#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439
|
|
8502
|
-
var noise_simplex_3D = "#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0)
|
|
8503
|
-
var noise_simplex_3D_grad = "#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2
|
|
8504
|
-
var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0
|
|
8505
|
-
var pbr_frag_define = "#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS
|
|
8506
|
-
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion)
|
|
8507
|
-
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){
|
|
8508
|
-
var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\
|
|
8509
|
-
var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x
|
|
8510
|
-
var pbr_frag = "#define GLSLIFY 1\nGeometry geometry
|
|
8501
|
+
var noise_simplex_2D = "#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D simplex noise function.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec2 v ) {\n\n const vec4 C = vec4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439 ); // 1.0 / 41.0\n // First corner\n vec2 i = floor( v + dot( v, C.yy ) );\n vec2 x0 = v - i + dot( i, C.xx );\n\n // Other corners\n vec2 i1;\n //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0\n //i1.y = 1.0 - i1.x;\n i1 = ( x0.x > x0.y ) ? vec2( 1.0, 0.0 ) : vec2( 0.0, 1.0 );\n // x0 = x0 - 0.0 + 0.0 * C.xx ;\n // x1 = x0 - i1 + 1.0 * C.xx ;\n // x2 = x0 - 1.0 + 2.0 * C.xx ;\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289( i ); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3( 0.0, i1.y, 1.0 ) )\n + i.x + vec3( 0.0, i1.x, 1.0 ) );\n\n vec3 m = max( 0.5 - vec3( dot( x0, x0 ), dot( x12.xy, x12.xy ), dot( x12.zw, x12.zw ) ), 0.0 );\n m = m*m ;\n m = m*m ;\n\n // Gradients: 41 points uniformly over a line, mapped onto a diamond.\n // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)\n\n vec3 x = 2.0 * fract( p * C.www ) - 1.0;\n vec3 h = abs( x ) - 0.5;\n vec3 ox = floor( x + 0.5 );\n vec3 a0 = x - ox;\n\n // Normalise gradients implicitly by scaling m\n // Approximation of: m *= inversesqrt( a0*a0 + h*h );\n m *= 1.79284291400159 - 0.85373472095314 * ( a0 * a0 + h * h );\n\n // Compute final noise value at P\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot( m, g );\n\n}\n"; // eslint-disable-line
|
|
8502
|
+
var noise_simplex_3D = "#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec3 v ) {\n\n const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );\n const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );\n\n // First corner\n vec3 i = floor( v + dot( v, C.yyy ) );\n vec3 x0 = v - i + dot( i, C.xxx );\n\n // Other corners\n vec3 g = step( x0.yzx, x0.xyz );\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289( i );\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor( p * ns.z * ns.z ); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs( x ) - abs( y );\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor( b0 ) * 2.0 + 1.0;\n vec4 s1 = floor( b1 ) * 2.0 + 1.0;\n vec4 sh = - step( h, vec4( 0.0 ) );\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;\n\n vec3 p0 = vec3( a0.xy, h.x );\n vec3 p1 = vec3( a0.zw, h.y );\n vec3 p2 = vec3( a1.xy, h.z );\n vec3 p3 = vec3( a1.zw, h.w );\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot( p0, x0 ), dot( p1, x1 ),\n dot( p2, x2 ), dot( p3, x3 ) ) );\n\n}\n"; // eslint-disable-line
|
|
8503
|
+
var noise_simplex_3D_grad = "#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20150104 (JcBernack)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec3 v, out vec3 gradient ) {\n\n const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );\n const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );\n\n // First corner\n vec3 i = floor( v + dot( v, C.yyy ) );\n vec3 x0 = v - i + dot( i, C.xxx ) ;\n\n // Other corners\n vec3 g = step( x0.yzx, x0.xyz );\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289( i );\n vec4 p = permute( permute( permute(\n i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) )\n + i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) )\n + i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) );\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs( x ) - abs( y );\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor( b0 ) * 2.0 + 1.0;\n vec4 s1 = floor( b1 ) * 2.0 + 1.0;\n vec4 sh = - step( h, vec4( 0.0 ) );\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;\n\n vec3 p0 = vec3( a0.xy, h.x );\n vec3 p1 = vec3( a0.zw, h.y );\n vec3 p2 = vec3( a1.xy, h.z );\n vec3 p3 = vec3( a1.zw, h.w );\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n vec4 m2 = m * m;\n vec4 m4 = m2 * m2;\n vec4 pdotx = vec4( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ), dot( p3, x3 ) );\n\n // Determine noise gradient\n vec4 temp = m2 * m * pdotx;\n gradient = - 8.0 * ( temp.x * x0 + temp.y * x1 + temp.z * x2 + temp.w * x3 );\n gradient += m4.x * p0 + m4.y * p1 + m4.z * p2 + m4.w * p3;\n gradient *= 42.0;\n\n return 42.0 * dot( m4, pdotx );\n\n}\n"; // eslint-disable-line
|
|
8504
|
+
var noise_simplex_4D = "#define GLSLIFY 1\n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nvec4 grad4( float j, vec4 ip ) {\n\n const vec4 ones = vec4( 1.0, 1.0, 1.0, -1.0 );\n vec4 p, s;\n\n p.xyz = floor( fract( vec3( j ) * ip.xyz ) * 7.0 ) * ip.z - 1.0;\n p.w = 1.5 - dot( abs( p.xyz ), ones.xyz );\n s = vec4( lessThan( p, vec4( 0.0 ) ) );\n p.xyz = p.xyz + ( s.xyz * 2.0 - 1.0 ) * s.www;\n\n return p;\n\n}\n\n// (sqrt(5) - 1)/4 = F4, used once below\n#define F4 0.309016994374947451\n\nfloat simplex(vec4 v) {\n\n const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4\n 0.276393202250021, // 2 * G4\n 0.414589803375032, // 3 * G4\n -0.447213595499958); // -1 + 4 * G4\n\n // First corner\n vec4 i = floor( v + dot( v, vec4( F4 ) ) );\n vec4 x0 = v - i + dot( i, C.xxxx );\n\n // Other corners\n\n // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)\n vec4 i0;\n vec3 isX = step( x0.yzw, x0.xxx );\n vec3 isYZ = step( x0.zww, x0.yyz );\n i0.x = isX.x + isX.y + isX.z;\n i0.yzw = 1.0 - isX;\n i0.y += isYZ.x + isYZ.y;\n i0.zw += 1.0 - isYZ.xy;\n i0.z += isYZ.z;\n i0.w += 1.0 - isYZ.z;\n\n vec4 i3 = clamp( i0, 0.0, 1.0 );\n vec4 i2 = clamp( i0 - 1.0, 0.0, 1.0 );\n vec4 i1 = clamp( i0 - 2.0, 0.0, 1.0 );\n\n vec4 x1 = x0 - i1 + C.xxxx;\n vec4 x2 = x0 - i2 + C.yyyy;\n vec4 x3 = x0 - i3 + C.zzzz;\n vec4 x4 = x0 + C.wwww;\n\n // Permutations\n i = mod289( i );\n float j0 = permute( permute( permute( permute( i.w ) + i.z ) + i.y ) + i.x );\n vec4 j1 = permute( permute( permute( permute (\n i.w + vec4(i1.w, i2.w, i3.w, 1.0 ))\n + i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))\n + i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))\n + i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));\n\n // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope\n // 7*7*6 = 294, which is close to the ring size 17*17 = 289.\n vec4 ip = vec4( 1.0 / 294.0, 1.0 / 49.0, 1.0 / 7.0, 0.0 );\n\n vec4 p0 = grad4(j0, ip);\n vec4 p1 = grad4(j1.x, ip);\n vec4 p2 = grad4(j1.y, ip);\n vec4 p3 = grad4(j1.z, ip);\n vec4 p4 = grad4(j1.w, ip);\n\n // Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n p4 *= taylorInvSqrt( dot( p4, p4 ) );\n\n // Mix contributions from the five corners\n vec3 m0 = max( 0.6 - vec3( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ) ), 0.0 );\n vec2 m1 = max( 0.6 - vec2( dot( x3, x3 ), dot( x4, x4 ) ), 0.0 );\n m0 = m0 * m0;\n m1 = m1 * m1;\n return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))\n + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;\n\n}\n"; // eslint-disable-line
|
|
8505
|
+
var pbr_frag_define = "#define GLSLIFY 1\n#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#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// 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 #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n};"; // eslint-disable-line
|
|
8506
|
+
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\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 #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\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 baseTextureColor = texture2D(material_BaseTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n baseTextureColor = gammaToLinear(baseTextureColor);\n #endif\n baseColor *= baseTextureColor;\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n baseColor *= v_color;\n #endif\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 = texture2D(material_SpecularGlossinessTexture, v_uv );\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n specularGlossinessColor = gammaToLinear(specularGlossinessColor);\n #endif\n specularColor *= specularGlossinessColor.rgb;\n glossiness *= specularGlossinessColor.a;\n #endif\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}\n\n// direct + indirect\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
8507
|
+
var brdf = "#define GLSLIFY 1\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_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\nvec3 isotropicLobe(vec3 specularColor, float alpha, float dotNV, float dotNL, float dotNH, float dotLH) {\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat D = D_GGX( alpha, dotNH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\treturn F * ( G * D );\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicLobe(vec3 h, vec3 l, Geometry geometry, vec3 specularColor, float alpha, float dotNV, float dotNL, float dotNH, float dotLH) {\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 \tvec3 F = F_Schlick( specularColor, dotLH );\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 F * ( G * D );\n }\n#endif\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX(vec3 incidentDirection, Geometry geometry, 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 #ifdef MATERIAL_ENABLE_ANISOTROPY\n return anisotropicLobe(halfDir, incidentDirection, geometry, specularColor, alpha, dotNV, dotNL, dotNH, dotLH);\n #else\n return isotropicLobe(specularColor, alpha, dotNV, dotNL, dotNH, dotLH);\n #endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\n"; // eslint-disable-line
|
|
8508
|
+
var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\n\nvoid addDirectRadiance(vec3 incidentDirection, vec3 color, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n float attenuation = 1.0;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoatDotNL = saturate( dot( geometry.clearCoatNormal, incidentDirection ) );\n vec3 clearCoatIrradiance = clearCoatDotNL * color;\n\n reflectedLight.directSpecular += material.clearCoat * clearCoatIrradiance * BRDF_Specular_GGX( incidentDirection, geometry, geometry.clearCoatNormal, vec3( 0.04 ), material.clearCoatRoughness );\n attenuation -= material.clearCoat * F_Schlick(material.f0, geometry.clearCoatDotNV);\n #endif\n\n float dotNL = saturate( dot( geometry.normal, incidentDirection ) );\n vec3 irradiance = dotNL * color * PI;\n\n reflectedLight.directSpecular += attenuation * irradiance * BRDF_Specular_GGX( incidentDirection, geometry, geometry.normal, material.specularColor, material.roughness);\n reflectedLight.directDiffuse += attenuation * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#ifdef SCENE_DIRECT_LIGHT_COUNT\n\n void addDirectionalDirectLightRadiance(DirectLight directionalLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n vec3 color = directionalLight.color;\n vec3 direction = -directionalLight.direction;\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n }\n\n#endif\n\n#ifdef SCENE_POINT_LIGHT_COUNT\n\n\tvoid addPointDirectLightRadiance(PointLight pointLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tvec3 direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tvec3 color = pointLight.color;\n\t\tcolor *= clamp(1.0 - pow(lightDistance/pointLight.distance, 4.0), 0.0, 1.0);\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#ifdef SCENE_SPOT_LIGHT_COUNT\n\n\tvoid addSpotDirectLightRadiance(SpotLight spotLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tvec3 direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( direction, -spotLight.direction );\n\n\t\tfloat spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n\t\tfloat decayEffect = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n\n\t\tvec3 color = spotLight.color;\n\t\tcolor *= spotEffect * decayEffect;\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\nvoid addTotalDirectRadiance(Geometry geometry, Material material, inout ReflectedLight reflectedLight){\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for ( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i ++ ) {\n // warning: use `continue` syntax may trigger flickering bug in safri 16.1.\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n addDirectionalDirectLightRadiance( directionalLight, geometry, material, reflectedLight );\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n\n PointLight pointLight;\n\n for ( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n addPointDirectLightRadiance( pointLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n\n SpotLight spotLight;\n\n for ( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n addSpotDirectLightRadiance( spotLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n}"; // eslint-disable-line
|
|
8509
|
+
var ibl_frag_define = "#define GLSLIFY 1\n// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n normal.x = -normal.x;\n vec3 result = sh[0] +\n\n sh[1] * (normal.y) +\n sh[2] * (normal.z) +\n sh[3] * (normal.x) +\n\n sh[4] * (normal.y * normal.x) +\n sh[5] * (normal.y * normal.z) +\n sh[6] * (3.0 * normal.z * normal.z - 1.0) +\n sh[7] * (normal.z * normal.x) +\n sh[8] * (normal.x * normal.x - normal.y * normal.y);\n \n return max(result, vec3(0.0));\n\n}\n\n// ------------------------Specular------------------------\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 envBRDFApprox(vec3 specularColor,float roughness, float dotNV ) {\n\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n vec4 r = roughness * c0 + c1;\n\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n return specularColor * AB.x + AB.y;\n}\n\nfloat getSpecularMIPLevel(float roughness, int maxMIPLevel ) {\n return roughness * float(maxMIPLevel);\n}\n\nvec3 getReflectedVector(Geometry geometry, vec3 n) {\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 r = reflect(-geometry.viewDir, geometry.anisotropicN);\n #else\n vec3 r = reflect(-geometry.viewDir, n);\n #endif\n\n return r;\n}\n\nvec3 getLightProbeRadiance(Geometry geometry, vec3 normal, float roughness, int maxMIPLevel, float specularIntensity) {\n\n #ifndef SCENE_USE_SPECULAR_ENV\n return vec3(0);\n #else\n vec3 reflectVec = getReflectedVector(geometry, normal);\n reflectVec.x = -reflectVec.x; // TextureCube is left-hand,so x need inverse\n \n float specularMIPLevel = getSpecularMIPLevel(roughness, maxMIPLevel );\n\n #ifdef HAS_TEX_LOD\n vec4 envMapColor = textureCubeLodEXT( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #endif\n\n #ifdef SCENE_IS_DECODE_ENV_RGBM\n envMapColor.rgb = RGBMToLinear(envMapColor, 5.0).rgb;\n #ifdef ENGINE_IS_COLORSPACE_GAMMA\n envMapColor = linearToGamma(envMapColor);\n #endif\n #else\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n envMapColor = gammaToLinear(envMapColor);\n #endif\n #endif\n \n return envMapColor.rgb * specularIntensity;\n\n #endif\n\n}"; // eslint-disable-line
|
|
8510
|
+
var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;\nMaterial material;\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\ninitGeometry(geometry, gl_FrontFacing);\ninitMaterial(material, geometry);\n\n// Direct Light\naddTotalDirectRadiance(geometry, material, reflectedLight);\n\n// IBL diffuse\n#ifdef SCENE_USE_SH\n vec3 irradiance = getLightProbeIrradiance(scene_EnvSH, geometry.normal);\n #ifdef ENGINE_IS_COLORSPACE_GAMMA\n irradiance = linearToGamma(vec4(irradiance, 1.0)).rgb;\n #endif\n irradiance *= scene_EnvMapLight.diffuseIntensity;\n#else\n vec3 irradiance = scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity;\n irradiance *= PI;\n#endif\n\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n// IBL specular\nvec3 radiance = getLightProbeRadiance(geometry, geometry.normal, material.roughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity);\nfloat radianceAttenuation = 1.0;\n\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatRadiance = getLightProbeRadiance( geometry, geometry.clearCoatNormal, material.clearCoatRoughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity );\n\n reflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * envBRDFApprox(vec3( 0.04 ), material.clearCoatRoughness, geometry.clearCoatDotNV);\n radianceAttenuation -= material.clearCoat * F_Schlick(material.f0, geometry.clearCoatDotNV);\n#endif\n\nreflectedLight.indirectSpecular += radianceAttenuation * radiance * envBRDFApprox(material.specularColor, material.roughness, geometry.dotNV );\n\n// Occlusion\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 float ambientOcclusion = (texture2D(material_OcclusionTexture, aoUV).r - 1.0) * material_OcclusionIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #ifdef SCENE_USE_SPECULAR_ENV\n reflectedLight.indirectSpecular *= computeSpecularOcclusion(ambientOcclusion, material.roughness, geometry.dotNV);\n #endif\n#endif\n\n// Emissive\nvec3 emissiveRadiance = material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n vec4 emissiveColor = texture2D(material_EmissiveTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n emissiveColor = gammaToLinear(emissiveColor);\n #endif\n emissiveRadiance *= emissiveColor.rgb;\n#endif\n\n// Total\nvec3 totalRadiance = reflectedLight.directDiffuse + \n reflectedLight.indirectDiffuse + \n reflectedLight.directSpecular + \n reflectedLight.indirectSpecular + \n emissiveRadiance;\n\nvec4 targetColor =vec4(totalRadiance, material.opacity);\ngl_FragColor = targetColor;\n"; // eslint-disable-line
|
|
8511
8511
|
var PBRShaderLib = {
|
|
8512
8512
|
pbr_frag_define: pbr_frag_define,
|
|
8513
8513
|
pbr_helper: pbr_helper,
|
|
@@ -8516,11 +8516,11 @@
|
|
|
8516
8516
|
ibl_frag_define: ibl_frag_define,
|
|
8517
8517
|
pbr_frag: pbr_frag
|
|
8518
8518
|
};
|
|
8519
|
-
var ShadowCoord = "#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1]
|
|
8520
|
-
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\
|
|
8521
|
-
var shadow_sample_tent = "#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5
|
|
8522
|
-
var ShadowVertexDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\
|
|
8523
|
-
var ShadowVertex = "#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\
|
|
8519
|
+
var ShadowCoord = "#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT + 1];\nuniform vec4 scene_ShadowSplitSpheres[4];\n\nmediump int computeCascadeIndex(vec3 positionWS) {\n vec3 fromCenter0 = positionWS - scene_ShadowSplitSpheres[0].xyz;\n vec3 fromCenter1 = positionWS - scene_ShadowSplitSpheres[1].xyz;\n vec3 fromCenter2 = positionWS - scene_ShadowSplitSpheres[2].xyz;\n vec3 fromCenter3 = positionWS - scene_ShadowSplitSpheres[3].xyz;\n\n mediump vec4 comparison = vec4(\n dot(fromCenter0, fromCenter0) < scene_ShadowSplitSpheres[0].w,\n dot(fromCenter1, fromCenter1) < scene_ShadowSplitSpheres[1].w,\n dot(fromCenter2, fromCenter2) < scene_ShadowSplitSpheres[2].w,\n dot(fromCenter3, fromCenter3) < scene_ShadowSplitSpheres[3].w);\n comparison.yzw = clamp(comparison.yzw - comparison.xyz,0.0,1.0);//keep the nearest\n mediump vec4 indexCoefficient = vec4(4.0,3.0,2.0,1.0);\n mediump int index = 4 - int(dot(comparison, indexCoefficient));\n return index;\n}\n\nvec3 getShadowCoord() {\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n mediump int cascadeIndex = 0;\n #else\n mediump int cascadeIndex = computeCascadeIndex(v_pos);\n #endif\n\n #ifdef GRAPHICS_API_WEBGL2\n mat4 shadowMatrix = scene_ShadowMatrices[cascadeIndex];\n #else\n mat4 shadowMatrix;\n #if SCENE_SHADOW_CASCADED_COUNT == 4\n if (cascadeIndex == 0) {\n shadowMatrix = scene_ShadowMatrices[0];\n } else if (cascadeIndex == 1) {\n shadowMatrix = scene_ShadowMatrices[1];\n } else if (cascadeIndex == 2) {\n shadowMatrix = scene_ShadowMatrices[2];\n } else if (cascadeIndex == 3) {\n shadowMatrix = scene_ShadowMatrices[3];\n } else {\n shadowMatrix = scene_ShadowMatrices[4];\n }\n #endif\n #if SCENE_SHADOW_CASCADED_COUNT == 2\n if (cascadeIndex == 0) {\n shadowMatrix = scene_ShadowMatrices[0];\n } else if (cascadeIndex == 1) {\n shadowMatrix = scene_ShadowMatrices[1];\n } else {\n shadowMatrix = scene_ShadowMatrices[2];\n } \n #endif\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n if (cascadeIndex == 0) {\n shadowMatrix = scene_ShadowMatrices[0];\n } else {\n shadowMatrix = scene_ShadowMatrices[1];\n } \n #endif\n #endif\n\n vec4 shadowCoord = shadowMatrix * vec4(v_pos, 1.0);\n return shadowCoord.xyz;\n}\n"; // eslint-disable-line
|
|
8520
|
+
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n #define SCENE_IS_CALCULATE_SHADOWS\n#endif\n\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n varying vec3 v_shadowCoord;\n #else\n #include <ShadowCoord>\n #endif\n \n // intensity, null, fadeScale, fadeBias\n uniform vec4 scene_ShadowInfo;\n uniform vec4 scene_ShadowMapSize;\n\n #ifdef GRAPHICS_API_WEBGL2\n uniform mediump sampler2DShadow scene_ShadowMap;\n #define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n #define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n #else\n uniform sampler2D scene_ShadowMap;\n #ifdef ENGINE_NO_DEPTH_TEXTURE\n const vec4 bitShift = vec4(1.0, 1.0/256.0, 1.0/(256.0*256.0), 1.0/(256.0*256.0*256.0));\n /**\n * Unpack depth value.\n */\n float unpack(const in vec4 rgbaDepth) {\n return dot(rgbaDepth, bitShift);\n }\n #define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n #else\n #define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n #endif\n #define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n #endif\n\n #if SCENE_SHADOW_TYPE == 2\n float sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap), vec3 shadowCoord, vec4 shadowMapSize) {\n float attenuation;\n vec4 attenuation4;\n vec2 offset=shadowMapSize.xy/2.0;\n vec3 shadowCoord0=shadowCoord + vec3(-offset,0.0);\n vec3 shadowCoord1=shadowCoord + vec3(offset.x,-offset.y,0.0);\n vec3 shadowCoord2=shadowCoord + vec3(-offset.x,offset.y,0.0);\n vec3 shadowCoord3=shadowCoord + vec3(offset,0.0);\n attenuation4.x = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord0);\n attenuation4.y = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord1);\n attenuation4.z = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord2);\n attenuation4.w = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord3);\n attenuation = dot(attenuation4, vec4(0.25));\n return attenuation;\n }\n #endif\n\n #if SCENE_SHADOW_TYPE == 3\n #include <shadow_sample_tent>\n\n float sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap), vec3 shadowCoord, vec4 shadowmapSize) {\n float attenuation;\n float fetchesWeights[9];\n vec2 fetchesUV[9];\n sampleShadowComputeSamplesTent5x5(shadowmapSize, shadowCoord.xy, fetchesWeights, fetchesUV);\n attenuation = fetchesWeights[0] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[0].xy, shadowCoord.z));\n attenuation += fetchesWeights[1] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[1].xy, shadowCoord.z));\n attenuation += fetchesWeights[2] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[2].xy, shadowCoord.z));\n attenuation += fetchesWeights[3] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[3].xy, shadowCoord.z));\n attenuation += fetchesWeights[4] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[4].xy, shadowCoord.z));\n attenuation += fetchesWeights[5] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[5].xy, shadowCoord.z));\n attenuation += fetchesWeights[6] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[6].xy, shadowCoord.z));\n attenuation += fetchesWeights[7] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[7].xy, shadowCoord.z));\n attenuation += fetchesWeights[8] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[8].xy, shadowCoord.z));\n return attenuation;\n }\n #endif\n\n float getShadowFade(vec3 positionWS){\n vec3 camToPixel = positionWS - camera_Position;\n float distanceCamToPixel2 = dot(camToPixel, camToPixel);\n return saturate( distanceCamToPixel2 * scene_ShadowInfo.z + scene_ShadowInfo.w );\n }\n\n float sampleShadowMap() {\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n vec3 shadowCoord = v_shadowCoord;\n #else\n vec3 shadowCoord = getShadowCoord();\n #endif\n \n float attenuation = 1.0;\n if(shadowCoord.z > 0.0 && shadowCoord.z < 1.0) {\n #if SCENE_SHADOW_TYPE == 1\n attenuation = SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap, shadowCoord);\n #endif\n\n #if SCENE_SHADOW_TYPE == 2\n attenuation = sampleShadowMapFiltered4(scene_ShadowMap, shadowCoord, scene_ShadowMapSize);\n #endif\n\n #if SCENE_SHADOW_TYPE == 3\n attenuation = sampleShadowMapFiltered9(scene_ShadowMap, shadowCoord, scene_ShadowMapSize);\n #endif\n\n float shadowFade = getShadowFade(v_pos);\n attenuation = mix(1.0, mix(attenuation, 1.0, shadowFade), scene_ShadowInfo.x);\n }\n return attenuation;\n }\n#endif"; // eslint-disable-line
|
|
8521
|
+
var shadow_sample_tent = "#define GLSLIFY 1\n// ------------------------------------------------------------------\n// PCF Filtering Tent Functions\n// ------------------------------------------------------------------\n\n// Assuming a isoceles right angled triangle of height \"triangleHeight\" (as drawn below).\n// This function return the area of the triangle above the first texel(in Y the first texel).\n//\n// |\\ <-- 45 degree slop isosceles right angled triangle\n// | \\\n// ---- <-- length of this side is \"triangleHeight\"\n// _ _ _ _ <-- texels\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight) {\n return triangleHeight - 0.5;\n}\n\n// Assuming a isoceles triangle of 1.5 texels height and 3 texels wide lying on 4 texels.\n// This function return the area of the triangle above each of those texels.\n// | <-- offset from -0.5 to 0.5, 0 meaning triangle is exactly in the center\n// / \\ <-- 45 degree slop isosceles triangle (ie tent projected in 2D)\n// / \\\n// _ _ _ _ <-- texels\n// X Y Z W <-- result indices (in computedArea.xyzw and computedAreaUncut.xyzw)\n// Top point at (right,top) in a texel,left bottom point at (middle,middle) in a texel,right bottom point at (middle,middle) in a texel.\nvoid sampleShadowGetTexelAreasTent3x3(float offset, out vec4 computedArea, out vec4 computedAreaUncut) {\n // Compute the exterior areas,a and h is same.\n float a = offset + 0.5;\n float offsetSquaredHalved = a * a * 0.5;\n computedAreaUncut.x = computedArea.x = offsetSquaredHalved - offset;\n computedAreaUncut.w = computedArea.w = offsetSquaredHalved;\n\n // Compute the middle areas\n // For Y : We find the area in Y of as if the left section of the isoceles triangle would\n // intersect the axis between Y and Z (ie where offset = 0).\n computedAreaUncut.y = sampleShadowGetIRTriangleTexelArea(1.5 - offset);\n // This area is superior to the one we are looking for if (offset < 0) thus we need to\n // subtract the area of the triangle defined by (0,1.5-offset), (0,1.5+offset), (-offset,1.5).\n float clampedOffsetLeft = min(offset,0.0);\n float areaOfSmallLeftTriangle = clampedOffsetLeft * clampedOffsetLeft;\n computedArea.y = computedAreaUncut.y - areaOfSmallLeftTriangle;\n\n // We do the same for the Z but with the right part of the isoceles triangle\n computedAreaUncut.z = sampleShadowGetIRTriangleTexelArea(1.5 + offset);\n float clampedOffsetRight = max(offset,0.0);\n float areaOfSmallRightTriangle = clampedOffsetRight * clampedOffsetRight;\n computedArea.z = computedAreaUncut.z - areaOfSmallRightTriangle;\n}\n\n// Assuming a isoceles triangle of 2.5 texel height and 5 texels wide lying on 6 texels.\n// This function return the weight of each texels area relative to the full triangle area.\n// / \\\n// _ _ _ _ _ _ <-- texels\n// 0 1 2 3 4 5 <-- computed area indices (in texelsWeights[])\n// Top point at (right,top) in a texel,left bottom point at (middle,middle) in a texel,right bottom point at (middle,middle) in a texel.\nvoid sampleShadowGetTexelWeightsTent5x5(float offset, out vec3 texelsWeightsA, out vec3 texelsWeightsB) {\n vec4 areaFrom3texelTriangle;\n vec4 areaUncutFrom3texelTriangle;\n sampleShadowGetTexelAreasTent3x3(offset, areaFrom3texelTriangle, areaUncutFrom3texelTriangle);\n\n // Triangle slope is 45 degree thus we can almost reuse the result of the 3 texel wide computation.\n // the 5 texel wide triangle can be seen as the 3 texel wide one but shifted up by one unit/texel.\n // 0.16 is 1/(the triangle area)\n texelsWeightsA.x = 0.16 * (areaFrom3texelTriangle.x);\n texelsWeightsA.y = 0.16 * (areaUncutFrom3texelTriangle.y);\n texelsWeightsA.z = 0.16 * (areaFrom3texelTriangle.y + 1.0);\n texelsWeightsB.x = 0.16 * (areaFrom3texelTriangle.z + 1.0);\n texelsWeightsB.y = 0.16 * (areaUncutFrom3texelTriangle.z);\n texelsWeightsB.z = 0.16 * (areaFrom3texelTriangle.w);\n}\n\n// 5x5 Tent filter (45 degree sloped triangles in U and V)\nvoid sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize, vec2 coord, out float fetchesWeights[9], out vec2 fetchesUV[9])\n{\n // tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches\n vec2 tentCenterInTexelSpace = coord.xy * shadowMapTextureTexelSize.zw;\n vec2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5);\n vec2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace;\n\n // find the weight of each texel based on the area of a 45 degree slop tent above each of them.\n vec3 texelsWeightsUA, texelsWeightsUB;\n vec3 texelsWeightsVA, texelsWeightsVB;\n sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsUA, texelsWeightsUB);\n sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsVA, texelsWeightsVB);\n\n // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels\n vec3 fetchesWeightsU = vec3(texelsWeightsUA.xz, texelsWeightsUB.y) + vec3(texelsWeightsUA.y, texelsWeightsUB.xz);\n vec3 fetchesWeightsV = vec3(texelsWeightsVA.xz, texelsWeightsVB.y) + vec3(texelsWeightsVA.y, texelsWeightsVB.xz);\n\n // move the PCF bilinear fetches to respect texels weights\n vec3 fetchesOffsetsU = vec3(texelsWeightsUA.y, texelsWeightsUB.xz) / fetchesWeightsU.xyz + vec3(-2.5,-0.5,1.5);\n vec3 fetchesOffsetsV = vec3(texelsWeightsVA.y, texelsWeightsVB.xz) / fetchesWeightsV.xyz + vec3(-2.5,-0.5,1.5);\n fetchesOffsetsU *= shadowMapTextureTexelSize.xxx;\n fetchesOffsetsV *= shadowMapTextureTexelSize.yyy;\n\n vec2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTextureTexelSize.xy;\n fetchesUV[0] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.x);\n fetchesUV[1] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.x);\n fetchesUV[2] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.x);\n fetchesUV[3] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.y);\n fetchesUV[4] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.y);\n fetchesUV[5] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.y);\n fetchesUV[6] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.z);\n fetchesUV[7] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.z);\n fetchesUV[8] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.z);\n\n fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x;\n fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x;\n fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x;\n fetchesWeights[3] = fetchesWeightsU.x * fetchesWeightsV.y;\n fetchesWeights[4] = fetchesWeightsU.y * fetchesWeightsV.y;\n fetchesWeights[5] = fetchesWeightsU.z * fetchesWeightsV.y;\n fetchesWeights[6] = fetchesWeightsU.x * fetchesWeightsV.z;\n fetchesWeights[7] = fetchesWeightsU.y * fetchesWeightsV.z;\n fetchesWeights[8] = fetchesWeightsU.z * fetchesWeightsV.z;\n}"; // eslint-disable-line
|
|
8522
|
+
var ShadowVertexDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n #define SCENE_IS_CALCULATE_SHADOWS\n#endif\n\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT==1\n #include <ShadowCoord>\n varying vec3 v_shadowCoord;\n #endif\n#endif"; // eslint-disable-line
|
|
8523
|
+
var ShadowVertex = "#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n #if SCENE_SHADOW_CASCADED_COUNT == 1\n v_shadowCoord = getShadowCoord();\n #endif\n#endif"; // eslint-disable-line
|
|
8524
8524
|
var ShadowLib = {
|
|
8525
8525
|
ShadowCoord: ShadowCoord,
|
|
8526
8526
|
ShadowFragmentDeclaration: ShadowFragmentDeclaration,
|
|
@@ -8528,17 +8528,17 @@
|
|
|
8528
8528
|
ShadowVertexDeclaration: ShadowVertexDeclaration,
|
|
8529
8529
|
ShadowVertex: ShadowVertex
|
|
8530
8530
|
};
|
|
8531
|
-
var particle_common = "#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5
|
|
8532
|
-
var velocity_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\
|
|
8533
|
-
var rotation_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\
|
|
8534
|
-
var size_over_lifetime_module = "#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\
|
|
8535
|
-
var color_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\
|
|
8536
|
-
var texture_sheet_animation_module = "#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\
|
|
8537
|
-
var sphere_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\
|
|
8538
|
-
var stretched_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\
|
|
8539
|
-
var vertical_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\
|
|
8540
|
-
var horizontal_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\
|
|
8541
|
-
var particle_mesh = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\
|
|
8531
|
+
var particle_common = "#define GLSLIFY 1\n\nvec3 rotationByEuler(in vec3 vector, in vec3 rot) {\n float halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n float halfYaw = rot.y * 0.5;\n\n float sinRoll = sin(halfRoll);\n float cosRoll = cos(halfRoll);\n float sinPitch = sin(halfPitch);\n float cosPitch = cos(halfPitch);\n float sinYaw = sin(halfYaw);\n float cosYaw = cos(halfYaw);\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\n float quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\n\n // vec4 q=vec4(quaX,quaY,quaZ,quaW);\n // vec3 temp = cross(q.xyz, vector) + q.w * vector;\n // return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\n float x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n float xx = quaX * x;\n float xy = quaX * y;\n float xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n\t((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n\t((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n}\n\n//假定axis已经归一化\nvec3 rotationByAxis(in vec3 vector, in vec3 axis, in float angle) {\n float halfAngle = angle * 0.5;\n float sin = sin(halfAngle);\n\n float quaX = axis.x * sin;\n float quaY = axis.y * sin;\n float quaZ = axis.z * sin;\n float quaW = cos(halfAngle);\n\n // vec4 q=vec4(quaX,quaY,quaZ,quaW);\n // vec3 temp = cross(q.xyz, vector) + q.w * vector;\n // return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\n float x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n float xx = quaX * x;\n float xy = quaX * y;\n float xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n\t((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n\t((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n}\n\nvec3 rotationByQuaternions(in vec3 v, in vec4 q) {\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nfloat evaluateParticleCurve(in vec2 keys[4], in float normalizedAge) {\n float value;\n for (int i = 1; i < 4; i++) {\n vec2 key = keys[i];\n float time = key.x;\n if (time >= normalizedAge) {\n vec2 lastKey = keys[i - 1];\n float lastTime = lastKey.x;\n float age = (normalizedAge - lastTime) / (time - lastTime);\n value = mix(lastKey.y, key.y, age);\n break;\n }\n }\n return value;\n}\n\nfloat evaluateParticleCurveCumulative(in vec2 keys[4], in float normalizedAge){\n float cumulativeValue = 0.0;\n for (int i = 1; i < 4; i++){\n\t vec2 key = keys[i];\n\t float time = key.x;\n\t vec2 lastKey = keys[i - 1];\n\t float lastValue = lastKey.y;\n\n\t if (time >= normalizedAge){\n\t\t float lastTime = lastKey.x;\n float offsetTime = normalizedAge - lastTime;\n\t\t float age = offsetTime / (time - lastTime);\n\t\t cumulativeValue += (lastValue + mix(lastValue, key.y, age)) * 0.5 * offsetTime;\n\t\t break;\n\t\t}\n\t else{\n\t\t cumulativeValue += (lastValue + key.y) * 0.5 * (time - lastKey.x);\n\t\t}\n\t}\n return cumulativeValue;\n}"; // eslint-disable-line
|
|
8532
|
+
var velocity_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n uniform int renderer_VOLSpace;\n\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\n uniform vec3 renderer_VOLMaxConst;\n\n #ifdef RENDERER_VOL_RANDOM_CONSTANT\n uniform vec3 renderer_VOLMinConst;\n #endif\n #endif\n\n #if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\n uniform vec2 renderer_VOLMaxGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientZ[4]; // x:time y:value\n\n #ifdef RENDERER_VOL_RANDOM_CURVE\n uniform vec2 renderer_VOLMinGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientZ[4]; // x:time y:value\n #endif\n #endif\n#endif\n\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n vec3 computeParticleLifeVelocity(in float normalizedAge) {\n vec3 velocity;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\n velocity = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_RANDOM_CONSTANT\n velocity = mix(renderer_VOLMinConst, velocity, vec3(a_Random1.y, a_Random1.z, a_Random1.w));\n #endif\n #endif\n \n #if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\n velocity = vec3(evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge), evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge), evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge));\n #endif\n \n #ifdef RENDERER_VOL_RANDOM_CURVE\n velocity = vec3(\n mix(velocity.x, evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge), a_Random1.y),\n mix(velocity.y, evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge), a_Random1.z),\n mix(velocity.z, evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge), a_Random1.w));\n #endif\n\n return velocity;\n }\n#endif\n\nvec3 getStartPosition(vec3 startVelocity, float age, vec3 dragData) {\n vec3 startPosition;\n float lastTime = min(startVelocity.x / dragData.x, age); // todo 0/0\n startPosition = lastTime * (startVelocity - 0.5 * dragData * lastTime);\n return startPosition;\n}\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, vec3 dragData) {\n vec3 startPosition = getStartPosition(startVelocity, age, dragData);\n vec3 lifePosition;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n #if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\n // @todo:just RENDERER_VOL_CONSTANT and RENDERER_VOL_RANDOM_CONSTANT need `lifeVelocity`\n lifePosition = lifeVelocity * age;\n #endif\n\n #if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\n lifePosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ, normalizedAge));\n\n #ifdef RENDERER_VOL_RANDOM_CURVE\n lifePosition = vec3(\n mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX, normalizedAge), lifePosition.x, a_Random1.y),\n mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY, normalizedAge), lifePosition.y, a_Random1.z),\n mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ, normalizedAge), lifePosition.z, a_Random1.w));\n #endif\n\n lifePosition *= vec3(a_ShapePositionStartLifeTime.w);\n #endif\n \n vec3 finalPosition;\n if (renderer_VOLSpace == 0) {\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + startPosition + lifePosition, worldRotation);\n } else {\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + startPosition, worldRotation) + lifePosition;\n }\n #else\n vec3 finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + startPosition, worldRotation);\n #endif\n\n if (renderer_SimulationSpace == 0) {\n finalPosition = finalPosition + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n\t finalPosition = finalPosition + a_SimulationWorldPosition;\n\t}\n\n finalPosition += 0.5 * gravityVelocity * age;\n\n return finalPosition;\n}\n"; // eslint-disable-line
|
|
8533
|
+
var rotation_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #ifdef RENDERER_ROL_CURVE_MODE\n uniform vec2 renderer_ROLMaxCurveZ[4];\n // #ifdef RENDERER_ROL_IS_SEPARATE\n // uniform vec2 renderer_ROLMaxCurveX[4];\n // uniform vec2 renderer_ROLMaxCurveY[4];\n // #endif\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec2 renderer_ROLMinCurveZ[4];\n // #ifdef RENDERER_ROL_IS_SEPARATE\n // uniform vec2 renderer_ROLMinCurveX[4];\n // uniform vec2 renderer_ROLMinCurveY[4];\n // #endif\n #endif\n #else\n uniform vec3 renderer_ROLMaxConst;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec3 renderer_ROLMinConst;\n #endif\n #endif\n#endif\n\nfloat computeParticleRotationFloat(in float rotation, in float age, in float normalizedAge) {\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #ifdef RENDERER_ROL_CURVE_MODE\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge), lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * a_ShapePositionStartLifeTime.w;\n #else\n float lifeRotation = renderer_ROLMaxConst.z;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(renderer_ROLMinConst.z, lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * age;\n #endif\n #endif\n return rotation;\n}\n\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,\n in float age,\n in float normalizedAge) {\n#ifdef ROTATION_OVER_LIFETIME\n #ifdef ROTATION_OVER_LIFETIME_CONSTANT\n float ageRot = u_ROLAngularVelocityConst * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_CURVE\n rotation += getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient, normalizedAge);\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\n float ageRot = mix(u_ROLAngularVelocityConst, u_ROLAngularVelocityConstMax, a_Random0.w) * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\n rotation += mix(\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient, normalizedAge),\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,\n normalizedAge),\n a_Random0.w);\n #endif\n#endif\n\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n #ifdef ROTATION_OVER_LIFETIME_CONSTANT\n vec3 ageRot = u_ROLAngularVelocityConstSeparate * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_CURVE\n rotation += vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,\n normalizedAge),\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,\n normalizedAge),\n getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,\n normalizedAge));\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\n vec3 ageRot = mix(u_ROLAngularVelocityConstSeparate,\n renderer_ROLMaxConst,\n a_Random0.w)\n * age;\n rotation += ageRot;\n #endif\n #ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\n rotation += vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,\n normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,\n normalizedAge),\n a_Random0.w),\n mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,\n normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,\n normalizedAge),\n a_Random0.w),\n mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,\n normalizedAge),\n getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,\n normalizedAge),\n a_Random0.w));\n #endif\n#endif\n return rotation;\n}\n#endif\n"; // eslint-disable-line
|
|
8534
|
+
var size_over_lifetime_module = "#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\n uniform vec2 renderer_SOLMaxCurveX[4]; // x:time y:value\n #ifdef RENDERER_SOL_IS_SEPARATE\n uniform vec2 renderer_SOLMaxCurveY[4]; // x:time y:value\n uniform vec2 renderer_SOLMaxCurveZ[4]; // x:time y:value\n #endif\n\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n uniform vec2 renderer_SOLMinCurveX[4]; // x:time y:value\n #ifdef RENDERER_SOL_IS_SEPARATE\n uniform vec2 renderer_SOLMinCurveY[4]; // x:time y:value\n uniform vec2 renderer_SOLMinCurveZ[4]; // x:time y:value\n #endif\n #endif\n#endif\n\nvec2 computeParticleSizeBillboard(in vec2 size, in float normalizedAge) {\n #ifdef RENDERER_SOL_CURVE_MODE\n float lifeSizeX = evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge);\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n lifeSizeX = mix(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge), lifeSizeX, a_Random0.z);\n #endif\n\n #ifdef RENDERER_SOL_IS_SEPARATE\n float lifeSizeY = evaluateParticleCurve(renderer_SOLMaxCurveY, normalizedAge);\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n lifeSizeY = mix(evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge), lifeSizeY, a_Random0.z);\n #endif\n size *= vec2(lifeSizeX, lifeSizeY);\n #else\n size *= lifeSizeX;\n #endif\n #endif\n return size;\n}\n\n#ifdef RENDERER_MODE_MESH\n vec3 computeParticleSizeMesh(in vec3 size, in float normalizedAge) {\n #ifdef RENDERER_SOL_CURVE\n size *= evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge);\n #endif\n #ifdef RENDERER_SOL_RANDOM_CURVES\n size *= mix(evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge),\n evaluateParticleCurve(u_SOLSizeGradientMax, normalizedAge),\n a_Random0.z);\n #endif\n #ifdef RENDERER_SOL_CURVE_SEPARATE\n size *= vec3(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge),\n evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge),\n evaluateParticleCurve(renderer_SOLMinCurveZ, normalizedAge));\n #endif\n #ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\n size *= vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge),\n a_Random0.z),\n mix(evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveY, normalizedAge),\n a_Random0.z),\n mix(evaluateParticleCurve(renderer_SOLMinCurveZ, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveZ, normalizedAge),\n a_Random0.z));\n #endif\n return size;\n }\n#endif"; // eslint-disable-line
|
|
8535
|
+
var color_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n uniform vec4 renderer_COLMaxGradientColor[4]; // x:time y:r z:g w:b\n uniform vec2 renderer_COLMaxGradientAlpha[4]; // x:time y:alpha\n\n #ifdef RENDERER_COL_RANDOM_GRADIENTS\n uniform vec4 renderer_COLMinGradientColor[4]; // x:time y:r z:g w:b\n uniform vec2 renderer_COLMinGradientAlpha[4]; // x:time y:alpha\n #endif\n\n uniform vec4 renderer_COLGradientKeysMaxTime; // x: minColorKeysMaxTime, y: minAlphaKeysMaxTime, z: maxColorKeysMaxTime, w: maxAlphaKeysMaxTime\n#endif\n\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n vec4 evaluateParticleGradient(in vec4 colorKeys[4], in float colorKeysMaxTime, in vec2 alphaKeys[4], in float alphaKeysMaxTime, in float normalizedAge){\n vec4 value;\n float alphaAge = min(normalizedAge, alphaKeysMaxTime);\n for(int i = 0; i < 4; i++){\n vec2 key = alphaKeys[i];\n float time = key.x;\n if(alphaAge <= time){\n if(i == 0){\n value.a = alphaKeys[0].y;\n }\n else {\n vec2 lastKey = alphaKeys[i-1];\n float lastTime = lastKey.x;\n float age = (alphaAge - lastTime) / (time - lastTime);\n value.a = mix(lastKey.y, key.y, age);\n }\n break;\n }\n }\n \n float colorAge = min(normalizedAge, colorKeysMaxTime);\n for(int i = 0; i < 4; i++){\n vec4 key = colorKeys[i];\n float time = key.x;\n if(colorAge <= time){\n if(i == 0){\n value.rgb = colorKeys[0].yzw;\n }\n else {\n vec4 lastKey = colorKeys[i-1];\n float lastTime = lastKey.x;\n float age = (colorAge - lastTime) / (time-lastTime);\n value.rgb = mix(lastKey.yzw, key.yzw, age);\n }\n break;\n }\n }\n return value;\n }\n#endif\n\nvec4 computeParticleColor(in vec4 color, in float normalizedAge) {\n #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n vec4 gradientColor = evaluateParticleGradient(renderer_COLMaxGradientColor, renderer_COLGradientKeysMaxTime.z, renderer_COLMaxGradientAlpha, renderer_COLGradientKeysMaxTime.w, normalizedAge);\n #endif\n\n #ifdef RENDERER_COL_RANDOM_GRADIENTS\n gradientColor = mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x, renderer_COLMinGradientAlpha, renderer_COLGradientKeysMaxTime.y, normalizedAge), gradientColor, a_Random0.y);\n #endif\n\n #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n color *= gradientColor;\n #endif\n\n return color;\n}\n"; // eslint-disable-line
|
|
8536
|
+
var texture_sheet_animation_module = "#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n uniform float renderer_TSACycles;\n uniform vec3 renderer_TSATillingParams; // x:subU y:subV z:tileCount\n uniform vec2 renderer_TSAFrameMaxCurve[4]; // x:time y:value\n\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n uniform vec2 renderer_TSAFrameMinCurve[4]; // x:time y:value\n #endif\n#endif\n\nvec2 computeParticleUV(in vec2 uv, in float normalizedAge) {\n #if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n float scaledNormalizedAge = normalizedAge * renderer_TSACycles;\n float cycleNormalizedAge = scaledNormalizedAge - floor(scaledNormalizedAge);\n float normalizedFrame = evaluateParticleCurve(renderer_TSAFrameMaxCurve, cycleNormalizedAge);\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n normalizedFrame = mix(evaluateParticleCurve(renderer_TSAFrameMinCurve, cycleNormalizedAge), normalizedFrame, a_Random1.x);\n #endif\n\n float frame = floor(normalizedFrame * renderer_TSATillingParams.z);\n\n float tileRow = frame * renderer_TSATillingParams.x;\n float tileRowIndex = floor(tileRow);\n uv.x += tileRow - tileRowIndex;\n uv.y += tileRowIndex * renderer_TSATillingParams.y;\n #endif\n \n return uv;\n}\n"; // eslint-disable-line
|
|
8537
|
+
var sphere_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n\tvec3 sideVector = normalize(cross(camera_Forward, camera_Up));\n\tvec3 upVector = normalize(cross(sideVector, camera_Forward));\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = vec3(a_StartRotation0.xy, computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge));\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, rotation);\n } else {\n float rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, a_StartRotation0);\n } else {\n float c = cos(a_StartRotation0.x);\n float s = sin(a_StartRotation0.x);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #endif\n#endif"; // eslint-disable-line
|
|
8538
|
+
var stretched_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n\tvec3 velocity;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n if (renderer_VOLSpace == 0){\n velocity = rotationByQuaternions(renderer_SizeScale * (startVelocity + lifeVelocity),\n worldRotation)\n + gravityVelocity;\n\t\t}\n else{\n velocity = rotationByQuaternions(renderer_SizeScale * startVelocity, worldRotation) + lifeVelocity + gravityVelocity;\n\t\t}\n #else\n\t velocity = rotationByQuaternions(renderer_SizeScale * startVelocity, worldRotation) + gravityVelocity;\n #endif\n\tvec3 cameraUpVector = normalize(velocity);\n\tvec3 direction = normalize(center - camera_Position);\n\tvec3 sideVector = normalize(cross(direction, normalize(velocity)));\n\n\tsideVector = renderer_SizeScale.xzy * sideVector;\n\tcameraUpVector = length(vec3(renderer_SizeScale.x, 0.0, 0.0)) * cameraUpVector;\n\n\tvec2 size = computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n\n\tconst mat2 rotationZHalfPI = mat2(0.0, -1.0, 1.0, 0.0);\n\tcorner = rotationZHalfPI * corner;\n\tcorner.y = corner.y - abs(corner.y);\n\n\tfloat speed = length(velocity); // TODO:\n\tcenter += sign(renderer_SizeScale.x) * (sign(renderer_StretchedBillboardLengthScale) * size.x * corner.x * sideVector\n\t + (speed * renderer_StretchedBillboardSpeedScale + size.y * renderer_StretchedBillboardLengthScale) * corner.y * cameraUpVector);\n#endif"; // eslint-disable-line
|
|
8539
|
+
var vertical_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy; // Billboard模式z轴无效\n\tconst vec3 cameraUpVector = vec3(0.0, 1.0, 0.0);\n\tvec3 sideVector = normalize(cross(camera_Forward, cameraUpVector));\n\n\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n\tfloat c = cos(rot);\n\tfloat s = sin(rot);\n\tmat2 rotation = mat2(c, -s, s, c);\n\tcorner = rotation * corner * cos(0.78539816339744830961566084581988); // TODO:临时缩小cos45,不确定U3D原因\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n\tcenter += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * cameraUpVector);\n#endif"; // eslint-disable-line
|
|
8540
|
+
var horizontal_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy; // Billboard模式z轴无效\n\tconst vec3 cameraUpVector = vec3(0.0, 0.0, 1.0);\n\tconst vec3 sideVector = vec3(-1.0, 0.0, 0.0);\n\n\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n\tfloat c = cos(rot);\n\tfloat s = sin(rot);\n\tmat2 rotation = mat2(c, -s, s, c);\n\tcorner = rotation * corner * cos(0.78539816339744830961566084581988); // TODO:临时缩小cos45,不确定U3D原因\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n\tcenter += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * cameraUpVector);\n#endif"; // eslint-disable-line
|
|
8541
|
+
var particle_mesh = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\n\tvec3 size = computeParticleSizeMesh(a_StartSize, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = vec3(\n a_StartRotation0.xy,\n computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge));\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByEuler(a_MeshPosition * size, rotation),\n worldRotation);\n } else {\n #ifdef RENDERER_ROL_IS_SEPARATE\n float angle = computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge);\n if (a_ShapePositionStartLifeTime.x != 0.0 || a_ShapePositionStartLifeTime.y != 0.0) {\n center += (rotationByQuaternions(\n rotationByAxis(\n renderer_SizeScale * a_MeshPosition * size,\n normalize(cross(vec3(0.0, 0.0, 1.0),\n vec3(a_ShapePositionStartLifeTime.xy, 0.0))),\n angle),\n worldRotation)); //已验证\n } else {\n #ifdef SHAPE\n center += renderer_SizeScale.xzy * (rotationByQuaternions(rotationByAxis(a_MeshPosition * size, vec3(0.0, -1.0, 0.0), angle), worldRotation));\n #else\n if (renderer_SimulationSpace == 1)\n center += rotationByAxis(renderer_SizeScale * a_MeshPosition * size,\n vec3(0.0, 0.0, -1.0),\n angle); //已验证\n else if (renderer_SimulationSpace == 0)\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, 0.0, -1.0), angle),\n worldRotation); //已验证\n #endif\n }\n #endif\n #ifdef ROTATION_OVER_LIFETIME_SEPARATE\n // TODO:是否应合并if(renderer_ThreeDStartRotation)分支代码,待测试\n vec3 angle = computeParticleRotationVec3(\n vec3(0.0, 0.0, -a_StartRotation0.x), age, normalizedAge);\n center += (rotationByQuaternions(\n rotationByEuler(renderer_SizeScale * a_MeshPosition * size,\n vec3(angle.x, angle.y, angle.z)),\n worldRotation)); //已验证\n #endif\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByEuler(a_MeshPosition * size, a_StartRotation0),\n worldRotation); //已验证\n } else {\n if (a_ShapePositionStartLifeTime.x != 0.0 || a_ShapePositionStartLifeTime.y != 0.0) {\n if (renderer_SimulationSpace == 1)\n center += rotationByAxis(\n renderer_SizeScale * a_MeshPosition * size,\n normalize(cross(vec3(0.0, 0.0, 1.0),\n vec3(a_ShapePositionStartLifeTime.xy, 0.0))),\n a_StartRotation0.x);\n else if (renderer_SimulationSpace == 0)\n center += (rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, normalize(cross(vec3(0.0, 0.0, 1.0),\n vec3(a_ShapePositionStartLifeTime.xy, 0.0))), a_StartRotation0.x),\n worldRotation)); //已验证\n } else {\n #ifdef SHAPE\n if (renderer_SimulationSpace == 1)\n center += renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, -1.0, 0.0), a_StartRotation0.x);\n else if (renderer_SimulationSpace == 0)\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, -1.0, 0.0), a_StartRotation0.x),\n worldRotation);\n #else\n if (renderer_SimulationSpace == 1)\n center += rotationByAxis(renderer_SizeScale * a_MeshPosition * size,\n vec3(0.0, 0.0, -1.0),\n a_StartRotation0.x);\n else if (renderer_SimulationSpace == 0)\n center += rotationByQuaternions(\n renderer_SizeScale * rotationByAxis(a_MeshPosition * size, vec3(0.0, 0.0, -1.0), a_StartRotation0.x),\n worldRotation); //已验证\n #endif\n }\n }\n #endif\n\tv_MeshColor = a_MeshColor;\n#endif"; // eslint-disable-line
|
|
8542
8542
|
var ParticleShaderLib = {
|
|
8543
8543
|
particle_common: particle_common,
|
|
8544
8544
|
velocity_over_lifetime_module: velocity_over_lifetime_module,
|
|
@@ -8552,7 +8552,7 @@
|
|
|
8552
8552
|
horizontal_billboard: horizontal_billboard,
|
|
8553
8553
|
particle_mesh: particle_mesh
|
|
8554
8554
|
};
|
|
8555
|
-
var normal_get = "#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\
|
|
8555
|
+
var normal_get = "#define GLSLIFY 1\n// gl_FrontFacing has random value on Adreno GPUs\n// the Adreno bug is only when gl_FrontFacing is inside a function\n// https://bugs.chromium.org/p/chromium/issues/detail?id=1154842\nvec3 getNormal(bool isFrontFacing){\n #ifdef RENDERER_HAS_NORMAL\n vec3 normal = normalize(v_normal);\n #elif defined(HAS_DERIVATIVES)\n vec3 pos_dx = dFdx(v_pos);\n vec3 pos_dy = dFdy(v_pos);\n vec3 normal = normalize( cross(pos_dx, pos_dy) );\n normal *= camera_ProjectionParams.x;\n #else\n vec3 normal = vec3(0, 0, 1);\n #endif\n\n normal *= float( isFrontFacing ) * 2.0 - 1.0;\n return normal;\n}\n\nvec3 getNormalByNormalTexture(mat3 tbn, sampler2D normalTexture, float normalIntensity, vec2 uv, bool isFrontFacing){\n vec3 normal = texture2D(normalTexture, uv).rgb;\n normal = normalize(tbn * ((2.0 * normal - 1.0) * vec3(normalIntensity, normalIntensity, 1.0)));\n normal *= float( isFrontFacing ) * 2.0 - 1.0;\n\n return normal;\n}\n\nmat3 getTBN(bool isFrontFacing){\n #if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\n mat3 tbn = v_TBN;\n #else\n vec3 normal = getNormal(isFrontFacing);\n vec3 position = v_pos;\n vec2 uv = isFrontFacing? v_uv: -v_uv;\n\n #ifdef HAS_DERIVATIVES\n // ref: http://www.thetenthplanet.de/archives/1180\n // get edge vectors of the pixel triangle\n\t vec3 dp1 = dFdx(position);\n\t vec3 dp2 = dFdy(position);\n\t vec2 duv1 = dFdx(uv);\n\t vec2 duv2 = dFdy(uv);\n\n\t // solve the linear system\n\t vec3 dp2perp = cross(dp2, normal);\n\t vec3 dp1perp = cross(normal, dp1);\n\t vec3 tangent = dp2perp * duv1.x + dp1perp * duv2.x;\n\t vec3 bitangent = dp2perp * duv1.y + dp1perp * duv2.y;\n\n\t // construct a scale-invariant frame \n float denom = max( dot(tangent, tangent), dot(bitangent, bitangent) );\n float invmax = (denom == 0.0) ? 0.0 : camera_ProjectionParams.x / sqrt( denom );\n\t mat3 tbn = mat3(tangent * invmax, bitangent * invmax, normal);\n #else\n mat3 tbn = mat3(vec3(0.0), vec3(0.0), normal);\n #endif\n #endif\n\t\n return tbn;\n}"; // eslint-disable-line
|
|
8556
8556
|
var ShaderLib = _extends$2({
|
|
8557
8557
|
common: common,
|
|
8558
8558
|
common_vert: common_vert,
|
|
@@ -13695,62 +13695,8 @@
|
|
|
13695
13695
|
}
|
|
13696
13696
|
return currentRenderTarget;
|
|
13697
13697
|
};
|
|
13698
|
-
/**
|
|
13699
|
-
* Blit texture to destination render target using a triangle.
|
|
13700
|
-
* @param engine - Engine
|
|
13701
|
-
* @param source - Source texture
|
|
13702
|
-
* @param destination - Destination render target
|
|
13703
|
-
* @param mipLevel - Mip level to blit
|
|
13704
|
-
* @param viewport - Viewport
|
|
13705
|
-
* @param material - The material to use when blitting
|
|
13706
|
-
* @param passIndex - Pass index to use of the provided material
|
|
13707
|
-
* @param flipYOfSource - Whether flip Y axis of source texture
|
|
13708
|
-
*/ PipelineUtils.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex, flipYOfSource) {
|
|
13709
|
-
if (mipLevel === void 0) mipLevel = 0;
|
|
13710
|
-
if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
|
|
13711
|
-
if (material === void 0) material = null;
|
|
13712
|
-
if (passIndex === void 0) passIndex = 0;
|
|
13713
|
-
if (flipYOfSource === void 0) flipYOfSource = false;
|
|
13714
|
-
var basicResources = engine._basicResources;
|
|
13715
|
-
var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
|
|
13716
|
-
var blitMaterial = material || basicResources.blitMaterial;
|
|
13717
|
-
var rhi = engine._hardwareRenderer;
|
|
13718
|
-
var context = engine._renderContext;
|
|
13719
|
-
// We not use projection matrix when blit, but we must modify flipProjection to make front face correct
|
|
13720
|
-
context.flipProjection = !!destination;
|
|
13721
|
-
rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
|
|
13722
|
-
var rendererShaderData = PipelineUtils._rendererShaderData;
|
|
13723
|
-
rendererShaderData.setTexture(PipelineUtils._blitTextureProperty, source);
|
|
13724
|
-
rendererShaderData.setFloat(PipelineUtils._blitMipLevelProperty, mipLevel);
|
|
13725
|
-
PipelineUtils._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
|
|
13726
|
-
rendererShaderData.setVector4(PipelineUtils._blitTexelSizeProperty, PipelineUtils._texelSize);
|
|
13727
|
-
if (flipYOfSource) {
|
|
13728
|
-
rendererShaderData.enableMacro(PipelineUtils._flipYTextureMacro);
|
|
13729
|
-
} else {
|
|
13730
|
-
rendererShaderData.disableMacro(PipelineUtils._flipYTextureMacro);
|
|
13731
|
-
}
|
|
13732
|
-
var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
|
|
13733
|
-
var compileMacros = Shader._compileMacros;
|
|
13734
|
-
ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, rendererShaderData._macroCollection, compileMacros);
|
|
13735
|
-
ShaderMacroCollection.unionCollection(compileMacros, blitMaterial.shaderData._macroCollection, compileMacros);
|
|
13736
|
-
var program = pass._getShaderProgram(engine, compileMacros);
|
|
13737
|
-
program.bind();
|
|
13738
|
-
program.groupingOtherUniformBlock();
|
|
13739
|
-
program.uploadAll(program.rendererUniformBlock, rendererShaderData);
|
|
13740
|
-
program.uploadAll(program.materialUniformBlock, blitMaterial.shaderData);
|
|
13741
|
-
program.uploadUnGroupTextures();
|
|
13742
|
-
(pass._renderState || blitMaterial.renderState)._applyStates(engine, false, pass._renderStateDataMap, blitMaterial.shaderData);
|
|
13743
|
-
rhi.drawPrimitive(blitMesh._primitive, blitMesh.subMesh, program);
|
|
13744
|
-
};
|
|
13745
13698
|
return PipelineUtils;
|
|
13746
13699
|
}();
|
|
13747
|
-
PipelineUtils._blitTextureProperty = ShaderProperty.getByName("renderer_BlitTexture");
|
|
13748
|
-
PipelineUtils._blitMipLevelProperty = ShaderProperty.getByName("renderer_BlitMipLevel");
|
|
13749
|
-
PipelineUtils._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
|
|
13750
|
-
;
|
|
13751
|
-
PipelineUtils._flipYTextureMacro = ShaderMacro.getByName("renderer_FlipYBlitTexture");
|
|
13752
|
-
PipelineUtils._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
|
|
13753
|
-
PipelineUtils._texelSize = new Vector4();
|
|
13754
13700
|
PipelineUtils.defaultViewport = new Vector4(0, 0, 1, 1);
|
|
13755
13701
|
/**
|
|
13756
13702
|
* @internal
|
|
@@ -13833,6 +13779,8 @@
|
|
|
13833
13779
|
* Culling mask - which layers the camera renders.
|
|
13834
13780
|
* @remarks Support bit manipulation, corresponding to `Layer`.
|
|
13835
13781
|
*/ _this.cullingMask = Layer.Everything, /**
|
|
13782
|
+
* Determines which PostProcess to use.
|
|
13783
|
+
*/ _this.postProcessMask = Layer.Everything, /**
|
|
13836
13784
|
* Depth texture mode.
|
|
13837
13785
|
* If `DepthTextureMode.PrePass` is used, the depth texture can be accessed in the shader using `camera_DepthTexture`.
|
|
13838
13786
|
*
|
|
@@ -14179,7 +14127,7 @@
|
|
|
14179
14127
|
* @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
|
|
14180
14128
|
*/ function get() {
|
|
14181
14129
|
// Uber pass need internal RT
|
|
14182
|
-
if (this.enablePostProcess && this.scene.
|
|
14130
|
+
if (this.enablePostProcess && this.scene.postProcessManager._isValid()) {
|
|
14183
14131
|
return true;
|
|
14184
14132
|
}
|
|
14185
14133
|
if (this.enableHDR || this.opaqueTextureEnabled) {
|
|
@@ -14713,6 +14661,61 @@
|
|
|
14713
14661
|
};
|
|
14714
14662
|
return RenderQueue;
|
|
14715
14663
|
}();
|
|
14664
|
+
/**
|
|
14665
|
+
* A helper class to blit texture to destination render target.
|
|
14666
|
+
*/ var Blitter = /*#__PURE__*/ function() {
|
|
14667
|
+
function Blitter() {}
|
|
14668
|
+
/**
|
|
14669
|
+
* Blit texture to destination render target using a triangle.
|
|
14670
|
+
* @param engine - Engine
|
|
14671
|
+
* @param source - Source texture
|
|
14672
|
+
* @param destination - Destination render target
|
|
14673
|
+
* @param mipLevel - Mip level to blit
|
|
14674
|
+
* @param viewport - Viewport
|
|
14675
|
+
* @param material - The material to use when blit
|
|
14676
|
+
* @param passIndex - Pass index to use of the provided material
|
|
14677
|
+
* @param flipYOfSource - Whether flip Y axis of source texture
|
|
14678
|
+
*/ Blitter.blitTexture = function blitTexture(engine, source, destination, mipLevel, viewport, material, passIndex, sourceScaleOffset) {
|
|
14679
|
+
if (mipLevel === void 0) mipLevel = 0;
|
|
14680
|
+
if (viewport === void 0) viewport = PipelineUtils.defaultViewport;
|
|
14681
|
+
if (material === void 0) material = null;
|
|
14682
|
+
if (passIndex === void 0) passIndex = 0;
|
|
14683
|
+
var basicResources = engine._basicResources;
|
|
14684
|
+
var blitMesh = destination ? basicResources.flipYBlitMesh : basicResources.blitMesh;
|
|
14685
|
+
var blitMaterial = material || basicResources.blitMaterial;
|
|
14686
|
+
var rhi = engine._hardwareRenderer;
|
|
14687
|
+
var context = engine._renderContext;
|
|
14688
|
+
// We not use projection matrix when blit, but we must modify flipProjection to make front face correct
|
|
14689
|
+
context.flipProjection = !!destination;
|
|
14690
|
+
rhi.activeRenderTarget(destination, viewport, context.flipProjection, 0);
|
|
14691
|
+
var rendererShaderData = Blitter._rendererShaderData;
|
|
14692
|
+
rendererShaderData.setTexture(Blitter._blitTextureProperty, source);
|
|
14693
|
+
rendererShaderData.setFloat(Blitter._blitMipLevelProperty, mipLevel);
|
|
14694
|
+
Blitter._texelSize.set(1 / source.width, 1 / source.height, source.width, source.height);
|
|
14695
|
+
rendererShaderData.setVector4(Blitter._blitTexelSizeProperty, Blitter._texelSize);
|
|
14696
|
+
rendererShaderData.setVector4(Blitter._sourceScaleOffsetProperty, sourceScaleOffset != null ? sourceScaleOffset : Blitter._defaultScaleOffset);
|
|
14697
|
+
var pass = blitMaterial.shader.subShaders[0].passes[passIndex];
|
|
14698
|
+
var compileMacros = Shader._compileMacros;
|
|
14699
|
+
ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, blitMaterial.shaderData._macroCollection, compileMacros);
|
|
14700
|
+
var program = pass._getShaderProgram(engine, compileMacros);
|
|
14701
|
+
program.bind();
|
|
14702
|
+
program.groupingOtherUniformBlock();
|
|
14703
|
+
program.uploadAll(program.rendererUniformBlock, rendererShaderData);
|
|
14704
|
+
program.uploadAll(program.materialUniformBlock, blitMaterial.shaderData);
|
|
14705
|
+
program.uploadUnGroupTextures();
|
|
14706
|
+
(pass._renderState || blitMaterial.renderState)._applyStates(engine, false, pass._renderStateDataMap, blitMaterial.shaderData);
|
|
14707
|
+
rhi.drawPrimitive(blitMesh._primitive, blitMesh.subMesh, program);
|
|
14708
|
+
};
|
|
14709
|
+
return Blitter;
|
|
14710
|
+
}();
|
|
14711
|
+
Blitter._blitTextureProperty = ShaderProperty.getByName("renderer_BlitTexture");
|
|
14712
|
+
Blitter._blitMipLevelProperty = ShaderProperty.getByName("renderer_BlitMipLevel");
|
|
14713
|
+
Blitter._blitTexelSizeProperty = ShaderProperty.getByName("renderer_texelSize") // x: 1/width, y: 1/height, z: width, w: height
|
|
14714
|
+
;
|
|
14715
|
+
Blitter._sourceScaleOffsetProperty = ShaderProperty.getByName("renderer_SourceScaleOffset");
|
|
14716
|
+
Blitter._rendererShaderData = new ShaderData(ShaderDataGroup.Renderer);
|
|
14717
|
+
Blitter._texelSize = new Vector4();
|
|
14718
|
+
Blitter._defaultScaleOffset = new Vector4(1, 1, 0, 0);
|
|
14716
14719
|
/**
|
|
14717
14720
|
* @internal
|
|
14718
14721
|
*/ var ShadowSliceData = function ShadowSliceData() {
|
|
@@ -15533,7 +15536,7 @@
|
|
|
15533
15536
|
this._renderTarget = opaqueRenderTarget;
|
|
15534
15537
|
};
|
|
15535
15538
|
_proto.onRender = function onRender(context) {
|
|
15536
|
-
|
|
15539
|
+
Blitter.blitTexture(this.engine, this._cameraColorTexture, this._renderTarget);
|
|
15537
15540
|
context.camera.shaderData.setTexture(exports.Camera._cameraOpaqueTextureProperty, this._renderTarget.getColorTexture(0));
|
|
15538
15541
|
};
|
|
15539
15542
|
return OpaqueTexturePass;
|
|
@@ -15546,6 +15549,7 @@
|
|
|
15546
15549
|
this._internalColorTarget = null;
|
|
15547
15550
|
this._canUseBlitFrameBuffer = false;
|
|
15548
15551
|
this._shouldGrabColor = false;
|
|
15552
|
+
this._sourceScaleOffset = new Vector4(1, 1, 0, 0);
|
|
15549
15553
|
this._camera = camera;
|
|
15550
15554
|
var engine = camera.engine;
|
|
15551
15555
|
this._cullingResults = new CullingResults();
|
|
@@ -15672,7 +15676,11 @@
|
|
|
15672
15676
|
// Copy RT's color buffer to grab texture
|
|
15673
15677
|
rhi.copyRenderTargetToSubTexture(camera.renderTarget, this._grabTexture, camera.viewport);
|
|
15674
15678
|
// Then blit grab texture to internal RT's color buffer
|
|
15675
|
-
|
|
15679
|
+
var sourceScaleOffset = this._sourceScaleOffset;
|
|
15680
|
+
sourceScaleOffset.y = camera.renderTarget ? 1 : -1;
|
|
15681
|
+
sourceScaleOffset.w = camera.renderTarget ? 0 : 1;
|
|
15682
|
+
// `uv.y = 1.0 - uv.y` if grab from screen
|
|
15683
|
+
Blitter.blitTexture(engine, this._grabTexture, internalColorTarget, 0, undefined, undefined, undefined, sourceScaleOffset);
|
|
15676
15684
|
} else {
|
|
15677
15685
|
rhi.clearRenderTarget(engine, CameraClearFlags.All, color);
|
|
15678
15686
|
}
|
|
@@ -15709,13 +15717,16 @@
|
|
|
15709
15717
|
transparentQueue.render(context, PipelineStage.Forward);
|
|
15710
15718
|
// Revert stencil buffer generated by mask
|
|
15711
15719
|
maskManager.clearMask(context, PipelineStage.Forward);
|
|
15712
|
-
var postProcessManager = scene.
|
|
15720
|
+
var postProcessManager = scene.postProcessManager;
|
|
15713
15721
|
var cameraRenderTarget = camera.renderTarget;
|
|
15714
|
-
if (camera.enablePostProcess && postProcessManager.
|
|
15715
|
-
postProcessManager._render(
|
|
15716
|
-
} else
|
|
15717
|
-
|
|
15718
|
-
|
|
15722
|
+
if (camera.enablePostProcess && postProcessManager._isValid()) {
|
|
15723
|
+
postProcessManager._render(camera, internalColorTarget, cameraRenderTarget);
|
|
15724
|
+
} else {
|
|
15725
|
+
postProcessManager._releaseSwapRenderTarget();
|
|
15726
|
+
if (internalColorTarget) {
|
|
15727
|
+
internalColorTarget._blitRenderTarget();
|
|
15728
|
+
Blitter.blitTexture(engine, internalColorTarget.getColorTexture(0), cameraRenderTarget, 0, camera.viewport);
|
|
15729
|
+
}
|
|
15719
15730
|
}
|
|
15720
15731
|
cameraRenderTarget == null ? void 0 : cameraRenderTarget._blitRenderTarget();
|
|
15721
15732
|
cameraRenderTarget == null ? void 0 : cameraRenderTarget.generateMipmaps();
|
|
@@ -17427,6 +17438,50 @@
|
|
|
17427
17438
|
target._isTransparent = this._isTransparent;
|
|
17428
17439
|
target._blendMode = this._blendMode;
|
|
17429
17440
|
};
|
|
17441
|
+
_proto._seIsTransparent = function _seIsTransparent(value) {
|
|
17442
|
+
if (value !== this._isTransparent) {
|
|
17443
|
+
this.setIsTransparent(0, value);
|
|
17444
|
+
var shaderData = this.shaderData;
|
|
17445
|
+
if (value) {
|
|
17446
|
+
// Use alpha test queue to simulate transparent shadow
|
|
17447
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17448
|
+
} else {
|
|
17449
|
+
var alphaCutoff = shaderData.getFloat(BaseMaterial._alphaCutoffProp);
|
|
17450
|
+
if (alphaCutoff) {
|
|
17451
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17452
|
+
} else {
|
|
17453
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.Opaque);
|
|
17454
|
+
}
|
|
17455
|
+
}
|
|
17456
|
+
this._isTransparent = value;
|
|
17457
|
+
}
|
|
17458
|
+
};
|
|
17459
|
+
_proto._setAlphaCutoff = function _setAlphaCutoff(value) {
|
|
17460
|
+
var shaderData = this.shaderData;
|
|
17461
|
+
if (shaderData.getFloat(BaseMaterial._alphaCutoffProp) !== value) {
|
|
17462
|
+
if (value) {
|
|
17463
|
+
shaderData.enableMacro(BaseMaterial._alphaCutoffMacro);
|
|
17464
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17465
|
+
} else {
|
|
17466
|
+
shaderData.disableMacro(BaseMaterial._alphaCutoffMacro);
|
|
17467
|
+
if (this._isTransparent) {
|
|
17468
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17469
|
+
} else {
|
|
17470
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.Opaque);
|
|
17471
|
+
}
|
|
17472
|
+
}
|
|
17473
|
+
var renderStates = this.renderStates;
|
|
17474
|
+
for(var i = 0, n = renderStates.length; i < n; i++){
|
|
17475
|
+
var renderState = renderStates[i];
|
|
17476
|
+
if (value > 0) {
|
|
17477
|
+
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.AlphaTest;
|
|
17478
|
+
} else {
|
|
17479
|
+
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.Opaque;
|
|
17480
|
+
}
|
|
17481
|
+
}
|
|
17482
|
+
shaderData.setFloat(BaseMaterial._alphaCutoffProp, value);
|
|
17483
|
+
}
|
|
17484
|
+
};
|
|
17430
17485
|
_create_class$2(BaseMaterial, [
|
|
17431
17486
|
{
|
|
17432
17487
|
key: "shader",
|
|
@@ -17468,22 +17523,7 @@
|
|
|
17468
17523
|
return this._isTransparent;
|
|
17469
17524
|
},
|
|
17470
17525
|
set: function set(value) {
|
|
17471
|
-
|
|
17472
|
-
this.setIsTransparent(0, value);
|
|
17473
|
-
var shaderData = this.shaderData;
|
|
17474
|
-
if (value) {
|
|
17475
|
-
// Use alpha test queue to simulate transparent shadow
|
|
17476
|
-
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17477
|
-
} else {
|
|
17478
|
-
var alphaCutoff = shaderData.getFloat(BaseMaterial._alphaCutoffProp);
|
|
17479
|
-
if (alphaCutoff) {
|
|
17480
|
-
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17481
|
-
} else {
|
|
17482
|
-
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.Opaque);
|
|
17483
|
-
}
|
|
17484
|
-
}
|
|
17485
|
-
this._isTransparent = value;
|
|
17486
|
-
}
|
|
17526
|
+
this._seIsTransparent(value);
|
|
17487
17527
|
}
|
|
17488
17528
|
},
|
|
17489
17529
|
{
|
|
@@ -17512,30 +17552,7 @@
|
|
|
17512
17552
|
return this.shaderData.getFloat(BaseMaterial._alphaCutoffProp);
|
|
17513
17553
|
},
|
|
17514
17554
|
set: function set(value) {
|
|
17515
|
-
|
|
17516
|
-
if (shaderData.getFloat(BaseMaterial._alphaCutoffProp) !== value) {
|
|
17517
|
-
if (value) {
|
|
17518
|
-
shaderData.enableMacro(BaseMaterial._alphaCutoffMacro);
|
|
17519
|
-
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17520
|
-
} else {
|
|
17521
|
-
shaderData.disableMacro(BaseMaterial._alphaCutoffMacro);
|
|
17522
|
-
if (this._isTransparent) {
|
|
17523
|
-
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
17524
|
-
} else {
|
|
17525
|
-
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.Opaque);
|
|
17526
|
-
}
|
|
17527
|
-
}
|
|
17528
|
-
var renderStates = this.renderStates;
|
|
17529
|
-
for(var i = 0, n = renderStates.length; i < n; i++){
|
|
17530
|
-
var renderState = renderStates[i];
|
|
17531
|
-
if (value > 0) {
|
|
17532
|
-
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.AlphaTest;
|
|
17533
|
-
} else {
|
|
17534
|
-
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.Opaque;
|
|
17535
|
-
}
|
|
17536
|
-
}
|
|
17537
|
-
shaderData.setFloat(BaseMaterial._alphaCutoffProp, value);
|
|
17538
|
-
}
|
|
17555
|
+
this._setAlphaCutoff(value);
|
|
17539
17556
|
}
|
|
17540
17557
|
},
|
|
17541
17558
|
{
|
|
@@ -18007,6 +18024,13 @@
|
|
|
18007
18024
|
PBRBaseMaterial._clearCoatRoughnessProp = ShaderProperty.getByName("material_ClearCoatRoughness");
|
|
18008
18025
|
PBRBaseMaterial._clearCoatRoughnessTextureProp = ShaderProperty.getByName("material_ClearCoatRoughnessTexture");
|
|
18009
18026
|
PBRBaseMaterial._clearCoatNormalTextureProp = ShaderProperty.getByName("material_ClearCoatNormalTexture");
|
|
18027
|
+
/**
|
|
18028
|
+
* Refraction mode.
|
|
18029
|
+
*/ var RefractionMode = /*#__PURE__*/ function(RefractionMode) {
|
|
18030
|
+
/** Use the sphere refraction model when light passes through the surface. */ RefractionMode[RefractionMode["Sphere"] = 0] = "Sphere";
|
|
18031
|
+
/** Use the planar refraction model when light passes through the surface. */ RefractionMode[RefractionMode["Planar"] = 1] = "Planar";
|
|
18032
|
+
return RefractionMode;
|
|
18033
|
+
}({});
|
|
18010
18034
|
/**
|
|
18011
18035
|
* PBR (Metallic-Roughness Workflow) Material.
|
|
18012
18036
|
*/ var PBRMaterial = /*#__PURE__*/ function(PBRBaseMaterial) {
|
|
@@ -18022,28 +18046,19 @@
|
|
|
18022
18046
|
shaderData.setVector4(PBRMaterial._iridescenceInfoProp, new Vector4(0, 1.3, 100, 400));
|
|
18023
18047
|
var sheenColor = new Color(0, 0, 0);
|
|
18024
18048
|
shaderData.setColor(PBRMaterial._sheenColorProp, sheenColor);
|
|
18049
|
+
_this.refractionMode = RefractionMode.Planar;
|
|
18050
|
+
shaderData.setFloat(PBRMaterial._transmissionProp, 0);
|
|
18051
|
+
shaderData.setFloat(PBRMaterial._thicknessProp, 0);
|
|
18052
|
+
shaderData.setFloat(PBRMaterial._attenuationDistanceProp, Infinity);
|
|
18053
|
+
var attenuationColor = new Color(1, 1, 1);
|
|
18054
|
+
shaderData.setColor(PBRMaterial._attenuationColorProp, attenuationColor);
|
|
18025
18055
|
// @ts-ignore
|
|
18026
18056
|
_this._iridescenceRange._onValueChanged = _this._onIridescenceRangeChanged.bind(_this);
|
|
18027
18057
|
// @ts-ignore
|
|
18028
|
-
sheenColor._onValueChanged =
|
|
18029
|
-
var enableSheen = sheenColor.r + sheenColor.g + sheenColor.b > 0;
|
|
18030
|
-
if (enableSheen !== _this._sheenEnabled) {
|
|
18031
|
-
_this._sheenEnabled = enableSheen;
|
|
18032
|
-
if (enableSheen) {
|
|
18033
|
-
_this.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN");
|
|
18034
|
-
} else {
|
|
18035
|
-
_this.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN");
|
|
18036
|
-
}
|
|
18037
|
-
}
|
|
18038
|
-
};
|
|
18058
|
+
sheenColor._onValueChanged = _this._onSheenColorChanged.bind(_this);
|
|
18039
18059
|
return _this;
|
|
18040
18060
|
}
|
|
18041
18061
|
var _proto = PBRMaterial.prototype;
|
|
18042
|
-
_proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
|
|
18043
|
-
var iridescenceInfo = this.shaderData.getVector4(PBRMaterial._iridescenceInfoProp);
|
|
18044
|
-
iridescenceInfo.z = this._iridescenceRange.x;
|
|
18045
|
-
iridescenceInfo.w = this._iridescenceRange.y;
|
|
18046
|
-
};
|
|
18047
18062
|
/**
|
|
18048
18063
|
* @inheritdoc
|
|
18049
18064
|
*/ _proto.clone = function clone() {
|
|
@@ -18051,6 +18066,23 @@
|
|
|
18051
18066
|
this.cloneTo(dest);
|
|
18052
18067
|
return dest;
|
|
18053
18068
|
};
|
|
18069
|
+
_proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
|
|
18070
|
+
var iridescenceInfo = this.shaderData.getVector4(PBRMaterial._iridescenceInfoProp);
|
|
18071
|
+
iridescenceInfo.z = this._iridescenceRange.x;
|
|
18072
|
+
iridescenceInfo.w = this._iridescenceRange.y;
|
|
18073
|
+
};
|
|
18074
|
+
_proto._onSheenColorChanged = function _onSheenColorChanged() {
|
|
18075
|
+
var sheenColor = this.sheenColor;
|
|
18076
|
+
var enableSheen = sheenColor.r + sheenColor.g + sheenColor.b > 0;
|
|
18077
|
+
if (enableSheen !== this._sheenEnabled) {
|
|
18078
|
+
this._sheenEnabled = enableSheen;
|
|
18079
|
+
if (enableSheen) {
|
|
18080
|
+
this.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN");
|
|
18081
|
+
} else {
|
|
18082
|
+
this.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN");
|
|
18083
|
+
}
|
|
18084
|
+
}
|
|
18085
|
+
};
|
|
18054
18086
|
_create_class$2(PBRMaterial, [
|
|
18055
18087
|
{
|
|
18056
18088
|
key: "ior",
|
|
@@ -18305,6 +18337,154 @@
|
|
|
18305
18337
|
this.shaderData.disableMacro("MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE");
|
|
18306
18338
|
}
|
|
18307
18339
|
}
|
|
18340
|
+
},
|
|
18341
|
+
{
|
|
18342
|
+
key: "refractionMode",
|
|
18343
|
+
get: /**
|
|
18344
|
+
* Refraction switch.
|
|
18345
|
+
* @remarks Use refractionMode to set the refraction shape.
|
|
18346
|
+
*/ function get() {
|
|
18347
|
+
return this._refractionMode;
|
|
18348
|
+
},
|
|
18349
|
+
set: function set(value) {
|
|
18350
|
+
if (value !== this._refractionMode) {
|
|
18351
|
+
this._refractionMode = value;
|
|
18352
|
+
this.shaderData.enableMacro("REFRACTION_MODE", value.toString());
|
|
18353
|
+
}
|
|
18354
|
+
}
|
|
18355
|
+
},
|
|
18356
|
+
{
|
|
18357
|
+
key: "isTransparent",
|
|
18358
|
+
get: /**
|
|
18359
|
+
* @inheritdoc
|
|
18360
|
+
*/ function get() {
|
|
18361
|
+
return this._isTransparent;
|
|
18362
|
+
},
|
|
18363
|
+
set: function set(value) {
|
|
18364
|
+
this._seIsTransparent(value);
|
|
18365
|
+
if (this.transmission > 0) {
|
|
18366
|
+
// If transmission enabled, always use transparent queue to ensure get correct opaque texture
|
|
18367
|
+
this.renderState.renderQueueType = RenderQueueType.Transparent;
|
|
18368
|
+
}
|
|
18369
|
+
}
|
|
18370
|
+
},
|
|
18371
|
+
{
|
|
18372
|
+
key: "alphaCutoff",
|
|
18373
|
+
get: /**
|
|
18374
|
+
* @inheritdoc
|
|
18375
|
+
*/ function get() {
|
|
18376
|
+
return this.shaderData.getFloat(BaseMaterial._alphaCutoffProp);
|
|
18377
|
+
},
|
|
18378
|
+
set: function set(value) {
|
|
18379
|
+
this._setAlphaCutoff(value);
|
|
18380
|
+
if (this.transmission > 0) {
|
|
18381
|
+
// If transmission enabled, always use transparent queue to ensure get correct opaque texture
|
|
18382
|
+
this.renderState.renderQueueType = RenderQueueType.Transparent;
|
|
18383
|
+
}
|
|
18384
|
+
}
|
|
18385
|
+
},
|
|
18386
|
+
{
|
|
18387
|
+
key: "transmission",
|
|
18388
|
+
get: /**
|
|
18389
|
+
* Transmission factor.
|
|
18390
|
+
* @defaultValue `0.0`
|
|
18391
|
+
*/ function get() {
|
|
18392
|
+
return this.shaderData.getFloat(PBRMaterial._transmissionProp);
|
|
18393
|
+
},
|
|
18394
|
+
set: function set(value) {
|
|
18395
|
+
value = MathUtil.clamp(value, 0, 1);
|
|
18396
|
+
if (!!this.shaderData.getFloat(PBRMaterial._transmissionProp) !== !!value) {
|
|
18397
|
+
if (value > 0) {
|
|
18398
|
+
this.shaderData.enableMacro(PBRMaterial._transmissionMacro);
|
|
18399
|
+
this.renderState.renderQueueType = RenderQueueType.Transparent;
|
|
18400
|
+
} else {
|
|
18401
|
+
this.shaderData.disableMacro(PBRMaterial._transmissionMacro);
|
|
18402
|
+
}
|
|
18403
|
+
}
|
|
18404
|
+
this.shaderData.setFloat(PBRMaterial._transmissionProp, value);
|
|
18405
|
+
}
|
|
18406
|
+
},
|
|
18407
|
+
{
|
|
18408
|
+
key: "transmissionTexture",
|
|
18409
|
+
get: /**
|
|
18410
|
+
* Transmission texture.
|
|
18411
|
+
* @remarks Use red channel, and multiply 'transmission'.
|
|
18412
|
+
*/ function get() {
|
|
18413
|
+
return this.shaderData.getTexture(PBRMaterial._transmissionTextureProp);
|
|
18414
|
+
},
|
|
18415
|
+
set: function set(value) {
|
|
18416
|
+
this.shaderData.setTexture(PBRMaterial._transmissionTextureProp, value);
|
|
18417
|
+
if (value) {
|
|
18418
|
+
this.shaderData.enableMacro(PBRMaterial._transmissionTextureMacro);
|
|
18419
|
+
} else {
|
|
18420
|
+
this.shaderData.disableMacro(PBRMaterial._transmissionTextureMacro);
|
|
18421
|
+
}
|
|
18422
|
+
}
|
|
18423
|
+
},
|
|
18424
|
+
{
|
|
18425
|
+
key: "attenuationColor",
|
|
18426
|
+
get: /**
|
|
18427
|
+
* Attenuation color.
|
|
18428
|
+
* @defaultValue `[1,1,1]`
|
|
18429
|
+
*/ function get() {
|
|
18430
|
+
return this.shaderData.getColor(PBRMaterial._attenuationColorProp);
|
|
18431
|
+
},
|
|
18432
|
+
set: function set(value) {
|
|
18433
|
+
var attenuationColor = this.shaderData.getColor(PBRMaterial._attenuationColorProp);
|
|
18434
|
+
if (value !== attenuationColor) {
|
|
18435
|
+
attenuationColor.copyFrom(value);
|
|
18436
|
+
}
|
|
18437
|
+
}
|
|
18438
|
+
},
|
|
18439
|
+
{
|
|
18440
|
+
key: "attenuationDistance",
|
|
18441
|
+
get: /**
|
|
18442
|
+
* Attenuation distance, greater than 0.0.
|
|
18443
|
+
* @defaultValue `infinity`
|
|
18444
|
+
*/ function get() {
|
|
18445
|
+
return this.shaderData.getFloat(PBRMaterial._attenuationDistanceProp);
|
|
18446
|
+
},
|
|
18447
|
+
set: function set(value) {
|
|
18448
|
+
value = Math.max(0, value);
|
|
18449
|
+
this.shaderData.setFloat(PBRMaterial._attenuationDistanceProp, value);
|
|
18450
|
+
}
|
|
18451
|
+
},
|
|
18452
|
+
{
|
|
18453
|
+
key: "thickness",
|
|
18454
|
+
get: /**
|
|
18455
|
+
* Thickness, greater than or equal to 0.0.
|
|
18456
|
+
* @defaultValue `0.0`
|
|
18457
|
+
*/ function get() {
|
|
18458
|
+
return this.shaderData.getFloat(PBRMaterial._thicknessProp);
|
|
18459
|
+
},
|
|
18460
|
+
set: function set(value) {
|
|
18461
|
+
value = Math.max(0, value);
|
|
18462
|
+
if (!!this.shaderData.getFloat(PBRMaterial._thicknessProp) !== !!value) {
|
|
18463
|
+
if (value > 0) {
|
|
18464
|
+
this.shaderData.enableMacro(PBRMaterial._thicknessMacro);
|
|
18465
|
+
} else {
|
|
18466
|
+
this.shaderData.disableMacro(PBRMaterial._thicknessMacro);
|
|
18467
|
+
}
|
|
18468
|
+
}
|
|
18469
|
+
this.shaderData.setFloat(PBRMaterial._thicknessProp, value);
|
|
18470
|
+
}
|
|
18471
|
+
},
|
|
18472
|
+
{
|
|
18473
|
+
key: "thicknessTexture",
|
|
18474
|
+
get: /**
|
|
18475
|
+
* Thickness texture.
|
|
18476
|
+
* @remarks Use green channel, and multiply 'thickness', range is 0.0 to 1.0.
|
|
18477
|
+
*/ function get() {
|
|
18478
|
+
return this.shaderData.getTexture(PBRMaterial._thicknessTextureProp);
|
|
18479
|
+
},
|
|
18480
|
+
set: function set(value) {
|
|
18481
|
+
this.shaderData.setTexture(PBRMaterial._thicknessTextureProp, value);
|
|
18482
|
+
if (value) {
|
|
18483
|
+
this.shaderData.enableMacro(PBRMaterial._thicknessTextureMacro);
|
|
18484
|
+
} else {
|
|
18485
|
+
this.shaderData.disableMacro(PBRMaterial._thicknessTextureMacro);
|
|
18486
|
+
}
|
|
18487
|
+
}
|
|
18308
18488
|
}
|
|
18309
18489
|
]);
|
|
18310
18490
|
return PBRMaterial;
|
|
@@ -18322,6 +18502,16 @@
|
|
|
18322
18502
|
PBRMaterial._sheenRoughnessProp = ShaderProperty.getByName("material_SheenRoughness");
|
|
18323
18503
|
PBRMaterial._sheenTextureProp = ShaderProperty.getByName("material_SheenTexture");
|
|
18324
18504
|
PBRMaterial._sheenRoughnessTextureProp = ShaderProperty.getByName("material_SheenRoughnessTexture");
|
|
18505
|
+
PBRMaterial._transmissionMacro = ShaderMacro.getByName("MATERIAL_ENABLE_TRANSMISSION");
|
|
18506
|
+
PBRMaterial._thicknessMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS");
|
|
18507
|
+
PBRMaterial._thicknessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS_TEXTURE");
|
|
18508
|
+
PBRMaterial._transmissionTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE");
|
|
18509
|
+
PBRMaterial._transmissionProp = ShaderProperty.getByName("material_Transmission");
|
|
18510
|
+
PBRMaterial._transmissionTextureProp = ShaderProperty.getByName("material_TransmissionTexture");
|
|
18511
|
+
PBRMaterial._attenuationColorProp = ShaderProperty.getByName("material_AttenuationColor");
|
|
18512
|
+
PBRMaterial._attenuationDistanceProp = ShaderProperty.getByName("material_AttenuationDistance");
|
|
18513
|
+
PBRMaterial._thicknessProp = ShaderProperty.getByName("material_Thickness");
|
|
18514
|
+
PBRMaterial._thicknessTextureProp = ShaderProperty.getByName("material_ThicknessTexture");
|
|
18325
18515
|
/**
|
|
18326
18516
|
* PBR (Specular-Glossiness Workflow) Material.
|
|
18327
18517
|
*/ var PBRSpecularMaterial = /*#__PURE__*/ function(PBRBaseMaterial) {
|
|
@@ -23583,6 +23773,7 @@
|
|
|
23583
23773
|
/** Source Font, include ttf, otf and woff. */ AssetType["SourceFont"] = "SourceFont";
|
|
23584
23774
|
/** AudioClip, include ogg, wav and mp3. */ AssetType["Audio"] = "Audio";
|
|
23585
23775
|
/** Project asset. */ AssetType["Project"] = "project";
|
|
23776
|
+
/** PhysicsMaterial. */ AssetType["PhysicsMaterial"] = "PhysicsMaterial";
|
|
23586
23777
|
return AssetType;
|
|
23587
23778
|
}({});
|
|
23588
23779
|
var SafeLoopArray = /*#__PURE__*/ function() {
|
|
@@ -25298,7 +25489,53 @@
|
|
|
25298
25489
|
exports.Collider = __decorate$1([
|
|
25299
25490
|
dependentComponents(Transform, DependentMode.CheckOnly)
|
|
25300
25491
|
], exports.Collider);
|
|
25301
|
-
|
|
25492
|
+
/**
|
|
25493
|
+
* Describes a contact point where the collision occurs.
|
|
25494
|
+
*/ var ContactPoint = function ContactPoint() {
|
|
25495
|
+
/** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
|
|
25496
|
+
/** The normal of the contacting surfaces at the contact point. The normal direction points from the second shape to the first shape. */ this.normal = new Vector3();
|
|
25497
|
+
/** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */ this.impulse = new Vector3();
|
|
25498
|
+
};
|
|
25499
|
+
/**
|
|
25500
|
+
* Collision information between two shapes when they collide.
|
|
25501
|
+
*/ var Collision = /*#__PURE__*/ function() {
|
|
25502
|
+
function Collision() {}
|
|
25503
|
+
var _proto = Collision.prototype;
|
|
25504
|
+
/**
|
|
25505
|
+
* Get contact points.
|
|
25506
|
+
* @param outContacts - The result of contact points
|
|
25507
|
+
* @returns The actual count of contact points
|
|
25508
|
+
*
|
|
25509
|
+
* @remarks To optimize performance, the engine does not modify the length of the array you pass.
|
|
25510
|
+
* You need to obtain the actual number of contact points from the function's return value.
|
|
25511
|
+
*/ _proto.getContacts = function getContacts(outContacts) {
|
|
25512
|
+
var nativeCollision = this._nativeCollision;
|
|
25513
|
+
var factor = nativeCollision.shape0Id < nativeCollision.shape1Id ? 1 : -1;
|
|
25514
|
+
var nativeContactPoints = nativeCollision.getContacts();
|
|
25515
|
+
var length = nativeContactPoints.size();
|
|
25516
|
+
for(var i = 0; i < length; i++){
|
|
25517
|
+
var _outContacts, _i;
|
|
25518
|
+
var nativeContractPoint = nativeContactPoints.get(i);
|
|
25519
|
+
var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
|
|
25520
|
+
contact.position.copyFrom(nativeContractPoint.position);
|
|
25521
|
+
contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
|
|
25522
|
+
contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
|
|
25523
|
+
contact.separation = nativeContractPoint.separation;
|
|
25524
|
+
}
|
|
25525
|
+
return length;
|
|
25526
|
+
};
|
|
25527
|
+
_create_class$2(Collision, [
|
|
25528
|
+
{
|
|
25529
|
+
key: "contactCount",
|
|
25530
|
+
get: /**
|
|
25531
|
+
* Count of contact points.
|
|
25532
|
+
*/ function get() {
|
|
25533
|
+
return this._nativeCollision.contactCount;
|
|
25534
|
+
}
|
|
25535
|
+
}
|
|
25536
|
+
]);
|
|
25537
|
+
return Collision;
|
|
25538
|
+
}();
|
|
25302
25539
|
/**
|
|
25303
25540
|
* A physics scene is a collection of colliders and constraints which can interact.
|
|
25304
25541
|
*/ var PhysicsScene = /*#__PURE__*/ function() {
|
|
@@ -25307,57 +25544,60 @@
|
|
|
25307
25544
|
this._fixedTimeStep = 1 / 60;
|
|
25308
25545
|
this._colliders = new DisorderedArray();
|
|
25309
25546
|
this._gravity = new Vector3(0, -9.81, 0);
|
|
25310
|
-
this._onContactEnter = function(
|
|
25547
|
+
this._onContactEnter = function(nativeCollision) {
|
|
25311
25548
|
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
25312
|
-
var
|
|
25313
|
-
var
|
|
25549
|
+
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
25550
|
+
var shape1 = physicalObjectsMap[shape0Id];
|
|
25551
|
+
var shape2 = physicalObjectsMap[shape1Id];
|
|
25552
|
+
var collision = PhysicsScene._collision;
|
|
25553
|
+
collision._nativeCollision = nativeCollision;
|
|
25314
25554
|
shape1.collider.entity._scripts.forEach(function(element) {
|
|
25315
|
-
var collision = PhysicsScene._collision;
|
|
25316
25555
|
collision.shape = shape2;
|
|
25317
25556
|
element.onCollisionEnter(collision);
|
|
25318
25557
|
}, function(element, index) {
|
|
25319
25558
|
element._entityScriptsIndex = index;
|
|
25320
25559
|
});
|
|
25321
25560
|
shape2.collider.entity._scripts.forEach(function(element) {
|
|
25322
|
-
var collision = PhysicsScene._collision;
|
|
25323
25561
|
collision.shape = shape1;
|
|
25324
25562
|
element.onCollisionEnter(collision);
|
|
25325
25563
|
}, function(element, index) {
|
|
25326
25564
|
element._entityScriptsIndex = index;
|
|
25327
25565
|
});
|
|
25328
25566
|
};
|
|
25329
|
-
this._onContactExit = function(
|
|
25567
|
+
this._onContactExit = function(nativeCollision) {
|
|
25330
25568
|
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
25331
|
-
var
|
|
25332
|
-
var
|
|
25569
|
+
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
25570
|
+
var shape1 = physicalObjectsMap[shape0Id];
|
|
25571
|
+
var shape2 = physicalObjectsMap[shape1Id];
|
|
25572
|
+
var collision = PhysicsScene._collision;
|
|
25573
|
+
collision._nativeCollision = nativeCollision;
|
|
25333
25574
|
shape1.collider.entity._scripts.forEach(function(element) {
|
|
25334
|
-
var collision = PhysicsScene._collision;
|
|
25335
25575
|
collision.shape = shape2;
|
|
25336
25576
|
element.onCollisionExit(collision);
|
|
25337
25577
|
}, function(element, index) {
|
|
25338
25578
|
element._entityScriptsIndex = index;
|
|
25339
25579
|
});
|
|
25340
25580
|
shape2.collider.entity._scripts.forEach(function(element) {
|
|
25341
|
-
var collision = PhysicsScene._collision;
|
|
25342
25581
|
collision.shape = shape1;
|
|
25343
25582
|
element.onCollisionExit(collision);
|
|
25344
25583
|
}, function(element, index) {
|
|
25345
25584
|
element._entityScriptsIndex = index;
|
|
25346
25585
|
});
|
|
25347
25586
|
};
|
|
25348
|
-
this._onContactStay = function(
|
|
25587
|
+
this._onContactStay = function(nativeCollision) {
|
|
25349
25588
|
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
25350
|
-
var
|
|
25351
|
-
var
|
|
25589
|
+
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
25590
|
+
var shape1 = physicalObjectsMap[shape0Id];
|
|
25591
|
+
var shape2 = physicalObjectsMap[shape1Id];
|
|
25592
|
+
var collision = PhysicsScene._collision;
|
|
25593
|
+
collision._nativeCollision = nativeCollision;
|
|
25352
25594
|
shape1.collider.entity._scripts.forEach(function(element) {
|
|
25353
|
-
var collision = PhysicsScene._collision;
|
|
25354
25595
|
collision.shape = shape2;
|
|
25355
25596
|
element.onCollisionStay(collision);
|
|
25356
25597
|
}, function(element, index) {
|
|
25357
25598
|
element._entityScriptsIndex = index;
|
|
25358
25599
|
});
|
|
25359
25600
|
shape2.collider.entity._scripts.forEach(function(element) {
|
|
25360
|
-
var collision = PhysicsScene._collision;
|
|
25361
25601
|
collision.shape = shape1;
|
|
25362
25602
|
element.onCollisionStay(collision);
|
|
25363
25603
|
}, function(element, index) {
|
|
@@ -25591,7 +25831,7 @@
|
|
|
25591
25831
|
_inherits$2(CharacterController, Collider);
|
|
25592
25832
|
function CharacterController(entity) {
|
|
25593
25833
|
var _this;
|
|
25594
|
-
_this = Collider.call(this, entity) || this, _this._stepOffset = 0.5, _this._nonWalkableMode = ControllerNonWalkableMode.PreventClimbing, _this._upDirection = new Vector3(0, 1, 0), _this._slopeLimit =
|
|
25834
|
+
_this = Collider.call(this, entity) || this, _this._stepOffset = 0.5, _this._nonWalkableMode = ControllerNonWalkableMode.PreventClimbing, _this._upDirection = new Vector3(0, 1, 0), _this._slopeLimit = 45;
|
|
25595
25835
|
_this._nativeCollider = PhysicsScene._nativePhysics.createCharacterController();
|
|
25596
25836
|
_this._setUpDirection = _this._setUpDirection.bind(_this);
|
|
25597
25837
|
//@ts-ignore
|
|
@@ -25712,8 +25952,8 @@
|
|
|
25712
25952
|
{
|
|
25713
25953
|
key: "slopeLimit",
|
|
25714
25954
|
get: /**
|
|
25715
|
-
* The slope limit for the controller, the value is the cosine value of the maximum slope angle.
|
|
25716
|
-
* @defaultValue
|
|
25955
|
+
* The slope limit in degrees for the controller, the value is the cosine value of the maximum slope angle.
|
|
25956
|
+
* @defaultValue 45 degrees
|
|
25717
25957
|
*/ function get() {
|
|
25718
25958
|
return this._slopeLimit;
|
|
25719
25959
|
},
|
|
@@ -25730,13 +25970,16 @@
|
|
|
25730
25970
|
__decorate$1([
|
|
25731
25971
|
deepClone
|
|
25732
25972
|
], CharacterController.prototype, "_upDirection", void 0);
|
|
25973
|
+
__decorate$1([
|
|
25974
|
+
ignoreClone
|
|
25975
|
+
], CharacterController.prototype, "_setUpDirection", null);
|
|
25733
25976
|
/**
|
|
25734
25977
|
* A dynamic collider can act with self-defined movement or physical force.
|
|
25735
25978
|
*/ var DynamicCollider = /*#__PURE__*/ function(Collider) {
|
|
25736
25979
|
_inherits$2(DynamicCollider, Collider);
|
|
25737
25980
|
function DynamicCollider(entity) {
|
|
25738
25981
|
var _this;
|
|
25739
|
-
_this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new Vector3(), _this._angularVelocity = new Vector3(), _this._mass = 1.0, _this._centerOfMass = new Vector3(), _this._inertiaTensor = new Vector3(1, 1, 1), _this._maxAngularVelocity =
|
|
25982
|
+
_this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new Vector3(), _this._angularVelocity = new Vector3(), _this._mass = 1.0, _this._centerOfMass = new Vector3(), _this._inertiaTensor = new Vector3(1, 1, 1), _this._maxAngularVelocity = 18000 / Math.PI, _this._maxDepenetrationVelocity = 1.0000000331813535e32, _this._solverIterations = 4, _this._useGravity = true, _this._isKinematic = false, _this._constraints = 0, _this._collisionDetectionMode = 0, _this._sleepThreshold = 5e-3, _this._automaticCenterOfMass = true, _this._automaticInertiaTensor = true;
|
|
25740
25983
|
var transform = _this.entity.transform;
|
|
25741
25984
|
_this._nativeCollider = PhysicsScene._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
|
|
25742
25985
|
_this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
|
|
@@ -25905,7 +26148,7 @@
|
|
|
25905
26148
|
{
|
|
25906
26149
|
key: "angularVelocity",
|
|
25907
26150
|
get: /**
|
|
25908
|
-
* The angular velocity vector of the dynamic collider measured in
|
|
26151
|
+
* The angular velocity vector of the dynamic collider measured in degrees per second.
|
|
25909
26152
|
*/ function get() {
|
|
25910
26153
|
//@ts-ignore
|
|
25911
26154
|
this._angularVelocity._onValueChanged = null;
|
|
@@ -26013,7 +26256,7 @@
|
|
|
26013
26256
|
{
|
|
26014
26257
|
key: "maxAngularVelocity",
|
|
26015
26258
|
get: /**
|
|
26016
|
-
* The maximum angular velocity of the collider measured in
|
|
26259
|
+
* The maximum angular velocity of the collider measured in degrees per second.
|
|
26017
26260
|
*/ function get() {
|
|
26018
26261
|
return this._maxAngularVelocity;
|
|
26019
26262
|
},
|
|
@@ -26066,6 +26309,20 @@
|
|
|
26066
26309
|
}
|
|
26067
26310
|
}
|
|
26068
26311
|
},
|
|
26312
|
+
{
|
|
26313
|
+
key: "useGravity",
|
|
26314
|
+
get: /**
|
|
26315
|
+
* Controls whether gravity affects the dynamic collider.
|
|
26316
|
+
*/ function get() {
|
|
26317
|
+
return this._useGravity;
|
|
26318
|
+
},
|
|
26319
|
+
set: function set(value) {
|
|
26320
|
+
if (this._useGravity !== value) {
|
|
26321
|
+
this._useGravity = value;
|
|
26322
|
+
this._nativeCollider.setUseGravity(value);
|
|
26323
|
+
}
|
|
26324
|
+
}
|
|
26325
|
+
},
|
|
26069
26326
|
{
|
|
26070
26327
|
key: "isKinematic",
|
|
26071
26328
|
get: /**
|
|
@@ -26187,8 +26444,8 @@
|
|
|
26187
26444
|
}
|
|
26188
26445
|
var _proto = PhysicsMaterial.prototype;
|
|
26189
26446
|
/**
|
|
26190
|
-
*
|
|
26191
|
-
*/ _proto.
|
|
26447
|
+
* Destroy the material when the material is no be used by any shape.
|
|
26448
|
+
*/ _proto.destroy = function destroy() {
|
|
26192
26449
|
!this._destroyed && this._nativeMaterial.destroy();
|
|
26193
26450
|
this._destroyed = true;
|
|
26194
26451
|
};
|
|
@@ -26303,8 +26560,9 @@
|
|
|
26303
26560
|
_this = Component.call(this, entity) || this, _this._colliderInfo = new JointColliderInfo(), _this._connectedColliderInfo = new JointColliderInfo(), _this._force = Infinity, _this._torque = Infinity, _this._automaticConnectedAnchor = true;
|
|
26304
26561
|
//@ts-ignore
|
|
26305
26562
|
_this._colliderInfo.anchor._onValueChanged = _this._updateActualAnchor.bind(_this, 1);
|
|
26563
|
+
_this._updateConnectedActualAnchor = _this._updateActualAnchor.bind(_this, 2);
|
|
26306
26564
|
//@ts-ignore
|
|
26307
|
-
_this._connectedColliderInfo.anchor._onValueChanged = _this.
|
|
26565
|
+
_this._connectedColliderInfo.anchor._onValueChanged = _this._updateConnectedActualAnchor;
|
|
26308
26566
|
_this._onSelfTransformChanged = _this._onSelfTransformChanged.bind(_this);
|
|
26309
26567
|
_this._onConnectedTransformChanged = _this._onConnectedTransformChanged.bind(_this);
|
|
26310
26568
|
// @ts-ignore
|
|
@@ -26405,7 +26663,7 @@
|
|
|
26405
26663
|
(_this__connectedColliderInfo_collider = this._connectedColliderInfo.collider) == null ? void 0 : _this__connectedColliderInfo_collider.entity._updateFlagManager.removeListener(this._onConnectedTransformChanged);
|
|
26406
26664
|
value == null ? void 0 : value.entity._updateFlagManager.addListener(this._onConnectedTransformChanged);
|
|
26407
26665
|
this._connectedColliderInfo.collider = value;
|
|
26408
|
-
(_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setConnectedCollider(value._nativeCollider);
|
|
26666
|
+
(_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setConnectedCollider(value == null ? void 0 : value._nativeCollider);
|
|
26409
26667
|
if (this._automaticConnectedAnchor) {
|
|
26410
26668
|
this._calculateConnectedAnchor();
|
|
26411
26669
|
} else {
|
|
@@ -26417,8 +26675,7 @@
|
|
|
26417
26675
|
{
|
|
26418
26676
|
key: "anchor",
|
|
26419
26677
|
get: /**
|
|
26420
|
-
* The
|
|
26421
|
-
* @remarks If connectedCollider is set, this anchor is relative offset, or the anchor is world position.
|
|
26678
|
+
* The anchor position.
|
|
26422
26679
|
*/ function get() {
|
|
26423
26680
|
return this._colliderInfo.anchor;
|
|
26424
26681
|
},
|
|
@@ -26436,11 +26693,20 @@
|
|
|
26436
26693
|
get: /**
|
|
26437
26694
|
* The connected anchor position.
|
|
26438
26695
|
* @remarks If connectedCollider is set, this anchor is relative offset, or the anchor is world position.
|
|
26696
|
+
* The connectedAnchor is automatically calculated, if you want to set it manually, please set automaticConnectedAnchor to false
|
|
26439
26697
|
*/ function get() {
|
|
26440
|
-
|
|
26698
|
+
var connectedColliderAnchor = this._connectedColliderInfo.anchor;
|
|
26699
|
+
if (this._automaticConnectedAnchor) {
|
|
26700
|
+
//@ts-ignore
|
|
26701
|
+
connectedColliderAnchor._onValueChanged = null;
|
|
26702
|
+
this._calculateConnectedAnchor();
|
|
26703
|
+
//@ts-ignore
|
|
26704
|
+
connectedColliderAnchor._onValueChanged = this._updateConnectedActualAnchor;
|
|
26705
|
+
}
|
|
26706
|
+
return connectedColliderAnchor;
|
|
26441
26707
|
},
|
|
26442
26708
|
set: function set(value) {
|
|
26443
|
-
if (this.
|
|
26709
|
+
if (this._automaticConnectedAnchor) {
|
|
26444
26710
|
console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");
|
|
26445
26711
|
return;
|
|
26446
26712
|
}
|
|
@@ -26466,7 +26732,7 @@
|
|
|
26466
26732
|
{
|
|
26467
26733
|
key: "connectedMassScale",
|
|
26468
26734
|
get: /**
|
|
26469
|
-
* The scale to apply to the
|
|
26735
|
+
* The scale to apply to the mass of collider 0 for resolving this constraint.
|
|
26470
26736
|
*/ function get() {
|
|
26471
26737
|
return this._connectedColliderInfo.massScale;
|
|
26472
26738
|
},
|
|
@@ -26481,7 +26747,7 @@
|
|
|
26481
26747
|
{
|
|
26482
26748
|
key: "massScale",
|
|
26483
26749
|
get: /**
|
|
26484
|
-
* The scale to apply to the
|
|
26750
|
+
* The scale to apply to the mass of collider 1 for resolving this constraint.
|
|
26485
26751
|
*/ function get() {
|
|
26486
26752
|
return this._colliderInfo.massScale;
|
|
26487
26753
|
},
|
|
@@ -26496,7 +26762,7 @@
|
|
|
26496
26762
|
{
|
|
26497
26763
|
key: "connectedInertiaScale",
|
|
26498
26764
|
get: /**
|
|
26499
|
-
* The scale to apply to the
|
|
26765
|
+
* The scale to apply to the inertia of collider0 for resolving this constraint.
|
|
26500
26766
|
*/ function get() {
|
|
26501
26767
|
return this._connectedColliderInfo.inertiaScale;
|
|
26502
26768
|
},
|
|
@@ -26511,7 +26777,7 @@
|
|
|
26511
26777
|
{
|
|
26512
26778
|
key: "inertiaScale",
|
|
26513
26779
|
get: /**
|
|
26514
|
-
* The scale to apply to the
|
|
26780
|
+
* The scale to apply to the inertia of collider1 for resolving this constraint.
|
|
26515
26781
|
*/ function get() {
|
|
26516
26782
|
return this._colliderInfo.inertiaScale;
|
|
26517
26783
|
},
|
|
@@ -26568,15 +26834,15 @@
|
|
|
26568
26834
|
], exports.Joint.prototype, "_nativeJoint", void 0);
|
|
26569
26835
|
__decorate$1([
|
|
26570
26836
|
ignoreClone
|
|
26571
|
-
], exports.Joint.prototype, "
|
|
26837
|
+
], exports.Joint.prototype, "_updateConnectedActualAnchor", void 0);
|
|
26572
26838
|
__decorate$1([
|
|
26573
26839
|
ignoreClone
|
|
26574
|
-
], exports.Joint.prototype, "
|
|
26840
|
+
], exports.Joint.prototype, "_onSelfTransformChanged", null);
|
|
26575
26841
|
__decorate$1([
|
|
26576
26842
|
ignoreClone
|
|
26577
|
-
], exports.Joint.prototype, "
|
|
26843
|
+
], exports.Joint.prototype, "_onConnectedTransformChanged", null);
|
|
26578
26844
|
exports.Joint = __decorate$1([
|
|
26579
|
-
dependentComponents(
|
|
26845
|
+
dependentComponents(DynamicCollider, DependentMode.AutoAdd)
|
|
26580
26846
|
], exports.Joint);
|
|
26581
26847
|
/**
|
|
26582
26848
|
* @internal
|
|
@@ -26929,15 +27195,15 @@
|
|
|
26929
27195
|
{
|
|
26930
27196
|
key: "max",
|
|
26931
27197
|
get: /**
|
|
26932
|
-
* The upper angular limit (in
|
|
27198
|
+
* The upper angular limit (in degrees) of the joint.
|
|
26933
27199
|
*/ function get() {
|
|
26934
27200
|
return this._max;
|
|
26935
27201
|
},
|
|
26936
27202
|
set: function set(value) {
|
|
26937
|
-
if (value < this._min) {
|
|
26938
|
-
throw new Error("Max limit must be greater than min limit");
|
|
26939
|
-
}
|
|
26940
27203
|
if (this._max !== value) {
|
|
27204
|
+
if (value < this._min) {
|
|
27205
|
+
this._min = value;
|
|
27206
|
+
}
|
|
26941
27207
|
this._max = value;
|
|
26942
27208
|
this._updateFlagManager.dispatch();
|
|
26943
27209
|
}
|
|
@@ -26946,15 +27212,15 @@
|
|
|
26946
27212
|
{
|
|
26947
27213
|
key: "min",
|
|
26948
27214
|
get: /**
|
|
26949
|
-
* The lower angular limit (in
|
|
27215
|
+
* The lower angular limit (in degrees) of the joint.
|
|
26950
27216
|
*/ function get() {
|
|
26951
27217
|
return this._min;
|
|
26952
27218
|
},
|
|
26953
27219
|
set: function set(value) {
|
|
26954
|
-
if (value > this._max) {
|
|
26955
|
-
throw new Error("Min limit must be less than max limit");
|
|
26956
|
-
}
|
|
26957
27220
|
if (this._min !== value) {
|
|
27221
|
+
if (value > this._max) {
|
|
27222
|
+
this._max = value;
|
|
27223
|
+
}
|
|
26958
27224
|
this._min = value;
|
|
26959
27225
|
this._updateFlagManager.dispatch();
|
|
26960
27226
|
}
|
|
@@ -27031,8 +27297,10 @@
|
|
|
27031
27297
|
return this._targetVelocity;
|
|
27032
27298
|
},
|
|
27033
27299
|
set: function set(value) {
|
|
27034
|
-
this._targetVelocity
|
|
27035
|
-
|
|
27300
|
+
if (this._targetVelocity !== value) {
|
|
27301
|
+
this._targetVelocity = value;
|
|
27302
|
+
this._updateFlagManager.dispatch();
|
|
27303
|
+
}
|
|
27036
27304
|
}
|
|
27037
27305
|
},
|
|
27038
27306
|
{
|
|
@@ -27043,8 +27311,10 @@
|
|
|
27043
27311
|
return this._forceLimit;
|
|
27044
27312
|
},
|
|
27045
27313
|
set: function set(value) {
|
|
27046
|
-
this._forceLimit
|
|
27047
|
-
|
|
27314
|
+
if (this._forceLimit !== value) {
|
|
27315
|
+
this._forceLimit = value;
|
|
27316
|
+
this._updateFlagManager.dispatch();
|
|
27317
|
+
}
|
|
27048
27318
|
}
|
|
27049
27319
|
},
|
|
27050
27320
|
{
|
|
@@ -27055,8 +27325,10 @@
|
|
|
27055
27325
|
return this._gearRatio;
|
|
27056
27326
|
},
|
|
27057
27327
|
set: function set(value) {
|
|
27058
|
-
this._gearRatio
|
|
27059
|
-
|
|
27328
|
+
if (this._gearRatio !== value) {
|
|
27329
|
+
this._gearRatio = value;
|
|
27330
|
+
this._updateFlagManager.dispatch();
|
|
27331
|
+
}
|
|
27060
27332
|
}
|
|
27061
27333
|
},
|
|
27062
27334
|
{
|
|
@@ -27067,8 +27339,10 @@
|
|
|
27067
27339
|
return this._freeSpin;
|
|
27068
27340
|
},
|
|
27069
27341
|
set: function set(value) {
|
|
27070
|
-
this._freeSpin
|
|
27071
|
-
|
|
27342
|
+
if (this._freeSpin !== value) {
|
|
27343
|
+
this._freeSpin = value;
|
|
27344
|
+
this._updateFlagManager.dispatch();
|
|
27345
|
+
}
|
|
27072
27346
|
}
|
|
27073
27347
|
}
|
|
27074
27348
|
]);
|
|
@@ -27102,6 +27376,26 @@
|
|
|
27102
27376
|
}
|
|
27103
27377
|
var _proto = ColliderShape.prototype;
|
|
27104
27378
|
/**
|
|
27379
|
+
* Get the distance and the closest point on the shape from a point.
|
|
27380
|
+
* @param point - Location in world space you want to find the closest point to
|
|
27381
|
+
* @param outClosestPoint - The closest point on the shape in world space
|
|
27382
|
+
* @returns The distance between the point and the shape
|
|
27383
|
+
*/ _proto.getClosestPoint = function getClosestPoint(point, outClosestPoint) {
|
|
27384
|
+
var collider = this._collider;
|
|
27385
|
+
if (collider.enabled === false || collider.entity._isActiveInHierarchy === false) {
|
|
27386
|
+
console.warn("The collider is not active in scene.");
|
|
27387
|
+
return -1;
|
|
27388
|
+
}
|
|
27389
|
+
var res = this._nativeShape.pointDistance(point);
|
|
27390
|
+
var distance = res.w;
|
|
27391
|
+
if (distance > 0) {
|
|
27392
|
+
outClosestPoint.set(res.x, res.y, res.z);
|
|
27393
|
+
} else {
|
|
27394
|
+
outClosestPoint.copyFrom(point);
|
|
27395
|
+
}
|
|
27396
|
+
return Math.sqrt(distance);
|
|
27397
|
+
};
|
|
27398
|
+
/**
|
|
27105
27399
|
* @internal
|
|
27106
27400
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
27107
27401
|
target._syncNative();
|
|
@@ -27167,11 +27461,14 @@
|
|
|
27167
27461
|
{
|
|
27168
27462
|
key: "material",
|
|
27169
27463
|
get: /**
|
|
27170
|
-
* Physical material.
|
|
27464
|
+
* Physical material, material can't be null.
|
|
27171
27465
|
*/ function get() {
|
|
27172
27466
|
return this._material;
|
|
27173
27467
|
},
|
|
27174
27468
|
set: function set(value) {
|
|
27469
|
+
if (!value) {
|
|
27470
|
+
throw new Error("The physics material of the shape can't be null.");
|
|
27471
|
+
}
|
|
27175
27472
|
if (this._material !== value) {
|
|
27176
27473
|
this._material = value;
|
|
27177
27474
|
this._nativeShape.setMaterial(value._nativeMaterial);
|
|
@@ -27181,7 +27478,7 @@
|
|
|
27181
27478
|
{
|
|
27182
27479
|
key: "rotation",
|
|
27183
27480
|
get: /**
|
|
27184
|
-
* The local rotation of this ColliderShape.
|
|
27481
|
+
* The local rotation of this ColliderShape, in degrees.
|
|
27185
27482
|
*/ function get() {
|
|
27186
27483
|
return this._rotation;
|
|
27187
27484
|
},
|
|
@@ -27329,6 +27626,11 @@
|
|
|
27329
27626
|
_this._nativeShape = PhysicsScene._nativePhysics.createPlaneColliderShape(_this._id, _this._material._nativeMaterial);
|
|
27330
27627
|
return _this;
|
|
27331
27628
|
}
|
|
27629
|
+
var _proto = PlaneColliderShape.prototype;
|
|
27630
|
+
_proto.getClosestPoint = function getClosestPoint(point, closestPoint) {
|
|
27631
|
+
console.error("PlaneColliderShape is not support getClosestPoint");
|
|
27632
|
+
return -1;
|
|
27633
|
+
};
|
|
27332
27634
|
return PlaneColliderShape;
|
|
27333
27635
|
}(ColliderShape);
|
|
27334
27636
|
/**
|
|
@@ -27951,33 +28253,529 @@
|
|
|
27951
28253
|
ParticleBufferUtils.boundsFloatStride = 8;
|
|
27952
28254
|
ParticleBufferUtils.boundsTimeOffset = 6;
|
|
27953
28255
|
ParticleBufferUtils.boundsMaxLifetimeOffset = 7;
|
|
27954
|
-
var
|
|
27955
|
-
|
|
27956
|
-
|
|
27957
|
-
|
|
27958
|
-
|
|
27959
|
-
|
|
27960
|
-
|
|
27961
|
-
|
|
27962
|
-
|
|
27963
|
-
|
|
27964
|
-
|
|
27965
|
-
|
|
27966
|
-
|
|
27967
|
-
|
|
27968
|
-
|
|
27969
|
-
|
|
27970
|
-
|
|
27971
|
-
|
|
27972
|
-
|
|
27973
|
-
|
|
27974
|
-
|
|
27975
|
-
|
|
27976
|
-
|
|
27977
|
-
|
|
27978
|
-
|
|
27979
|
-
|
|
27980
|
-
|
|
28256
|
+
var blitVs = "#define GLSLIFY 1\nattribute vec4 POSITION_UV;\nvarying vec2 v_uv;\n\nvoid main() {\t\n\tgl_Position = vec4(POSITION_UV.xy, 0.0, 1.0);\t\n\tv_uv = POSITION_UV.zw;\n}"; // eslint-disable-line
|
|
28257
|
+
/**
|
|
28258
|
+
* Represents a parameter of a post process effect.
|
|
28259
|
+
* @remarks
|
|
28260
|
+
* The parameter will be mixed to a final value and be used in post process manager.
|
|
28261
|
+
*/ var PostProcessEffectParameter = /*#__PURE__*/ function() {
|
|
28262
|
+
function PostProcessEffectParameter(value, needLerpOrMin, max, needLerp) {
|
|
28263
|
+
/**
|
|
28264
|
+
* Whether the parameter is enabled.
|
|
28265
|
+
*/ this.enabled = true;
|
|
28266
|
+
this._needLerp = false;
|
|
28267
|
+
if (typeof value === "number") {
|
|
28268
|
+
if (typeof needLerpOrMin === "boolean") {
|
|
28269
|
+
this._needLerp = needLerpOrMin;
|
|
28270
|
+
this._min = Number.NEGATIVE_INFINITY;
|
|
28271
|
+
this._max = Number.POSITIVE_INFINITY;
|
|
28272
|
+
} else if (typeof needLerpOrMin === "number") {
|
|
28273
|
+
this._min = needLerpOrMin;
|
|
28274
|
+
this._max = max != null ? max : Number.POSITIVE_INFINITY;
|
|
28275
|
+
this._needLerp = needLerp != null ? needLerp : false;
|
|
28276
|
+
} else if (needLerpOrMin == undefined) {
|
|
28277
|
+
this._min = Number.NEGATIVE_INFINITY;
|
|
28278
|
+
this._max = Number.POSITIVE_INFINITY;
|
|
28279
|
+
}
|
|
28280
|
+
} else {
|
|
28281
|
+
this._needLerp = needLerpOrMin != null ? needLerpOrMin : false;
|
|
28282
|
+
}
|
|
28283
|
+
this.value = value;
|
|
28284
|
+
}
|
|
28285
|
+
var _proto = PostProcessEffectParameter.prototype;
|
|
28286
|
+
/**
|
|
28287
|
+
* @internal
|
|
28288
|
+
*/ _proto._lerp = function _lerp(to, factor) {
|
|
28289
|
+
if (this._needLerp) {
|
|
28290
|
+
var _this_value;
|
|
28291
|
+
switch((_this_value = this.value) == null ? void 0 : _this_value.constructor){
|
|
28292
|
+
case Number:
|
|
28293
|
+
this.value = MathUtil.lerp(this.value, to, factor);
|
|
28294
|
+
break;
|
|
28295
|
+
case Color:
|
|
28296
|
+
Color.lerp(this.value, to, factor, this.value);
|
|
28297
|
+
break;
|
|
28298
|
+
case Vector2:
|
|
28299
|
+
Vector2.lerp(this.value, to, factor, this.value);
|
|
28300
|
+
break;
|
|
28301
|
+
case Vector3:
|
|
28302
|
+
Vector3.lerp(this.value, to, factor, this.value);
|
|
28303
|
+
break;
|
|
28304
|
+
case Vector4:
|
|
28305
|
+
Vector4.lerp(this.value, to, factor, this.value);
|
|
28306
|
+
break;
|
|
28307
|
+
default:
|
|
28308
|
+
if (factor > 0) {
|
|
28309
|
+
this.value = to;
|
|
28310
|
+
}
|
|
28311
|
+
}
|
|
28312
|
+
} else if (factor > 0) {
|
|
28313
|
+
this.value = to;
|
|
28314
|
+
}
|
|
28315
|
+
};
|
|
28316
|
+
_create_class$2(PostProcessEffectParameter, [
|
|
28317
|
+
{
|
|
28318
|
+
key: "value",
|
|
28319
|
+
get: /**
|
|
28320
|
+
* The value of the parameter.
|
|
28321
|
+
*/ function get() {
|
|
28322
|
+
return this._value;
|
|
28323
|
+
},
|
|
28324
|
+
set: function set(value) {
|
|
28325
|
+
if ((value == null ? void 0 : value.constructor) === Number) {
|
|
28326
|
+
this._value = MathUtil.clamp(value, this._min, this._max);
|
|
28327
|
+
} else {
|
|
28328
|
+
this._value = value;
|
|
28329
|
+
}
|
|
28330
|
+
}
|
|
28331
|
+
}
|
|
28332
|
+
]);
|
|
28333
|
+
return PostProcessEffectParameter;
|
|
28334
|
+
}();
|
|
28335
|
+
/**
|
|
28336
|
+
* The base class for post process effect.
|
|
28337
|
+
*/ var PostProcessEffect = /*#__PURE__*/ function() {
|
|
28338
|
+
function PostProcessEffect() {
|
|
28339
|
+
this._enabled = true;
|
|
28340
|
+
this._parameters = [];
|
|
28341
|
+
this._parameterInitialized = false;
|
|
28342
|
+
}
|
|
28343
|
+
var _proto = PostProcessEffect.prototype;
|
|
28344
|
+
/**
|
|
28345
|
+
* Whether the post process effect is valid.
|
|
28346
|
+
* @remarks
|
|
28347
|
+
* This method can be overridden to control the effect's real validity.
|
|
28348
|
+
*/ _proto.isValid = function isValid() {
|
|
28349
|
+
return this._enabled;
|
|
28350
|
+
};
|
|
28351
|
+
/**
|
|
28352
|
+
* @internal
|
|
28353
|
+
*/ _proto._lerp = function _lerp(to, factor) {
|
|
28354
|
+
var parameters = this._getParameters();
|
|
28355
|
+
var toParameters = to._getParameters();
|
|
28356
|
+
for(var i = 0, n = parameters.length; i < n; i++){
|
|
28357
|
+
var toParameter = toParameters[i];
|
|
28358
|
+
if (toParameter.enabled) {
|
|
28359
|
+
parameters[i]._lerp(toParameter.value, factor);
|
|
28360
|
+
}
|
|
28361
|
+
}
|
|
28362
|
+
};
|
|
28363
|
+
/**
|
|
28364
|
+
* Get all parameters of the post process effect.
|
|
28365
|
+
* @remarks
|
|
28366
|
+
* Only get the parameters that are initialized in the constructor.
|
|
28367
|
+
* It will don't take effect if you add a new parameter after the post process effect is created, such as `effect.** = new PostProcessEffectParameter(1)`
|
|
28368
|
+
*/ _proto._getParameters = function _getParameters() {
|
|
28369
|
+
if (!this._parameterInitialized) {
|
|
28370
|
+
this._parameterInitialized = true;
|
|
28371
|
+
for(var key in this){
|
|
28372
|
+
var value = this[key];
|
|
28373
|
+
if (_instanceof1$2(value, PostProcessEffectParameter)) {
|
|
28374
|
+
this._parameters.push(value);
|
|
28375
|
+
}
|
|
28376
|
+
}
|
|
28377
|
+
}
|
|
28378
|
+
return this._parameters;
|
|
28379
|
+
};
|
|
28380
|
+
_create_class$2(PostProcessEffect, [
|
|
28381
|
+
{
|
|
28382
|
+
key: "enabled",
|
|
28383
|
+
get: /**
|
|
28384
|
+
* Indicates whether the post process effect is enabled.
|
|
28385
|
+
*/ function get() {
|
|
28386
|
+
return this._enabled;
|
|
28387
|
+
},
|
|
28388
|
+
set: function set(value) {
|
|
28389
|
+
if (value === this._enabled) {
|
|
28390
|
+
return;
|
|
28391
|
+
}
|
|
28392
|
+
this._enabled = value;
|
|
28393
|
+
}
|
|
28394
|
+
}
|
|
28395
|
+
]);
|
|
28396
|
+
return PostProcessEffect;
|
|
28397
|
+
}();
|
|
28398
|
+
var fragBlurH = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n\tvec2 texelSize = renderer_texelSize.xy * 2.0;\n\n // 9-tap gaussian blur on the downsampled source\n mediump vec4 c0 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 4.0, 0.0));\n mediump vec4 c1 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 3.0, 0.0));\n mediump vec4 c2 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 2.0, 0.0));\n mediump vec4 c3 = sampleTexture(renderer_BlitTexture, v_uv - vec2(texelSize.x * 1.0, 0.0));\n mediump vec4 c4 = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 c5 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 1.0, 0.0));\n mediump vec4 c6 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 2.0, 0.0));\n mediump vec4 c7 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 3.0, 0.0));\n mediump vec4 c8 = sampleTexture(renderer_BlitTexture, v_uv + vec2(texelSize.x * 4.0, 0.0));\n\n gl_FragColor = c0 * 0.01621622 + c1 * 0.05405405 + c2 * 0.12162162 + c3 * 0.19459459\n + c4 * 0.22702703\n + c5 * 0.19459459 + c6 * 0.12162162 + c7 * 0.05405405 + c8 * 0.01621622;\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
28399
|
+
var fragBlurV = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n vec2 texelSize = renderer_texelSize.xy;\n\n // Optimized bilinear 5-tap gaussian on the same-sized source (9-tap equivalent)\n mediump vec4 c0 = sampleTexture(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 3.23076923));\n mediump vec4 c1 = sampleTexture(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c2 = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 c3 = sampleTexture(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c4 = sampleTexture(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 3.23076923));\n\n gl_FragColor = c0 * 0.07027027 + c1 * 0.31621622\n + c2 * 0.22702703\n + c3 * 0.31621622 + c4 * 0.07027027;\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
28400
|
+
var fragPrefilter = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n\t#ifdef BLOOM_HQ\n vec2 texelSize = renderer_texelSize.xy;\n mediump vec4 A = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, -1.0));\n mediump vec4 C = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, -1.0));\n mediump vec4 D = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, -0.5));\n mediump vec4 F = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 H = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 0.0));\n mediump vec4 I = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, 0.5));\n mediump vec4 K = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, 1.0));\n mediump vec4 M = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 1.0));\n\n mediump vec2 scale = vec2(0.5, 0.125);\n mediump vec2 div = (1.0 / 4.0) * scale;\n\n mediump vec4 samplerColor = (D + E + I + J) * div.x;\n samplerColor += (A + B + G + F) * div.y;\n samplerColor += (B + C + H + G) * div.y;\n samplerColor += (F + G + L + K) * div.y;\n samplerColor += (G + H + M + L) * div.y;\n #else\n mediump vec4 samplerColor = sampleTexture(renderer_BlitTexture, v_uv);\n #endif\n\n mediump vec3 color = samplerColor.rgb;\n\n // User controlled clamp to limit crazy high broken spec\n color = min(color, HALF_MAX);\n\n // Thresholding\n mediump float brightness = max3(color);\n float threshold = material_BloomParams.x;\n float thresholdKnee = material_BloomParams.y;\n mediump float softness = clamp(brightness - threshold + thresholdKnee, 0.0, 2.0 * thresholdKnee);\n softness = (softness * softness) / (4.0 * thresholdKnee + 1e-4);\n mediump float multiplier = max(brightness - threshold, softness) / max(brightness, 1e-4);\n color *= multiplier;\n\n // Clamp colors to positive once in prefilter. Encode can have a sqrt, and sqrt(-x) == NaN. Up/Downsample passes would then spread the NaN.\n color = max(color, 0.0);\n\n gl_FragColor = vec4(color, samplerColor.a);\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
28401
|
+
var fragUpsample = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform sampler2D material_lowMipTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 material_lowMipTexelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n mediump vec4 highMip = sampleTexture(renderer_BlitTexture, v_uv);\n\n #ifdef BLOOM_HQ\n mediump vec4 lowMip = sampleTexture2DBicubic(material_lowMipTexture, v_uv, material_lowMipTexelSize);\n #else\n mediump vec4 lowMip = sampleTexture(material_lowMipTexture, v_uv);\n #endif\n \n gl_FragColor = mix(highMip, lowMip, material_BloomParams.z);\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
28402
|
+
/**
|
|
28403
|
+
* This controls the size of the bloom texture.
|
|
28404
|
+
*/ var BloomDownScaleMode = /*#__PURE__*/ function(BloomDownScaleMode) {
|
|
28405
|
+
/** Use this to select half size as the starting resolution. */ BloomDownScaleMode[BloomDownScaleMode["Half"] = 0] = "Half";
|
|
28406
|
+
/** Use this to select quarter size as the starting resolution. */ BloomDownScaleMode[BloomDownScaleMode["Quarter"] = 1] = "Quarter";
|
|
28407
|
+
return BloomDownScaleMode;
|
|
28408
|
+
}({});
|
|
28409
|
+
var BloomEffect = /*#__PURE__*/ function(PostProcessEffect) {
|
|
28410
|
+
_inherits$2(BloomEffect, PostProcessEffect);
|
|
28411
|
+
function BloomEffect() {
|
|
28412
|
+
var _this;
|
|
28413
|
+
_this = PostProcessEffect.apply(this, arguments) || this, /**
|
|
28414
|
+
* Controls whether to use bicubic sampling instead of bilinear sampling for the upSampling passes.
|
|
28415
|
+
* @remarks This is slightly more expensive but helps getting smoother visuals.
|
|
28416
|
+
*/ _this.highQualityFiltering = new PostProcessEffectParameter(false), /**
|
|
28417
|
+
* Controls the starting resolution that this effect begins processing.
|
|
28418
|
+
*/ _this.downScale = new PostProcessEffectParameter(0), /**
|
|
28419
|
+
* Specifies a Texture to add smudges or dust to the bloom effect.
|
|
28420
|
+
*/ _this.dirtTexture = new PostProcessEffectParameter(null), /**
|
|
28421
|
+
* Set the level of brightness to filter out pixels under this level.
|
|
28422
|
+
* @remarks This value is expressed in gamma-space.
|
|
28423
|
+
*/ _this.threshold = new PostProcessEffectParameter(0.9, 0, Number.POSITIVE_INFINITY, true), /**
|
|
28424
|
+
* Controls the radius of the bloom effect.
|
|
28425
|
+
*/ _this.scatter = new PostProcessEffectParameter(0.7, 0, 1, true), /**
|
|
28426
|
+
* Controls the strength of the bloom effect.
|
|
28427
|
+
*/ _this.intensity = new PostProcessEffectParameter(0, 0, Number.POSITIVE_INFINITY, true), /**
|
|
28428
|
+
* Controls the strength of the lens dirt.
|
|
28429
|
+
*/ _this.dirtIntensity = new PostProcessEffectParameter(0, 0, Number.POSITIVE_INFINITY, true), /**
|
|
28430
|
+
* Specifies the tint of the bloom effect.
|
|
28431
|
+
*/ _this.tint = new PostProcessEffectParameter(new Color(1, 1, 1, 1), true);
|
|
28432
|
+
return _this;
|
|
28433
|
+
}
|
|
28434
|
+
var _proto = BloomEffect.prototype;
|
|
28435
|
+
/** @inheritdoc */ _proto.isValid = function isValid() {
|
|
28436
|
+
return this.enabled && this.intensity.value > 0;
|
|
28437
|
+
};
|
|
28438
|
+
return BloomEffect;
|
|
28439
|
+
}(PostProcessEffect);
|
|
28440
|
+
BloomEffect.SHADER_NAME = "PostProcessEffect Bloom";
|
|
28441
|
+
// Bloom shader properties
|
|
28442
|
+
/** @internal */ BloomEffect._maxIterations = 6;
|
|
28443
|
+
/** @internal */ BloomEffect._hqMacro = ShaderMacro.getByName("BLOOM_HQ");
|
|
28444
|
+
/** @internal */ BloomEffect._dirtMacro = ShaderMacro.getByName("BLOOM_DIRT");
|
|
28445
|
+
/** @internal */ BloomEffect._bloomParams = ShaderProperty.getByName("material_BloomParams") // x: threshold (linear), y: threshold knee, z: scatter
|
|
28446
|
+
;
|
|
28447
|
+
/** @internal */ BloomEffect._lowMipTextureProp = ShaderProperty.getByName("material_lowMipTexture");
|
|
28448
|
+
/** @internal */ BloomEffect._lowMipTexelSizeProp = ShaderProperty.getByName("material_lowMipTexelSize") // x: 1/width, y: 1/height, z: width, w: height
|
|
28449
|
+
;
|
|
28450
|
+
// Uber shader properties
|
|
28451
|
+
/** @internal */ BloomEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_BLOOM");
|
|
28452
|
+
/** @internal */ BloomEffect._bloomTextureProp = ShaderProperty.getByName("material_BloomTexture");
|
|
28453
|
+
/** @internal */ BloomEffect._dirtTextureProp = ShaderProperty.getByName("material_BloomDirtTexture");
|
|
28454
|
+
/** @internal */ BloomEffect._tintProp = ShaderProperty.getByName("material_BloomTint");
|
|
28455
|
+
/** @internal */ BloomEffect._bloomIntensityParams = ShaderProperty.getByName("material_BloomIntensityParams") // x: bloom intensity, y: dirt intensity
|
|
28456
|
+
;
|
|
28457
|
+
/** @internal */ BloomEffect._dirtTilingOffsetProp = ShaderProperty.getByName("material_BloomDirtTilingOffset");
|
|
28458
|
+
Shader.create(BloomEffect.SHADER_NAME, [
|
|
28459
|
+
new ShaderPass("Bloom Prefilter", blitVs, fragPrefilter),
|
|
28460
|
+
new ShaderPass("Bloom Blur Horizontal", blitVs, fragBlurH),
|
|
28461
|
+
new ShaderPass("Bloom Blur Vertical", blitVs, fragBlurV),
|
|
28462
|
+
new ShaderPass("Bloom Upsample", blitVs, fragUpsample)
|
|
28463
|
+
]);
|
|
28464
|
+
/**
|
|
28465
|
+
* Options to select a tonemapping algorithm to use.
|
|
28466
|
+
*/ var TonemappingMode = /*#__PURE__*/ function(TonemappingMode) {
|
|
28467
|
+
/**
|
|
28468
|
+
* Neutral tonemapper.
|
|
28469
|
+
* @remarks Use this option if you only want range-remapping with minimal impact on color hue and saturation.
|
|
28470
|
+
*/ TonemappingMode[TonemappingMode["Neutral"] = 0] = "Neutral";
|
|
28471
|
+
/**
|
|
28472
|
+
* ACES Filmic reference tonemapper (custom approximation).
|
|
28473
|
+
* @remarks
|
|
28474
|
+
* Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
|
|
28475
|
+
* It is more contrasted than Neutral and has an effect on actual color hue and saturation.
|
|
28476
|
+
*/ TonemappingMode[TonemappingMode["ACES"] = 1] = "ACES";
|
|
28477
|
+
return TonemappingMode;
|
|
28478
|
+
}({});
|
|
28479
|
+
var TonemappingEffect = /*#__PURE__*/ function(PostProcessEffect) {
|
|
28480
|
+
_inherits$2(TonemappingEffect, PostProcessEffect);
|
|
28481
|
+
function TonemappingEffect() {
|
|
28482
|
+
var _this;
|
|
28483
|
+
_this = PostProcessEffect.apply(this, arguments) || this, /**
|
|
28484
|
+
* Use this to select a tonemapping algorithm to use.
|
|
28485
|
+
*/ _this.mode = new PostProcessEffectParameter(0, false);
|
|
28486
|
+
return _this;
|
|
28487
|
+
}
|
|
28488
|
+
return TonemappingEffect;
|
|
28489
|
+
}(PostProcessEffect);
|
|
28490
|
+
/** @internal */ TonemappingEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_TONEMAPPING");
|
|
28491
|
+
/**
|
|
28492
|
+
* Controls when the post process pass executes.
|
|
28493
|
+
*/ var PostProcessPassEvent = /*#__PURE__*/ function(PostProcessPassEvent) {
|
|
28494
|
+
/** Before the uber pass. */ PostProcessPassEvent[PostProcessPassEvent["BeforeUber"] = 0] = "BeforeUber";
|
|
28495
|
+
/** After the uber pass. */ PostProcessPassEvent[PostProcessPassEvent["AfterUber"] = 100] = "AfterUber";
|
|
28496
|
+
return PostProcessPassEvent;
|
|
28497
|
+
}({});
|
|
28498
|
+
/**
|
|
28499
|
+
* Post process pass.
|
|
28500
|
+
*/ var PostProcessPass = /*#__PURE__*/ function(EngineObject) {
|
|
28501
|
+
_inherits$2(PostProcessPass, EngineObject);
|
|
28502
|
+
function PostProcessPass() {
|
|
28503
|
+
var _this;
|
|
28504
|
+
_this = EngineObject.apply(this, arguments) || this, _this._event = 100, _this._isActive = true;
|
|
28505
|
+
return _this;
|
|
28506
|
+
}
|
|
28507
|
+
var _proto = PostProcessPass.prototype;
|
|
28508
|
+
/**
|
|
28509
|
+
* Whether the post process pass is valid in current post process manager.
|
|
28510
|
+
* @remarks
|
|
28511
|
+
* This method can be overridden to control the pass's real validity.
|
|
28512
|
+
* @param postProcessManager - The post process manager
|
|
28513
|
+
*/ _proto.isValid = function isValid(postProcessManager) {
|
|
28514
|
+
return this._isActive;
|
|
28515
|
+
};
|
|
28516
|
+
/**
|
|
28517
|
+
* @inheritdoc
|
|
28518
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
28519
|
+
EngineObject.prototype._onDestroy.call(this);
|
|
28520
|
+
this.engine._removePostProcessPass(this);
|
|
28521
|
+
};
|
|
28522
|
+
_create_class$2(PostProcessPass, [
|
|
28523
|
+
{
|
|
28524
|
+
key: "event",
|
|
28525
|
+
get: /**
|
|
28526
|
+
* When the post process pass is rendered.
|
|
28527
|
+
* @remarks
|
|
28528
|
+
* Users can also inject pass events in a specific point by doing PostProcessPassEvent + offset.
|
|
28529
|
+
*/ function get() {
|
|
28530
|
+
return this._event;
|
|
28531
|
+
},
|
|
28532
|
+
set: function set(value) {
|
|
28533
|
+
if (value !== this._event) {
|
|
28534
|
+
this._event = value;
|
|
28535
|
+
if (this._isActive) {
|
|
28536
|
+
this.engine._postProcessPassNeedRefresh = true;
|
|
28537
|
+
}
|
|
28538
|
+
}
|
|
28539
|
+
}
|
|
28540
|
+
},
|
|
28541
|
+
{
|
|
28542
|
+
key: "isActive",
|
|
28543
|
+
get: /**
|
|
28544
|
+
* Whether the post process pass is active.
|
|
28545
|
+
*/ function get() {
|
|
28546
|
+
return this._isActive;
|
|
28547
|
+
},
|
|
28548
|
+
set: function set(value) {
|
|
28549
|
+
if (value !== this._isActive) {
|
|
28550
|
+
this._isActive = value;
|
|
28551
|
+
this.engine._postProcessPassNeedRefresh = true;
|
|
28552
|
+
}
|
|
28553
|
+
}
|
|
28554
|
+
}
|
|
28555
|
+
]);
|
|
28556
|
+
return PostProcessPass;
|
|
28557
|
+
}(EngineObject);
|
|
28558
|
+
var Filtering = "#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\n\nvec2 bSpline3MiddleLeft(vec2 x){\n return 0.16666667 + x * (0.5 + x * (0.5 - x * 0.5));\n}\n\nvec2 bSpline3MiddleRight(vec2 x){\n return 0.66666667 + x * (-1.0 + 0.5 * x) * x;\n}\n\nvec2 bSpline3Rightmost(vec2 x){\n return 0.16666667 + x * (-0.5 + x * (0.5 - x * 0.16666667));\n}\n\n// Compute weights & offsets for 4x bilinear taps for the bicubic B-Spline filter.\n// The fractional coordinate should be in the [0, 1] range (centered on 0.5).\n// Inspired by: http://vec3.ca/bicubic-filtering-in-fewer-taps/\nvoid bicubicFilter(vec2 fracCoord, out vec2 weights[2], out vec2 offsets[2]){\n vec2 r = bSpline3Rightmost(fracCoord);\n vec2 mr = bSpline3MiddleRight(fracCoord);\n vec2 ml = bSpline3MiddleLeft(fracCoord);\n vec2 l = 1.0 - mr - ml - r;\n\n weights[0] = r + mr;\n weights[1] = ml + l;\n offsets[0] = -1.0 + mr / weights[0];\n offsets[1] = 1.0 + l / weights[1];\n}\n\n// texSize: (1/width, 1/height, width, height)\nvec4 sampleTexture2DBicubic(sampler2D tex, vec2 coord, vec4 texSize){\n\tvec2 xy = coord * texSize.zw + 0.5;\n vec2 ic = floor(xy);\n vec2 fc = fract(xy);\n\n vec2 weights[2], offsets[2];\n bicubicFilter(fc, weights, offsets);\n\n return weights[0].y * (weights[0].x * sampleTexture(tex, (ic + vec2(offsets[0].x, offsets[0].y) - 0.5) * texSize.xy) +\n \tweights[1].x * sampleTexture(tex, (ic + vec2(offsets[1].x, offsets[0].y) - 0.5) * texSize.xy)) +\n weights[1].y * (weights[0].x * sampleTexture(tex, (ic + vec2(offsets[0].x, offsets[1].y) - 0.5) * texSize.xy) +\n weights[1].x * sampleTexture(tex, (ic + vec2(offsets[1].x, offsets[1].y) - 0.5) * texSize.xy));\n}\n\n#endif"; // eslint-disable-line
|
|
28559
|
+
var PostCommon = "#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n\n#include <common>\n#define FLT_MIN 1.175494351e-38 // Minimum normalized positive floating-point number\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_MAX 65504.0 // (2 - 2^-10) * 2^15\n\nfloat min3(vec3 val) { return min(min(val.x, val.y), val.z); }\nfloat max3(vec3 val) { return max(max(val.x, val.y), val.z); }\n\nconst float INVERT_LOG10 = 0.43429448190325176;\n\nfloat log10(float x){\n return log(x) * INVERT_LOG10;\n}\n\nvec4 sampleTexture(sampler2D tex, vec2 uv){\n vec4 color = texture2D(tex, uv);\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n color = gammaToLinear(color);\n #endif \n\n return color;\n}\n\n#endif"; // eslint-disable-line
|
|
28560
|
+
var ACESTonemapping = "#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\n\nvec3 ACESTonemap(vec3 color){\n vec3 aces = sRGB_2_AP0 * color;\n \n // --- Glow module --- //\n mediump float saturation = rgb_2_saturation(aces);\n mediump float ycIn = rgb_2_yc(aces);\n mediump float s = sigmoid_shaper((saturation - 0.4) / 0.2);\n float addedGlow = 1.0 + glow_fwd(ycIn, RRT_GLOW_GAIN * s, RRT_GLOW_MID);\n aces *= addedGlow;\n\n // --- Red modifier --- //\n mediump float hue = rgb_2_hue(vec3(aces));\n mediump float centeredHue = center_hue(hue, RRT_RED_HUE);\n float hueWeight = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * centeredHue / RRT_RED_WIDTH));\n hueWeight *= hueWeight;\n\n aces.r += hueWeight * saturation * (RRT_RED_PIVOT - aces.r) * (1.0 - RRT_RED_SCALE);\n\n // --- ACES to RGB rendering space --- //\n vec3 acescg = max(AP0_2_AP1_MAT * aces, 0.0);\n\n // --- Global desaturation --- //\n acescg = mix(vec3(dot(acescg, AP1_RGB2Y)), acescg, RRT_SAT_FACTOR);\n\n // Apply RRT and ODT\n // https://github.com/TheRealMJP/BakingLab/blob/master/BakingLab/ACES.hlsl\n const float a = 0.0245786;\n const float b = 0.000090537;\n const float c = 0.983729;\n const float d = 0.4329510;\n const float e = 0.238081;\n\n // To reduce the likelyhood of extremely large values, we avoid using the x^2 term and therefore\n // divide numerator and denominator by it. This will lead to the constant factors of the\n // quadratic in the numerator and denominator to be divided by x; we add a tiny epsilon to avoid divide by 0.\n vec3 rcpAcesCG = 1.0 / (acescg + FLT_MIN);\n mediump vec3 rgbPost = (acescg + a - b * rcpAcesCG) /\n (acescg * c + d + e * rcpAcesCG);\n\n // Apply gamma adjustment to compensate for dim surround\n vec3 linearCV = darkSurround_to_dimSurround(rgbPost);\n\n // Apply desaturation to compensate for luminance difference\n linearCV = mix(vec3(dot(linearCV, AP1_RGB2Y)), linearCV, ODT_SAT_FACTOR);\n\n // Convert to display primary encoding\n // Rendering space RGB to XYZ\n vec3 XYZ = AP1_2_XYZ_MAT * linearCV;\n\n // Apply CAT from ACES white point to assumed observer adapted white point\n XYZ = D60_2_D65_CAT * XYZ;\n\n // CIE XYZ to display primaries\n linearCV = XYZ_2_REC709_MAT * XYZ;\n\n return linearCV;\n\n}"; // eslint-disable-line
|
|
28561
|
+
var ColorTransform = "#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\n\n// Precomputed matrices (pre-transposed)\n// See https://github.com/ampas/aces-dev/blob/master/transforms/ctl/README-MATRIX.md\n \n const mediump mat3 sRGB_2_AP0 = mat3(\n 0.4397010, 0.0897923, 0.0175440,\n 0.3829780, 0.8134230, 0.1115440,\n 0.1773350, 0.0967616, 0.8707040\n );\n\n const mediump mat3 AP1_2_AP0_MAT = mat3(\n vec3(0.6954522414, 0.0447945634, -0.0055258826),\n vec3(0.1406786965, 0.8596711185, 0.0040252103),\n vec3(0.1638690622, 0.0955343182, 1.0015006723)\n );\n\n const mediump mat3 AP0_2_AP1_MAT = mat3(\n\tvec3(1.4514393161, -0.0765537734, 0.0083161484),\n vec3(-0.2365107469, 1.1762296998, -0.0060324498),\n vec3(-0.2149285693, -0.0996759264, 0.9977163014)\n );\n\n const mediump mat3 AP1_2_XYZ_MAT = mat3(\n vec3(0.6624541811, 0.2722287168, -0.0055746495),\n vec3(0.1340042065, 0.6740817658, 0.0040607335),\n vec3(0.1561876870, 0.0536895174, 1.0103391003)\n );\n\n const mediump mat3 XYZ_2_AP1_MAT = mat3(\n vec3(1.6410233797, -0.6636628587, 0.0117218943),\n vec3(-0.3248032942, 1.6153315917, -0.0082844420),\n vec3(-0.2364246952, 0.0167563477, 0.9883948585)\n );\n\n const mediump mat3 D60_2_D65_CAT = mat3(\n vec3(0.987224, -0.00759836, 0.00307257),\n vec3(-0.00611327, 1.00186, -0.00509595),\n vec3(0.0159533, 0.00533002, 1.08168)\n );\n\n const mediump mat3 XYZ_2_REC709_MAT = mat3(\n vec3(3.2409699419, -0.9692436363, 0.0556300797),\n vec3(-1.5373831776, 1.8759675015, -0.2039769589),\n vec3(-0.498610760, 0.0415550574, 1.0569715142)\n );\n\n const mediump vec3 AP1_RGB2Y = vec3(0.2722287168, 0.6740817658, 0.0536895174);\n\n mediump float rgb_2_saturation(mediump vec3 rgb){\n const mediump float TINY = 1e-4;\n mediump float mi = min3(rgb);\n mediump float ma = max3(rgb);\n return (max(ma, TINY) - max(mi, TINY)) / max(ma, 1e-2);\n }\n\n mediump float rgb_2_yc(mediump vec3 rgb){\n const mediump float ycRadiusWeight = 1.75;\n\n // Converts RGB to a luminance proxy, here called YC\n // YC is ~ Y + K * Chroma\n // Constant YC is a cone-shaped surface in RGB space, with the tip on the\n // neutral axis, towards white.\n // YC is normalized: RGB 1 1 1 maps to YC = 1\n //\n // ycRadiusWeight defaults to 1.75, although can be overridden in function\n // call to rgb_2_yc\n // ycRadiusWeight = 1 -> YC for pure cyan, magenta, yellow == YC for neutral\n // of same value\n // ycRadiusWeight = 2 -> YC for pure red, green, blue == YC for neutral of\n // same value.\n\n mediump float r = rgb.x;\n mediump float g = rgb.y;\n mediump float b = rgb.z;\n mediump float k = b * (b - g) + g * (g - r) + r * (r - b);\n k = max(k, 0.0); // Clamp to avoid precision issue causing k < 0, making sqrt(k) undefined\n float chroma = k == 0.0 ? 0.0 : sqrt(k); // Avoid NaN\n\n return (b + g + r + ycRadiusWeight * chroma) / 3.0;\n }\n\n mediump float rgb_2_hue(mediump vec3 rgb){\n // Returns a geometric hue angle in degrees (0-360) based on RGB values.\n // For neutral colors, hue is undefined and the function will return a quiet NaN value.\n mediump float hue;\n if (rgb.x == rgb.y && rgb.y == rgb.z){\n hue = 0.0; // RGB triplets where RGB are equal have an undefined hue\n } else{\n hue = (180.0 / PI) * atan(sqrt(3.0) * (rgb.y - rgb.z), 2.0 * rgb.x - rgb.y - rgb.z);\n }\n\n if (hue < 0.0){\n hue = hue + 360.0;\n } \n\n return hue;\n }\n\n mediump float center_hue(mediump float hue, mediump float centerH){\n mediump float hueCentered = hue - centerH;\n if (hueCentered < -180.0){\n hueCentered = hueCentered + 360.0;\n } else if (hueCentered > 180.0){\n hueCentered = hueCentered - 360.0;\n } \n\n return hueCentered;\n }\n\n#endif"; // eslint-disable-line
|
|
28562
|
+
var ODT = "#define GLSLIFY 1\n#include <Tonescale>\n\n// Output Device Transform - RGB computer monitor\n\nconst float CINEMA_WHITE = 48.0;\nconst float CINEMA_BLACK = 0.02; // CINEMA_WHITE / 2400.0;\nconst float ODT_SAT_FACTOR = 0.93;\n\nmediump vec3 Y_2_linCV(mediump vec3 Y, mediump float Ymax, mediump float Ymin){\n return (Y - Ymin) / (Ymax - Ymin);\n}\n\nmediump vec3 XYZ_2_xyY(mediump vec3 XYZ){\n mediump float divisor = max(dot(XYZ, vec3(1.0)), 1e-4);\n return vec3(XYZ.xy / divisor, XYZ.y);\n}\n\nmediump vec3 xyY_2_XYZ(mediump vec3 xyY){\n mediump float m = xyY.z / max(xyY.y, 1e-4);\n mediump vec3 XYZ = vec3(xyY.xz, (1.0 - xyY.x - xyY.y));\n XYZ.xz *= m;\n return XYZ;\n}\n\nconst mediump float DIM_SURROUND_GAMMA = 0.9811;\n\nmediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){\n // Extra conversions to float3/vec3 are required to avoid floating-point precision issues on some platforms.\n\n mediump vec3 XYZ = AP1_2_XYZ_MAT * linearCV;\n mediump vec3 xyY = XYZ_2_xyY(XYZ);\n xyY.z = clamp(xyY.z, 0.0, HALF_MAX);\n xyY.z = pow(xyY.z, DIM_SURROUND_GAMMA);\n XYZ = xyY_2_XYZ(xyY);\n\n return XYZ_2_AP1_MAT * XYZ;\n}\n\n//\n// Summary :\n// This transform is intended for mapping OCES onto a desktop computer monitor\n// typical of those used in motion picture visual effects production. These\n// monitors may occasionally be referred to as \"sRGB\" displays, however, the\n// monitor for which this transform is designed does not exactly match the\n// specifications in IEC 61966-2-1:1999.\n//\n// The assumed observer adapted white is D65, and the viewing environment is\n// that of a dim surround.\n//\n// The monitor specified is intended to be more typical of those found in\n// visual effects production.\n//\n// Device Primaries :\n// Primaries are those specified in Rec. ITU-R BT.709\n// CIE 1931 chromaticities: x y Y\n// Red: 0.64 0.33\n// Green: 0.3 0.6\n// Blue: 0.15 0.06\n// White: 0.3127 0.329 100 cd/m^2\n//\n// Display EOTF :\n// The reference electro-optical transfer function specified in\n// IEC 61966-2-1:1999.\n//\n// Signal Range:\n// This transform outputs full range code values.\n//\n// Assumed observer adapted white point:\n// CIE 1931 chromaticities: x y\n// 0.3127 0.329\n//\n\n// Viewing Environment:\n// This ODT has a compensation for viewing environment variables more typical\n// of those associated with video mastering.\n//\nmediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){\n // The metal compiler does not optimize structure access\n // const SegmentedSplineParams_c9 ODT_48nits = SegmentedSplineParams_c9(\n // // coefsLow[10]\n // float[10]( -1.6989700043, -1.6989700043, -1.4779000000, -1.2291000000, -0.8648000000, -0.4480000000, 0.0051800000, 0.4511080334, 0.9113744414, 0.9113744414),\n // // coefsHigh[10]\n // float[10]( 0.5154386965, 0.8470437783, 1.1358000000, 1.3802000000, 1.5197000000, 1.5985000000, 1.6467000000, 1.6746091357, 1.6878733390, 1.6878733390 ),\n // vec2(segmented_spline_c5_fwd(0.18*pow(2.,-6.5)), 0.02), // minPoint\n // vec2(segmented_spline_c5_fwd(0.18), 4.8), // midPoint\n // vec2(segmented_spline_c5_fwd(0.18*pow(2.,6.5)), 48.0), // maxPoint\n // 0.0, // slopeLow\n // 0.04 // slopeHigh\n // );\n\n // OCES to RGB rendering space\n mediump vec3 rgbPre = AP0_2_AP1_MAT * oces;\n\n // Apply the tonescale independently in rendering-space RGB\n mediump vec3 rgbPost;\n\n // rgbPost.r = segmented_spline_c9_fwd(rgbPre.r, ODT_48nits);\n // rgbPost.g = segmented_spline_c9_fwd(rgbPre.g, ODT_48nits);\n // rgbPost.b = segmented_spline_c9_fwd(rgbPre.b, ODT_48nits);\n\n rgbPost.r = segmented_spline_c9_fwd(rgbPre.r);\n rgbPost.g = segmented_spline_c9_fwd(rgbPre.g);\n rgbPost.b = segmented_spline_c9_fwd(rgbPre.b);\n\n // Scale luminance to linear code value\n mediump vec3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);\n\n // Apply gamma adjustment to compensate for dim surround\n linearCV = darkSurround_to_dimSurround(linearCV);\n\n // Apply desaturation to compensate for luminance difference\n linearCV = mix(vec3(dot(linearCV, AP1_RGB2Y)), linearCV, ODT_SAT_FACTOR);\n\n // Convert to display primary encoding\n // Rendering space RGB to XYZ\n mediump vec3 XYZ = AP1_2_XYZ_MAT * linearCV;\n\n // Apply CAT from ACES white point to assumed observer adapted white point\n XYZ = D60_2_D65_CAT * XYZ;\n\n // CIE XYZ to display primaries\n linearCV = XYZ_2_REC709_MAT * XYZ;\n\n // Handle out-of-gamut values\n // Clip values < 0 or > 1 (i.e. projecting outside the display primaries)\n linearCV = clamp(linearCV, vec3(0), vec3(1));\n\n // Unity already draws to a sRGB target\n return linearCV;\n}"; // eslint-disable-line
|
|
28563
|
+
var RRT = "#define GLSLIFY 1\n#include <Tonescale>\n\n// Reference Rendering Transform (RRT)\n\n// Sigmoid function in the range 0 to 1 spanning -2 to +2.\nmediump float sigmoid_shaper(mediump float x){\n mediump float t = max(1.0 - abs(x / 2.0), 0.0);\n mediump float y = 1.0 + sign(x) * (1.0 - t * t);\n\n return y * 0.5;\n}\n\nmediump float glow_fwd(mediump float ycIn, mediump float glowGainIn, mediump float glowMid){\n mediump float glowGainOut;\n\n if (ycIn <= 2.0 / 3.0 * glowMid){\n glowGainOut = glowGainIn;\n } else if (ycIn >= 2.0 * glowMid){\n glowGainOut = 0.0;\n } else{\n glowGainOut = glowGainIn * (glowMid / ycIn - 1.0 / 2.0);\n }\n\n return glowGainOut;\n}\n\n// \"Glow\" module constants\nconst mediump float RRT_GLOW_GAIN = 0.05;\nconst mediump float RRT_GLOW_MID = 0.08;\n\n// Red modifier constants\nconst mediump float RRT_RED_SCALE = 0.82;\nconst mediump float RRT_RED_PIVOT = 0.03;\nconst mediump float RRT_RED_HUE = 0.0;\nconst mediump float RRT_RED_WIDTH = 135.0;\n\n// Desaturation contants\nconst mediump float RRT_SAT_FACTOR = 0.96;\n\n// ACES to OCES\nmediump vec3 RRT(mediump vec3 aces){\n // --- Glow module --- //\n mediump float saturation = rgb_2_saturation(aces);\n mediump float ycIn = rgb_2_yc(aces);\n mediump float s = sigmoid_shaper((saturation - 0.4) / 0.2);\n mediump float addedGlow = 1.0 + glow_fwd(ycIn, RRT_GLOW_GAIN * s, RRT_GLOW_MID);\n aces *= addedGlow;\n\n // --- Red modifier --- //\n mediump float hue = rgb_2_hue(aces);\n mediump float centeredHue = center_hue(hue, RRT_RED_HUE);\n\n mediump float hueWeight = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * centeredHue / RRT_RED_WIDTH));\n hueWeight *= hueWeight;\n\n aces.r += hueWeight * saturation * (RRT_RED_PIVOT - aces.r) * (1.0 - RRT_RED_SCALE);\n\n // --- ACES to RGB rendering space --- //\n aces = clamp(aces, 0.0, HALF_MAX); // avoids saturated negative colors from becoming positive in the matrix\n mediump vec3 rgbPre = AP0_2_AP1_MAT * aces;\n rgbPre = clamp(rgbPre, 0.0, HALF_MAX);\n\n // --- Global desaturation --- //\n rgbPre = mix(vec3(dot(rgbPre, AP1_RGB2Y)), rgbPre, RRT_SAT_FACTOR);\n\n // --- Apply the tonescale independently in rendering-space RGB --- //\n mediump vec3 rgbPost;\n rgbPost.x = segmented_spline_c5_fwd(rgbPre.x);\n rgbPost.y = segmented_spline_c5_fwd(rgbPre.y);\n rgbPost.z = segmented_spline_c5_fwd(rgbPre.z);\n\n // --- RGB rendering space to OCES --- //\n mediump vec3 outputVal = AP1_2_AP0_MAT * rgbPost;\n\n return outputVal;\n}"; // eslint-disable-line
|
|
28564
|
+
var Tonescale = "#define GLSLIFY 1\n #ifndef TONE_SCALE\n #define TONE_SCALE\n \n const mediump mat3 M = mat3(\n vec3(0.5, -1.0, 0.5),\n vec3(-1.0, 1.0, 0.5),\n vec3(0.5, 0.0, 0.0)\n );\n\n mediump float segmented_spline_c5_fwd(mediump float x){\n #ifdef GRAPHICS_API_WEBGL2\n const mediump float coefsLow[6] = float[6](-4.0000000000, -4.0000000000, -3.1573765773, -0.4852499958, 1.8477324706, 1.8477324706); // coefs for B-spline between minPoint and midPoint (units of log luminance)\n const mediump float coefsHigh[6] = float[6](-0.7185482425, 2.0810307172, 3.6681241237, 4.0000000000, 4.0000000000, 4.0000000000); // coefs for B-spline between midPoint and maxPoint (units of log luminance)\n #else\n const mediump float coefsLow_0 = -4.0000000000;\n const mediump float coefsLow_1 = -4.0000000000;\n const mediump float coefsLow_2 = -3.1573765773;\n const mediump float coefsLow_3 = -0.4852499958;\n const mediump float coefsLow_4 = 1.8477324706;\n const mediump float coefsLow_5 = 1.8477324706;\n\n const mediump float coefsHigh_0 = -0.7185482425;\n const mediump float coefsHigh_1 = 2.0810307172;\n const mediump float coefsHigh_2 = 3.6681241237;\n const mediump float coefsHigh_3 = 4.0000000000;\n const mediump float coefsHigh_4 = 4.0000000000;\n const mediump float coefsHigh_5 = 4.0000000000;\n #endif\n\n // const vec2 minPoint = vec2(0.18 * exp2(-15.0), 0.0001); // {luminance, luminance} linear extension below this\n const mediump vec2 minPoint = vec2(0.0000054931640625, 0.0001); // {luminance, luminance} linear extension below this\n const mediump vec2 midPoint = vec2(0.18, 0.48); // {luminance, luminance}\n // const vec2 maxPoint = vec2(0.18 * exp2(18.0), 10000.0); // {luminance, luminance} linear extension above this\n const mediump vec2 maxPoint = vec2(47185.92, 10000.0); // {luminance, luminance} linear extension above this\n const mediump float slopeLow = 0.0; // log-log slope of low linear extension\n const mediump float slopeHigh = 0.0; // log-log slope of high linear extension\n\n const int N_KNOTS_LOW = 4;\n const int N_KNOTS_HIGH = 4;\n\n // Check for negatives or zero before taking the log. If negative or zero,\n // set to ACESMIN.1\n mediump float logx = log10(max(x, HALF_MIN));\n mediump float logy;\n\n if (logx <= log10(minPoint.x)){\n logy = logx * slopeLow + (log10(minPoint.y) - slopeLow * log10(minPoint.x));\n } else if ((logx > log10(minPoint.x)) && (logx < log10(midPoint.x))){\n mediump float knot_coord = float(N_KNOTS_LOW - 1) * (logx - log10(minPoint.x)) / (log10(midPoint.x) - log10(minPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsLow[j], coefsLow[j + 1], coefsLow[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsLow_0, coefsLow_1, coefsLow_2);\n } else if (j == 1) {\n cf = vec3(coefsLow_1, coefsLow_2, coefsLow_3);\n } else if (j == 2) {\n cf = vec3(coefsLow_2, coefsLow_3, coefsLow_4);\n } else { // if (j == 3)\n cf = vec3(coefsLow_3, coefsLow_4, coefsLow_5);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else if ((logx >= log10(midPoint.x)) && (logx < log10(maxPoint.x))){\n mediump float knot_coord = float(N_KNOTS_HIGH - 1) * (logx - log10(midPoint.x)) / (log10(maxPoint.x) - log10(midPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsHigh[j], coefsHigh[j + 1], coefsHigh[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsHigh_0, coefsHigh_1, coefsHigh_2);\n } else if (j == 1) {\n cf = vec3(coefsHigh_1, coefsHigh_2, coefsHigh_3);\n } else if (j == 2) {\n cf = vec3(coefsHigh_2, coefsHigh_3, coefsHigh_4);\n } else { // if (j == 3)\n cf = vec3(coefsHigh_3, coefsHigh_4, coefsHigh_5);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else {\n logy = logx * slopeHigh + (log10(maxPoint.y) - slopeHigh * log10(maxPoint.x));\n }\n\n return pow(10.0, logy);\n }\n\n // The metal compiler does not optimize structure access\n // struct SegmentedSplineParams_c9{\n // float coefsLow[10]; // coefs for B-spline between minPoint and midPoint (units of log luminance)\n // float coefsHigh[10]; // coefs for B-spline between midPoint and maxPoint (units of log luminance)\n // mediump vec2 minPoint; // {luminance, luminance} linear extension below this\n // mediump vec2 midPoint; // {luminance, luminance}\n // mediump vec2 maxPoint; // {luminance, luminance} linear extension above this\n // float slopeLow; // log-log slope of low linear extension\n // float slopeHigh; // log-log slope of high linear extension\n // };\n\n mediump float segmented_spline_c9_fwd(mediump float x){\n // ODT_48nits\n #ifdef GRAPHICS_API_WEBGL2\n const mediump float coefsLow[10] = float[10](-1.6989700043, -1.6989700043, -1.4779000000, -1.2291000000, -0.8648000000, -0.4480000000, 0.0051800000, 0.4511080334, 0.9113744414, 0.9113744414);\n const mediump float coefsHigh[10] = float[10](0.5154386965, 0.8470437783, 1.1358000000, 1.3802000000, 1.5197000000, 1.5985000000, 1.6467000000, 1.6746091357, 1.6878733390, 1.6878733390);\n #else\n const mediump float coefsLow_0 = -1.6989700043;\n const mediump float coefsLow_1 = -1.6989700043;\n const mediump float coefsLow_2 = -1.4779000000;\n const mediump float coefsLow_3 = -1.2291000000;\n const mediump float coefsLow_4 = -0.8648000000;\n const mediump float coefsLow_5 = -0.4480000000;\n const mediump float coefsLow_6 = 0.0051800000;\n const mediump float coefsLow_7 = 0.4511080334;\n const mediump float coefsLow_8 = 0.9113744414;\n const mediump float coefsLow_9 = 0.9113744414;\n\n const mediump float coefsHigh_0 = 0.5154386965;\n const mediump float coefsHigh_1 = 0.8470437783;\n const mediump float coefsHigh_2 = 1.1358000000;\n const mediump float coefsHigh_3 = 1.3802000000;\n const mediump float coefsHigh_4 = 1.5197000000;\n const mediump float coefsHigh_5 = 1.5985000000;\n const mediump float coefsHigh_6 = 1.6467000000;\n const mediump float coefsHigh_7 = 1.6746091357;\n const mediump float coefsHigh_8 = 1.6878733390;\n const mediump float coefsHigh_9 = 1.6878733390;\n #endif\n\n // mediump vec2 minPoint = vec2(segmented_spline_c5_fwd(0.18 * pow(2.0, -6.5)), 0.02);\n // mediump vec2 midPoint = vec2(segmented_spline_c5_fwd(0.18), 4.8);\n // mediump vec2 maxPoint = vec2(segmented_spline_c5_fwd(0.18 * pow(2., 6.5)), 48.0);\n\n const mediump vec2 minPoint = vec2(0.0028799, 0.02);\n const mediump vec2 midPoint = vec2(4.799999, 4.8);\n const mediump vec2 maxPoint = vec2(1005.719, 48.0);\n\n const mediump float slopeLow = 0.0;\n const mediump float slopeHigh = 0.04;\n\n const int N_KNOTS_LOW = 8;\n const int N_KNOTS_HIGH = 8;\n\n // Check for negatives or zero before taking the log. If negative or zero,\n // set to OCESMIN.\n mediump float logx = log10(max(x, 1e-4));\n mediump float logy;\n\n if (logx <= log10(minPoint.x)) {\n logy = logx * slopeLow + (log10(minPoint.y) - slopeLow * log10(minPoint.x));\n } else if ((logx > log10(minPoint.x)) && (logx < log10(midPoint.x))) {\n mediump float knot_coord = float(N_KNOTS_LOW - 1) * (logx - log10(minPoint.x)) / (log10(midPoint.x) - log10(minPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsLow[j], coefsLow[j + 1], coefsLow[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsLow_0, coefsLow_1, coefsLow_2);\n } else if (j == 1) {\n cf = vec3(coefsLow_1, coefsLow_2, coefsLow_3);\n } else if (j == 2) {\n cf = vec3(coefsLow_2, coefsLow_3, coefsLow_4);\n } else if (j == 3) {\n cf = vec3(coefsLow_3, coefsLow_4, coefsLow_5);\n } else if (j == 4) {\n cf = vec3(coefsLow_4, coefsLow_5, coefsLow_6);\n } else if (j == 5) {\n cf = vec3(coefsLow_5, coefsLow_6, coefsLow_7);\n } else if (j == 6) {\n cf = vec3(coefsLow_6, coefsLow_7, coefsLow_8);\n } else { // if (j == 7)\n cf = vec3(coefsLow_7, coefsLow_8, coefsLow_9);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else if ((logx >= log10(midPoint.x)) && (logx < log10(maxPoint.x))) {\n mediump float knot_coord = float(N_KNOTS_HIGH - 1) * (logx - log10(midPoint.x)) / (log10(maxPoint.x) - log10(midPoint.x));\n int j = int(knot_coord);\n mediump float t = knot_coord - float(j);\n\n mediump vec3 cf;\n #ifdef GRAPHICS_API_WEBGL2\n cf = vec3(coefsHigh[j], coefsHigh[j + 1], coefsHigh[j + 2]);\n #else\n if (j <= 0) {\n cf = vec3(coefsHigh_0, coefsHigh_1, coefsHigh_2);\n } else if (j == 1) {\n cf = vec3(coefsHigh_1, coefsHigh_2, coefsHigh_3);\n } else if (j == 2) {\n cf = vec3(coefsHigh_2, coefsHigh_3, coefsHigh_4);\n } else if (j == 3) {\n cf = vec3(coefsHigh_3, coefsHigh_4, coefsHigh_5);\n } else if (j == 4) {\n cf = vec3(coefsHigh_4, coefsHigh_5, coefsHigh_6);\n } else if (j == 5) {\n cf = vec3(coefsHigh_5, coefsHigh_6, coefsHigh_7);\n } else if (j == 6) {\n cf = vec3(coefsHigh_6, coefsHigh_7, coefsHigh_8);\n } else { // if (j == 7)\n cf = vec3(coefsHigh_7, coefsHigh_8, coefsHigh_9);\n }\n #endif\n\n mediump vec3 monomials = vec3(t * t, t, 1.0);\n logy = dot(monomials, M * cf);\n } else {\n logy = logx * slopeHigh + (log10(maxPoint.y) - slopeHigh * log10(maxPoint.x));\n }\n\n return pow(10.0, logy);\n }\n\n#endif"; // eslint-disable-line
|
|
28565
|
+
var NeutralTonemapping = "#define GLSLIFY 1\n// Neutral tonemapping (Hable/Hejl/Frostbite)\n// Input is linear RGB\n// More accuracy to avoid NaN on extremely high values.\nvec3 neutralCurve(vec3 x, float a, float b, float c, float d, float e, float f){\n return vec3(((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f);\n}\n\n#define TONEMAPPING_CLAMP_MAX 435.18712 //(-b + sqrt(b * b - 4 * a * (HALF_MAX - d * f))) / (2 * a * whiteScale)\n//Extremely high values cause NaN output when using fp16, we clamp to avoid the performace hit of switching to fp32\n//The overflow happens in (x * (a * x + b) + d * f) of the NeutralCurve, highest value that avoids fp16 precision errors is ~571.56873\n//Since whiteScale is constant (~1.31338) max input is ~435.18712\n\nvec3 neutralTonemap(vec3 color){\n const float a = 0.2;\n const float b = 0.29;\n const float c = 0.24;\n const float d = 0.272;\n const float e = 0.02;\n const float f = 0.3;\n // const float whiteLevel = 5.3;\n // const float whiteClip = 1.0;\n\n #ifndef GL_FRAGMENT_PRECISION_HIGH\n color = min(color, TONEMAPPING_CLAMP_MAX);\n #endif\n\n // 1.0 / neutralCurve(whiteLevel, a, b, c, d, e, f);\n const float whiteScale = 1.31338; \n color = neutralCurve(color * whiteScale, a, b, c, d, e, f);\n color *= whiteScale;\n\n // Post-curve white point adjustment\n // color /= whiteClip;\n\n return color;\n}"; // eslint-disable-line
|
|
28566
|
+
var UberPost = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n#ifdef ENABLE_EFFECT_BLOOM\n\tuniform sampler2D material_BloomTexture;\n\tuniform sampler2D material_BloomDirtTexture;\n\tuniform vec4 material_BloomTint;\n\tuniform vec4 material_BloomDirtTilingOffset;\n\tuniform vec4 material_BloomIntensityParams; // x: bloom intensity, y: dirt intensity\n#endif\n\nvoid main(){\n\tmediump vec4 color = sampleTexture(renderer_BlitTexture, v_uv);\n\n\t#ifdef ENABLE_EFFECT_BLOOM\n \t#ifdef BLOOM_HQ\n \t mediump vec4 bloom = sampleTexture2DBicubic(material_BloomTexture, v_uv, renderer_texelSize);\n \t#else\n \t mediump vec4 bloom = sampleTexture(material_BloomTexture, v_uv);\n \t#endif\n\n \tbloom *= material_BloomIntensityParams.x;\n \tcolor += bloom * material_BloomTint;\n\n \t#ifdef BLOOM_DIRT\n \t mediump vec4 dirt = sampleTexture(material_BloomDirtTexture, v_uv * material_BloomDirtTilingOffset.xy + material_BloomDirtTilingOffset.zw);\n \t dirt *= material_BloomIntensityParams.y;\n \t // Additive bloom (artist friendly)\n \t color += dirt * bloom;\n \t#endif\n\t#endif\n\n\t#ifdef ENABLE_EFFECT_TONEMAPPING\n\t\t#if TONEMAPPING_MODE == 0\n \t\tcolor.rgb = neutralTonemap(color.rgb);\n \t#elif TONEMAPPING_MODE == 1\n \t\tcolor.rgb = ACESTonemap(color.rgb);\n \t#endif\n\n \tcolor.rgb = clamp(color.rgb, vec3(0), vec3(1));\n\t#endif\n\n gl_FragColor = color;\n\n\t#ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
28567
|
+
var PostProcessUberPass = /*#__PURE__*/ function(PostProcessPass) {
|
|
28568
|
+
_inherits$2(PostProcessUberPass, PostProcessPass);
|
|
28569
|
+
function PostProcessUberPass(engine) {
|
|
28570
|
+
var _this;
|
|
28571
|
+
_this = PostProcessPass.call(this, engine) || this, _this._mipDownRT = [], _this._mipUpRT = [];
|
|
28572
|
+
_this.event = PostProcessPassEvent.AfterUber - 1;
|
|
28573
|
+
// Uber Material
|
|
28574
|
+
var uberMaterial = new Material(engine, Shader.find(PostProcessUberPass.UBER_SHADER_NAME));
|
|
28575
|
+
var uberDepthState = uberMaterial.renderState.depthState;
|
|
28576
|
+
uberDepthState.enabled = false;
|
|
28577
|
+
uberDepthState.writeEnabled = false;
|
|
28578
|
+
_this._uberMaterial = uberMaterial;
|
|
28579
|
+
// Bloom Material
|
|
28580
|
+
var bloomMaterial = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
|
|
28581
|
+
var bloomDepthState = bloomMaterial.renderState.depthState;
|
|
28582
|
+
bloomDepthState.enabled = false;
|
|
28583
|
+
bloomDepthState.writeEnabled = false;
|
|
28584
|
+
_this._bloomMaterial = bloomMaterial;
|
|
28585
|
+
// ShaderData initialization
|
|
28586
|
+
var bloomShaderData = bloomMaterial.shaderData;
|
|
28587
|
+
var uberShaderData = uberMaterial.shaderData;
|
|
28588
|
+
bloomShaderData.setVector4(BloomEffect._bloomParams, new Vector4());
|
|
28589
|
+
bloomShaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
|
|
28590
|
+
uberShaderData.setVector4(BloomEffect._bloomIntensityParams, new Vector4());
|
|
28591
|
+
uberShaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
|
|
28592
|
+
uberShaderData.setColor(BloomEffect._tintProp, new Color());
|
|
28593
|
+
return _this;
|
|
28594
|
+
}
|
|
28595
|
+
var _proto = PostProcessUberPass.prototype;
|
|
28596
|
+
/** @inheritdoc */ _proto.isValid = function isValid(postProcessManager) {
|
|
28597
|
+
if (!this.isActive) {
|
|
28598
|
+
return false;
|
|
28599
|
+
}
|
|
28600
|
+
var bloomBlend = postProcessManager.getBlendEffect(BloomEffect);
|
|
28601
|
+
var tonemappingBlend = postProcessManager.getBlendEffect(TonemappingEffect);
|
|
28602
|
+
return (bloomBlend == null ? void 0 : bloomBlend.isValid()) || (tonemappingBlend == null ? void 0 : tonemappingBlend.isValid());
|
|
28603
|
+
};
|
|
28604
|
+
/**
|
|
28605
|
+
* @inheritdoc
|
|
28606
|
+
*/ _proto.onRender = function onRender(camera, srcTexture, destTarget) {
|
|
28607
|
+
var postProcessManager = camera.scene.postProcessManager;
|
|
28608
|
+
var uberShaderData = this._uberMaterial.shaderData;
|
|
28609
|
+
var bloomBlend = postProcessManager.getBlendEffect(BloomEffect);
|
|
28610
|
+
var tonemappingBlend = postProcessManager.getBlendEffect(TonemappingEffect);
|
|
28611
|
+
if (bloomBlend == null ? void 0 : bloomBlend.isValid()) {
|
|
28612
|
+
this._setupBloom(bloomBlend, camera, srcTexture);
|
|
28613
|
+
uberShaderData.enableMacro(BloomEffect._enableMacro);
|
|
28614
|
+
} else {
|
|
28615
|
+
uberShaderData.disableMacro(BloomEffect._enableMacro);
|
|
28616
|
+
this._releaseBloomRenderTargets();
|
|
28617
|
+
}
|
|
28618
|
+
if (tonemappingBlend == null ? void 0 : tonemappingBlend.isValid()) {
|
|
28619
|
+
uberShaderData.enableMacro("TONEMAPPING_MODE", tonemappingBlend.mode.value.toString());
|
|
28620
|
+
uberShaderData.enableMacro(TonemappingEffect._enableMacro);
|
|
28621
|
+
} else {
|
|
28622
|
+
uberShaderData.disableMacro(TonemappingEffect._enableMacro);
|
|
28623
|
+
}
|
|
28624
|
+
Blitter.blitTexture(camera.engine, srcTexture, destTarget, 0, camera.viewport, this._uberMaterial, undefined);
|
|
28625
|
+
};
|
|
28626
|
+
/**
|
|
28627
|
+
* @inheritdoc
|
|
28628
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
28629
|
+
PostProcessPass.prototype._onDestroy.call(this);
|
|
28630
|
+
this._releaseBloomRenderTargets();
|
|
28631
|
+
this._uberMaterial.destroy();
|
|
28632
|
+
this._bloomMaterial.destroy();
|
|
28633
|
+
};
|
|
28634
|
+
_proto._setupBloom = function _setupBloom(bloomBlend, camera, srcTexture) {
|
|
28635
|
+
var engine = camera.engine;
|
|
28636
|
+
var bloomMaterial = this._bloomMaterial;
|
|
28637
|
+
var bloomShaderData = bloomMaterial.shaderData;
|
|
28638
|
+
var uberMaterial = this._uberMaterial;
|
|
28639
|
+
var uberShaderData = uberMaterial.shaderData;
|
|
28640
|
+
var downScale = bloomBlend.downScale, threshold = bloomBlend.threshold, scatter = bloomBlend.scatter, intensity = bloomBlend.intensity, tint = bloomBlend.tint, highQualityFiltering = bloomBlend.highQualityFiltering, dirtTexture = bloomBlend.dirtTexture, dirtIntensity = bloomBlend.dirtIntensity;
|
|
28641
|
+
// Update shaderData
|
|
28642
|
+
var thresholdLinear = Color.gammaToLinearSpace(threshold.value);
|
|
28643
|
+
var thresholdKnee = thresholdLinear * 0.5; // Hardcoded soft knee
|
|
28644
|
+
var bloomParams = bloomShaderData.getVector4(BloomEffect._bloomParams);
|
|
28645
|
+
var scatterLerp = MathUtil.lerp(0.05, 0.95, scatter.value);
|
|
28646
|
+
bloomParams.x = threshold.value;
|
|
28647
|
+
bloomParams.y = thresholdKnee;
|
|
28648
|
+
bloomParams.z = scatterLerp;
|
|
28649
|
+
var bloomIntensityParams = uberShaderData.getVector4(BloomEffect._bloomIntensityParams);
|
|
28650
|
+
bloomIntensityParams.x = intensity.value;
|
|
28651
|
+
bloomIntensityParams.y = dirtIntensity.value;
|
|
28652
|
+
var tintParam = uberShaderData.getColor(BloomEffect._tintProp);
|
|
28653
|
+
tintParam.copyFrom(tint.value);
|
|
28654
|
+
if (highQualityFiltering.value) {
|
|
28655
|
+
bloomShaderData.enableMacro(BloomEffect._hqMacro);
|
|
28656
|
+
uberShaderData.enableMacro(BloomEffect._hqMacro);
|
|
28657
|
+
} else {
|
|
28658
|
+
bloomShaderData.disableMacro(BloomEffect._hqMacro);
|
|
28659
|
+
uberShaderData.disableMacro(BloomEffect._hqMacro);
|
|
28660
|
+
}
|
|
28661
|
+
uberShaderData.setTexture(BloomEffect._dirtTextureProp, dirtTexture.value);
|
|
28662
|
+
if (dirtTexture) {
|
|
28663
|
+
uberShaderData.enableMacro(BloomEffect._dirtMacro);
|
|
28664
|
+
} else {
|
|
28665
|
+
uberShaderData.disableMacro(BloomEffect._dirtMacro);
|
|
28666
|
+
}
|
|
28667
|
+
// Determine the iteration count
|
|
28668
|
+
var downRes = downScale.value === BloomDownScaleMode.Half ? 1 : 2;
|
|
28669
|
+
var pixelViewport = camera.pixelViewport;
|
|
28670
|
+
var tw = pixelViewport.width >> downRes;
|
|
28671
|
+
var th = pixelViewport.height >> downRes;
|
|
28672
|
+
var maxSize = Math.max(tw, th);
|
|
28673
|
+
var iterations = Math.floor(Math.log2(maxSize) - 1);
|
|
28674
|
+
var mipCount = Math.min(Math.max(iterations, 1), BloomEffect._maxIterations);
|
|
28675
|
+
// Prefilter
|
|
28676
|
+
var internalColorTextureFormat = camera._getInternalColorTextureFormat();
|
|
28677
|
+
var mipWidth = tw, mipHeight = th;
|
|
28678
|
+
for(var i = 0; i < mipCount; i++){
|
|
28679
|
+
this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipUpRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode$1.Clamp, TextureFilterMode.Bilinear);
|
|
28680
|
+
this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipDownRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode$1.Clamp, TextureFilterMode.Bilinear);
|
|
28681
|
+
mipWidth = Math.max(1, Math.floor(mipWidth / 2));
|
|
28682
|
+
mipHeight = Math.max(1, Math.floor(mipHeight / 2));
|
|
28683
|
+
}
|
|
28684
|
+
Blitter.blitTexture(engine, srcTexture, this._mipDownRT[0], undefined, undefined, bloomMaterial, 0);
|
|
28685
|
+
// Down sample - gaussian pyramid
|
|
28686
|
+
var lastDown = this._mipDownRT[0];
|
|
28687
|
+
for(var i1 = 1; i1 < mipCount; i1++){
|
|
28688
|
+
// Classic two pass gaussian blur - use mipUp as a temporary target
|
|
28689
|
+
// First pass does 2x downsampling + 9-tap gaussian
|
|
28690
|
+
// Second pass does 9-tap gaussian using a 5-tap filter + bilinear filtering
|
|
28691
|
+
Blitter.blitTexture(engine, lastDown.getColorTexture(0), this._mipUpRT[i1], undefined, undefined, bloomMaterial, 1);
|
|
28692
|
+
Blitter.blitTexture(engine, this._mipUpRT[i1].getColorTexture(0), this._mipDownRT[i1], undefined, undefined, bloomMaterial, 2);
|
|
28693
|
+
lastDown = this._mipDownRT[i1];
|
|
28694
|
+
}
|
|
28695
|
+
// Up sample (bilinear by default, HQ filtering does bicubic instead
|
|
28696
|
+
for(var i2 = mipCount - 2; i2 >= 0; i2--){
|
|
28697
|
+
var lowMip = i2 == mipCount - 2 ? this._mipDownRT[i2 + 1] : this._mipUpRT[i2 + 1];
|
|
28698
|
+
var highMip = this._mipDownRT[i2];
|
|
28699
|
+
var dst = this._mipUpRT[i2];
|
|
28700
|
+
bloomShaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
|
|
28701
|
+
if (highQualityFiltering) {
|
|
28702
|
+
var texelSizeLow = bloomShaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
|
|
28703
|
+
texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
|
|
28704
|
+
}
|
|
28705
|
+
Blitter.blitTexture(engine, highMip.getColorTexture(0), dst, undefined, undefined, bloomMaterial, 3);
|
|
28706
|
+
}
|
|
28707
|
+
// Setup bloom on uber
|
|
28708
|
+
if (dirtTexture.value) {
|
|
28709
|
+
var dirtTilingOffset = uberShaderData.getVector4(BloomEffect._dirtTilingOffsetProp);
|
|
28710
|
+
var dirtRatio = dirtTexture.value.width / dirtTexture.value.height;
|
|
28711
|
+
var screenRatio = camera.aspectRatio;
|
|
28712
|
+
if (dirtRatio > screenRatio) {
|
|
28713
|
+
dirtTilingOffset.set(screenRatio / dirtRatio, 1, (1 - dirtTilingOffset.x) * 0.5, 0);
|
|
28714
|
+
} else if (dirtRatio < screenRatio) {
|
|
28715
|
+
dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
|
|
28716
|
+
} else {
|
|
28717
|
+
dirtTilingOffset.set(1, 1, 0, 0);
|
|
28718
|
+
}
|
|
28719
|
+
}
|
|
28720
|
+
uberShaderData.setTexture(BloomEffect._bloomTextureProp, this._mipUpRT[0].getColorTexture(0));
|
|
28721
|
+
};
|
|
28722
|
+
_proto._releaseBloomRenderTargets = function _releaseBloomRenderTargets() {
|
|
28723
|
+
var length = this._mipDownRT.length;
|
|
28724
|
+
for(var i = 0; i < length; i++){
|
|
28725
|
+
var downRT = this._mipDownRT[i];
|
|
28726
|
+
var upRT = this._mipUpRT[i];
|
|
28727
|
+
if (downRT) {
|
|
28728
|
+
downRT.getColorTexture(0).destroy(true);
|
|
28729
|
+
downRT.destroy(true);
|
|
28730
|
+
}
|
|
28731
|
+
if (upRT) {
|
|
28732
|
+
upRT.getColorTexture(0).destroy(true);
|
|
28733
|
+
upRT.destroy(true);
|
|
28734
|
+
}
|
|
28735
|
+
}
|
|
28736
|
+
this._mipDownRT.length = 0;
|
|
28737
|
+
this._mipUpRT.length = 0;
|
|
28738
|
+
};
|
|
28739
|
+
return PostProcessUberPass;
|
|
28740
|
+
}(PostProcessPass);
|
|
28741
|
+
PostProcessUberPass.UBER_SHADER_NAME = "UberPost";
|
|
28742
|
+
Object.assign(ShaderLib, {
|
|
28743
|
+
PostCommon: PostCommon,
|
|
28744
|
+
Filtering: Filtering,
|
|
28745
|
+
ODT: ODT,
|
|
28746
|
+
RRT: RRT,
|
|
28747
|
+
Tonescale: Tonescale,
|
|
28748
|
+
ColorTransform: ColorTransform,
|
|
28749
|
+
NeutralTonemapping: NeutralTonemapping,
|
|
28750
|
+
ACESTonemapping: ACESTonemapping
|
|
28751
|
+
});
|
|
28752
|
+
Shader.create(PostProcessUberPass.UBER_SHADER_NAME, blitVs, UberPost);
|
|
28753
|
+
var blitFs = "#define GLSLIFY 1\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 = texture2DLodEXT( renderer_BlitTexture, uv, renderer_BlitMipLevel );\n\t#else\n\t\tgl_FragColor = texture2D( renderer_BlitTexture, uv );\n\t#endif\n}\n\n"; // eslint-disable-line
|
|
28754
|
+
var skyProceduralFs = "#define GLSLIFY 1\n// 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#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n\t#define LINEAR_2_OUTPUT(color) sqrt(color)\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 #ifdef ENGINE_IS_COLORSPACE_GAMMA\n\t\tcol = LINEAR_2_OUTPUT(col); // linear space convert to gamma space\n\t#endif\n\n\tgl_FragColor = vec4(col,1.0);\n\n\t#ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n\n"; // eslint-disable-line
|
|
28755
|
+
var skyProceduralVs = "#define GLSLIFY 1\n// 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#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\t// Rayleigh constant\n#define MIE 0.0010\t// Mie constant\n#define SUN_BRIGHTNESS 20.0\t// Sun brightness\n#define MAX_SCATTER 50.0 // Maximum scattering value, to prevent math overflows on Adrenos\n\nconst float SKY_GROUND_THRESHOLD = 0.02;\nconst float outerRadius = OUTER_RADIUS;\nconst float outerRadius2 = OUTER_RADIUS*OUTER_RADIUS;\nconst float innerRadius = 1.0;\nconst float innerRadius2 = 1.0;\nconst float cameraHeight = 0.0001;\n\nconst float HDSundiskIntensityFactor = 15.0;\nconst float simpleSundiskIntensityFactor = 27.0;\n\nconst float sunScale = 400.0 * SUN_BRIGHTNESS;\nconst float kmESun = MIE * SUN_BRIGHTNESS;\nconst float km4PI = MIE * 4.0 * 3.14159265;\nconst float scale = 1.0 / (OUTER_RADIUS - 1.0);\nconst float scaleDepth = 0.25;\nconst float scaleOverScaleDepth = (1.0 / (OUTER_RADIUS - 1.0)) / 0.25;\nconst float samples = 2.0; // THIS IS UNROLLED MANUALLY, DON'T TOUCH\n\n// RGB wavelengths .35 (.62=158), .43 (.68=174), .525 (.75=190)\nconst vec3 c_DefaultScatteringWavelength = vec3(0.65, 0.57, 0.475);\nconst vec3 c_VariableRangeForScatteringWavelength = vec3(0.15, 0.15, 0.15);\n\nattribute vec4 POSITION;\n\nuniform mat4 camera_VPMat;\nuniform vec3 material_SkyTint;\nuniform vec3 material_GroundTint;\nuniform float material_Exposure;\nuniform float material_AtmosphereThickness;\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#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n\t#define COLOR_2_GAMMA(color) color\n\t#define COLOR_2_LINEAR(color) color*color\n#else\n\t#define GAMMA 2.2\n\t#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n\t#define COLOR_2_LINEAR(color) color\n#endif\n\n// Calculates the Rayleigh phase function\nfloat getRayleighPhase(vec3 light, vec3 ray) \n{\n\tfloat eyeCos = dot(light, ray);\n\treturn 0.75 + 0.75 * eyeCos * eyeCos;\n}\n\nfloat scaleAngle(float inCos)\n{\n\tfloat x = 1.0 - inCos;\n\treturn 0.25 * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\n}\n\nvoid main () {\n\tgl_Position = camera_VPMat*vec4(POSITION.xyz,1.0);\n\n \tvec3 skyTintInGammaSpace = COLOR_2_GAMMA(material_SkyTint);\n\tvec3 scatteringWavelength = mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0) - skyTintInGammaSpace); // using Tint in sRGB+ gamma allows for more visually linear interpolation and to keep (0.5) at (128, gray in sRGB) point\n\tvec3 invWavelength = 1.0 / pow(scatteringWavelength, vec3(4.0));\n\n\tfloat krESun = RAYLEIGH * SUN_BRIGHTNESS;\n\tfloat kr4PI = RAYLEIGH * 4.0 * 3.14159265;\n\n\tvec3 cameraPos = vec3(0.0,innerRadius + cameraHeight,0.0); // The camera's current position\n\n\t// Get the ray from the camera to the vertex and its length (which is the far point of the ray passing through the atmosphere)\n\tvec3 eyeRay = normalize(POSITION.xyz);\n\n\tfloat far = 0.0;\n\tvec3 cIn, cOut;\n\tif (eyeRay.y >= 0.0) {\n\t\t// Sky \n\t\t// Calculate the length of the \"atmosphere\"\n\t\tfar = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\n\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\n\t\tfloat height = innerRadius + cameraHeight;\n\t\tfloat depth = exp(scaleOverScaleDepth * -cameraHeight);\n\t\tfloat startAngle = dot(eyeRay, cameraPos) / height;\n\t\tfloat startOffset = depth*scaleAngle(startAngle);\n\n\t\t// Initialize the scattering loop variables\n\t\tfloat sampleLength = far / samples;\n\t\tfloat scaledLength = sampleLength * scale;\n\t\tvec3 sampleRay = eyeRay * sampleLength;\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n\t\tvec3 frontColor = vec3(0.0);\n\t\t//unrolling this manually to avoid some platform for loop slow\n\t\t{\n\t\t\tfloat height = length(samplePoint);\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\n\t\t\tfloat lightAngle = dot(-scene_SunlightDirection, samplePoint) / height;\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\n\t\t\tsamplePoint += sampleRay;\n\t\t}\n\t\t{\n\t\t\tfloat height = length(samplePoint);\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\n\t\t\tfloat lightAngle = dot(-scene_SunlightDirection, samplePoint) / height;\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\n\t\t\tsamplePoint += sampleRay;\n\t\t}\n\n\t\t// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\n\t\tcIn = frontColor * (invWavelength * krESun);\n\t\tcOut = frontColor * kmESun;\n\t} else {\n\t\t// Ground\n\t\tfar = (-cameraHeight) / (min(-0.001, eyeRay.y));\n\t\tvec3 pos = cameraPos + far * eyeRay;\n\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\n\t\tfloat depth = exp((-cameraHeight) * (1.0/scaleDepth));\n\t\tfloat cameraAngle = dot(-eyeRay, pos);\n\t\tfloat lightAngle = dot(-scene_SunlightDirection, pos);\n\t\tfloat cameraScale = scaleAngle(cameraAngle);\n\t\tfloat lightScale = scaleAngle(lightAngle);\n\t\tfloat cameraOffset = depth*cameraScale;\n\t\tfloat temp = lightScale + cameraScale;\n\n\t\t// Initialize the scattering loop variables\n\t\tfloat sampleLength = far / samples;\n\t\tfloat scaledLength = sampleLength * scale;\n\t\tvec3 sampleRay = eyeRay * sampleLength;\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n\t\t// Now loop through the sample rays\n\t\tvec3 frontColor = vec3(0.0, 0.0, 0.0);\n\t\tvec3 attenuate;\n\n\t\t// Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much\n\t\t{\n\t\t\tfloat height = length(samplePoint);\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\n\t\t\tfloat scatter = depth*temp - cameraOffset;\n\t\t\tattenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\n\t\t\tsamplePoint += sampleRay;\n\t\t}\n\n\t\tcIn = frontColor * (invWavelength * krESun + kmESun);\n\t\tcOut = clamp(attenuate, 0.0, 1.0);\n\t}\n\n\t#ifdef MATERIAL_SUN_HIGH_QUALITY\n\t\tv_Vertex = -POSITION.xyz;\n\t#elif defined(MATERIAL_SUN_SIMPLE) \n\t\tv_RayDir = -eyeRay;\n\t#else\n\t\tv_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\n\t#endif\n\n\t// if we want to calculate color in vprog:\n\t// 1. in case of linear: multiply by _Exposure in here (even in case of lerp it will be common multiplier, so we can skip mul in fshader)\n\t// 2. in case of gamma: do sqrt right away instead of doing that in fshader\n\t\n\tv_GroundColor = material_Exposure * (cIn + COLOR_2_LINEAR(material_GroundTint) * cOut);\n\tv_SkyColor = material_Exposure * (cIn * getRayleighPhase(-scene_SunlightDirection, -eyeRay));\n\n\t\n\t// The sun should have a stable intensity in its course in the sky. Moreover it should match the highlight of a purely specular material.\n\t// This matching was done using the standard shader BRDF1 on the 5/31/2017\n\t// Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\n\tfloat lightColorIntensity = clamp(length(scene_SunlightColor.xyz), 0.25, 1.0);\n\n\t#ifdef MATERIAL_SUN_HIGH_QUALITY \n\t\tv_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * scene_SunlightColor.xyz / lightColorIntensity;\n\t#elif defined(MATERIAL_SUN_SIMPLE) \n\t\tv_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * scene_SunlightColor.xyz / lightColorIntensity;\n\t#endif\n}\n"; // eslint-disable-line
|
|
28756
|
+
var backgroundTextureFs = "#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;\n\nvarying vec2 v_uv;\n\nvoid main() {\n gl_FragColor = texture2D(material_BaseTexture, v_uv);\n}"; // eslint-disable-line
|
|
28757
|
+
var backgroundTextureVs = "#define GLSLIFY 1\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nvarying vec2 v_uv;\nuniform vec4 camera_ProjectionParams;\n\nvoid main() {\n gl_Position = vec4(POSITION, 1.0);\n gl_Position.y *= camera_ProjectionParams.x;\n \n v_uv = TEXCOORD_0;\n}"; // eslint-disable-line
|
|
28758
|
+
var blinnPhongFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n\n#include <FogFragmentDeclaration>\n#include <normal_get>\n\nvoid main() {\n\n #include <begin_mobile_frag>\n #include <begin_viewdir_frag>\n #include <mobile_blinnphong_frag>\n\n gl_FragColor = emission + ambient + diffuse + specular;\n\n #ifdef MATERIAL_IS_TRANSPARENT\n gl_FragColor.a = diffuse.a;\n #else\n gl_FragColor.a = 1.0;\n #endif\n\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
|
|
28759
|
+
var blinnPhongVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <color_vert>\n #include <normal_vert>\n #include <worldpos_vert>\n #include <position_vert>\n\n #include <ShadowVertex>\n #include <FogVertex>\n}\n"; // eslint-disable-line
|
|
28760
|
+
var depthOnlyFs = "#define GLSLIFY 1\nvoid main() {\n}"; // eslint-disable-line
|
|
28761
|
+
var depthOnlyVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <position_vert>\n\n}\n"; // eslint-disable-line
|
|
28762
|
+
var particleFs = "#define GLSLIFY 1\n#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n\n#ifdef RENDERER_MODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\nvoid main() {\n\tvec4 color = material_BaseColor * v_Color;\n\n\t#ifdef RENDERER_MODE_MESH\n\t\tcolor *= v_MeshColor;\n\t#endif\n\n\t#ifdef MATERIAL_HAS_BASETEXTURE\n\t\tvec4 textureColor = texture2D(material_BaseTexture,v_TextureCoordinate);\n\t\t#ifndef ENGINE_IS_COLORSPACE_GAMMA\n textureColor = gammaToLinear(textureColor);\n #endif\n\t\tcolor *= textureColor;\n\t#endif\n\tgl_FragColor = color; \n\n\t #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
28763
|
+
var particleVs = "#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 a_MeshPosition;\n attribute vec4 a_MeshColor;\n attribute vec2 a_MeshTextureCoordinate;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 u_DragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n vec3 lifeVelocity;\n if (normalizedAge < 1.0) {\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n lifeVelocity = computeParticleLifeVelocity(normalizedAge); \n #endif\n \n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n //drag\n vec3 dragData = a_DirectionTime.xyz * mix(u_DragConstant.x, u_DragConstant.y, a_Random0.x);\n vec3 center = computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge, gravityVelocity, worldRotation, dragData); //计算粒子位置\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.xy + a_MeshTextureCoordinate * a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n\t gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}\n"; // eslint-disable-line
|
|
28764
|
+
var pbrSpecularFs = "#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
|
|
28765
|
+
var pbrFs = "#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
|
|
28766
|
+
var pbrVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <color_vert>\n #include <normal_vert>\n #include <worldpos_vert>\n #include <position_vert>\n\n #include <ShadowVertex>\n #include <FogVertex>\n}\n"; // eslint-disable-line
|
|
28767
|
+
var shadowMapFs = "#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\n /**\n * Decompose and save depth value.\n */\n vec4 pack (float depth) {\n // Use rgba 4 bytes with a total of 32 bits to store the z value, and the accuracy of 1 byte is 1/256.\n const vec4 bitShift = vec4(1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0);\n const vec4 bitMask = vec4(1.0/256.0, 1.0/256.0, 1.0/256.0, 0.0);\n\n vec4 rgbaDepth = fract(depth * bitShift); // Calculate the z value of each point\n\n // Cut off the value which do not fit in 8 bits\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n\n return rgbaDepth;\n }\n#endif\n\nuniform vec4 material_BaseColor;\nuniform sampler2D material_BaseTexture;\nuniform float material_AlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main() {\n #if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\n float alpha = material_BaseColor.a;\n #ifdef MATERIAL_HAS_BASETEXTURE\n alpha *= texture2D(material_BaseTexture, v_uv).a;\n #endif\n \n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if(alpha < material_AlphaCutoff){\n discard;\n }\n #endif\n \n #if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\n // Interleaved gradient noise\n float noise = fract(52.982919 * fract(dot(vec2(0.06711, 0.00584), gl_FragCoord.xy)));\n if (alpha <= noise) {\n discard;\n };\n #endif\n #endif\n\n #ifdef ENGINE_NO_DEPTH_TEXTURE\n gl_FragColor = pack(gl_FragCoord.z);\n #else\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}"; // eslint-disable-line
|
|
28768
|
+
var shadowMapVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\n#include <uv_share>\nuniform mat4 camera_VPMat;\nuniform vec2 scene_ShadowBias; // x: depth bias, y: normal bias\nuniform vec3 scene_LightDirection;\n\nvec3 applyShadowBias(vec3 positionWS) {\n positionWS -= scene_LightDirection * scene_ShadowBias.x;\n return positionWS;\n}\n\nvec3 applyShadowNormalBias(vec3 positionWS, vec3 normalWS) {\n float invNdotL = 1.0 - clamp(dot(-scene_LightDirection, normalWS), 0.0, 1.0);\n float scale = invNdotL * scene_ShadowBias.y;\n positionWS += normalWS * vec3(scale);\n return positionWS;\n}\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n \n vec4 positionWS = renderer_ModelMat * position;\n\n positionWS.xyz = applyShadowBias(positionWS.xyz);\n #ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n vec3 normalWS = normalize( mat3(renderer_NormalMat) * normal );\n positionWS.xyz = applyShadowNormalBias(positionWS.xyz, normalWS);\n #endif\n #endif\n\n vec4 positionCS = camera_VPMat * positionWS;\n positionCS.z = max(positionCS.z, -1.0);// clamp to min ndc z\n\n gl_Position = positionCS;\n\n}\n"; // eslint-disable-line
|
|
28769
|
+
var skyboxFs = "#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;\n\nvarying vec3 v_cubeUV;\nuniform float material_Exposure;\nuniform vec4 material_TintColor;\n\nvoid main() {\n vec4 textureColor = textureCube( material_CubeTexture, v_cubeUV );\n\n #ifdef MATERIAL_IS_DECODE_SKY_RGBM\n textureColor = RGBMToLinear(textureColor, 5.0);\n #elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\n textureColor = gammaToLinear(textureColor);\n #endif\n\n textureColor.rgb *= material_Exposure * material_TintColor.rgb;\n \n gl_FragColor = textureColor;\n\n #if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
|
|
28770
|
+
var skyboxVs = "#define GLSLIFY 1\n#include <common_vert>\n\nuniform mat4 camera_VPMat;\n\nvarying vec3 v_cubeUV;\nuniform float material_Rotation;\n\nvec4 rotateY(vec4 v, float angle) {\n\tconst float deg2rad = 3.1415926 / 180.0;\n\tfloat radian = angle * deg2rad;\n\tfloat sina = sin(radian);\n\tfloat cosa = cos(radian);\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\n\treturn vec4(m * v.xz, v.yw).xzyw;\n}\n\nvoid main() {\n v_cubeUV = vec3( -POSITION.x, POSITION.yz ); // TextureCube is left-hand,so x need inverse\n gl_Position = camera_VPMat * rotateY(vec4(POSITION, 1.0), material_Rotation);\n}\n"; // eslint-disable-line
|
|
28771
|
+
var spriteMaskFs = "#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;\nuniform float renderer_MaskAlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main()\n{\n vec4 color = texture2D(renderer_MaskTexture, v_uv);\n if (color.a < renderer_MaskAlphaCutoff) {\n discard;\n }\n\n gl_FragColor = color;\n}\n"; // eslint-disable-line
|
|
28772
|
+
var spriteMaskVs = "#define GLSLIFY 1\nuniform mat4 camera_VPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\n\nvarying vec2 v_uv;\n\nvoid main()\n{\n gl_Position = camera_VPMat * vec4(POSITION, 1.0);\n v_uv = TEXCOORD_0;\n}\n"; // eslint-disable-line
|
|
28773
|
+
var spriteFs = "#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 baseColor = texture2D(renderer_SpriteTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n"; // eslint-disable-line
|
|
28774
|
+
var spriteVs = "#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nattribute vec4 COLOR_0;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n\n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n}\n"; // eslint-disable-line
|
|
28775
|
+
var textFs = "#define GLSLIFY 1\nuniform sampler2D renderElement_TextTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 baseColor = texture2D(renderElement_TextTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n"; // eslint-disable-line
|
|
28776
|
+
var textVs = "#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nattribute vec4 COLOR_0;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n\n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n}\n"; // eslint-disable-line
|
|
28777
|
+
var unlitFs = "#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\n\nuniform vec4 material_BaseColor;\nuniform float material_AlphaCutoff;\n\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\nvoid main() {\n vec4 baseColor = material_BaseColor;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec4 textureColor = texture2D(material_BaseTexture, v_uv);\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n textureColor = gammaToLinear(textureColor);\n #endif\n baseColor *= textureColor;\n #endif\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( baseColor.a < material_AlphaCutoff ) {\n discard;\n }\n #endif\n\n gl_FragColor = baseColor;\n\n #ifndef MATERIAL_IS_TRANSPARENT\n gl_FragColor.a = 1.0;\n #endif\n\n #include <FogFragment>\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
|
|
28778
|
+
var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <position_vert>\n\n #include <FogVertex>\n}\n"; // eslint-disable-line
|
|
27981
28779
|
/**
|
|
27982
28780
|
* Internal shader pool.
|
|
27983
28781
|
* @internal
|
|
@@ -28194,7 +28992,7 @@
|
|
|
28194
28992
|
_inherits$2(Engine, EventDispatcher);
|
|
28195
28993
|
function Engine(canvas, hardwareRenderer, configuration) {
|
|
28196
28994
|
var _this;
|
|
28197
|
-
_this = EventDispatcher.call(this) || this, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._subRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._textSubRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramPools = [], /** @internal */ _this._fontMap = {}, /** @internal @todo: temporary solution */ _this._macroCollection = new ShaderMacroCollection(), _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._frameInProcess = false, _this._waitingDestroy = false, _this._isDeviceLost = false, _this._waitingGC = false, _this._animate = function() {
|
|
28995
|
+
_this = EventDispatcher.call(this) || this, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._subRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._textSubRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramPools = [], /** @internal */ _this._fontMap = {}, /** @internal @todo: temporary solution */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._frameInProcess = false, _this._waitingDestroy = false, _this._isDeviceLost = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._animate = function() {
|
|
28198
28996
|
if (_this._vSyncCount) {
|
|
28199
28997
|
var _this_xrManager;
|
|
28200
28998
|
var raf = ((_this_xrManager = _this.xrManager) == null ? void 0 : _this_xrManager._getRequestAnimationFrame()) || requestAnimationFrame;
|
|
@@ -28241,6 +29039,8 @@
|
|
|
28241
29039
|
innerSettings.colorSpace = colorSpace;
|
|
28242
29040
|
_this._basicResources = new BasicResources(_this);
|
|
28243
29041
|
_this._particleBufferUtils = new ParticleBufferUtils(_this);
|
|
29042
|
+
var uberPass = new PostProcessUberPass(_this);
|
|
29043
|
+
_this.addPostProcessPass(uberPass);
|
|
28244
29044
|
return _this;
|
|
28245
29045
|
}
|
|
28246
29046
|
var _proto = Engine.prototype;
|
|
@@ -28288,6 +29088,7 @@
|
|
|
28288
29088
|
(_this_xrManager = this.xrManager) == null ? void 0 : _this_xrManager._update();
|
|
28289
29089
|
var _this = this, inputManager = _this.inputManager, physicsInitialized = _this._physicsInitialized;
|
|
28290
29090
|
inputManager._update();
|
|
29091
|
+
this._refreshActivePostProcessPasses();
|
|
28291
29092
|
var scenes = this._sceneManager._scenes.getLoopArray();
|
|
28292
29093
|
var sceneCount = scenes.length;
|
|
28293
29094
|
// Sort cameras and fire script `onStart`
|
|
@@ -28364,6 +29165,58 @@
|
|
|
28364
29165
|
*/ _proto.forceRestoreDevice = function forceRestoreDevice() {
|
|
28365
29166
|
this._hardwareRenderer.forceRestoreDevice();
|
|
28366
29167
|
};
|
|
29168
|
+
/**
|
|
29169
|
+
* Add a post process pass.
|
|
29170
|
+
* @param pass - Post process pass to add
|
|
29171
|
+
*/ _proto.addPostProcessPass = function addPostProcessPass(pass) {
|
|
29172
|
+
if (pass.engine !== this) {
|
|
29173
|
+
throw "The pass is not belong to this engine.";
|
|
29174
|
+
}
|
|
29175
|
+
var passes = this._postProcessPasses;
|
|
29176
|
+
if (passes.indexOf(pass) === -1) {
|
|
29177
|
+
passes.push(pass);
|
|
29178
|
+
pass.isActive && (this._postProcessPassNeedRefresh = true);
|
|
29179
|
+
}
|
|
29180
|
+
};
|
|
29181
|
+
/**
|
|
29182
|
+
* @internal
|
|
29183
|
+
*/ _proto._removePostProcessPass = function _removePostProcessPass(pass) {
|
|
29184
|
+
var passes = this._postProcessPasses;
|
|
29185
|
+
var index = passes.indexOf(pass);
|
|
29186
|
+
if (index !== -1) {
|
|
29187
|
+
passes.splice(index, 1);
|
|
29188
|
+
pass.isActive && (this._postProcessPassNeedRefresh = true);
|
|
29189
|
+
}
|
|
29190
|
+
};
|
|
29191
|
+
/**
|
|
29192
|
+
* @internal
|
|
29193
|
+
*/ _proto._refreshActivePostProcessPasses = function _refreshActivePostProcessPasses() {
|
|
29194
|
+
if (this._postProcessPassNeedRefresh) {
|
|
29195
|
+
this._postProcessPassNeedRefresh = false;
|
|
29196
|
+
var postProcessPasses = this._postProcessPasses;
|
|
29197
|
+
var activePostProcesses = this._activePostProcessPasses;
|
|
29198
|
+
activePostProcesses.length = 0;
|
|
29199
|
+
// Filter
|
|
29200
|
+
for(var i = 0, n = postProcessPasses.length; i < n; i++){
|
|
29201
|
+
var pass = postProcessPasses[i];
|
|
29202
|
+
if (pass.isActive) {
|
|
29203
|
+
activePostProcesses.push(pass);
|
|
29204
|
+
}
|
|
29205
|
+
}
|
|
29206
|
+
// Sort
|
|
29207
|
+
if (activePostProcesses.length) {
|
|
29208
|
+
activePostProcesses.sort(function(a, b) {
|
|
29209
|
+
return a.event - b.event;
|
|
29210
|
+
});
|
|
29211
|
+
}
|
|
29212
|
+
}
|
|
29213
|
+
};
|
|
29214
|
+
/**
|
|
29215
|
+
* @internal
|
|
29216
|
+
*/ _proto._getActivePostProcessPasses = function _getActivePostProcessPasses() {
|
|
29217
|
+
this._refreshActivePostProcessPasses();
|
|
29218
|
+
return this._activePostProcessPasses;
|
|
29219
|
+
};
|
|
28367
29220
|
_proto._destroy = function _destroy() {
|
|
28368
29221
|
var _this_xrManager;
|
|
28369
29222
|
this._sceneManager._destroyAllScene();
|
|
@@ -28429,6 +29282,8 @@
|
|
|
28429
29282
|
cameras.forEach(function(camera) {
|
|
28430
29283
|
var componentsManager = scene._componentsManager;
|
|
28431
29284
|
componentsManager.callCameraOnBeginRender(camera);
|
|
29285
|
+
// Update post process manager
|
|
29286
|
+
scene.postProcessManager._update(camera);
|
|
28432
29287
|
camera.render();
|
|
28433
29288
|
componentsManager.callCameraOnEndRender(camera);
|
|
28434
29289
|
// Temp solution for webgl implement bug
|
|
@@ -28595,6 +29450,14 @@
|
|
|
28595
29450
|
this._targetFrameInterval = 1000 / value;
|
|
28596
29451
|
}
|
|
28597
29452
|
},
|
|
29453
|
+
{
|
|
29454
|
+
key: "postProcessPasses",
|
|
29455
|
+
get: /**
|
|
29456
|
+
* All post process passes.
|
|
29457
|
+
*/ function get() {
|
|
29458
|
+
return this._postProcessPasses;
|
|
29459
|
+
}
|
|
29460
|
+
},
|
|
28598
29461
|
{
|
|
28599
29462
|
key: "destroyed",
|
|
28600
29463
|
get: /**
|
|
@@ -29967,434 +30830,312 @@
|
|
|
29967
30830
|
/**
|
|
29968
30831
|
* Each type of light source is at most 10, beyond which it will not take effect.
|
|
29969
30832
|
* */ LightManager._maxLight = 10;
|
|
29970
|
-
var fragBlurH = "#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy*2.0;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*4.0,0.0));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*3.0,0.0));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*2.0,0.0));mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*1.0,0.0));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c5=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*1.0,0.0));mediump vec4 c6=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*2.0,0.0));mediump vec4 c7=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*3.0,0.0));mediump vec4 c8=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*4.0,0.0));gl_FragColor=c0*0.01621622+c1*0.05405405+c2*0.12162162+c3*0.19459459+c4*0.22702703+c5*0.19459459+c6*0.12162162+c7*0.05405405+c8*0.01621622;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
|
|
29971
|
-
var fragBlurV = "#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*3.23076923));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*1.38461538));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*1.38461538));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*3.23076923));gl_FragColor=c0*0.07027027+c1*0.31621622+c2*0.22702703+c3*0.31621622+c4*0.07027027;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
|
|
29972
|
-
var fragPrefilter = "#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 material_BloomParams;uniform vec4 renderer_texelSize;void main(){\n#ifdef BLOOM_HQ\nvec2 texelSize=renderer_texelSize.xy;mediump vec4 A=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,-1.0));mediump vec4 B=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,-1.0));mediump vec4 C=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,-1.0));mediump vec4 D=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,-0.5));mediump vec4 E=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,-0.5));mediump vec4 F=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,0.0));mediump vec4 G=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 H=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,0.0));mediump vec4 I=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,0.5));mediump vec4 J=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,0.5));mediump vec4 K=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,1.0));mediump vec4 L=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,1.0));mediump vec4 M=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,1.0));mediump vec2 scale=vec2(0.5,0.125);mediump vec2 div=(1.0/4.0)*scale;mediump vec4 samplerColor=(D+E+I+J)*div.x;samplerColor+=(A+B+G+F)*div.y;samplerColor+=(B+C+H+G)*div.y;samplerColor+=(F+G+L+K)*div.y;samplerColor+=(G+H+M+L)*div.y;\n#else\nmediump vec4 samplerColor=sampleTexture(renderer_BlitTexture,v_uv);\n#endif\nmediump vec3 color=samplerColor.rgb;color=min(color,HALF_MAX);mediump float brightness=max3(color);float threshold=material_BloomParams.x;float thresholdKnee=material_BloomParams.y;mediump float softness=clamp(brightness-threshold+thresholdKnee,0.0,2.0*thresholdKnee);softness=(softness*softness)/(4.0*thresholdKnee+1e-4);mediump float multiplier=max(brightness-threshold,softness)/max(brightness,1e-4);color*=multiplier;color=max(color,0.0);gl_FragColor=vec4(color,samplerColor.a);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
|
|
29973
|
-
var fragUpsample = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform sampler2D material_lowMipTexture;uniform vec4 material_BloomParams;uniform vec4 material_lowMipTexelSize;void main(){mediump vec4 highMip=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef BLOOM_HQ\nmediump vec4 lowMip=sampleTexture2DBicubic(material_lowMipTexture,v_uv,material_lowMipTexelSize);\n#else\nmediump vec4 lowMip=sampleTexture(material_lowMipTexture,v_uv);\n#endif\ngl_FragColor=mix(highMip,lowMip,material_BloomParams.z);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
|
|
29974
30833
|
/**
|
|
29975
|
-
*
|
|
29976
|
-
*/ var
|
|
29977
|
-
|
|
29978
|
-
|
|
29979
|
-
|
|
29980
|
-
|
|
29981
|
-
*
|
|
29982
|
-
*/
|
|
29983
|
-
|
|
29984
|
-
|
|
29985
|
-
|
|
29986
|
-
function BloomEffect(_uberMaterial) {
|
|
29987
|
-
this._uberMaterial = _uberMaterial;
|
|
29988
|
-
this._highQualityFiltering = false;
|
|
29989
|
-
this._mipDownRT = [];
|
|
29990
|
-
this._mipUpRT = [];
|
|
29991
|
-
this._maxIterations = 6;
|
|
29992
|
-
this._enabled = false;
|
|
29993
|
-
this./**
|
|
29994
|
-
* Controls the starting resolution that this effect begins processing.
|
|
29995
|
-
*/ downScale = 0;
|
|
29996
|
-
var engine = _uberMaterial.engine;
|
|
29997
|
-
var material = new Material(engine, Shader.find(BloomEffect.SHADER_NAME));
|
|
29998
|
-
var depthState = material.renderState.depthState;
|
|
29999
|
-
depthState.enabled = false;
|
|
30000
|
-
depthState.writeEnabled = false;
|
|
30001
|
-
var bloomShaderData = material.shaderData;
|
|
30002
|
-
var uberShaderData = _uberMaterial.shaderData;
|
|
30003
|
-
bloomShaderData.setVector4(BloomEffect._bloomParams, new Vector4());
|
|
30004
|
-
bloomShaderData.setVector4(BloomEffect._lowMipTexelSizeProp, new Vector4());
|
|
30005
|
-
uberShaderData.setVector4(BloomEffect._bloomIntensityParams, new Vector4(1, 1, 0, 0));
|
|
30006
|
-
uberShaderData.setVector4(BloomEffect._dirtTilingOffsetProp, new Vector4());
|
|
30007
|
-
uberShaderData.setColor(BloomEffect._tintProp, new Color(1, 1, 1, 1));
|
|
30008
|
-
this._bloomMaterial = material;
|
|
30009
|
-
this.threshold = 0.9;
|
|
30010
|
-
this.scatter = 0.7;
|
|
30011
|
-
this.intensity = 1;
|
|
30012
|
-
this.dirtIntensity = 1;
|
|
30834
|
+
* Post Process component can be used for global or local post-processing.
|
|
30835
|
+
*/ var PostProcess = /*#__PURE__*/ function(Component) {
|
|
30836
|
+
_inherits$2(PostProcess, Component);
|
|
30837
|
+
function PostProcess() {
|
|
30838
|
+
var _this;
|
|
30839
|
+
_this = Component.apply(this, arguments) || this, /**
|
|
30840
|
+
* The layer to which the PostProcess belongs.
|
|
30841
|
+
*/ _this.layer = Layer.Layer0, /**
|
|
30842
|
+
* The outer distance to start blending from, only takes effect when the `isGlobal` is false.
|
|
30843
|
+
*/ _this.blendDistance = 0, /** @internal */ _this._effects = [], _this._priority = 0, _this._isGlobal = true;
|
|
30844
|
+
return _this;
|
|
30013
30845
|
}
|
|
30014
|
-
var _proto =
|
|
30015
|
-
|
|
30016
|
-
|
|
30017
|
-
|
|
30018
|
-
|
|
30019
|
-
|
|
30020
|
-
var
|
|
30021
|
-
|
|
30022
|
-
var
|
|
30023
|
-
|
|
30024
|
-
|
|
30025
|
-
|
|
30026
|
-
this._downsample(mipCount);
|
|
30027
|
-
// Up sample (bilinear by default, HQ filtering does bicubic instead
|
|
30028
|
-
this._upsample(mipCount);
|
|
30029
|
-
// Setup bloom on uber
|
|
30030
|
-
this._setupUber(camera);
|
|
30031
|
-
};
|
|
30032
|
-
_proto._calculateMipCount = function _calculateMipCount(tw, th) {
|
|
30033
|
-
var maxSize = Math.max(tw, th);
|
|
30034
|
-
var iterations = Math.floor(Math.log2(maxSize) - 1);
|
|
30035
|
-
return Math.min(Math.max(iterations, 1), this._maxIterations);
|
|
30036
|
-
};
|
|
30037
|
-
_proto._prefilter = function _prefilter(camera, srcTexture, tw, th, mipCount) {
|
|
30038
|
-
var engine = this._uberMaterial.engine;
|
|
30039
|
-
var internalColorTextureFormat = camera._getInternalColorTextureFormat();
|
|
30040
|
-
var mipWidth = tw, mipHeight = th;
|
|
30041
|
-
for(var i = 0; i < mipCount; i++){
|
|
30042
|
-
this._mipUpRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipUpRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode$1.Clamp, TextureFilterMode.Bilinear);
|
|
30043
|
-
this._mipDownRT[i] = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._mipDownRT[i], mipWidth, mipHeight, internalColorTextureFormat, null, false, false, 1, TextureWrapMode$1.Clamp, TextureFilterMode.Bilinear);
|
|
30044
|
-
mipWidth = Math.max(1, Math.floor(mipWidth / 2));
|
|
30045
|
-
mipHeight = Math.max(1, Math.floor(mipHeight / 2));
|
|
30046
|
-
}
|
|
30047
|
-
PipelineUtils.blitTexture(engine, srcTexture, this._mipDownRT[0], undefined, undefined, this._bloomMaterial, 0);
|
|
30048
|
-
};
|
|
30049
|
-
_proto._downsample = function _downsample(mipCount) {
|
|
30050
|
-
var material = this._bloomMaterial;
|
|
30051
|
-
var engine = material.engine;
|
|
30052
|
-
var lastDown = this._mipDownRT[0];
|
|
30053
|
-
// Down sample - gaussian pyramid
|
|
30054
|
-
for(var i = 1; i < mipCount; i++){
|
|
30055
|
-
// Classic two pass gaussian blur - use mipUp as a temporary target
|
|
30056
|
-
// First pass does 2x downsampling + 9-tap gaussian
|
|
30057
|
-
// Second pass does 9-tap gaussian using a 5-tap filter + bilinear filtering
|
|
30058
|
-
PipelineUtils.blitTexture(engine, lastDown.getColorTexture(0), this._mipUpRT[i], undefined, undefined, material, 1);
|
|
30059
|
-
PipelineUtils.blitTexture(engine, this._mipUpRT[i].getColorTexture(0), this._mipDownRT[i], undefined, undefined, material, 2);
|
|
30060
|
-
lastDown = this._mipDownRT[i];
|
|
30061
|
-
}
|
|
30062
|
-
};
|
|
30063
|
-
_proto._upsample = function _upsample(mipCount) {
|
|
30064
|
-
var material = this._bloomMaterial;
|
|
30065
|
-
var engine = material.engine;
|
|
30066
|
-
var shaderData = material.shaderData;
|
|
30067
|
-
// Up sample (bilinear by default, HQ filtering does bicubic instead
|
|
30068
|
-
for(var i = mipCount - 2; i >= 0; i--){
|
|
30069
|
-
var lowMip = i == mipCount - 2 ? this._mipDownRT[i + 1] : this._mipUpRT[i + 1];
|
|
30070
|
-
var highMip = this._mipDownRT[i];
|
|
30071
|
-
var dst = this._mipUpRT[i];
|
|
30072
|
-
shaderData.setTexture(BloomEffect._lowMipTextureProp, lowMip.getColorTexture(0));
|
|
30073
|
-
if (this.highQualityFiltering) {
|
|
30074
|
-
var texelSizeLow = shaderData.getVector4(BloomEffect._lowMipTexelSizeProp);
|
|
30075
|
-
texelSizeLow.set(1 / lowMip.width, 1 / lowMip.height, lowMip.width, lowMip.height);
|
|
30846
|
+
var _proto = PostProcess.prototype;
|
|
30847
|
+
/**
|
|
30848
|
+
* Get the PostProcessEffect by type.
|
|
30849
|
+
* @param type - The type of PostProcessEffect
|
|
30850
|
+
* @returns The PostProcessEffect found
|
|
30851
|
+
*/ _proto.getEffect = function getEffect(type) {
|
|
30852
|
+
var effects = this._effects;
|
|
30853
|
+
var length = effects.length;
|
|
30854
|
+
for(var i = 0; i < length; i++){
|
|
30855
|
+
var effect = effects[i];
|
|
30856
|
+
if (_instanceof1$2(effect, type)) {
|
|
30857
|
+
return effect;
|
|
30076
30858
|
}
|
|
30077
|
-
PipelineUtils.blitTexture(engine, highMip.getColorTexture(0), dst, undefined, undefined, material, 3);
|
|
30078
30859
|
}
|
|
30079
30860
|
};
|
|
30080
|
-
|
|
30081
|
-
|
|
30082
|
-
|
|
30083
|
-
|
|
30084
|
-
|
|
30085
|
-
|
|
30086
|
-
|
|
30087
|
-
|
|
30088
|
-
|
|
30089
|
-
} else if (dirtRatio < screenRatio) {
|
|
30090
|
-
dirtTilingOffset.set(1, dirtRatio / screenRatio, 0, (1 - dirtTilingOffset.y) * 0.5);
|
|
30091
|
-
} else {
|
|
30092
|
-
dirtTilingOffset.set(1, 1, 0, 0);
|
|
30093
|
-
}
|
|
30861
|
+
/**
|
|
30862
|
+
* Add a PostProcessEffect to the PostProcess.
|
|
30863
|
+
* @remarks Only one effect of the same type can be added to the PostProcess.
|
|
30864
|
+
* @param type - The type of PostProcessEffect
|
|
30865
|
+
* @returns The PostProcessEffect added
|
|
30866
|
+
*/ _proto.addEffect = function addEffect(type) {
|
|
30867
|
+
if (this.getEffect(type)) {
|
|
30868
|
+
Logger.error('effect "' + type.name + '" already exists in the PostProcess.');
|
|
30869
|
+
return;
|
|
30094
30870
|
}
|
|
30095
|
-
|
|
30871
|
+
var effect = new type();
|
|
30872
|
+
this._effects.push(effect);
|
|
30873
|
+
return effect;
|
|
30096
30874
|
};
|
|
30097
|
-
|
|
30098
|
-
|
|
30875
|
+
/**
|
|
30876
|
+
* Remove a PostProcessEffect from the PostProcess.
|
|
30877
|
+
* @param type - The type of PostProcessEffect
|
|
30878
|
+
* @returns The PostProcessEffect removed
|
|
30879
|
+
*/ _proto.removeEffect = function removeEffect(type) {
|
|
30880
|
+
var effects = this._effects;
|
|
30881
|
+
var length = effects.length;
|
|
30099
30882
|
for(var i = 0; i < length; i++){
|
|
30100
|
-
var
|
|
30101
|
-
|
|
30102
|
-
|
|
30103
|
-
|
|
30104
|
-
downRT.destroy(true);
|
|
30105
|
-
}
|
|
30106
|
-
if (upRT) {
|
|
30107
|
-
upRT.getColorTexture(0).destroy(true);
|
|
30108
|
-
upRT.destroy(true);
|
|
30883
|
+
var effect = effects[i];
|
|
30884
|
+
if (_instanceof1$2(effect, type)) {
|
|
30885
|
+
effects.splice(i, 1);
|
|
30886
|
+
return effect;
|
|
30109
30887
|
}
|
|
30110
30888
|
}
|
|
30111
|
-
this._mipDownRT.length = 0;
|
|
30112
|
-
this._mipUpRT.length = 0;
|
|
30113
30889
|
};
|
|
30114
|
-
|
|
30115
|
-
|
|
30116
|
-
|
|
30117
|
-
|
|
30118
|
-
|
|
30119
|
-
|
|
30120
|
-
|
|
30121
|
-
|
|
30122
|
-
|
|
30123
|
-
|
|
30124
|
-
|
|
30125
|
-
if (value) {
|
|
30126
|
-
this._uberMaterial.shaderData.enableMacro(BloomEffect._enableMacro);
|
|
30127
|
-
} else {
|
|
30128
|
-
this._uberMaterial.shaderData.disableMacro(BloomEffect._enableMacro);
|
|
30129
|
-
this._releaseRenderTargets();
|
|
30130
|
-
}
|
|
30131
|
-
}
|
|
30132
|
-
}
|
|
30133
|
-
},
|
|
30134
|
-
{
|
|
30135
|
-
key: "threshold",
|
|
30136
|
-
get: /**
|
|
30137
|
-
* Set the level of brightness to filter out pixels under this level.
|
|
30138
|
-
* @remarks This value is expressed in gamma-space.
|
|
30139
|
-
*/ function get() {
|
|
30140
|
-
return this._threshold;
|
|
30141
|
-
},
|
|
30142
|
-
set: function set(value) {
|
|
30143
|
-
value = Math.max(0, value);
|
|
30144
|
-
if (value !== this._threshold) {
|
|
30145
|
-
this._threshold = value;
|
|
30146
|
-
var threshold = Color.gammaToLinearSpace(value);
|
|
30147
|
-
var thresholdKnee = threshold * 0.5; // Hardcoded soft knee
|
|
30148
|
-
var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
|
|
30149
|
-
params.x = threshold;
|
|
30150
|
-
params.y = thresholdKnee;
|
|
30151
|
-
}
|
|
30152
|
-
}
|
|
30153
|
-
},
|
|
30154
|
-
{
|
|
30155
|
-
key: "scatter",
|
|
30156
|
-
get: /**
|
|
30157
|
-
* Controls the radius of the bloom effect.
|
|
30158
|
-
*/ function get() {
|
|
30159
|
-
return this._scatter;
|
|
30160
|
-
},
|
|
30161
|
-
set: function set(value) {
|
|
30162
|
-
value = MathUtil.clamp(value, 0, 1);
|
|
30163
|
-
if (value !== this._scatter) {
|
|
30164
|
-
this._scatter = value;
|
|
30165
|
-
var params = this._bloomMaterial.shaderData.getVector4(BloomEffect._bloomParams);
|
|
30166
|
-
var scatter = MathUtil.lerp(0.05, 0.95, value);
|
|
30167
|
-
params.z = scatter;
|
|
30168
|
-
}
|
|
30169
|
-
}
|
|
30170
|
-
},
|
|
30171
|
-
{
|
|
30172
|
-
key: "intensity",
|
|
30173
|
-
get: /**
|
|
30174
|
-
* Controls the strength of the bloom effect.
|
|
30175
|
-
*/ function get() {
|
|
30176
|
-
return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x;
|
|
30177
|
-
},
|
|
30178
|
-
set: function set(value) {
|
|
30179
|
-
value = Math.max(0, value);
|
|
30180
|
-
this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).x = value;
|
|
30181
|
-
}
|
|
30182
|
-
},
|
|
30183
|
-
{
|
|
30184
|
-
key: "tint",
|
|
30185
|
-
get: /**
|
|
30186
|
-
* Specifies the tint of the bloom effect.
|
|
30187
|
-
*/ function get() {
|
|
30188
|
-
return this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
|
|
30189
|
-
},
|
|
30190
|
-
set: function set(value) {
|
|
30191
|
-
var tint = this._uberMaterial.shaderData.getColor(BloomEffect._tintProp);
|
|
30192
|
-
if (value !== tint) {
|
|
30193
|
-
tint.copyFrom(value);
|
|
30194
|
-
}
|
|
30195
|
-
}
|
|
30196
|
-
},
|
|
30890
|
+
/**
|
|
30891
|
+
* @inheritdoc
|
|
30892
|
+
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
30893
|
+
this.scene.postProcessManager._addPostProcess(this);
|
|
30894
|
+
};
|
|
30895
|
+
/**
|
|
30896
|
+
* @inheritdoc
|
|
30897
|
+
*/ _proto._onDisableInScene = function _onDisableInScene() {
|
|
30898
|
+
this.scene.postProcessManager._removePostProcess(this);
|
|
30899
|
+
};
|
|
30900
|
+
_create_class$2(PostProcess, [
|
|
30197
30901
|
{
|
|
30198
|
-
key: "
|
|
30902
|
+
key: "isGlobal",
|
|
30199
30903
|
get: /**
|
|
30200
|
-
*
|
|
30201
|
-
* @remarks
|
|
30904
|
+
* Whether the PostProcess is global.
|
|
30905
|
+
* @remarks
|
|
30906
|
+
* Specifies whether to apply the PostProcess to the entire Scene or in Colliders.
|
|
30907
|
+
* Only support local PostProcess in physics enabled Scenes.
|
|
30202
30908
|
*/ function get() {
|
|
30203
|
-
return this.
|
|
30909
|
+
return this._isGlobal;
|
|
30204
30910
|
},
|
|
30205
30911
|
set: function set(value) {
|
|
30206
|
-
if (value !== this.
|
|
30207
|
-
this.
|
|
30208
|
-
|
|
30209
|
-
|
|
30210
|
-
this._uberMaterial.shaderData.enableMacro(BloomEffect._hqMacro);
|
|
30211
|
-
} else {
|
|
30212
|
-
this._bloomMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
|
|
30213
|
-
this._uberMaterial.shaderData.disableMacro(BloomEffect._hqMacro);
|
|
30912
|
+
if (value !== this._isGlobal) {
|
|
30913
|
+
if (!value && !this.engine._physicsInitialized) {
|
|
30914
|
+
Logger.warn("Only support local PostProcess in physics enabled Scenes.");
|
|
30915
|
+
return;
|
|
30214
30916
|
}
|
|
30917
|
+
this._isGlobal = value;
|
|
30215
30918
|
}
|
|
30216
30919
|
}
|
|
30217
30920
|
},
|
|
30218
30921
|
{
|
|
30219
|
-
key: "
|
|
30922
|
+
key: "priority",
|
|
30220
30923
|
get: /**
|
|
30221
|
-
*
|
|
30924
|
+
* A value which determines which PostProcess is being used when PostProcess have an equal amount of influence on the Scene.
|
|
30925
|
+
* @remarks
|
|
30926
|
+
* PostProcess with a higher priority will override lower ones.
|
|
30222
30927
|
*/ function get() {
|
|
30223
|
-
return this.
|
|
30928
|
+
return this._priority;
|
|
30224
30929
|
},
|
|
30225
30930
|
set: function set(value) {
|
|
30226
|
-
this.
|
|
30227
|
-
if (
|
|
30228
|
-
this.
|
|
30229
|
-
} else {
|
|
30230
|
-
this._uberMaterial.shaderData.disableMacro(BloomEffect._dirtMacro);
|
|
30931
|
+
this._priority = value;
|
|
30932
|
+
if (this.scene) {
|
|
30933
|
+
this.scene.postProcessManager._postProcessNeedSorting = true;
|
|
30231
30934
|
}
|
|
30232
30935
|
}
|
|
30233
|
-
},
|
|
30234
|
-
{
|
|
30235
|
-
key: "dirtIntensity",
|
|
30236
|
-
get: /**
|
|
30237
|
-
* Controls the strength of the lens dirt.
|
|
30238
|
-
*/ function get() {
|
|
30239
|
-
return this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y;
|
|
30240
|
-
},
|
|
30241
|
-
set: function set(value) {
|
|
30242
|
-
value = Math.max(0, value);
|
|
30243
|
-
this._uberMaterial.shaderData.getVector4(BloomEffect._bloomIntensityParams).y = value;
|
|
30244
|
-
}
|
|
30245
30936
|
}
|
|
30246
30937
|
]);
|
|
30247
|
-
return
|
|
30248
|
-
}();
|
|
30249
|
-
|
|
30250
|
-
|
|
30251
|
-
|
|
30252
|
-
BloomEffect._dirtMacro = ShaderMacro.getByName("BLOOM_DIRT");
|
|
30253
|
-
BloomEffect._bloomParams = ShaderProperty.getByName("material_BloomParams") // x: threshold (linear), y: threshold knee, z: scatter
|
|
30254
|
-
;
|
|
30255
|
-
BloomEffect._lowMipTextureProp = ShaderProperty.getByName("material_lowMipTexture");
|
|
30256
|
-
BloomEffect._lowMipTexelSizeProp = ShaderProperty.getByName("material_lowMipTexelSize") // x: 1/width, y: 1/height, z: width, w: height
|
|
30257
|
-
;
|
|
30258
|
-
// Uber shader properties
|
|
30259
|
-
BloomEffect._enableMacro = ShaderMacro.getByName("ENABLE_EFFECT_BLOOM");
|
|
30260
|
-
BloomEffect._bloomTextureProp = ShaderProperty.getByName("material_BloomTexture");
|
|
30261
|
-
BloomEffect._dirtTextureProp = ShaderProperty.getByName("material_BloomDirtTexture");
|
|
30262
|
-
BloomEffect._tintProp = ShaderProperty.getByName("material_BloomTint");
|
|
30263
|
-
BloomEffect._bloomIntensityParams = ShaderProperty.getByName("material_BloomIntensityParams") // x: bloom intensity, y: dirt intensity
|
|
30264
|
-
;
|
|
30265
|
-
BloomEffect._dirtTilingOffsetProp = ShaderProperty.getByName("material_BloomDirtTilingOffset");
|
|
30266
|
-
Shader.create(BloomEffect.SHADER_NAME, [
|
|
30267
|
-
new ShaderPass("Bloom Prefilter", blitVs, fragPrefilter),
|
|
30268
|
-
new ShaderPass("Bloom Blur Horizontal", blitVs, fragBlurH),
|
|
30269
|
-
new ShaderPass("Bloom Blur Vertical", blitVs, fragBlurV),
|
|
30270
|
-
new ShaderPass("Bloom Upsample", blitVs, fragUpsample)
|
|
30271
|
-
]);
|
|
30938
|
+
return PostProcess;
|
|
30939
|
+
}(Component);
|
|
30940
|
+
__decorate$1([
|
|
30941
|
+
deepClone
|
|
30942
|
+
], PostProcess.prototype, "_effects", void 0);
|
|
30272
30943
|
/**
|
|
30273
|
-
*
|
|
30274
|
-
*/ var
|
|
30944
|
+
* A global manager of the PostProcess.
|
|
30945
|
+
*/ var PostProcessManager = /*#__PURE__*/ function() {
|
|
30946
|
+
function PostProcessManager(scene) {
|
|
30947
|
+
this.scene = scene;
|
|
30948
|
+
this./** @internal */ _postProcessNeedSorting = false;
|
|
30949
|
+
this./** @internal */ _postProcessPassNeedSorting = false;
|
|
30950
|
+
this._activePostProcesses = [];
|
|
30951
|
+
this._blendEffectMap = new Map();
|
|
30952
|
+
this._defaultEffectMap = new Map();
|
|
30953
|
+
this._remainActivePassCount = 0;
|
|
30954
|
+
}
|
|
30955
|
+
var _proto = PostProcessManager.prototype;
|
|
30275
30956
|
/**
|
|
30276
|
-
*
|
|
30277
|
-
*
|
|
30278
|
-
*/
|
|
30957
|
+
* @internal
|
|
30958
|
+
* Whether has any valid post process pass.
|
|
30959
|
+
*/ _proto._isValid = function _isValid() {
|
|
30960
|
+
var scene = this.scene;
|
|
30961
|
+
var engine = scene.engine;
|
|
30962
|
+
var activePasses = engine._getActivePostProcessPasses();
|
|
30963
|
+
return activePasses.some(function(pass) {
|
|
30964
|
+
return pass.isValid(scene.postProcessManager);
|
|
30965
|
+
});
|
|
30966
|
+
};
|
|
30279
30967
|
/**
|
|
30280
|
-
*
|
|
30281
|
-
|
|
30282
|
-
|
|
30283
|
-
|
|
30284
|
-
|
|
30285
|
-
|
|
30286
|
-
|
|
30287
|
-
|
|
30288
|
-
|
|
30289
|
-
|
|
30290
|
-
|
|
30291
|
-
|
|
30292
|
-
|
|
30293
|
-
|
|
30294
|
-
|
|
30295
|
-
|
|
30296
|
-
|
|
30297
|
-
|
|
30298
|
-
|
|
30299
|
-
|
|
30300
|
-
|
|
30301
|
-
|
|
30302
|
-
|
|
30303
|
-
|
|
30304
|
-
if (
|
|
30305
|
-
|
|
30306
|
-
}
|
|
30307
|
-
|
|
30968
|
+
* @internal
|
|
30969
|
+
*/ _proto._update = function _update(camera) {
|
|
30970
|
+
// Start by resetting post process effect instance to default values
|
|
30971
|
+
this._resetDefaultValue();
|
|
30972
|
+
// Sort post process
|
|
30973
|
+
this._sortActivePostProcess();
|
|
30974
|
+
var activePostProcesses = this._activePostProcesses;
|
|
30975
|
+
for(var i = 0, n = activePostProcesses.length; i < n; i++){
|
|
30976
|
+
var postProcess = activePostProcesses[i];
|
|
30977
|
+
if (!(camera.postProcessMask & postProcess.layer)) {
|
|
30978
|
+
continue;
|
|
30979
|
+
}
|
|
30980
|
+
var isGlobal = postProcess.isGlobal;
|
|
30981
|
+
var interpFactor = 1; // Global default value
|
|
30982
|
+
if (!isGlobal) {
|
|
30983
|
+
var currentColliders = PostProcessManager._tempColliders;
|
|
30984
|
+
var cameraPosition = camera.entity.transform.worldPosition;
|
|
30985
|
+
var blendDistance = postProcess.blendDistance;
|
|
30986
|
+
var hasColliderShape = false;
|
|
30987
|
+
// Find closest distance to current postProcess, 0 means it's inside it
|
|
30988
|
+
var closestDistance = Number.POSITIVE_INFINITY;
|
|
30989
|
+
postProcess.entity.getComponents(exports.Collider, currentColliders);
|
|
30990
|
+
for(var i1 = 0; i1 < currentColliders.length; i1++){
|
|
30991
|
+
var collider = currentColliders[i1];
|
|
30992
|
+
if (!collider.enabled) {
|
|
30993
|
+
continue;
|
|
30994
|
+
}
|
|
30995
|
+
var shapes = collider.shapes;
|
|
30996
|
+
for(var j = 0; j < shapes.length; j++){
|
|
30997
|
+
var currentShape = shapes[j];
|
|
30998
|
+
hasColliderShape = true;
|
|
30999
|
+
var distance = currentShape.getClosestPoint(cameraPosition, PostProcessManager._tempVector3);
|
|
31000
|
+
if (distance < closestDistance) {
|
|
31001
|
+
closestDistance = distance;
|
|
31002
|
+
}
|
|
30308
31003
|
}
|
|
30309
31004
|
}
|
|
31005
|
+
if (!hasColliderShape) {
|
|
31006
|
+
Logger.warn('No collider shape found in the entity:"' + postProcess.entity.name + '", the local mode of post process will not take effect.');
|
|
31007
|
+
continue;
|
|
31008
|
+
}
|
|
31009
|
+
// Post process has no influence, ignore it
|
|
31010
|
+
if (closestDistance > blendDistance) {
|
|
31011
|
+
continue;
|
|
31012
|
+
}
|
|
31013
|
+
if (blendDistance > 0) {
|
|
31014
|
+
interpFactor = 1 - closestDistance / blendDistance;
|
|
31015
|
+
}
|
|
30310
31016
|
}
|
|
30311
|
-
|
|
30312
|
-
|
|
30313
|
-
|
|
30314
|
-
|
|
30315
|
-
|
|
30316
|
-
*/ function get() {
|
|
30317
|
-
return this._mode;
|
|
30318
|
-
},
|
|
30319
|
-
set: function set(value) {
|
|
30320
|
-
if (value !== this._mode) {
|
|
30321
|
-
this._mode = value;
|
|
30322
|
-
this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE", value.toString());
|
|
31017
|
+
var effects = postProcess._effects;
|
|
31018
|
+
for(var j1 = 0; j1 < effects.length; j1++){
|
|
31019
|
+
var effect = effects[j1];
|
|
31020
|
+
if (!effect.enabled) {
|
|
31021
|
+
continue;
|
|
30323
31022
|
}
|
|
31023
|
+
var PostConstructor = effect.constructor;
|
|
31024
|
+
var blendEffect = this._blendEffectMap.get(PostConstructor);
|
|
31025
|
+
if (!blendEffect) {
|
|
31026
|
+
blendEffect = new PostConstructor();
|
|
31027
|
+
this._blendEffectMap.set(PostConstructor, blendEffect);
|
|
31028
|
+
}
|
|
31029
|
+
blendEffect._lerp(effect, interpFactor);
|
|
31030
|
+
blendEffect.enabled = true;
|
|
30324
31031
|
}
|
|
30325
31032
|
}
|
|
30326
|
-
|
|
30327
|
-
|
|
30328
|
-
|
|
30329
|
-
|
|
30330
|
-
|
|
30331
|
-
|
|
30332
|
-
|
|
30333
|
-
|
|
30334
|
-
|
|
30335
|
-
|
|
30336
|
-
|
|
30337
|
-
|
|
30338
|
-
|
|
30339
|
-
|
|
30340
|
-
var depthState = uberMaterial.renderState.depthState;
|
|
30341
|
-
depthState.enabled = false;
|
|
30342
|
-
depthState.writeEnabled = false;
|
|
30343
|
-
var bloomEffect = new BloomEffect(uberMaterial);
|
|
30344
|
-
var tonemappingEffect = new TonemappingEffect(uberMaterial);
|
|
30345
|
-
this._uberMaterial = uberMaterial;
|
|
30346
|
-
this._bloomEffect = bloomEffect;
|
|
30347
|
-
this._tonemappingEffect = tonemappingEffect;
|
|
30348
|
-
}
|
|
30349
|
-
var _proto = _PostProcessManager.prototype;
|
|
30350
|
-
/**
|
|
30351
|
-
* @internal
|
|
30352
|
-
*/ _proto._render = function _render(context, srcTarget, destTarget) {
|
|
30353
|
-
var camera = context.camera;
|
|
30354
|
-
var engine = camera.engine;
|
|
30355
|
-
// Should blit to resolve the MSAA
|
|
30356
|
-
srcTarget._blitRenderTarget();
|
|
30357
|
-
var srcTexture = srcTarget.getColorTexture();
|
|
30358
|
-
var bloomEffect = this._bloomEffect;
|
|
30359
|
-
if (bloomEffect.enabled) {
|
|
30360
|
-
bloomEffect.onRender(context, srcTexture);
|
|
31033
|
+
};
|
|
31034
|
+
/**
|
|
31035
|
+
* @internal
|
|
31036
|
+
*/ _proto._addPostProcess = function _addPostProcess(postProcess) {
|
|
31037
|
+
this._activePostProcesses.push(postProcess);
|
|
31038
|
+
this._postProcessNeedSorting = true;
|
|
31039
|
+
};
|
|
31040
|
+
/**
|
|
31041
|
+
* @internal
|
|
31042
|
+
*/ _proto._removePostProcess = function _removePostProcess(postProcess) {
|
|
31043
|
+
var index = this._activePostProcesses.indexOf(postProcess);
|
|
31044
|
+
if (index >= 0) {
|
|
31045
|
+
this._activePostProcesses.splice(index, 1);
|
|
31046
|
+
this._postProcessNeedSorting = true;
|
|
30361
31047
|
}
|
|
30362
|
-
// Done with Uber, blit it
|
|
30363
|
-
PipelineUtils.blitTexture(engine, srcTexture, destTarget, 0, camera.viewport, this._uberMaterial);
|
|
30364
31048
|
};
|
|
30365
|
-
|
|
30366
|
-
|
|
30367
|
-
|
|
30368
|
-
|
|
30369
|
-
*
|
|
30370
|
-
|
|
30371
|
-
|
|
31049
|
+
/**
|
|
31050
|
+
* Get the blend effect by type.
|
|
31051
|
+
* @remarks
|
|
31052
|
+
* The blend effect is a post process effect that is used to blend all result of the effects by the type.
|
|
31053
|
+
* @param type - The type of PostProcessEffect
|
|
31054
|
+
* @returns The PostProcessEffect instance found
|
|
31055
|
+
*/ _proto.getBlendEffect = function getBlendEffect(type) {
|
|
31056
|
+
return this._blendEffectMap.get(type);
|
|
31057
|
+
};
|
|
31058
|
+
/**
|
|
31059
|
+
* @internal
|
|
31060
|
+
*/ _proto._render = function _render(camera, srcRenderTarget, destRenderTarget) {
|
|
31061
|
+
var engine = this.scene.engine;
|
|
31062
|
+
this._srcRenderTarget = srcRenderTarget;
|
|
31063
|
+
this._destRenderTarget = destRenderTarget;
|
|
31064
|
+
// Should blit to resolve the MSAA
|
|
31065
|
+
srcRenderTarget._blitRenderTarget();
|
|
31066
|
+
var activePasses = engine._getActivePostProcessPasses();
|
|
31067
|
+
this._remainActivePassCount = activePasses.length;
|
|
31068
|
+
this._initSwapRenderTarget(camera);
|
|
31069
|
+
for(var i = 0, n = activePasses.length; i < n; i++){
|
|
31070
|
+
var pass = activePasses[i];
|
|
31071
|
+
pass.onRender(camera, this._getCurrentSourceTexture(), this._currentDestRenderTarget);
|
|
31072
|
+
this._remainActivePassCount--;
|
|
31073
|
+
this._swapRT();
|
|
31074
|
+
}
|
|
31075
|
+
};
|
|
31076
|
+
/**
|
|
31077
|
+
* @internal
|
|
31078
|
+
*/ _proto._releaseSwapRenderTarget = function _releaseSwapRenderTarget() {
|
|
31079
|
+
var swapRenderTarget = this._swapRenderTarget;
|
|
31080
|
+
if (swapRenderTarget) {
|
|
31081
|
+
var _swapRenderTarget_getColorTexture;
|
|
31082
|
+
(_swapRenderTarget_getColorTexture = swapRenderTarget.getColorTexture(0)) == null ? void 0 : _swapRenderTarget_getColorTexture.destroy(true);
|
|
31083
|
+
swapRenderTarget.destroy(true);
|
|
31084
|
+
this._swapRenderTarget = null;
|
|
31085
|
+
}
|
|
31086
|
+
};
|
|
31087
|
+
_proto._sortActivePostProcess = function _sortActivePostProcess() {
|
|
31088
|
+
if (this._postProcessNeedSorting) {
|
|
31089
|
+
var postProcesses = this._activePostProcesses;
|
|
31090
|
+
if (postProcesses.length) {
|
|
31091
|
+
postProcesses.sort(function(a, b) {
|
|
31092
|
+
return a.priority - b.priority;
|
|
31093
|
+
});
|
|
30372
31094
|
}
|
|
31095
|
+
this._postProcessNeedSorting = false;
|
|
30373
31096
|
}
|
|
30374
|
-
|
|
30375
|
-
|
|
31097
|
+
};
|
|
31098
|
+
_proto._resetDefaultValue = function _resetDefaultValue() {
|
|
31099
|
+
var _this = this;
|
|
31100
|
+
this._blendEffectMap.forEach(function(blendEffect, typeofBlendEffect) {
|
|
31101
|
+
var defaultEffect = _this._defaultEffectMap.get(typeofBlendEffect);
|
|
31102
|
+
if (!defaultEffect) {
|
|
31103
|
+
defaultEffect = new typeofBlendEffect();
|
|
31104
|
+
_this._defaultEffectMap.set(typeofBlendEffect, defaultEffect);
|
|
31105
|
+
}
|
|
31106
|
+
// Reset effectInstance's value by defaultEffect
|
|
31107
|
+
blendEffect._lerp(defaultEffect, 1);
|
|
31108
|
+
blendEffect.enabled = false;
|
|
31109
|
+
});
|
|
31110
|
+
};
|
|
31111
|
+
_proto._initSwapRenderTarget = function _initSwapRenderTarget(camera) {
|
|
31112
|
+
if (this._remainActivePassCount > 1) {
|
|
31113
|
+
var viewport = camera.pixelViewport;
|
|
31114
|
+
var swapRenderTarget = PipelineUtils.recreateRenderTargetIfNeeded(this.scene.engine, this._swapRenderTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), TextureFormat.Depth24Stencil8, false, false, 1, TextureWrapMode$1.Clamp, TextureFilterMode.Bilinear);
|
|
31115
|
+
this._swapRenderTarget = swapRenderTarget;
|
|
31116
|
+
this._currentDestRenderTarget = this._swapRenderTarget;
|
|
31117
|
+
} else {
|
|
31118
|
+
this._currentDestRenderTarget = this._destRenderTarget;
|
|
31119
|
+
}
|
|
31120
|
+
this._currentSourceRenderTarget = this._srcRenderTarget;
|
|
31121
|
+
};
|
|
31122
|
+
_proto._swapRT = function _swapRT() {
|
|
31123
|
+
var currentSourceRenderTarget = this._currentSourceRenderTarget;
|
|
31124
|
+
var currentDestRenderTarget = this._currentDestRenderTarget;
|
|
31125
|
+
this._currentSourceRenderTarget = currentDestRenderTarget;
|
|
31126
|
+
if (this._remainActivePassCount > 1) {
|
|
31127
|
+
this._currentDestRenderTarget = currentSourceRenderTarget;
|
|
31128
|
+
} else {
|
|
31129
|
+
this._currentDestRenderTarget = this._destRenderTarget;
|
|
31130
|
+
}
|
|
31131
|
+
};
|
|
31132
|
+
_proto._getCurrentSourceTexture = function _getCurrentSourceTexture() {
|
|
31133
|
+
return this._currentSourceRenderTarget.getColorTexture(0);
|
|
31134
|
+
};
|
|
31135
|
+
return PostProcessManager;
|
|
30376
31136
|
}();
|
|
30377
|
-
|
|
30378
|
-
|
|
30379
|
-
var PostCommon = "#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n#include <common>\n#define FLT_MIN 1.175494351e-38\n#define HALF_MIN 6.103515625e-5\n#define HALF_MAX 65504.0\nfloat min3(vec3 val){return min(min(val.x,val.y),val.z);}float max3(vec3 val){return max(max(val.x,val.y),val.z);}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}vec4 sampleTexture(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ncolor=gammaToLinear(color);\n#endif\nreturn color;}\n#endif\n"; // eslint-disable-line
|
|
30380
|
-
var ACESTonemapping = "#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\nvec3 ACESTonemap(vec3 color){vec3 aces=sRGB_2_AP0*color;mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(vec3(aces));mediump float centeredHue=center_hue(hue,RRT_RED_HUE);float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);vec3 acescg=max(AP0_2_AP1_MAT*aces,0.0);acescg=mix(vec3(dot(acescg,AP1_RGB2Y)),acescg,RRT_SAT_FACTOR);const float a=0.0245786;const float b=0.000090537;const float c=0.983729;const float d=0.4329510;const float e=0.238081;vec3 rcpAcesCG=1.0/(acescg+FLT_MIN);mediump vec3 rgbPost=(acescg+a-b*rcpAcesCG)/(acescg*c+d+e*rcpAcesCG);vec3 linearCV=darkSurround_to_dimSurround(rgbPost);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;return linearCV;}"; // eslint-disable-line
|
|
30381
|
-
var ColorTransform = "#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\nconst mediump mat3 sRGB_2_AP0=mat3(0.4397010,0.0897923,0.0175440,0.3829780,0.8134230,0.1115440,0.1773350,0.0967616,0.8707040);const mediump mat3 AP1_2_AP0_MAT=mat3(vec3(0.6954522414,0.0447945634,-0.0055258826),vec3(0.1406786965,0.8596711185,0.0040252103),vec3(0.1638690622,0.0955343182,1.0015006723));const mediump mat3 AP0_2_AP1_MAT=mat3(vec3(1.4514393161,-0.0765537734,0.0083161484),vec3(-0.2365107469,1.1762296998,-0.0060324498),vec3(-0.2149285693,-0.0996759264,0.9977163014));const mediump mat3 AP1_2_XYZ_MAT=mat3(vec3(0.6624541811,0.2722287168,-0.0055746495),vec3(0.1340042065,0.6740817658,0.0040607335),vec3(0.1561876870,0.0536895174,1.0103391003));const mediump mat3 XYZ_2_AP1_MAT=mat3(vec3(1.6410233797,-0.6636628587,0.0117218943),vec3(-0.3248032942,1.6153315917,-0.0082844420),vec3(-0.2364246952,0.0167563477,0.9883948585));const mediump mat3 D60_2_D65_CAT=mat3(vec3(0.987224,-0.00759836,0.00307257),vec3(-0.00611327,1.00186,-0.00509595),vec3(0.0159533,0.00533002,1.08168));const mediump mat3 XYZ_2_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));const mediump vec3 AP1_RGB2Y=vec3(0.2722287168,0.6740817658,0.0536895174);mediump float rgb_2_saturation(mediump vec3 rgb){const mediump float TINY=1e-4;mediump float mi=min3(rgb);mediump float ma=max3(rgb);return(max(ma,TINY)-max(mi,TINY))/max(ma,1e-2);}mediump float rgb_2_yc(mediump vec3 rgb){const mediump float ycRadiusWeight=1.75;mediump float r=rgb.x;mediump float g=rgb.y;mediump float b=rgb.z;mediump float k=b*(b-g)+g*(g-r)+r*(r-b);k=max(k,0.0);float chroma=k==0.0 ? 0.0 : sqrt(k);return(b+g+r+ycRadiusWeight*chroma)/3.0;}mediump float rgb_2_hue(mediump vec3 rgb){mediump float hue;if(rgb.x==rgb.y&&rgb.y==rgb.z){hue=0.0;}else{hue=(180.0/PI)*atan(sqrt(3.0)*(rgb.y-rgb.z),2.0*rgb.x-rgb.y-rgb.z);}if(hue<0.0){hue=hue+360.0;}return hue;}mediump float center_hue(mediump float hue,mediump float centerH){mediump float hueCentered=hue-centerH;if(hueCentered<-180.0){hueCentered=hueCentered+360.0;}else if(hueCentered>180.0){hueCentered=hueCentered-360.0;}return hueCentered;}\n#endif\n"; // eslint-disable-line
|
|
30382
|
-
var ODT = "#define GLSLIFY 1\n#include <Tonescale>\nconst float CINEMA_WHITE=48.0;const float CINEMA_BLACK=0.02;const float ODT_SAT_FACTOR=0.93;mediump vec3 Y_2_linCV(mediump vec3 Y,mediump float Ymax,mediump float Ymin){return(Y-Ymin)/(Ymax-Ymin);}mediump vec3 XYZ_2_xyY(mediump vec3 XYZ){mediump float divisor=max(dot(XYZ,vec3(1.0)),1e-4);return vec3(XYZ.xy/divisor,XYZ.y);}mediump vec3 xyY_2_XYZ(mediump vec3 xyY){mediump float m=xyY.z/max(xyY.y,1e-4);mediump vec3 XYZ=vec3(xyY.xz,(1.0-xyY.x-xyY.y));XYZ.xz*=m;return XYZ;}const mediump float DIM_SURROUND_GAMMA=0.9811;mediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;mediump vec3 xyY=XYZ_2_xyY(XYZ);xyY.z=clamp(xyY.z,0.0,HALF_MAX);xyY.z=pow(xyY.z,DIM_SURROUND_GAMMA);XYZ=xyY_2_XYZ(xyY);return XYZ_2_AP1_MAT*XYZ;}mediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){mediump vec3 rgbPre=AP0_2_AP1_MAT*oces;mediump vec3 rgbPost;rgbPost.r=segmented_spline_c9_fwd(rgbPre.r);rgbPost.g=segmented_spline_c9_fwd(rgbPre.g);rgbPost.b=segmented_spline_c9_fwd(rgbPre.b);mediump vec3 linearCV=Y_2_linCV(rgbPost,CINEMA_WHITE,CINEMA_BLACK);linearCV=darkSurround_to_dimSurround(linearCV);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;linearCV=clamp(linearCV,vec3(0),vec3(1));return linearCV;}"; // eslint-disable-line
|
|
30383
|
-
var RRT = "#define GLSLIFY 1\n#include <Tonescale>\nmediump float sigmoid_shaper(mediump float x){mediump float t=max(1.0-abs(x/2.0),0.0);mediump float y=1.0+sign(x)*(1.0-t*t);return y*0.5;}mediump float glow_fwd(mediump float ycIn,mediump float glowGainIn,mediump float glowMid){mediump float glowGainOut;if(ycIn<=2.0/3.0*glowMid){glowGainOut=glowGainIn;}else if(ycIn>=2.0*glowMid){glowGainOut=0.0;}else{glowGainOut=glowGainIn*(glowMid/ycIn-1.0/2.0);}return glowGainOut;}const mediump float RRT_GLOW_GAIN=0.05;const mediump float RRT_GLOW_MID=0.08;const mediump float RRT_RED_SCALE=0.82;const mediump float RRT_RED_PIVOT=0.03;const mediump float RRT_RED_HUE=0.0;const mediump float RRT_RED_WIDTH=135.0;const mediump float RRT_SAT_FACTOR=0.96;mediump vec3 RRT(mediump vec3 aces){mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);mediump float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(aces);mediump float centeredHue=center_hue(hue,RRT_RED_HUE);mediump float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);aces=clamp(aces,0.0,HALF_MAX);mediump vec3 rgbPre=AP0_2_AP1_MAT*aces;rgbPre=clamp(rgbPre,0.0,HALF_MAX);rgbPre=mix(vec3(dot(rgbPre,AP1_RGB2Y)),rgbPre,RRT_SAT_FACTOR);mediump vec3 rgbPost;rgbPost.x=segmented_spline_c5_fwd(rgbPre.x);rgbPost.y=segmented_spline_c5_fwd(rgbPre.y);rgbPost.z=segmented_spline_c5_fwd(rgbPre.z);mediump vec3 outputVal=AP1_2_AP0_MAT*rgbPost;return outputVal;}"; // eslint-disable-line
|
|
30384
|
-
var Tonescale = "#define GLSLIFY 1\n#ifndef TONE_SCALE\n#define TONE_SCALE\nconst mediump mat3 M=mat3(vec3(0.5,-1.0,0.5),vec3(-1.0,1.0,0.5),vec3(0.5,0.0,0.0));mediump float segmented_spline_c5_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[6]=float[6](-4.0000000000,-4.0000000000,-3.1573765773,-0.4852499958,1.8477324706,1.8477324706);const mediump float coefsHigh[6]=float[6](-0.7185482425,2.0810307172,3.6681241237,4.0000000000,4.0000000000,4.0000000000);\n#else\nconst mediump float coefsLow_0=-4.0000000000;const mediump float coefsLow_1=-4.0000000000;const mediump float coefsLow_2=-3.1573765773;const mediump float coefsLow_3=-0.4852499958;const mediump float coefsLow_4=1.8477324706;const mediump float coefsLow_5=1.8477324706;const mediump float coefsHigh_0=-0.7185482425;const mediump float coefsHigh_1=2.0810307172;const mediump float coefsHigh_2=3.6681241237;const mediump float coefsHigh_3=4.0000000000;const mediump float coefsHigh_4=4.0000000000;const mediump float coefsHigh_5=4.0000000000;\n#endif\nconst mediump vec2 minPoint=vec2(0.0000054931640625,0.0001);const mediump vec2 midPoint=vec2(0.18,0.48);const mediump vec2 maxPoint=vec2(47185.92,10000.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.0;const int N_KNOTS_LOW=4;const int N_KNOTS_HIGH=4;mediump float logx=log10(max(x,HALF_MIN));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else{cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else{cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}mediump float segmented_spline_c9_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[10]=float[10](-1.6989700043,-1.6989700043,-1.4779000000,-1.2291000000,-0.8648000000,-0.4480000000,0.0051800000,0.4511080334,0.9113744414,0.9113744414);const mediump float coefsHigh[10]=float[10](0.5154386965,0.8470437783,1.1358000000,1.3802000000,1.5197000000,1.5985000000,1.6467000000,1.6746091357,1.6878733390,1.6878733390);\n#else\nconst mediump float coefsLow_0=-1.6989700043;const mediump float coefsLow_1=-1.6989700043;const mediump float coefsLow_2=-1.4779000000;const mediump float coefsLow_3=-1.2291000000;const mediump float coefsLow_4=-0.8648000000;const mediump float coefsLow_5=-0.4480000000;const mediump float coefsLow_6=0.0051800000;const mediump float coefsLow_7=0.4511080334;const mediump float coefsLow_8=0.9113744414;const mediump float coefsLow_9=0.9113744414;const mediump float coefsHigh_0=0.5154386965;const mediump float coefsHigh_1=0.8470437783;const mediump float coefsHigh_2=1.1358000000;const mediump float coefsHigh_3=1.3802000000;const mediump float coefsHigh_4=1.5197000000;const mediump float coefsHigh_5=1.5985000000;const mediump float coefsHigh_6=1.6467000000;const mediump float coefsHigh_7=1.6746091357;const mediump float coefsHigh_8=1.6878733390;const mediump float coefsHigh_9=1.6878733390;\n#endif\nconst mediump vec2 minPoint=vec2(0.0028799,0.02);const mediump vec2 midPoint=vec2(4.799999,4.8);const mediump vec2 maxPoint=vec2(1005.719,48.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.04;const int N_KNOTS_LOW=8;const int N_KNOTS_HIGH=8;mediump float logx=log10(max(x,1e-4));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else if(j==3){cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}else if(j==4){cf=vec3(coefsLow_4,coefsLow_5,coefsLow_6);}else if(j==5){cf=vec3(coefsLow_5,coefsLow_6,coefsLow_7);}else if(j==6){cf=vec3(coefsLow_6,coefsLow_7,coefsLow_8);}else{cf=vec3(coefsLow_7,coefsLow_8,coefsLow_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else if(j==3){cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}else if(j==4){cf=vec3(coefsHigh_4,coefsHigh_5,coefsHigh_6);}else if(j==5){cf=vec3(coefsHigh_5,coefsHigh_6,coefsHigh_7);}else if(j==6){cf=vec3(coefsHigh_6,coefsHigh_7,coefsHigh_8);}else{cf=vec3(coefsHigh_7,coefsHigh_8,coefsHigh_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}\n#endif\n"; // eslint-disable-line
|
|
30385
|
-
var NeutralTonemapping = "#define GLSLIFY 1\nvec3 neutralCurve(vec3 x,float a,float b,float c,float d,float e,float f){return vec3(((x*(a*x+c*b)+d*e)/(x*(a*x+b)+d*f))-e/f);}\n#define TONEMAPPING_CLAMP_MAX 435.18712\nvec3 neutralTonemap(vec3 color){const float a=0.2;const float b=0.29;const float c=0.24;const float d=0.272;const float e=0.02;const float f=0.3;\n#ifndef GL_FRAGMENT_PRECISION_HIGH\ncolor=min(color,TONEMAPPING_CLAMP_MAX);\n#endif\nconst float whiteScale=1.31338;color=neutralCurve(color*whiteScale,a,b,c,d,e,f);color*=whiteScale;return color;}"; // eslint-disable-line
|
|
30386
|
-
var UberPost = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;\n#ifdef ENABLE_EFFECT_BLOOM\nuniform sampler2D material_BloomTexture;uniform sampler2D material_BloomDirtTexture;uniform vec4 material_BloomTint;uniform vec4 material_BloomDirtTilingOffset;uniform vec4 material_BloomIntensityParams;\n#endif\nvoid main(){mediump vec4 color=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef ENABLE_EFFECT_BLOOM\n#ifdef BLOOM_HQ\nmediump vec4 bloom=sampleTexture2DBicubic(material_BloomTexture,v_uv,renderer_texelSize);\n#else\nmediump vec4 bloom=sampleTexture(material_BloomTexture,v_uv);\n#endif\nbloom*=material_BloomIntensityParams.x;color+=bloom*material_BloomTint;\n#ifdef BLOOM_DIRT\nmediump vec4 dirt=sampleTexture(material_BloomDirtTexture,v_uv*material_BloomDirtTilingOffset.xy+material_BloomDirtTilingOffset.zw);dirt*=material_BloomIntensityParams.y;color+=dirt*bloom;\n#endif\n#endif\n#ifdef ENABLE_EFFECT_TONEMAPPING\n#if TONEMAPPING_MODE == 0\ncolor.rgb=neutralTonemap(color.rgb);\n#elif TONEMAPPING_MODE == 1\ncolor.rgb=ACESTonemap(color.rgb);\n#endif\ncolor.rgb=clamp(color.rgb,vec3(0),vec3(1));\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"; // eslint-disable-line
|
|
30387
|
-
Object.assign(ShaderLib, {
|
|
30388
|
-
PostCommon: PostCommon,
|
|
30389
|
-
Filtering: Filtering,
|
|
30390
|
-
ODT: ODT,
|
|
30391
|
-
RRT: RRT,
|
|
30392
|
-
Tonescale: Tonescale,
|
|
30393
|
-
ColorTransform: ColorTransform,
|
|
30394
|
-
NeutralTonemapping: NeutralTonemapping,
|
|
30395
|
-
ACESTonemapping: ACESTonemapping
|
|
30396
|
-
});
|
|
30397
|
-
Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
|
|
31137
|
+
PostProcessManager._tempColliders = [];
|
|
31138
|
+
PostProcessManager._tempVector3 = new Vector3();
|
|
30398
31139
|
/**
|
|
30399
31140
|
* Scene.
|
|
30400
31141
|
*/ var Scene = /*#__PURE__*/ function(EngineObject) {
|
|
@@ -30404,7 +31145,7 @@
|
|
|
30404
31145
|
_this = EngineObject.call(this, engine) || this, /** Physics. */ _this.physics = new PhysicsScene(_this), /** If cast shadows. */ _this.castShadows = true, /** The resolution of the shadow maps. */ _this.shadowResolution = ShadowResolution.Medium, /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0, /** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0), /** Max Shadow distance. */ _this.shadowDistance = 50, /**
|
|
30405
31146
|
* Last shadow fade distance in percentage, range [0,1].
|
|
30406
31147
|
* @remarks Value 0 is used for no shadow fade.
|
|
30407
|
-
*/ _this.shadowFadeBorder = 0.1, /* @internal */ _this._lightManager = new LightManager(), /* @internal */ _this._componentsManager = new ComponentsManager(), /** @internal */ _this._maskManager = new MaskManager(), /** @internal */ _this._isActiveInEngine = false, /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection(), /** @internal */ _this._rootEntities = [],
|
|
31148
|
+
*/ _this.shadowFadeBorder = 0.1, /** Post process manager. */ _this.postProcessManager = new PostProcessManager(_this), /* @internal */ _this._lightManager = new LightManager(), /* @internal */ _this._componentsManager = new ComponentsManager(), /** @internal */ _this._maskManager = new MaskManager(), /** @internal */ _this._isActiveInEngine = false, /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection(), /** @internal */ _this._rootEntities = [], _this._background = new Background(_this._engine), _this._shaderData = new ShaderData(ShaderDataGroup.Scene), _this._shadowCascades = ShadowCascadesMode.NoCascades, _this._fogMode = FogMode.None, _this._fogColor = new Color(0.5, 0.5, 0.5, 1.0), _this._fogStart = 0, _this._fogEnd = 300, _this._fogDensity = 0.01, _this._fogParams = new Vector4(), _this._isActive = true, _this._enableTransparentShadow = false;
|
|
30408
31149
|
_this.name = name || "";
|
|
30409
31150
|
var shaderData = _this.shaderData;
|
|
30410
31151
|
shaderData._addReferCount(1);
|
|
@@ -38453,8 +39194,8 @@
|
|
|
38453
39194
|
]);
|
|
38454
39195
|
return SphereShape;
|
|
38455
39196
|
}(BaseShape);
|
|
38456
|
-
var FRAG_SHADER = "#define GLSLIFY 1\nvarying vec2 v_uv
|
|
38457
|
-
var VERT_SHADER = "#define GLSLIFY 1\nattribute vec3 POSITION
|
|
39197
|
+
var FRAG_SHADER = "#define GLSLIFY 1\nvarying vec2 v_uv;\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n\n gl_FragColor = texture2D(u_texture, v_uv);\n\n}\n"; // eslint-disable-line
|
|
39198
|
+
var VERT_SHADER = "#define GLSLIFY 1\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\n\nvarying vec2 v_uv;\n\nuniform mat4 camera_ProjMat;\nuniform mat4 camera_ViewMat;\n\nvoid main() {\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4( POSITION, 1.0 );\n v_uv = TEXCOORD_0;\n\n}\n"; // eslint-disable-line
|
|
38458
39199
|
Shader.create("trail", VERT_SHADER, FRAG_SHADER);
|
|
38459
39200
|
var TrailMaterial = /*#__PURE__*/ function(Material) {
|
|
38460
39201
|
_inherits$2(TrailMaterial, Material);
|
|
@@ -39236,6 +39977,7 @@
|
|
|
39236
39977
|
BlendShapeFrame: BlendShapeFrame,
|
|
39237
39978
|
BlendState: BlendState,
|
|
39238
39979
|
BlinnPhongMaterial: BlinnPhongMaterial,
|
|
39980
|
+
Blitter: Blitter,
|
|
39239
39981
|
BloomDownScaleMode: BloomDownScaleMode,
|
|
39240
39982
|
BloomEffect: BloomEffect,
|
|
39241
39983
|
BoolUpdateFlag: BoolUpdateFlag,
|
|
@@ -39259,6 +40001,7 @@
|
|
|
39259
40001
|
get Collider () { return exports.Collider; },
|
|
39260
40002
|
ColliderShape: ColliderShape,
|
|
39261
40003
|
ColliderShapeUpAxis: ColliderShapeUpAxis,
|
|
40004
|
+
Collision: Collision,
|
|
39262
40005
|
CollisionDetectionMode: CollisionDetectionMode,
|
|
39263
40006
|
ColorOverLifetimeModule: ColorOverLifetimeModule,
|
|
39264
40007
|
ColorSpace: ColorSpace,
|
|
@@ -39267,6 +40010,7 @@
|
|
|
39267
40010
|
Component: Component,
|
|
39268
40011
|
ConeEmitType: ConeEmitType,
|
|
39269
40012
|
ConeShape: ConeShape,
|
|
40013
|
+
ContactPoint: ContactPoint,
|
|
39270
40014
|
ContentRestorer: ContentRestorer,
|
|
39271
40015
|
ControllerCollisionFlag: ControllerCollisionFlag,
|
|
39272
40016
|
ControllerNonWalkableMode: ControllerNonWalkableMode,
|
|
@@ -39348,11 +40092,19 @@
|
|
|
39348
40092
|
Pointer: Pointer,
|
|
39349
40093
|
PointerButton: PointerButton,
|
|
39350
40094
|
PointerPhase: PointerPhase,
|
|
40095
|
+
PostProcess: PostProcess,
|
|
40096
|
+
PostProcessEffect: PostProcessEffect,
|
|
40097
|
+
PostProcessEffectParameter: PostProcessEffectParameter,
|
|
40098
|
+
PostProcessManager: PostProcessManager,
|
|
40099
|
+
PostProcessPass: PostProcessPass,
|
|
40100
|
+
PostProcessPassEvent: PostProcessPassEvent,
|
|
40101
|
+
PostProcessUberPass: PostProcessUberPass,
|
|
39351
40102
|
Primitive: Primitive,
|
|
39352
40103
|
PrimitiveMesh: PrimitiveMesh,
|
|
39353
40104
|
Probe: Probe,
|
|
39354
40105
|
RasterState: RasterState,
|
|
39355
40106
|
ReferResource: ReferResource,
|
|
40107
|
+
RefractionMode: RefractionMode,
|
|
39356
40108
|
RenderBufferDepthFormat: RenderBufferDepthFormat,
|
|
39357
40109
|
RenderFace: RenderFace,
|
|
39358
40110
|
RenderQueue: RenderQueue,
|
|
@@ -39443,7 +40195,6 @@
|
|
|
39443
40195
|
VertexElementFormat: VertexElementFormat,
|
|
39444
40196
|
WrapMode: WrapMode,
|
|
39445
40197
|
XRManager: XRManager,
|
|
39446
|
-
_PostProcessManager: _PostProcessManager,
|
|
39447
40198
|
assignmentClone: assignmentClone,
|
|
39448
40199
|
deepClone: deepClone,
|
|
39449
40200
|
dependentComponents: dependentComponents,
|
|
@@ -42138,11 +42889,7 @@
|
|
|
42138
42889
|
return ParserType;
|
|
42139
42890
|
}({});
|
|
42140
42891
|
/**
|
|
42141
|
-
*
|
|
42142
|
-
* @export
|
|
42143
|
-
* @class ParserContext
|
|
42144
|
-
* @template T
|
|
42145
|
-
* @template I
|
|
42892
|
+
* @internal
|
|
42146
42893
|
*/ var ParserContext = /*#__PURE__*/ function() {
|
|
42147
42894
|
function ParserContext(engine, type, resource) {
|
|
42148
42895
|
if (type === void 0) type = 1;
|
|
@@ -42154,13 +42901,39 @@
|
|
|
42154
42901
|
this.components = new Map();
|
|
42155
42902
|
this.rootIds = [];
|
|
42156
42903
|
this.strippedIds = [];
|
|
42904
|
+
this.componentWaitingMap = new Map();
|
|
42157
42905
|
this.resourceManager = engine.resourceManager;
|
|
42158
42906
|
}
|
|
42159
42907
|
var _proto = ParserContext.prototype;
|
|
42160
|
-
|
|
42161
|
-
|
|
42162
|
-
|
|
42163
|
-
|
|
42908
|
+
_proto.addComponent = function addComponent(id, component) {
|
|
42909
|
+
this.components.set(id, component);
|
|
42910
|
+
var waitingList = this.componentWaitingMap.get(id);
|
|
42911
|
+
if (waitingList == null ? void 0 : waitingList.length) {
|
|
42912
|
+
waitingList.forEach(function(resolve) {
|
|
42913
|
+
return resolve(component);
|
|
42914
|
+
});
|
|
42915
|
+
this.componentWaitingMap.delete(id);
|
|
42916
|
+
}
|
|
42917
|
+
};
|
|
42918
|
+
_proto.getComponentByRef = function getComponentByRef(ref) {
|
|
42919
|
+
var _this = this;
|
|
42920
|
+
return new Promise(function(resolve, reject) {
|
|
42921
|
+
var component = _this.components.get(ref.componentId);
|
|
42922
|
+
if (component) {
|
|
42923
|
+
resolve(component);
|
|
42924
|
+
} else {
|
|
42925
|
+
var resolves = _this.componentWaitingMap.get(ref.componentId);
|
|
42926
|
+
if (resolves) {
|
|
42927
|
+
resolves.push(resolve);
|
|
42928
|
+
} else {
|
|
42929
|
+
_this.componentWaitingMap.set(ref.componentId, [
|
|
42930
|
+
resolve
|
|
42931
|
+
]);
|
|
42932
|
+
}
|
|
42933
|
+
}
|
|
42934
|
+
});
|
|
42935
|
+
};
|
|
42936
|
+
_proto.clear = function clear() {
|
|
42164
42937
|
this.entityMap.clear();
|
|
42165
42938
|
this.components.clear();
|
|
42166
42939
|
this.entityConfigMap.clear();
|
|
@@ -42259,6 +43032,8 @@
|
|
|
42259
43032
|
}
|
|
42260
43033
|
return resource;
|
|
42261
43034
|
});
|
|
43035
|
+
} else if (ReflectionParser._isComponentRef(value)) {
|
|
43036
|
+
return this._context.getComponentByRef(value);
|
|
42262
43037
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
42263
43038
|
// entity reference
|
|
42264
43039
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
@@ -42320,13 +43095,16 @@
|
|
|
42320
43095
|
this.customParseComponentHandles[componentType] = handle;
|
|
42321
43096
|
};
|
|
42322
43097
|
ReflectionParser._isClass = function _isClass(value) {
|
|
42323
|
-
return value["class"]
|
|
43098
|
+
return value["class"] !== undefined;
|
|
42324
43099
|
};
|
|
42325
43100
|
ReflectionParser._isAssetRef = function _isAssetRef(value) {
|
|
42326
|
-
return value["refId"]
|
|
43101
|
+
return value["refId"] !== undefined;
|
|
42327
43102
|
};
|
|
42328
43103
|
ReflectionParser._isEntityRef = function _isEntityRef(value) {
|
|
42329
|
-
return value["entityId"]
|
|
43104
|
+
return value["entityId"] !== undefined;
|
|
43105
|
+
};
|
|
43106
|
+
ReflectionParser._isComponentRef = function _isComponentRef(value) {
|
|
43107
|
+
return value["ownerId"] !== undefined && value["componentId"] !== undefined;
|
|
42330
43108
|
};
|
|
42331
43109
|
return ReflectionParser;
|
|
42332
43110
|
}();
|
|
@@ -42670,7 +43448,6 @@
|
|
|
42670
43448
|
_proto._parseComponents = function _parseComponents() {
|
|
42671
43449
|
var entitiesConfig = this.data.entities;
|
|
42672
43450
|
var entityMap = this.context.entityMap;
|
|
42673
|
-
var components = this.context.components;
|
|
42674
43451
|
var promises = [];
|
|
42675
43452
|
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
42676
43453
|
var entityConfig = entitiesConfig[i];
|
|
@@ -42679,11 +43456,17 @@
|
|
|
42679
43456
|
var componentConfig = entityConfig.components[i1];
|
|
42680
43457
|
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
42681
43458
|
var component = entity.addComponent(Loader.getClass(key));
|
|
42682
|
-
|
|
43459
|
+
this.context.addComponent(componentConfig.id, component);
|
|
42683
43460
|
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
42684
43461
|
promises.push(promise);
|
|
42685
43462
|
}
|
|
42686
43463
|
}
|
|
43464
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.context.componentWaitingMap.values()), _step; !(_step = _iterator()).done;){
|
|
43465
|
+
var waitingList = _step.value;
|
|
43466
|
+
waitingList.forEach(function(resolve) {
|
|
43467
|
+
return resolve(null);
|
|
43468
|
+
});
|
|
43469
|
+
}
|
|
42687
43470
|
return Promise.all(promises);
|
|
42688
43471
|
};
|
|
42689
43472
|
_proto._parsePrefabModification = function _parsePrefabModification() {
|
|
@@ -47991,6 +48774,33 @@
|
|
|
47991
48774
|
"gsl"
|
|
47992
48775
|
])
|
|
47993
48776
|
], ShaderLoader);
|
|
48777
|
+
var PhysicsMaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
48778
|
+
_inherits(PhysicsMaterialLoader, Loader);
|
|
48779
|
+
function PhysicsMaterialLoader() {
|
|
48780
|
+
return Loader.apply(this, arguments) || this;
|
|
48781
|
+
}
|
|
48782
|
+
var _proto = PhysicsMaterialLoader.prototype;
|
|
48783
|
+
_proto.load = function load(item, resourceManager) {
|
|
48784
|
+
return resourceManager // @ts-ignore
|
|
48785
|
+
._request(item.url, _extends({}, item, {
|
|
48786
|
+
type: "json"
|
|
48787
|
+
})).then(function(data) {
|
|
48788
|
+
var physicsMaterial = new PhysicsMaterial();
|
|
48789
|
+
physicsMaterial.bounciness = data.bounciness;
|
|
48790
|
+
physicsMaterial.dynamicFriction = data.dynamicFriction;
|
|
48791
|
+
physicsMaterial.staticFriction = data.staticFriction;
|
|
48792
|
+
physicsMaterial.bounceCombine = data.bounceCombine;
|
|
48793
|
+
physicsMaterial.frictionCombine = data.frictionCombine;
|
|
48794
|
+
return physicsMaterial;
|
|
48795
|
+
});
|
|
48796
|
+
};
|
|
48797
|
+
return PhysicsMaterialLoader;
|
|
48798
|
+
}(Loader);
|
|
48799
|
+
PhysicsMaterialLoader = __decorate([
|
|
48800
|
+
resourceLoader(AssetType.PhysicsMaterial, [
|
|
48801
|
+
"mesh"
|
|
48802
|
+
])
|
|
48803
|
+
], PhysicsMaterialLoader);
|
|
47994
48804
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
47995
48805
|
_inherits(SceneLoader, Loader);
|
|
47996
48806
|
function SceneLoader() {
|
|
@@ -48096,28 +48906,7 @@
|
|
|
48096
48906
|
// Post Process
|
|
48097
48907
|
var postProcessData = data.scene.postProcess;
|
|
48098
48908
|
if (postProcessData) {
|
|
48099
|
-
|
|
48100
|
-
var postProcessManager = scene._postProcessManager;
|
|
48101
|
-
var bloomEffect = postProcessManager._bloomEffect;
|
|
48102
|
-
var tonemappingEffect = postProcessManager._tonemappingEffect;
|
|
48103
|
-
postProcessManager.isActive = postProcessData.isActive;
|
|
48104
|
-
bloomEffect.enabled = postProcessData.bloom.enabled;
|
|
48105
|
-
bloomEffect.downScale = postProcessData.bloom.downScale;
|
|
48106
|
-
bloomEffect.threshold = postProcessData.bloom.threshold;
|
|
48107
|
-
bloomEffect.scatter = postProcessData.bloom.scatter;
|
|
48108
|
-
bloomEffect.intensity = postProcessData.bloom.intensity;
|
|
48109
|
-
bloomEffect.tint.copyFrom(postProcessData.bloom.tint);
|
|
48110
|
-
bloomEffect.dirtIntensity = postProcessData.bloom.dirtIntensity;
|
|
48111
|
-
tonemappingEffect.enabled = postProcessData.tonemapping.enabled;
|
|
48112
|
-
tonemappingEffect.mode = postProcessData.tonemapping.mode;
|
|
48113
|
-
if (postProcessData.bloom.dirtTexture) {
|
|
48114
|
-
// @ts-ignore
|
|
48115
|
-
// prettier-ignore
|
|
48116
|
-
var dirtTexturePromise = resourceManager.getResourceByRef(postProcessData.bloom.dirtTexture).then(function(texture) {
|
|
48117
|
-
bloomEffect.dirtTexture = texture;
|
|
48118
|
-
});
|
|
48119
|
-
promises.push(dirtTexturePromise);
|
|
48120
|
-
}
|
|
48909
|
+
Logger.warn("Post Process is not supported in scene yet, please add PostProcess component in entity instead.");
|
|
48121
48910
|
}
|
|
48122
48911
|
return Promise.all(promises).then(function() {
|
|
48123
48912
|
resolve(scene);
|
|
@@ -48306,6 +49095,27 @@
|
|
|
48306
49095
|
KHR_materials_sheen = __decorate([
|
|
48307
49096
|
registerGLTFExtension("KHR_materials_sheen", GLTFExtensionMode.AdditiveParse)
|
|
48308
49097
|
], KHR_materials_sheen);
|
|
49098
|
+
var KHR_materials_transmission = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
49099
|
+
_inherits(KHR_materials_transmission, GLTFExtensionParser);
|
|
49100
|
+
function KHR_materials_transmission() {
|
|
49101
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
49102
|
+
}
|
|
49103
|
+
var _proto = KHR_materials_transmission.prototype;
|
|
49104
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
49105
|
+
var _schema_transmissionFactor = schema.transmissionFactor, transmissionFactor = _schema_transmissionFactor === void 0 ? 0 : _schema_transmissionFactor, transmissionTexture = schema.transmissionTexture;
|
|
49106
|
+
material.transmission = transmissionFactor;
|
|
49107
|
+
if (transmissionTexture) {
|
|
49108
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(transmissionTexture, "Transmission texture");
|
|
49109
|
+
context.get(GLTFParserType.Texture, transmissionTexture.index).then(function(texture) {
|
|
49110
|
+
material.transmissionTexture = texture;
|
|
49111
|
+
});
|
|
49112
|
+
}
|
|
49113
|
+
};
|
|
49114
|
+
return KHR_materials_transmission;
|
|
49115
|
+
}(GLTFExtensionParser);
|
|
49116
|
+
KHR_materials_transmission = __decorate([
|
|
49117
|
+
registerGLTFExtension("KHR_materials_transmission", GLTFExtensionMode.AdditiveParse)
|
|
49118
|
+
], KHR_materials_transmission);
|
|
48309
49119
|
var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
48310
49120
|
_inherits(KHR_materials_unlit, GLTFExtensionParser);
|
|
48311
49121
|
function KHR_materials_unlit() {
|
|
@@ -48356,6 +49166,31 @@
|
|
|
48356
49166
|
KHR_materials_variants = __decorate([
|
|
48357
49167
|
registerGLTFExtension("KHR_materials_variants", GLTFExtensionMode.AdditiveParse)
|
|
48358
49168
|
], KHR_materials_variants);
|
|
49169
|
+
var KHR_materials_volume = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
49170
|
+
_inherits(KHR_materials_volume, GLTFExtensionParser);
|
|
49171
|
+
function KHR_materials_volume() {
|
|
49172
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
49173
|
+
}
|
|
49174
|
+
var _proto = KHR_materials_volume.prototype;
|
|
49175
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
49176
|
+
var _schema_thicknessFactor = schema.thicknessFactor, thicknessFactor = _schema_thicknessFactor === void 0 ? 0 : _schema_thicknessFactor, thicknessTexture = schema.thicknessTexture, _schema_attenuationDistance = schema.attenuationDistance, attenuationDistance = _schema_attenuationDistance === void 0 ? Infinity : _schema_attenuationDistance, attenuationColor = schema.attenuationColor;
|
|
49177
|
+
material.thickness = thicknessFactor;
|
|
49178
|
+
material.attenuationDistance = attenuationDistance;
|
|
49179
|
+
if (attenuationColor) {
|
|
49180
|
+
material.attenuationColor.set(Color.linearToGammaSpace(attenuationColor[0]), Color.linearToGammaSpace(attenuationColor[1]), Color.linearToGammaSpace(attenuationColor[2]), undefined);
|
|
49181
|
+
}
|
|
49182
|
+
if (thicknessTexture) {
|
|
49183
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(thicknessTexture, "Thickness texture");
|
|
49184
|
+
context.get(GLTFParserType.Texture, thicknessTexture.index).then(function(texture) {
|
|
49185
|
+
material.thicknessTexture = texture;
|
|
49186
|
+
});
|
|
49187
|
+
}
|
|
49188
|
+
};
|
|
49189
|
+
return KHR_materials_volume;
|
|
49190
|
+
}(GLTFExtensionParser);
|
|
49191
|
+
KHR_materials_volume = __decorate([
|
|
49192
|
+
registerGLTFExtension("KHR_materials_volume", GLTFExtensionMode.AdditiveParse)
|
|
49193
|
+
], KHR_materials_volume);
|
|
48359
49194
|
var KHR_mesh_quantization = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
48360
49195
|
_inherits(KHR_mesh_quantization, GLTFExtensionParser);
|
|
48361
49196
|
function KHR_mesh_quantization() {
|
|
@@ -48605,7 +49440,7 @@
|
|
|
48605
49440
|
], EXT_texture_webp);
|
|
48606
49441
|
|
|
48607
49442
|
//@ts-ignore
|
|
48608
|
-
var version = "1.4.0-alpha.
|
|
49443
|
+
var version = "1.4.0-alpha.2";
|
|
48609
49444
|
console.log("Galacean engine version: " + version);
|
|
48610
49445
|
for(var key in CoreObjects){
|
|
48611
49446
|
Loader.registerClass(key, CoreObjects[key]);
|
|
@@ -48646,6 +49481,7 @@
|
|
|
48646
49481
|
exports.BlendShapeFrame = BlendShapeFrame;
|
|
48647
49482
|
exports.BlendState = BlendState;
|
|
48648
49483
|
exports.BlinnPhongMaterial = BlinnPhongMaterial;
|
|
49484
|
+
exports.Blitter = Blitter;
|
|
48649
49485
|
exports.BloomDownScaleMode = BloomDownScaleMode;
|
|
48650
49486
|
exports.BloomEffect = BloomEffect;
|
|
48651
49487
|
exports.BoolUpdateFlag = BoolUpdateFlag;
|
|
@@ -48672,6 +49508,7 @@
|
|
|
48672
49508
|
exports.CloneManager = CloneManager;
|
|
48673
49509
|
exports.ColliderShape = ColliderShape;
|
|
48674
49510
|
exports.ColliderShapeUpAxis = ColliderShapeUpAxis;
|
|
49511
|
+
exports.Collision = Collision;
|
|
48675
49512
|
exports.CollisionDetectionMode = CollisionDetectionMode;
|
|
48676
49513
|
exports.CollisionUtil = CollisionUtil;
|
|
48677
49514
|
exports.Color = Color;
|
|
@@ -48682,6 +49519,7 @@
|
|
|
48682
49519
|
exports.Component = Component;
|
|
48683
49520
|
exports.ConeEmitType = ConeEmitType;
|
|
48684
49521
|
exports.ConeShape = ConeShape;
|
|
49522
|
+
exports.ContactPoint = ContactPoint;
|
|
48685
49523
|
exports.ContainmentType = ContainmentType;
|
|
48686
49524
|
exports.ContentRestorer = ContentRestorer;
|
|
48687
49525
|
exports.ControllerCollisionFlag = ControllerCollisionFlag;
|
|
@@ -48784,6 +49622,13 @@
|
|
|
48784
49622
|
exports.Pointer = Pointer;
|
|
48785
49623
|
exports.PointerButton = PointerButton;
|
|
48786
49624
|
exports.PointerPhase = PointerPhase;
|
|
49625
|
+
exports.PostProcess = PostProcess;
|
|
49626
|
+
exports.PostProcessEffect = PostProcessEffect;
|
|
49627
|
+
exports.PostProcessEffectParameter = PostProcessEffectParameter;
|
|
49628
|
+
exports.PostProcessManager = PostProcessManager;
|
|
49629
|
+
exports.PostProcessPass = PostProcessPass;
|
|
49630
|
+
exports.PostProcessPassEvent = PostProcessPassEvent;
|
|
49631
|
+
exports.PostProcessUberPass = PostProcessUberPass;
|
|
48787
49632
|
exports.PrefabResource = PrefabResource;
|
|
48788
49633
|
exports.Primitive = Primitive;
|
|
48789
49634
|
exports.PrimitiveMesh = PrimitiveMesh;
|
|
@@ -48795,6 +49640,7 @@
|
|
|
48795
49640
|
exports.Rect = Rect;
|
|
48796
49641
|
exports.ReferResource = ReferResource;
|
|
48797
49642
|
exports.ReflectionParser = ReflectionParser;
|
|
49643
|
+
exports.RefractionMode = RefractionMode;
|
|
48798
49644
|
exports.RenderBufferDepthFormat = RenderBufferDepthFormat;
|
|
48799
49645
|
exports.RenderFace = RenderFace;
|
|
48800
49646
|
exports.RenderQueue = RenderQueue;
|
|
@@ -48894,7 +49740,6 @@
|
|
|
48894
49740
|
exports.WebGLMode = WebGLMode;
|
|
48895
49741
|
exports.WrapMode = WrapMode;
|
|
48896
49742
|
exports.XRManager = XRManager;
|
|
48897
|
-
exports._PostProcessManager = _PostProcessManager;
|
|
48898
49743
|
exports.assignmentClone = assignmentClone;
|
|
48899
49744
|
exports.decode = decode;
|
|
48900
49745
|
exports.decoder = decoder;
|