@galacean/engine-core 2.0.0-alpha.25 → 2.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +912 -155
- package/dist/main.js.map +1 -1
- package/dist/module.js +912 -156
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/particle/ParticleGenerator.d.ts +3 -0
- package/types/particle/index.d.ts +1 -0
- package/types/particle/modules/NoiseModule.d.ts +90 -0
- package/types/shader/Shader.d.ts +2 -0
- package/types/shader/ShaderMacroProcessor.d.ts +1 -0
- package/types/shader/ShaderPass.d.ts +17 -3
- package/types/shader/enums/ShaderPreprocessorDirective.d.ts +16 -0
- package/types/shaderlib/ShaderLib.d.ts +1 -14
- package/types/shaderlib/particle/index.d.ts +1 -0
package/dist/main.js
CHANGED
|
@@ -1327,6 +1327,12 @@ SystemInfo._initialize();
|
|
|
1327
1327
|
case TextureFormat.ETC2_RGB:
|
|
1328
1328
|
case TextureFormat.ETC2_RGBA8:
|
|
1329
1329
|
case TextureFormat.ASTC_4x4:
|
|
1330
|
+
case TextureFormat.ASTC_5x5:
|
|
1331
|
+
case TextureFormat.ASTC_6x6:
|
|
1332
|
+
case TextureFormat.ASTC_8x8:
|
|
1333
|
+
case TextureFormat.ASTC_10x10:
|
|
1334
|
+
case TextureFormat.ASTC_12x12:
|
|
1335
|
+
case TextureFormat.ETC2_RGBA5:
|
|
1330
1336
|
return true;
|
|
1331
1337
|
default:
|
|
1332
1338
|
return false;
|
|
@@ -1865,7 +1871,7 @@ SystemInfo._initialize();
|
|
|
1865
1871
|
_this = ReferResource.call(this, engine) || this, _this._charInfoMap = {}, _this._space = 1, _this._curX = 1, _this._curY = 1, _this._nextY = 1;
|
|
1866
1872
|
_this.isGCIgnored = true;
|
|
1867
1873
|
var format = engine._hardwareRenderer.isWebGL2 ? TextureFormat.R8 : TextureFormat.Alpha8;
|
|
1868
|
-
var texture = new Texture2D(engine, 512, 512, format, false);
|
|
1874
|
+
var texture = new Texture2D(engine, 512, 512, format, false, false);
|
|
1869
1875
|
texture.filterMode = TextureFilterMode.Bilinear;
|
|
1870
1876
|
texture.isGCIgnored = true;
|
|
1871
1877
|
_this.texture = texture;
|
|
@@ -4825,37 +4831,9 @@ var begin_viewdir_frag = "#ifdef CAMERA_ORTHOGRAPHIC\n vec3 V = -camera_Forwa
|
|
|
4825
4831
|
|
|
4826
4832
|
var mobile_blinnphong_frag = " #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
|
|
4827
4833
|
|
|
4828
|
-
var
|
|
4829
|
-
|
|
4830
|
-
var noise_cellular_2D = "\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
|
|
4831
|
-
|
|
4832
|
-
var noise_cellular_2x2 = "\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
|
|
4833
|
-
|
|
4834
|
-
var noise_cellular_2x2x2 = "\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
|
|
4835
|
-
|
|
4836
|
-
var noise_cellular_3D = "\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
|
|
4837
|
-
|
|
4838
|
-
var noise_common = "// 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
|
|
4839
|
-
|
|
4840
|
-
var noise_perlin = "#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n"; // eslint-disable-line
|
|
4841
|
-
|
|
4842
|
-
var noise_perlin_2D = "//\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
|
|
4843
|
-
|
|
4844
|
-
var noise_perlin_3D = "//\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
|
|
4834
|
+
var noise_common = "// Common helper functions for simplex noise.\n// Algorithm: Ken Perlin, \"Noise hardware\" (2001) — simplex lattice improvement over classic Perlin noise (1985).\n// GLSL implementation: Ian McEwan, Ashima Arts (MIT License) — https://github.com/ashima/webgl-noise\n\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
|
|
4845
4835
|
|
|
4846
|
-
var noise_perlin_4D = "//\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
|
|
4847
|
-
|
|
4848
|
-
var noise_psrd_2D = "// 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
|
|
4849
|
-
|
|
4850
|
-
var noise_simplex = "#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"; // eslint-disable-line
|
|
4851
|
-
|
|
4852
|
-
var noise_simplex_2D = "//\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
|
|
4853
|
-
|
|
4854
|
-
var noise_simplex_3D = "//\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
|
|
4855
|
-
|
|
4856
|
-
var noise_simplex_3D_grad = "//\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
|
|
4857
|
-
|
|
4858
|
-
var noise_simplex_4D = "//\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
|
|
4836
|
+
var noise_simplex_3D_grad = "// 3D simplex noise analytical gradient.\n// Algorithm: Ken Perlin, \"Noise hardware\" (2001) — simplex lattice improvement over classic Perlin noise (1985).\n// Curl noise: Robert Bridson et al., \"Curl-noise for procedural fluid flow\" (2007).\n// GLSL implementation: Ian McEwan, Ashima Arts (MIT License) — https://github.com/ashima/webgl-noise\n\nvec3 simplexGrad( 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 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 // Compute and return noise gradient\n vec4 temp = m2 * m * pdotx;\n vec3 grad = - 8.0 * ( temp.x * x0 + temp.y * x1 + temp.z * x2 + temp.w * x3 );\n grad += m4.x * p0 + m4.y * p1 + m4.z * p2 + m4.w * p3;\n return grad * 42.0;\n\n}\n"; // eslint-disable-line
|
|
4859
4837
|
|
|
4860
4838
|
var pbr_frag_define = "#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n\nuniform float material_AlphaCutoff;\nuniform vec4 material_BaseColor;\nuniform float material_Metal;\nuniform float material_Roughness;\nuniform float material_IOR;\nuniform vec3 material_EmissiveColor;\nuniform float material_NormalIntensity;\nuniform float material_OcclusionIntensity;\nuniform float material_OcclusionTextureCoord;\nuniform float material_SpecularIntensity;\nuniform vec3 material_SpecularColor;\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_TEXTURE\n uniform sampler2D material_SpecularIntensityTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\n uniform sampler2D material_SpecularColorTexture;\n#endif\n\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n uniform sampler2D material_OcclusionTexture;\n#endif\n\n\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform float material_SheenRoughness;\n uniform vec3 material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n uniform sampler2D material_SheenTexture;\n #endif\n\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n uniform sampler2D material_SheenRoughnessTexture;\n #endif\n#endif\n\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n uniform vec4 material_IridescenceInfo;\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n uniform sampler2D material_IridescenceThicknessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n uniform sampler2D material_IridescenceTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION\n uniform float material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n uniform sampler2D material_TransmissionTexture;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n uniform vec3 material_AttenuationColor;\n uniform float material_AttenuationDistance;\n uniform float material_Thickness;\n\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n uniform sampler2D material_ThicknessTexture;\n #endif\n #endif\n#endif\n\n// Runtime\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct Geometry {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n float dotNV;\n \n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatNormal;\n float clearCoatDotNV;\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicT;\n vec3 anisotropicB;\n vec3 anisotropicN;\n float anisotropy;\n #endif\n};\n\nstruct Material {\n vec3 diffuseColor;\n float roughness;\n vec3 specularF0;\n vec3 resolvedSpecularF0;\n float specularF90;\n float specularIntensity;\n vec3 specularColor;\n float opacity;\n float diffuseAO;\n float specularAO;\n vec3 envSpecularDFG;\n vec3 energyCompensation; // Multi-scattering energy compensation factor\n float IOR;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float iridescenceIOR;\n float iridescenceFactor;\n float iridescenceThickness;\n vec3 iridescenceSpecularColor;\n #endif\n\n #ifdef MATERIAL_ENABLE_SHEEN\n float sheenRoughness;\n vec3 sheenColor;\n float sheenScaling;\n float approxIBLSheenDG;\n #endif\n\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 absorptionCoefficient;\n float transmission;\n float thickness;\n #endif\n};\n"; // eslint-disable-line
|
|
4861
4839
|
|
|
@@ -4918,7 +4896,9 @@ var force_over_lifetime_module = "#if defined(RENDERER_FOL_CONSTANT_MODE) || def
|
|
|
4918
4896
|
|
|
4919
4897
|
var limit_velocity_over_lifetime_module = "#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform float renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform float renderer_LVLSpeedMinConst;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedMinCurve[4];\n #endif\n #endif\n #endif\n\n // Per-axis limit\n #ifdef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform vec3 renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec3 renderer_LVLSpeedMinConstVector;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedXMaxCurve[4];\n uniform vec2 renderer_LVLSpeedYMaxCurve[4];\n uniform vec2 renderer_LVLSpeedZMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedXMinCurve[4];\n uniform vec2 renderer_LVLSpeedYMinCurve[4];\n uniform vec2 renderer_LVLSpeedZMinCurve[4];\n #endif\n #endif\n #endif\n\n // Drag curve\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n uniform vec2 renderer_LVLDragMaxCurve[4];\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n uniform vec2 renderer_LVLDragMinCurve[4];\n #endif\n #endif\n\n float evaluateLVLDrag(float normalizedAge, float dragRand) {\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n float dragMax = evaluateParticleCurve(renderer_LVLDragMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n float dragMin = evaluateParticleCurve(renderer_LVLDragMinCurve, normalizedAge);\n return mix(dragMin, dragMax, dragRand);\n #else\n return dragMax;\n #endif\n #else\n return mix(renderer_LVLDragConstant.x, renderer_LVLDragConstant.y, dragRand);\n #endif\n }\n\n vec3 applyLVLSpeedLimitTF(vec3 velocity, float normalizedAge, float limitRand, float effectiveDampen) {\n #ifdef RENDERER_LVL_SEPARATE_AXES\n vec3 limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConstVector, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMaxCurve, normalizedAge)\n );\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n vec3 minLimitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMinCurve, normalizedAge)\n );\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n vec3 absVel = abs(velocity);\n vec3 excess = max(absVel - limitSpeed, vec3(0.0));\n velocity = sign(velocity) * (absVel - excess * effectiveDampen);\n #else\n float limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConst, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = evaluateParticleCurve(renderer_LVLSpeedMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n float minLimitSpeed = evaluateParticleCurve(renderer_LVLSpeedMinCurve, normalizedAge);\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n float speed = length(velocity);\n if (speed > limitSpeed && speed > 0.0) {\n float excess = speed - limitSpeed;\n velocity = velocity * ((speed - excess * effectiveDampen) / speed);\n }\n #endif\n return velocity;\n }\n\n#endif\n"; // eslint-disable-line
|
|
4920
4898
|
|
|
4921
|
-
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // Only VOL overlay needs to be added here.\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n // Local: integrate in local space\n totalVelocity = localVelocity + volLocal\n + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n // World: integrate in world space\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
4899
|
+
var noise_module = "#ifdef RENDERER_NOISE_MODULE_ENABLED\n\n#include <noise_common>\n#include <noise_simplex_3D_grad>\n\nuniform vec4 renderer_NoiseParams; // xyz = strength (constant mode only), w = frequency\nuniform vec4 renderer_NoiseOctaveParams; // x = scrollSpeed, y = octaveCount, z = octaveIntensityMultiplier, w = octaveFrequencyMultiplier\n\n#ifdef RENDERER_NOISE_STRENGTH_CURVE\n uniform vec2 renderer_NoiseStrengthMaxCurveX[4];\n #ifdef RENDERER_NOISE_IS_SEPARATE\n uniform vec2 renderer_NoiseStrengthMaxCurveY[4];\n uniform vec2 renderer_NoiseStrengthMaxCurveZ[4];\n #endif\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n uniform vec2 renderer_NoiseStrengthMinCurveX[4];\n #ifdef RENDERER_NOISE_IS_SEPARATE\n uniform vec2 renderer_NoiseStrengthMinCurveY[4];\n uniform vec2 renderer_NoiseStrengthMinCurveZ[4];\n #endif\n #endif\n#else\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n uniform vec3 renderer_NoiseStrengthMinConst;\n #endif\n#endif\n\nvec3 sampleCurlNoise3D(vec3 coord) {\n float axisOffset = 100.0;\n vec3 gradX = simplexGrad(vec3(coord.z, coord.y, coord.x));\n vec3 gradY = simplexGrad(vec3(coord.x + axisOffset, coord.z, coord.y));\n vec3 gradZ = simplexGrad(vec3(coord.y, coord.x + axisOffset, coord.z));\n return vec3(\n gradZ.x - gradY.y,\n gradX.x - gradZ.y,\n gradY.x - gradX.y\n );\n}\n\nvec3 computeNoiseVelocity(vec3 currentPosition, float normalizedAge) {\n vec3 coord = currentPosition * renderer_NoiseParams.w\n + vec3(renderer_CurrentTime * renderer_NoiseOctaveParams.x);\n\n int octaveCount = int(renderer_NoiseOctaveParams.y);\n float octaveIntensityMultiplier = renderer_NoiseOctaveParams.z;\n float octaveFrequencyMultiplier = renderer_NoiseOctaveParams.w;\n\n vec3 noiseValue = sampleCurlNoise3D(coord);\n float totalAmplitude = 1.0;\n\n // Unrolled octave loop (GLSL ES 1.0 requires constant loop bounds)\n if (octaveCount >= 2) {\n float amplitude = octaveIntensityMultiplier;\n totalAmplitude += amplitude;\n noiseValue += amplitude * sampleCurlNoise3D(coord * octaveFrequencyMultiplier);\n\n if (octaveCount >= 3) {\n amplitude *= octaveIntensityMultiplier;\n totalAmplitude += amplitude;\n noiseValue += amplitude * sampleCurlNoise3D(coord * octaveFrequencyMultiplier * octaveFrequencyMultiplier);\n }\n }\n\n // Evaluate strength (supports Constant, TwoConstants, Curve, TwoCurves).\n vec3 strength;\n #ifdef RENDERER_NOISE_STRENGTH_CURVE\n float sx = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveX, normalizedAge);\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n sx = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveX, normalizedAge), sx, a_Random0.z);\n #endif\n #ifdef RENDERER_NOISE_IS_SEPARATE\n float sy = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveY, normalizedAge);\n float sz = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveZ, normalizedAge);\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n sy = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveY, normalizedAge), sy, a_Random0.z);\n sz = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveZ, normalizedAge), sz, a_Random0.z);\n #endif\n strength = vec3(sx, sy, sz);\n #else\n strength = vec3(sx);\n #endif\n #else\n strength = renderer_NoiseParams.xyz;\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n strength = mix(renderer_NoiseStrengthMinConst, strength, a_Random0.z);\n #endif\n #endif\n\n return (noiseValue / totalAmplitude) * strength;\n}\n\n#endif\n"; // eslint-disable-line
|
|
4900
|
+
|
|
4901
|
+
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n#include <noise_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // VOL and Noise overlays are added here (not persisted).\n\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n totalVelocity = localVelocity + volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n #ifdef RENDERER_NOISE_MODULE_ENABLED\n // Use analytical base position (birth + initial velocity * age) instead of\n // a_FeedbackPosition to avoid feedback loop: position → noise → velocity → position\n vec3 noiseBasePos;\n if (renderer_SimulationSpace == 0) {\n noiseBasePos = a_ShapePositionStartLifeTime.xyz + a_DirectionTime.xyz * a_StartSpeed * age;\n } else {\n noiseBasePos = rotationByQuaternions(\n a_ShapePositionStartLifeTime.xyz + a_DirectionTime.xyz * a_StartSpeed * age,\n worldRotation) + a_SimulationWorldPosition;\n }\n totalVelocity += computeNoiseVelocity(noiseBasePos, normalizedAge);\n #endif\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
4922
4902
|
|
|
4923
4903
|
var sphere_billboard = "#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 = radians(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 = radians(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, radians(a_StartRotation0));\n } else {\n float c = cos(radians(a_StartRotation0.x));\n float s = sin(radians(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
|
|
4924
4904
|
|
|
@@ -4939,6 +4919,7 @@ var ParticleShaderLib = {
|
|
|
4939
4919
|
texture_sheet_animation_module: texture_sheet_animation_module,
|
|
4940
4920
|
force_over_lifetime_module: force_over_lifetime_module,
|
|
4941
4921
|
limit_velocity_over_lifetime_module: limit_velocity_over_lifetime_module,
|
|
4922
|
+
noise_module: noise_module,
|
|
4942
4923
|
particle_feedback_simulation: particle_feedback_simulation,
|
|
4943
4924
|
sphere_billboard: sphere_billboard,
|
|
4944
4925
|
stretched_billboard: stretched_billboard,
|
|
@@ -4980,21 +4961,7 @@ var ShaderLib = _extends({
|
|
|
4980
4961
|
begin_viewdir_frag: begin_viewdir_frag,
|
|
4981
4962
|
mobile_blinnphong_frag: mobile_blinnphong_frag,
|
|
4982
4963
|
noise_common: noise_common,
|
|
4983
|
-
|
|
4984
|
-
noise_cellular_2x2: noise_cellular_2x2,
|
|
4985
|
-
noise_cellular_2x2x2: noise_cellular_2x2x2,
|
|
4986
|
-
noise_cellular_3D: noise_cellular_3D,
|
|
4987
|
-
noise_cellular: noise_cellular,
|
|
4988
|
-
noise_perlin_2D: noise_perlin_2D,
|
|
4989
|
-
noise_perlin_3D: noise_perlin_3D,
|
|
4990
|
-
noise_perlin_4D: noise_perlin_4D,
|
|
4991
|
-
noise_perlin: noise_perlin,
|
|
4992
|
-
noise_psrd_2D: noise_psrd_2D,
|
|
4993
|
-
noise_simplex_2D: noise_simplex_2D,
|
|
4994
|
-
noise_simplex_3D_grad: noise_simplex_3D_grad,
|
|
4995
|
-
noise_simplex_3D: noise_simplex_3D,
|
|
4996
|
-
noise_simplex_4D: noise_simplex_4D,
|
|
4997
|
-
noise_simplex: noise_simplex
|
|
4964
|
+
noise_simplex_3D_grad: noise_simplex_3D_grad
|
|
4998
4965
|
}, ShadowLib, PBRShaderLib, {
|
|
4999
4966
|
normal_get: normal_get
|
|
5000
4967
|
}, ParticleShaderLib);
|
|
@@ -5787,26 +5754,492 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
5787
5754
|
}();
|
|
5788
5755
|
ShaderProgram._counter = 0;
|
|
5789
5756
|
|
|
5757
|
+
function _array_like_to_array(arr, len) {
|
|
5758
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
5759
|
+
|
|
5760
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
5761
|
+
|
|
5762
|
+
return arr2;
|
|
5763
|
+
}
|
|
5764
|
+
|
|
5765
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
5766
|
+
if (!o) return;
|
|
5767
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
5768
|
+
|
|
5769
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5770
|
+
|
|
5771
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5772
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
5773
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
5774
|
+
}
|
|
5775
|
+
|
|
5776
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
5777
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
5778
|
+
|
|
5779
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
5780
|
+
// Fallback for engines without symbol support
|
|
5781
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
5782
|
+
if (it) o = it;
|
|
5783
|
+
|
|
5784
|
+
var i = 0;
|
|
5785
|
+
|
|
5786
|
+
return function() {
|
|
5787
|
+
if (i >= o.length) return { done: true };
|
|
5788
|
+
|
|
5789
|
+
return { done: false, value: o[i++] };
|
|
5790
|
+
};
|
|
5791
|
+
}
|
|
5792
|
+
|
|
5793
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5794
|
+
}
|
|
5795
|
+
|
|
5796
|
+
/**
|
|
5797
|
+
* Directive types for shader preprocessor instructions.
|
|
5798
|
+
*/ var ShaderPreprocessorDirective = /*#__PURE__*/ function(ShaderPreprocessorDirective) {
|
|
5799
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Text"] = 0] = "Text";
|
|
5800
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfDef"] = 1] = "IfDef";
|
|
5801
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfNdef"] = 2] = "IfNdef";
|
|
5802
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfCmp"] = 3] = "IfCmp";
|
|
5803
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfExpr"] = 4] = "IfExpr";
|
|
5804
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Else"] = 5] = "Else";
|
|
5805
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Endif"] = 6] = "Endif";
|
|
5806
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Define"] = 7] = "Define";
|
|
5807
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["DefineVal"] = 8] = "DefineVal";
|
|
5808
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["DefineFunc"] = 9] = "DefineFunc";
|
|
5809
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Undef"] = 10] = "Undef";
|
|
5810
|
+
return ShaderPreprocessorDirective;
|
|
5811
|
+
}({});
|
|
5812
|
+
|
|
5813
|
+
/**
|
|
5814
|
+
* @internal
|
|
5815
|
+
*/ var ShaderMacroProcessor = /*#__PURE__*/ function() {
|
|
5816
|
+
function ShaderMacroProcessor() {}
|
|
5817
|
+
/**
|
|
5818
|
+
* Evaluate a flat instruction array with active macros.
|
|
5819
|
+
* Macros are expanded immediately when text chunks are collected,
|
|
5820
|
+
* using the current macro state at that point (conforming to GLSL/C99 §6.10 standard).
|
|
5821
|
+
* @param instructions - Pre-parsed instruction array
|
|
5822
|
+
* @param macros - Active runtime macros
|
|
5823
|
+
* @returns Pure GLSL string with all conditionals resolved and macros expanded
|
|
5824
|
+
*/ ShaderMacroProcessor.evaluate = function evaluate(instructions, macros) {
|
|
5825
|
+
var valueMacros = ShaderMacroProcessor._valueMacros;
|
|
5826
|
+
var funcMacros = ShaderMacroProcessor._funcMacros;
|
|
5827
|
+
var shaderChunks = ShaderMacroProcessor._shaderChunks;
|
|
5828
|
+
valueMacros.clear();
|
|
5829
|
+
funcMacros.clear();
|
|
5830
|
+
shaderChunks.length = 0;
|
|
5831
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(macros), _step; !(_step = _iterator()).done;){
|
|
5832
|
+
var _step_value = _step.value, name = _step_value[0], value = _step_value[1];
|
|
5833
|
+
valueMacros.set(name, value);
|
|
5834
|
+
}
|
|
5835
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
5836
|
+
var index = 0;
|
|
5837
|
+
var length = instructions.length;
|
|
5838
|
+
while(index < length){
|
|
5839
|
+
var instruction = instructions[index];
|
|
5840
|
+
switch(instruction[0]){
|
|
5841
|
+
case ShaderPreprocessorDirective.Text:
|
|
5842
|
+
// Immediately expand macros using current macro state (GLSL/C99 conformant)
|
|
5843
|
+
shaderChunks.push(ShaderMacroProcessor._expandChunk(instruction[1], valueMacros, funcMacros));
|
|
5844
|
+
index++;
|
|
5845
|
+
break;
|
|
5846
|
+
case ShaderPreprocessorDirective.IfDef:
|
|
5847
|
+
{
|
|
5848
|
+
var name1 = instruction[1];
|
|
5849
|
+
index = valueMacros.has(name1) || funcMacros.has(name1) ? index + 1 : instruction[2];
|
|
5850
|
+
break;
|
|
5851
|
+
}
|
|
5852
|
+
case ShaderPreprocessorDirective.IfNdef:
|
|
5853
|
+
{
|
|
5854
|
+
var name2 = instruction[1];
|
|
5855
|
+
index = !valueMacros.has(name2) && !funcMacros.has(name2) ? index + 1 : instruction[2];
|
|
5856
|
+
break;
|
|
5857
|
+
}
|
|
5858
|
+
case ShaderPreprocessorDirective.IfCmp:
|
|
5859
|
+
{
|
|
5860
|
+
var name3 = instruction[1];
|
|
5861
|
+
var val = valueMacros.get(name3);
|
|
5862
|
+
var matched = val !== undefined && ShaderMacroProcessor._compareValues(Number(val) || 0, instruction[2], instruction[3]);
|
|
5863
|
+
index = matched ? index + 1 : instruction[4];
|
|
5864
|
+
break;
|
|
5865
|
+
}
|
|
5866
|
+
case ShaderPreprocessorDirective.IfExpr:
|
|
5867
|
+
index = ShaderMacroProcessor._evalCondition(instruction[1], valueMacros, funcMacros) ? index + 1 : instruction[2];
|
|
5868
|
+
break;
|
|
5869
|
+
case ShaderPreprocessorDirective.Else:
|
|
5870
|
+
index = instruction[1];
|
|
5871
|
+
break;
|
|
5872
|
+
case ShaderPreprocessorDirective.Endif:
|
|
5873
|
+
index++;
|
|
5874
|
+
break;
|
|
5875
|
+
case ShaderPreprocessorDirective.Define:
|
|
5876
|
+
valueMacros.set(instruction[1], "");
|
|
5877
|
+
index++;
|
|
5878
|
+
break;
|
|
5879
|
+
case ShaderPreprocessorDirective.DefineVal:
|
|
5880
|
+
valueMacros.set(instruction[1], instruction[2]);
|
|
5881
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
5882
|
+
index++;
|
|
5883
|
+
break;
|
|
5884
|
+
case ShaderPreprocessorDirective.DefineFunc:
|
|
5885
|
+
funcMacros.set(instruction[1], {
|
|
5886
|
+
params: instruction[2],
|
|
5887
|
+
body: instruction[3]
|
|
5888
|
+
});
|
|
5889
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
5890
|
+
index++;
|
|
5891
|
+
break;
|
|
5892
|
+
case ShaderPreprocessorDirective.Undef:
|
|
5893
|
+
valueMacros.delete(instruction[1]);
|
|
5894
|
+
funcMacros.delete(instruction[1]);
|
|
5895
|
+
index++;
|
|
5896
|
+
break;
|
|
5897
|
+
default:
|
|
5898
|
+
index++;
|
|
5899
|
+
break;
|
|
5900
|
+
}
|
|
5901
|
+
}
|
|
5902
|
+
return ShaderMacroProcessor._concatChunks(shaderChunks);
|
|
5903
|
+
};
|
|
5904
|
+
/**
|
|
5905
|
+
* Expand macros in a single text chunk using the current macro state.
|
|
5906
|
+
* Returns the chunk as-is if no expandable macros exist.
|
|
5907
|
+
*/ ShaderMacroProcessor._expandChunk = function _expandChunk(chunk, valueMacros, funcMacros) {
|
|
5908
|
+
// Fast path: no expandable macros at this point
|
|
5909
|
+
if (funcMacros.size === 0) {
|
|
5910
|
+
var hasExpandable = false;
|
|
5911
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(valueMacros), _step; !(_step = _iterator()).done;){
|
|
5912
|
+
var _step_value = _step.value, val = _step_value[1];
|
|
5913
|
+
if (val !== "") {
|
|
5914
|
+
hasExpandable = true;
|
|
5915
|
+
break;
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
if (!hasExpandable) return chunk;
|
|
5919
|
+
}
|
|
5920
|
+
// Rebuild first-char filter if macros changed
|
|
5921
|
+
if (ShaderMacroProcessor._macroFirstCharsDirty) {
|
|
5922
|
+
var macroFirstChars = ShaderMacroProcessor._macroFirstChars;
|
|
5923
|
+
macroFirstChars.clear();
|
|
5924
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(valueMacros.keys()), _step1; !(_step1 = _iterator1()).done;){
|
|
5925
|
+
var name = _step1.value;
|
|
5926
|
+
macroFirstChars.add(name.charCodeAt(0));
|
|
5927
|
+
}
|
|
5928
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(funcMacros.keys()), _step2; !(_step2 = _iterator2()).done;){
|
|
5929
|
+
var name1 = _step2.value;
|
|
5930
|
+
macroFirstChars.add(name1.charCodeAt(0));
|
|
5931
|
+
}
|
|
5932
|
+
ShaderMacroProcessor._macroFirstCharsDirty = false;
|
|
5933
|
+
}
|
|
5934
|
+
var macroFirstChars1 = ShaderMacroProcessor._macroFirstChars;
|
|
5935
|
+
var expandedNames = ShaderMacroProcessor._expandedNames;
|
|
5936
|
+
var out = ShaderMacroProcessor._out;
|
|
5937
|
+
out.length = 0;
|
|
5938
|
+
var len = chunk.length;
|
|
5939
|
+
var i = 0;
|
|
5940
|
+
while(i < len){
|
|
5941
|
+
var cc = chunk.charCodeAt(i);
|
|
5942
|
+
if (ShaderMacroProcessor._isIdentifierStart(cc)) {
|
|
5943
|
+
var start = i;
|
|
5944
|
+
i++;
|
|
5945
|
+
while(i < len && ShaderMacroProcessor._isIdentifierPart(chunk.charCodeAt(i)))i++;
|
|
5946
|
+
// Fast path: first char not in any macro name
|
|
5947
|
+
if (!macroFirstChars1.has(chunk.charCodeAt(start))) {
|
|
5948
|
+
out.push(chunk.substring(start, i));
|
|
5949
|
+
continue;
|
|
5950
|
+
}
|
|
5951
|
+
var name2 = chunk.substring(start, i);
|
|
5952
|
+
// Try function macro
|
|
5953
|
+
var func = funcMacros.get(name2);
|
|
5954
|
+
if (func) {
|
|
5955
|
+
var lookAhead = i;
|
|
5956
|
+
while(lookAhead < len && (chunk.charCodeAt(lookAhead) === 32 /* space */ || chunk.charCodeAt(lookAhead) === 9))lookAhead++;
|
|
5957
|
+
if (lookAhead < len && chunk.charCodeAt(lookAhead) === 40 /* '(' */ ) {
|
|
5958
|
+
var args = ShaderMacroProcessor._parseFuncArgs(chunk, lookAhead);
|
|
5959
|
+
if (args) {
|
|
5960
|
+
i = args.end;
|
|
5961
|
+
var expanded = ShaderMacroProcessor._expandFuncBody(func, args.values);
|
|
5962
|
+
expandedNames.clear();
|
|
5963
|
+
expandedNames.add(name2);
|
|
5964
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(expanded, valueMacros, funcMacros, expandedNames));
|
|
5965
|
+
continue;
|
|
5966
|
+
}
|
|
5967
|
+
}
|
|
5968
|
+
}
|
|
5969
|
+
// Try value macro
|
|
5970
|
+
var val1 = valueMacros.get(name2);
|
|
5971
|
+
if (val1 !== undefined && val1 !== "") {
|
|
5972
|
+
expandedNames.clear();
|
|
5973
|
+
expandedNames.add(name2);
|
|
5974
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(val1, valueMacros, funcMacros, expandedNames));
|
|
5975
|
+
continue;
|
|
5976
|
+
}
|
|
5977
|
+
out.push(name2);
|
|
5978
|
+
continue;
|
|
5979
|
+
}
|
|
5980
|
+
// Batch collect non-identifier characters
|
|
5981
|
+
var batchStart = i;
|
|
5982
|
+
while(i < len && !ShaderMacroProcessor._isIdentifierStart(chunk.charCodeAt(i)))i++;
|
|
5983
|
+
out.push(chunk.substring(batchStart, i));
|
|
5984
|
+
}
|
|
5985
|
+
return out.join("");
|
|
5986
|
+
};
|
|
5987
|
+
/**
|
|
5988
|
+
* Recursively expand macro substitution results until no more macros remain.
|
|
5989
|
+
* @param macroExpansion - Intermediate text from a macro substitution that may contain further macro references
|
|
5990
|
+
* @param valueMacros - Current value macro definitions
|
|
5991
|
+
* @param funcMacros - Current function macro definitions
|
|
5992
|
+
* @param expandedNames - Macro names already on the expansion chain, prevents circular references (C99 §6.10.3.4)
|
|
5993
|
+
*/ ShaderMacroProcessor._recursiveExpandMacro = function _recursiveExpandMacro(macroExpansion, valueMacros, funcMacros, expandedNames) {
|
|
5994
|
+
if (macroExpansion.length === 0) return macroExpansion;
|
|
5995
|
+
var len = macroExpansion.length;
|
|
5996
|
+
var out = [];
|
|
5997
|
+
var i = 0;
|
|
5998
|
+
while(i < len){
|
|
5999
|
+
var cc = macroExpansion.charCodeAt(i);
|
|
6000
|
+
if (ShaderMacroProcessor._isIdentifierStart(cc)) {
|
|
6001
|
+
var start = i;
|
|
6002
|
+
i++;
|
|
6003
|
+
while(i < len && ShaderMacroProcessor._isIdentifierPart(macroExpansion.charCodeAt(i)))i++;
|
|
6004
|
+
var name = macroExpansion.substring(start, i);
|
|
6005
|
+
// Skip already-expanded names (circular reference prevention)
|
|
6006
|
+
// Skip GL_ prefixed names (reserved GLSL built-ins, charCodes: G=71, L=76, _=95)
|
|
6007
|
+
if (expandedNames.has(name) || name.charCodeAt(0) === 71 && name.charCodeAt(1) === 76 && name.charCodeAt(2) === 95) {
|
|
6008
|
+
out.push(name);
|
|
6009
|
+
continue;
|
|
6010
|
+
}
|
|
6011
|
+
var func = funcMacros.get(name);
|
|
6012
|
+
if (func) {
|
|
6013
|
+
var lookAhead = i;
|
|
6014
|
+
while(lookAhead < len && (macroExpansion.charCodeAt(lookAhead) === 32 /* space */ || macroExpansion.charCodeAt(lookAhead) === 9))lookAhead++;
|
|
6015
|
+
if (lookAhead < len && macroExpansion.charCodeAt(lookAhead) === 40 /* '(' */ ) {
|
|
6016
|
+
var args = ShaderMacroProcessor._parseFuncArgs(macroExpansion, lookAhead);
|
|
6017
|
+
if (args) {
|
|
6018
|
+
i = args.end;
|
|
6019
|
+
expandedNames.add(name);
|
|
6020
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(ShaderMacroProcessor._expandFuncBody(func, args.values), valueMacros, funcMacros, expandedNames));
|
|
6021
|
+
expandedNames.delete(name);
|
|
6022
|
+
continue;
|
|
6023
|
+
}
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
var val = valueMacros.get(name);
|
|
6027
|
+
if (val !== undefined && val !== "") {
|
|
6028
|
+
expandedNames.add(name);
|
|
6029
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(val, valueMacros, funcMacros, expandedNames));
|
|
6030
|
+
expandedNames.delete(name);
|
|
6031
|
+
continue;
|
|
6032
|
+
}
|
|
6033
|
+
out.push(name);
|
|
6034
|
+
continue;
|
|
6035
|
+
}
|
|
6036
|
+
// Batch collect non-identifier characters
|
|
6037
|
+
var batchStart = i;
|
|
6038
|
+
while(i < len && !ShaderMacroProcessor._isIdentifierStart(macroExpansion.charCodeAt(i)))i++;
|
|
6039
|
+
out.push(macroExpansion.substring(batchStart, i));
|
|
6040
|
+
}
|
|
6041
|
+
return out.join("");
|
|
6042
|
+
};
|
|
6043
|
+
/**
|
|
6044
|
+
* Substitute function macro params in body.
|
|
6045
|
+
*/ ShaderMacroProcessor._expandFuncBody = function _expandFuncBody(func, args) {
|
|
6046
|
+
if (func.params.length === 0 || args.length !== func.params.length) return func.body;
|
|
6047
|
+
var result = func.body;
|
|
6048
|
+
for(var i = 0; i < func.params.length; i++){
|
|
6049
|
+
result = ShaderMacroProcessor._replaceWord(result, func.params[i], args[i]);
|
|
6050
|
+
}
|
|
6051
|
+
return result;
|
|
6052
|
+
};
|
|
6053
|
+
/**
|
|
6054
|
+
* Evaluate a compound condition tree.
|
|
6055
|
+
*/ ShaderMacroProcessor._evalCondition = function _evalCondition(cond, valueMacros, funcMacros) {
|
|
6056
|
+
switch(cond.t){
|
|
6057
|
+
case "def":
|
|
6058
|
+
return valueMacros.has(cond.m) || funcMacros.has(cond.m);
|
|
6059
|
+
case "ndef":
|
|
6060
|
+
return !valueMacros.has(cond.m) && !funcMacros.has(cond.m);
|
|
6061
|
+
case "cmp":
|
|
6062
|
+
{
|
|
6063
|
+
var val = valueMacros.get(cond.m);
|
|
6064
|
+
if (val === undefined) return false;
|
|
6065
|
+
return ShaderMacroProcessor._compareValues(Number(val) || 0, cond.op, cond.v);
|
|
6066
|
+
}
|
|
6067
|
+
case "and":
|
|
6068
|
+
return ShaderMacroProcessor._evalCondition(cond.l, valueMacros, funcMacros) && ShaderMacroProcessor._evalCondition(cond.r, valueMacros, funcMacros);
|
|
6069
|
+
case "or":
|
|
6070
|
+
return ShaderMacroProcessor._evalCondition(cond.l, valueMacros, funcMacros) || ShaderMacroProcessor._evalCondition(cond.r, valueMacros, funcMacros);
|
|
6071
|
+
case "not":
|
|
6072
|
+
return !ShaderMacroProcessor._evalCondition(cond.c, valueMacros, funcMacros);
|
|
6073
|
+
case "bool":
|
|
6074
|
+
return cond.v;
|
|
6075
|
+
}
|
|
6076
|
+
};
|
|
6077
|
+
/**
|
|
6078
|
+
* Evaluate a comparison operator.
|
|
6079
|
+
*/ ShaderMacroProcessor._compareValues = function _compareValues(numVal, op, value) {
|
|
6080
|
+
switch(op){
|
|
6081
|
+
case "==":
|
|
6082
|
+
return numVal === value;
|
|
6083
|
+
case "!=":
|
|
6084
|
+
return numVal !== value;
|
|
6085
|
+
case ">":
|
|
6086
|
+
return numVal > value;
|
|
6087
|
+
case "<":
|
|
6088
|
+
return numVal < value;
|
|
6089
|
+
case ">=":
|
|
6090
|
+
return numVal >= value;
|
|
6091
|
+
case "<=":
|
|
6092
|
+
return numVal <= value;
|
|
6093
|
+
default:
|
|
6094
|
+
return false;
|
|
6095
|
+
}
|
|
6096
|
+
};
|
|
6097
|
+
/**
|
|
6098
|
+
* Parse function macro call arguments.
|
|
6099
|
+
* Returns reusable static result object to avoid allocation.
|
|
6100
|
+
*/ ShaderMacroProcessor._parseFuncArgs = function _parseFuncArgs(text, openParen) {
|
|
6101
|
+
var result = ShaderMacroProcessor._parsedFuncArgs;
|
|
6102
|
+
result.values.length = 0;
|
|
6103
|
+
var level = 1;
|
|
6104
|
+
var argStart = openParen + 1;
|
|
6105
|
+
var k = argStart;
|
|
6106
|
+
var len = text.length;
|
|
6107
|
+
while(k < len && level > 0){
|
|
6108
|
+
var cc = text.charCodeAt(k);
|
|
6109
|
+
if (cc === 40 /* '(' */ ) {
|
|
6110
|
+
level++;
|
|
6111
|
+
} else if (cc === 41 /* ')' */ ) {
|
|
6112
|
+
if (--level === 0) {
|
|
6113
|
+
var arg = text.substring(argStart, k).trim();
|
|
6114
|
+
if (arg.length > 0 || result.values.length > 0) result.values.push(arg);
|
|
6115
|
+
result.end = k + 1;
|
|
6116
|
+
return result;
|
|
6117
|
+
}
|
|
6118
|
+
} else if (cc === 44 /* ',' */ && level === 1) {
|
|
6119
|
+
result.values.push(text.substring(argStart, k).trim());
|
|
6120
|
+
argStart = k + 1;
|
|
6121
|
+
}
|
|
6122
|
+
k++;
|
|
6123
|
+
}
|
|
6124
|
+
return null;
|
|
6125
|
+
};
|
|
6126
|
+
/**
|
|
6127
|
+
* Replace all whole-word occurrences of `word` in `text` with `replacement`.
|
|
6128
|
+
*/ ShaderMacroProcessor._replaceWord = function _replaceWord(text, word, replacement) {
|
|
6129
|
+
var wLen = word.length;
|
|
6130
|
+
var parts = ShaderMacroProcessor._replaceWordParts;
|
|
6131
|
+
parts.length = 0;
|
|
6132
|
+
var start = 0;
|
|
6133
|
+
var idx = text.indexOf(word, start);
|
|
6134
|
+
while(idx !== -1){
|
|
6135
|
+
if (idx > 0 && ShaderMacroProcessor._isIdentifierPart(text.charCodeAt(idx - 1))) {
|
|
6136
|
+
idx = text.indexOf(word, idx + 1);
|
|
6137
|
+
continue;
|
|
6138
|
+
}
|
|
6139
|
+
var afterIdx = idx + wLen;
|
|
6140
|
+
if (afterIdx < text.length && ShaderMacroProcessor._isIdentifierPart(text.charCodeAt(afterIdx))) {
|
|
6141
|
+
idx = text.indexOf(word, idx + 1);
|
|
6142
|
+
continue;
|
|
6143
|
+
}
|
|
6144
|
+
parts.push(text.substring(start, idx));
|
|
6145
|
+
parts.push(replacement);
|
|
6146
|
+
start = afterIdx;
|
|
6147
|
+
idx = text.indexOf(word, start);
|
|
6148
|
+
}
|
|
6149
|
+
if (start === 0) return text;
|
|
6150
|
+
parts.push(text.substring(start));
|
|
6151
|
+
return parts.join("");
|
|
6152
|
+
};
|
|
6153
|
+
/**
|
|
6154
|
+
* Concatenate shader chunks with consecutive blank lines collapsed to a single newline.
|
|
6155
|
+
*/ ShaderMacroProcessor._concatChunks = function _concatChunks(shaderChunks) {
|
|
6156
|
+
var out = ShaderMacroProcessor._out;
|
|
6157
|
+
out.length = 0;
|
|
6158
|
+
var lastNewline = false;
|
|
6159
|
+
for(var p = 0; p < shaderChunks.length; p++){
|
|
6160
|
+
var text = shaderChunks[p];
|
|
6161
|
+
var len = text.length;
|
|
6162
|
+
var i = 0;
|
|
6163
|
+
while(i < len){
|
|
6164
|
+
if (text.charCodeAt(i) === 10 /* \n */ ) {
|
|
6165
|
+
if (!lastNewline) {
|
|
6166
|
+
out.push("\n");
|
|
6167
|
+
lastNewline = true;
|
|
6168
|
+
}
|
|
6169
|
+
i++;
|
|
6170
|
+
while(i < len){
|
|
6171
|
+
var c = text.charCodeAt(i);
|
|
6172
|
+
if (c === 32 /* space */ || c === 9 /* tab */ || c === 10 /* \n */ ) i++;
|
|
6173
|
+
else break;
|
|
6174
|
+
}
|
|
6175
|
+
} else {
|
|
6176
|
+
var batchStart = i;
|
|
6177
|
+
while(i < len && text.charCodeAt(i) !== 10 /* \n */ )i++;
|
|
6178
|
+
out.push(text.substring(batchStart, i));
|
|
6179
|
+
lastNewline = false;
|
|
6180
|
+
}
|
|
6181
|
+
}
|
|
6182
|
+
}
|
|
6183
|
+
return out.join("");
|
|
6184
|
+
};
|
|
6185
|
+
/**
|
|
6186
|
+
* Check if char code is a valid identifier start.
|
|
6187
|
+
* Matches: [A-Z] | [a-z] | _
|
|
6188
|
+
*/ ShaderMacroProcessor._isIdentifierStart = function _isIdentifierStart(charCode) {
|
|
6189
|
+
return charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122 || charCode === 95;
|
|
6190
|
+
};
|
|
6191
|
+
/**
|
|
6192
|
+
* Check if char code is a valid identifier part.
|
|
6193
|
+
* Matches: [A-Z] | [a-z] | [0-9] | _
|
|
6194
|
+
*/ ShaderMacroProcessor._isIdentifierPart = function _isIdentifierPart(charCode) {
|
|
6195
|
+
return charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122 || charCode >= 48 && charCode <= 57 || charCode === 95;
|
|
6196
|
+
};
|
|
6197
|
+
return ShaderMacroProcessor;
|
|
6198
|
+
}();
|
|
6199
|
+
ShaderMacroProcessor._valueMacros = new Map();
|
|
6200
|
+
ShaderMacroProcessor._funcMacros = new Map();
|
|
6201
|
+
ShaderMacroProcessor._shaderChunks = [];
|
|
6202
|
+
ShaderMacroProcessor._out = [];
|
|
6203
|
+
ShaderMacroProcessor._expandedNames = new Set();
|
|
6204
|
+
ShaderMacroProcessor._macroFirstChars = new Set();
|
|
6205
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
6206
|
+
ShaderMacroProcessor._replaceWordParts = [];
|
|
6207
|
+
ShaderMacroProcessor._parsedFuncArgs = {
|
|
6208
|
+
values: [],
|
|
6209
|
+
end: 0
|
|
6210
|
+
};
|
|
6211
|
+
|
|
5790
6212
|
var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";
|
|
5791
6213
|
/**
|
|
5792
6214
|
* Shader pass containing vertex and fragment source.
|
|
5793
6215
|
*/ var ShaderPass = /*#__PURE__*/ function(ShaderPart) {
|
|
5794
6216
|
_inherits(ShaderPass, ShaderPart);
|
|
5795
|
-
function ShaderPass(nameOrVertexSource,
|
|
6217
|
+
function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSourceOrInstructions, fragmentSourceOrTags, tagsOrPlatformTarget, tags) {
|
|
5796
6218
|
var _this;
|
|
5797
6219
|
_this = ShaderPart.call(this) || this, /** @internal */ _this._shaderPassId = 0, /** @internal */ _this._renderStateDataMap = {}, /** @internal */ _this._shaderProgramPools = [];
|
|
5798
6220
|
_this._shaderPassId = ShaderPass._shaderPassCounter++;
|
|
5799
|
-
if (
|
|
6221
|
+
if (Array.isArray(vertexSourceOrFragmentSourceOrInstructions)) {
|
|
6222
|
+
// Instructions overload: (name, vertexInst, fragInst, platformTarget, tags?)
|
|
5800
6223
|
_this._name = nameOrVertexSource;
|
|
5801
|
-
_this.
|
|
5802
|
-
_this.
|
|
6224
|
+
_this._vertexShaderInstructions = vertexSourceOrFragmentSourceOrInstructions;
|
|
6225
|
+
_this._fragmentShaderInstructions = fragmentSourceOrTags;
|
|
6226
|
+
_this._platformTarget = tagsOrPlatformTarget;
|
|
5803
6227
|
tags = _extends({
|
|
5804
6228
|
pipelineStage: PipelineStage.Forward
|
|
5805
6229
|
}, tags);
|
|
6230
|
+
} else if (typeof fragmentSourceOrTags === "string") {
|
|
6231
|
+
// Named overload: (name, vertexSource, fragmentSource, tags?)
|
|
6232
|
+
_this._name = nameOrVertexSource;
|
|
6233
|
+
_this._vertexSource = vertexSourceOrFragmentSourceOrInstructions;
|
|
6234
|
+
_this._fragmentSource = fragmentSourceOrTags;
|
|
6235
|
+
tags = _extends({
|
|
6236
|
+
pipelineStage: PipelineStage.Forward
|
|
6237
|
+
}, tagsOrPlatformTarget);
|
|
5806
6238
|
} else {
|
|
6239
|
+
// Unnamed overload: (vertexSource, fragmentSource, tags?)
|
|
5807
6240
|
_this._name = "Default";
|
|
5808
6241
|
_this._vertexSource = nameOrVertexSource;
|
|
5809
|
-
_this._fragmentSource =
|
|
6242
|
+
_this._fragmentSource = vertexSourceOrFragmentSourceOrInstructions;
|
|
5810
6243
|
tags = _extends({
|
|
5811
6244
|
pipelineStage: PipelineStage.Forward
|
|
5812
6245
|
}, fragmentSourceOrTags);
|
|
@@ -5842,15 +6275,16 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
5842
6275
|
shaderProgramPools.length = 0;
|
|
5843
6276
|
};
|
|
5844
6277
|
_proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
|
|
5845
|
-
|
|
5846
|
-
return this._getShaderLabProgram(engine, macroCollection);
|
|
5847
|
-
}
|
|
5848
|
-
var _ShaderFactory_compilePlatformSource = ShaderFactory.compilePlatformSource(engine, macroCollection, this._vertexSource, this._fragmentSource), vertexSource = _ShaderFactory_compilePlatformSource.vertexSource, fragmentSource = _ShaderFactory_compilePlatformSource.fragmentSource;
|
|
6278
|
+
var _ref = this._platformTarget != undefined ? this._compileShaderLabSource(engine, macroCollection) : this._compilePlatformSource(engine, macroCollection), vertexSource = _ref.vertexSource, fragmentSource = _ref.fragmentSource;
|
|
5849
6279
|
return new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
5850
6280
|
};
|
|
5851
|
-
_proto.
|
|
6281
|
+
_proto._compilePlatformSource = function _compilePlatformSource(engine, macroCollection) {
|
|
6282
|
+
return ShaderFactory.compilePlatformSource(engine, macroCollection, this._vertexSource, this._fragmentSource);
|
|
6283
|
+
};
|
|
6284
|
+
_proto._compileShaderLabSource = function _compileShaderLabSource(engine, macroCollection) {
|
|
5852
6285
|
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
5853
|
-
var shaderMacroList =
|
|
6286
|
+
var shaderMacroList = ShaderPass._shaderMacroList;
|
|
6287
|
+
shaderMacroList.length = 0;
|
|
5854
6288
|
ShaderMacro._getMacrosElements(macroCollection, shaderMacroList);
|
|
5855
6289
|
shaderMacroList.push(ShaderMacro.getByName(isWebGL2 ? "GRAPHICS_API_WEBGL2" : "GRAPHICS_API_WEBGL1"));
|
|
5856
6290
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.shaderTextureLod)) {
|
|
@@ -5859,23 +6293,31 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
5859
6293
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
|
|
5860
6294
|
shaderMacroList.push(ShaderMacro.getByName("HAS_DERIVATIVES"));
|
|
5861
6295
|
}
|
|
5862
|
-
var
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
6296
|
+
var macroMap = ShaderPass._macroMap;
|
|
6297
|
+
macroMap.clear();
|
|
6298
|
+
for(var i = 0, n = shaderMacroList.length; i < n; i++){
|
|
6299
|
+
var macro = shaderMacroList[i];
|
|
6300
|
+
var _macro_value;
|
|
6301
|
+
macroMap.set(macro.name, (_macro_value = macro.value) != null ? _macro_value : "");
|
|
6302
|
+
}
|
|
6303
|
+
var vertexSource = ShaderMacroProcessor.evaluate(this._vertexShaderInstructions, macroMap);
|
|
6304
|
+
var fragmentSource = ShaderMacroProcessor.evaluate(this._fragmentShaderInstructions, macroMap);
|
|
5866
6305
|
if (isWebGL2 && this._platformTarget === ShaderLanguage.GLSLES100) {
|
|
5867
|
-
|
|
5868
|
-
|
|
6306
|
+
vertexSource = ShaderFactory.convertTo300(vertexSource);
|
|
6307
|
+
fragmentSource = ShaderFactory.convertTo300(fragmentSource, true);
|
|
5869
6308
|
}
|
|
5870
6309
|
var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
6310
|
+
return {
|
|
6311
|
+
vertexSource: " " + versionStr + "\n " + vertexSource + "\n ",
|
|
6312
|
+
fragmentSource: " " + versionStr + "\n " + (isWebGL2 ? "" : ShaderFactory._shaderExtension) + "\n " + precisionStr + "\n " + fragmentSource + "\n "
|
|
6313
|
+
};
|
|
5874
6314
|
};
|
|
5875
6315
|
return ShaderPass;
|
|
5876
6316
|
}(ShaderPart);
|
|
5877
6317
|
/** @internal */ ShaderPass._shaderPassCounter = 0;
|
|
5878
6318
|
/** @internal */ ShaderPass._shaderRootPath = "shaders://root/";
|
|
6319
|
+
ShaderPass._shaderMacroList = [];
|
|
6320
|
+
ShaderPass._macroMap = new Map();
|
|
5879
6321
|
|
|
5880
6322
|
/**
|
|
5881
6323
|
* Sub shader.
|
|
@@ -6624,36 +7066,14 @@ __decorate([
|
|
|
6624
7066
|
var subShaderList = shaderSource.subShaders.map(function(subShaderSource) {
|
|
6625
7067
|
var passList = subShaderSource.passes.map(function(passSource) {
|
|
6626
7068
|
if (passSource.isUsePass) {
|
|
6627
|
-
|
|
6628
|
-
var _passSource_name_split = passSource.name.split("/"), shaderName = _passSource_name_split[0], subShaderName = _passSource_name_split[1], passName = _passSource_name_split[2];
|
|
6629
|
-
return (_Shader_find = Shader.find(shaderName)) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
|
|
6630
|
-
return subShader.name === subShaderName;
|
|
6631
|
-
})) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
|
|
6632
|
-
return pass.name === passName;
|
|
6633
|
-
});
|
|
7069
|
+
return Shader._resolveUsePass(passSource.name);
|
|
6634
7070
|
}
|
|
6635
7071
|
var shaderPassSource = Shader._shaderLab._parseShaderPass(passSource.contents, passSource.vertexEntry, passSource.fragmentEntry, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, new URL(fragmentSourceOrPath != null ? fragmentSourceOrPath : "", ShaderPass._shaderRootPath).href);
|
|
6636
7072
|
if (!shaderPassSource) {
|
|
6637
7073
|
throw 'Shader pass "' + shaderSource.name + "." + subShaderSource.name + "." + passSource.name + '" parse failed, please check the shader source code.';
|
|
6638
7074
|
}
|
|
6639
|
-
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.
|
|
6640
|
-
shaderPass.
|
|
6641
|
-
var _passSource_renderStates = passSource.renderStates, constantMap = _passSource_renderStates.constantMap, variableMap = _passSource_renderStates.variableMap;
|
|
6642
|
-
// Compatible shader lab no render state use material `renderState` to modify render state
|
|
6643
|
-
if (Object.keys(constantMap).length > 0 || Object.keys(variableMap).length > 0) {
|
|
6644
|
-
// Parse const render state
|
|
6645
|
-
var renderState = new RenderState();
|
|
6646
|
-
for(var k in constantMap){
|
|
6647
|
-
Shader._applyConstRenderStates(renderState, +k, constantMap[k]);
|
|
6648
|
-
}
|
|
6649
|
-
shaderPass._renderState = renderState;
|
|
6650
|
-
// Parse variable render state
|
|
6651
|
-
var renderStateDataMap = {};
|
|
6652
|
-
for(var k1 in variableMap){
|
|
6653
|
-
renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
|
|
6654
|
-
}
|
|
6655
|
-
shaderPass._renderStateDataMap = renderStateDataMap;
|
|
6656
|
-
}
|
|
7075
|
+
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.vertexShaderInstructions, shaderPassSource.fragmentShaderInstructions, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, passSource.tags);
|
|
7076
|
+
Shader._applyRenderStates(shaderPass, passSource.renderStates.constantMap, passSource.renderStates.variableMap, false);
|
|
6657
7077
|
return shaderPass;
|
|
6658
7078
|
});
|
|
6659
7079
|
return new SubShader(subShaderSource.name, passList, subShaderSource.tags);
|
|
@@ -6698,6 +7118,29 @@ __decorate([
|
|
|
6698
7118
|
};
|
|
6699
7119
|
/**
|
|
6700
7120
|
* @internal
|
|
7121
|
+
*/ Shader._createFromPrecompiled = function _createFromPrecompiled(data) {
|
|
7122
|
+
var shaderMap = Shader._shaderMap;
|
|
7123
|
+
if (shaderMap[data.name]) {
|
|
7124
|
+
console.error('Shader named "' + data.name + '" already exists.');
|
|
7125
|
+
return;
|
|
7126
|
+
}
|
|
7127
|
+
var subShaderList = data.subShaders.map(function(subData) {
|
|
7128
|
+
var passList = subData.passes.map(function(passData) {
|
|
7129
|
+
if (passData.isUsePass) {
|
|
7130
|
+
return Shader._resolveUsePass(passData.name);
|
|
7131
|
+
}
|
|
7132
|
+
var shaderPass = new ShaderPass(passData.name, passData.vertexShaderInstructions, passData.fragmentShaderInstructions, data.platformTarget, passData.tags);
|
|
7133
|
+
Shader._applyRenderStates(shaderPass, passData.renderStates.constantMap, passData.renderStates.variableMap, true);
|
|
7134
|
+
return shaderPass;
|
|
7135
|
+
});
|
|
7136
|
+
return new SubShader(subData.name, passList, subData.tags);
|
|
7137
|
+
});
|
|
7138
|
+
var shader = new Shader(data.name, subShaderList);
|
|
7139
|
+
shaderMap[data.name] = shader;
|
|
7140
|
+
return shader;
|
|
7141
|
+
};
|
|
7142
|
+
/**
|
|
7143
|
+
* @internal
|
|
6701
7144
|
*/ Shader._clear = function _clear(engine) {
|
|
6702
7145
|
var shaderMap = Shader._shaderMap;
|
|
6703
7146
|
for(var key in shaderMap){
|
|
@@ -6718,6 +7161,34 @@ __decorate([
|
|
|
6718
7161
|
}
|
|
6719
7162
|
}
|
|
6720
7163
|
};
|
|
7164
|
+
Shader._resolveUsePass = function _resolveUsePass(passName) {
|
|
7165
|
+
var _Shader_find_subShaders_find, _Shader_find;
|
|
7166
|
+
var _passName_split = passName.split("/"), shaderName = _passName_split[0], subShaderName = _passName_split[1], passNamePart = _passName_split[2];
|
|
7167
|
+
return (_Shader_find = Shader.find(shaderName)) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
|
|
7168
|
+
return subShader.name === subShaderName;
|
|
7169
|
+
})) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
|
|
7170
|
+
return pass.name === passNamePart;
|
|
7171
|
+
});
|
|
7172
|
+
};
|
|
7173
|
+
Shader._applyRenderStates = function _applyRenderStates(shaderPass, constantMap, variableMap, deserializeColor) {
|
|
7174
|
+
if (Object.keys(constantMap).length > 0 || Object.keys(variableMap).length > 0) {
|
|
7175
|
+
var renderState = new RenderState();
|
|
7176
|
+
for(var k in constantMap){
|
|
7177
|
+
var value = constantMap[k];
|
|
7178
|
+
if (deserializeColor && Array.isArray(value)) {
|
|
7179
|
+
Shader._applyConstRenderStates(renderState, +k, new engineMath.Color(value[0], value[1], value[2], value[3]));
|
|
7180
|
+
} else {
|
|
7181
|
+
Shader._applyConstRenderStates(renderState, +k, value);
|
|
7182
|
+
}
|
|
7183
|
+
}
|
|
7184
|
+
shaderPass._renderState = renderState;
|
|
7185
|
+
var renderStateDataMap = {};
|
|
7186
|
+
for(var k1 in variableMap){
|
|
7187
|
+
renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
|
|
7188
|
+
}
|
|
7189
|
+
shaderPass._renderStateDataMap = renderStateDataMap;
|
|
7190
|
+
}
|
|
7191
|
+
};
|
|
6721
7192
|
Shader._applyConstRenderStates = function _applyConstRenderStates(renderState, key, value) {
|
|
6722
7193
|
switch(key){
|
|
6723
7194
|
case RenderStateElementKey.BlendStateEnabled0:
|
|
@@ -9158,7 +9629,15 @@ exports.Camera = /*#__PURE__*/ function(Component) {
|
|
|
9158
9629
|
*/ _proto._getInvViewProjMat = function _getInvViewProjMat() {
|
|
9159
9630
|
if (this._isInvViewProjDirty.flag) {
|
|
9160
9631
|
this._isInvViewProjDirty.flag = false;
|
|
9161
|
-
|
|
9632
|
+
var matrix = this._invViewProjMat;
|
|
9633
|
+
if (this._isCustomViewMatrix) {
|
|
9634
|
+
engineMath.Matrix.invert(this.viewMatrix, matrix);
|
|
9635
|
+
} else {
|
|
9636
|
+
// Ignore scale, consistent with viewMatrix getter
|
|
9637
|
+
var transform = this._entity.transform;
|
|
9638
|
+
engineMath.Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, matrix);
|
|
9639
|
+
}
|
|
9640
|
+
matrix.multiply(this._getInverseProjectionMatrix());
|
|
9162
9641
|
}
|
|
9163
9642
|
return this._invViewProjMat;
|
|
9164
9643
|
};
|
|
@@ -22447,7 +22926,7 @@ __decorate([
|
|
|
22447
22926
|
deepClone
|
|
22448
22927
|
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
22449
22928
|
__decorate([
|
|
22450
|
-
|
|
22929
|
+
deepClone
|
|
22451
22930
|
], Skin.prototype, "_skinMatrices", void 0);
|
|
22452
22931
|
__decorate([
|
|
22453
22932
|
ignoreClone
|
|
@@ -23447,7 +23926,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
23447
23926
|
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
23448
23927
|
var activeChangedComponents = this._activeChangedComponents;
|
|
23449
23928
|
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
23450
|
-
activeChangedComponents[i]
|
|
23929
|
+
var component = activeChangedComponents[i];
|
|
23930
|
+
// Skip components whose scene was already cleared by an earlier callback's removeChild
|
|
23931
|
+
if (!isActive && !component._entity._scene) continue;
|
|
23932
|
+
component._setActive(isActive, activeChangeFlag);
|
|
23451
23933
|
}
|
|
23452
23934
|
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
23453
23935
|
this._activeChangedComponents = null;
|
|
@@ -23467,18 +23949,19 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
23467
23949
|
}
|
|
23468
23950
|
};
|
|
23469
23951
|
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
23952
|
+
// Children-first, reverse traversal for safe removeChild during callbacks
|
|
23953
|
+
var children = this._children;
|
|
23954
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
23955
|
+
var child = children[i];
|
|
23956
|
+
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
23957
|
+
}
|
|
23470
23958
|
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
23471
23959
|
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
23472
23960
|
var components = this._components;
|
|
23473
|
-
for(var
|
|
23474
|
-
var component = components[
|
|
23961
|
+
for(var i1 = 0, n = components.length; i1 < n; i1++){
|
|
23962
|
+
var component = components[i1];
|
|
23475
23963
|
component.enabled && activeChangedComponents.push(component);
|
|
23476
23964
|
}
|
|
23477
|
-
var children = this._children;
|
|
23478
|
-
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
23479
|
-
var child = children[i1];
|
|
23480
|
-
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
23481
|
-
}
|
|
23482
23965
|
};
|
|
23483
23966
|
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
23484
23967
|
target = Math.min(target, sibling.length - 1);
|
|
@@ -26390,7 +26873,7 @@ var depthOnlyVs = "#define MATERIAL_OMIT_NORMAL\n#include <common>\n#include <co
|
|
|
26390
26873
|
|
|
26391
26874
|
var particleFs = "#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n \nuniform mediump vec3 material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\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#if defined(RENDERER_MODE_MESH) && defined(RENDERER_ENABLE_VERTEXCOLOR)\n\t\tcolor *= v_MeshColor;\n\t#endif\n\n\t#ifdef MATERIAL_HAS_BASETEXTURE\n\t\tcolor *= texture2DSRGB(material_BaseTexture, v_TextureCoordinate);\n\t#endif\n\t\n\t// Emissive\n\tvec3 emissiveRadiance = material_EmissiveColor;\n\t#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n\t\temissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_TextureCoordinate).rgb;\n\t#endif\n\n\tcolor.rgb += emissiveRadiance;\n\n\tgl_FragColor = color;\n}"; // eslint-disable-line
|
|
26392
26875
|
|
|
26393
|
-
var particleVs = "#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 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\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_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\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 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 <force_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\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\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\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\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.zw + TEXCOORD_0 * a_SimulationUV.xy;\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}"; // eslint-disable-line
|
|
26876
|
+
var particleVs = "#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 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\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_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\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 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 <force_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#include <noise_module>\n\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\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\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\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.zw + TEXCOORD_0 * a_SimulationUV.xy;\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}"; // eslint-disable-line
|
|
26394
26877
|
|
|
26395
26878
|
var pbrSpecularFs = "#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\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n}\n"; // eslint-disable-line
|
|
26396
26879
|
|
|
@@ -28860,45 +29343,6 @@ Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
|
|
|
28860
29343
|
Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
|
|
28861
29344
|
Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
|
|
28862
29345
|
|
|
28863
|
-
function _array_like_to_array(arr, len) {
|
|
28864
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
28865
|
-
|
|
28866
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
28867
|
-
|
|
28868
|
-
return arr2;
|
|
28869
|
-
}
|
|
28870
|
-
|
|
28871
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
28872
|
-
if (!o) return;
|
|
28873
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
28874
|
-
|
|
28875
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
28876
|
-
|
|
28877
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
28878
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
28879
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
28880
|
-
}
|
|
28881
|
-
|
|
28882
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
28883
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
28884
|
-
|
|
28885
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
28886
|
-
// Fallback for engines without symbol support
|
|
28887
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
28888
|
-
if (it) o = it;
|
|
28889
|
-
|
|
28890
|
-
var i = 0;
|
|
28891
|
-
|
|
28892
|
-
return function() {
|
|
28893
|
-
if (i >= o.length) return { done: true };
|
|
28894
|
-
|
|
28895
|
-
return { done: false, value: o[i++] };
|
|
28896
|
-
};
|
|
28897
|
-
}
|
|
28898
|
-
|
|
28899
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
28900
|
-
}
|
|
28901
|
-
|
|
28902
29346
|
/**
|
|
28903
29347
|
* Script class, used for logic writing.
|
|
28904
29348
|
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
@@ -33293,7 +33737,7 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
|
|
|
33293
33737
|
_inherits(ParticleRenderer, Renderer);
|
|
33294
33738
|
function ParticleRenderer(entity) {
|
|
33295
33739
|
var _this;
|
|
33296
|
-
_this = Renderer.call(this, entity) || this, /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0, /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2, /** The pivot of particle. */ _this.pivot = new engineMath.Vector3(), /** @internal */ _this._generatorBounds = new engineMath.BoundingBox(), /** @internal */ _this._transformedBounds = new engineMath.BoundingBox();
|
|
33740
|
+
_this = Renderer.call(this, entity) || this, /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0, /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2, /** The pivot of particle. */ _this.pivot = new engineMath.Vector3(), /** @internal */ _this._generatorBounds = new engineMath.BoundingBox(), /** @internal */ _this._transformedBounds = new engineMath.BoundingBox(), _this._renderMode = ParticleRenderMode.Billboard;
|
|
33297
33741
|
_this._onGeneratorParamsChanged = _this._onGeneratorParamsChanged.bind(_this);
|
|
33298
33742
|
_this.generator = new ParticleGenerator(_this);
|
|
33299
33743
|
_this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
|
|
@@ -33899,6 +34343,7 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
33899
34343
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 2759560269] = "GravityModifier";
|
|
33900
34344
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["ForceOverLifetime"] = 3875246972] = "ForceOverLifetime";
|
|
33901
34345
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["LimitVelocityOverLifetime"] = 3047300990] = "LimitVelocityOverLifetime";
|
|
34346
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Noise"] = 4105357473] = "Noise";
|
|
33902
34347
|
return ParticleRandomSubSeeds;
|
|
33903
34348
|
}({});
|
|
33904
34349
|
|
|
@@ -35282,7 +35727,7 @@ __decorate([
|
|
|
35282
35727
|
return;
|
|
35283
35728
|
}
|
|
35284
35729
|
this._enabled = value;
|
|
35285
|
-
this._generator._setTransformFeedback(
|
|
35730
|
+
this._generator._setTransformFeedback();
|
|
35286
35731
|
this._generator._renderer._onGeneratorParamsChanged();
|
|
35287
35732
|
}
|
|
35288
35733
|
}
|
|
@@ -36228,6 +36673,298 @@ __decorate([
|
|
|
36228
36673
|
ignoreClone
|
|
36229
36674
|
], TextureSheetAnimationModule.prototype, "_onTilingChanged", null);
|
|
36230
36675
|
|
|
36676
|
+
/**
|
|
36677
|
+
* Noise module for particle system.
|
|
36678
|
+
* Adds simplex noise-based turbulence displacement to particles.
|
|
36679
|
+
*/ var NoiseModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
36680
|
+
_inherits(NoiseModule, ParticleGeneratorModule);
|
|
36681
|
+
function NoiseModule(generator) {
|
|
36682
|
+
var _this;
|
|
36683
|
+
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._noiseRand = new engineMath.Rand(0, ParticleRandomSubSeeds.Noise), _this._noiseParams = new engineMath.Vector4(), _this._noiseOctaveParams = new engineMath.Vector4(), _this._strengthMinConst = new engineMath.Vector3(), _this._scrollSpeed = 0, _this._separateAxes = false, _this._frequency = 0.5, _this._octaveCount = 1, _this._octaveIntensityMultiplier = 0.5, _this._octaveFrequencyMultiplier = 2.0;
|
|
36684
|
+
_this.strengthX = new ParticleCompositeCurve(1);
|
|
36685
|
+
_this.strengthY = new ParticleCompositeCurve(1);
|
|
36686
|
+
_this.strengthZ = new ParticleCompositeCurve(1);
|
|
36687
|
+
return _this;
|
|
36688
|
+
}
|
|
36689
|
+
var _proto = NoiseModule.prototype;
|
|
36690
|
+
/**
|
|
36691
|
+
* @internal
|
|
36692
|
+
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
36693
|
+
var enabledMacro = null;
|
|
36694
|
+
var strengthCurveMacro = null;
|
|
36695
|
+
var strengthIsRandomTwoMacro = null;
|
|
36696
|
+
var separateAxesMacro = null;
|
|
36697
|
+
if (this.enabled) {
|
|
36698
|
+
enabledMacro = NoiseModule._enabledMacro;
|
|
36699
|
+
var strengthX = this._strengthX;
|
|
36700
|
+
var strengthY = this._strengthY;
|
|
36701
|
+
var strengthZ = this._strengthZ;
|
|
36702
|
+
var separateAxes = this._separateAxes;
|
|
36703
|
+
// Determine strength curve mode (following SOL pattern)
|
|
36704
|
+
var isRandomCurveMode = separateAxes ? strengthX.mode === ParticleCurveMode.TwoCurves && strengthY.mode === ParticleCurveMode.TwoCurves && strengthZ.mode === ParticleCurveMode.TwoCurves : strengthX.mode === ParticleCurveMode.TwoCurves;
|
|
36705
|
+
var isCurveMode = isRandomCurveMode || (separateAxes ? strengthX.mode === ParticleCurveMode.Curve && strengthY.mode === ParticleCurveMode.Curve && strengthZ.mode === ParticleCurveMode.Curve : strengthX.mode === ParticleCurveMode.Curve);
|
|
36706
|
+
var isRandomConstMode = separateAxes ? strengthX.mode === ParticleCurveMode.TwoConstants && strengthY.mode === ParticleCurveMode.TwoConstants && strengthZ.mode === ParticleCurveMode.TwoConstants : strengthX.mode === ParticleCurveMode.TwoConstants;
|
|
36707
|
+
// noiseParams.w = frequency (always needed)
|
|
36708
|
+
var noiseParams = this._noiseParams;
|
|
36709
|
+
if (isCurveMode) {
|
|
36710
|
+
// Curve/TwoCurves: encode curve data as float arrays
|
|
36711
|
+
shaderData.setFloatArray(NoiseModule._strengthMaxCurveXProperty, strengthX.curveMax._getTypeArray());
|
|
36712
|
+
if (separateAxes) {
|
|
36713
|
+
shaderData.setFloatArray(NoiseModule._strengthMaxCurveYProperty, strengthY.curveMax._getTypeArray());
|
|
36714
|
+
shaderData.setFloatArray(NoiseModule._strengthMaxCurveZProperty, strengthZ.curveMax._getTypeArray());
|
|
36715
|
+
}
|
|
36716
|
+
if (isRandomCurveMode) {
|
|
36717
|
+
shaderData.setFloatArray(NoiseModule._strengthMinCurveXProperty, strengthX.curveMin._getTypeArray());
|
|
36718
|
+
if (separateAxes) {
|
|
36719
|
+
shaderData.setFloatArray(NoiseModule._strengthMinCurveYProperty, strengthY.curveMin._getTypeArray());
|
|
36720
|
+
shaderData.setFloatArray(NoiseModule._strengthMinCurveZProperty, strengthZ.curveMin._getTypeArray());
|
|
36721
|
+
}
|
|
36722
|
+
strengthIsRandomTwoMacro = NoiseModule._strengthIsRandomTwoMacro;
|
|
36723
|
+
}
|
|
36724
|
+
strengthCurveMacro = NoiseModule._strengthCurveMacro;
|
|
36725
|
+
// xyz unused in curve mode, just set frequency
|
|
36726
|
+
noiseParams.set(0, 0, 0, this._frequency);
|
|
36727
|
+
} else {
|
|
36728
|
+
// Constant/TwoConstants: pack strength into noiseParams.xyz
|
|
36729
|
+
if (separateAxes) {
|
|
36730
|
+
noiseParams.set(strengthX.constantMax, strengthY.constantMax, strengthZ.constantMax, this._frequency);
|
|
36731
|
+
} else {
|
|
36732
|
+
var s = strengthX.constantMax;
|
|
36733
|
+
noiseParams.set(s, s, s, this._frequency);
|
|
36734
|
+
}
|
|
36735
|
+
if (isRandomConstMode) {
|
|
36736
|
+
var minConst = this._strengthMinConst;
|
|
36737
|
+
if (separateAxes) {
|
|
36738
|
+
minConst.set(strengthX.constantMin, strengthY.constantMin, strengthZ.constantMin);
|
|
36739
|
+
} else {
|
|
36740
|
+
var sMin = strengthX.constantMin;
|
|
36741
|
+
minConst.set(sMin, sMin, sMin);
|
|
36742
|
+
}
|
|
36743
|
+
shaderData.setVector3(NoiseModule._strengthMinConstProperty, minConst);
|
|
36744
|
+
strengthIsRandomTwoMacro = NoiseModule._strengthIsRandomTwoMacro;
|
|
36745
|
+
}
|
|
36746
|
+
}
|
|
36747
|
+
shaderData.setVector4(NoiseModule._noiseProperty, noiseParams);
|
|
36748
|
+
if (separateAxes) {
|
|
36749
|
+
separateAxesMacro = NoiseModule._separateAxesMacro;
|
|
36750
|
+
}
|
|
36751
|
+
var noiseOctaveParams = this._noiseOctaveParams;
|
|
36752
|
+
noiseOctaveParams.set(this._scrollSpeed, this._octaveCount, this._octaveIntensityMultiplier, this._octaveFrequencyMultiplier);
|
|
36753
|
+
shaderData.setVector4(NoiseModule._noiseOctaveProperty, noiseOctaveParams);
|
|
36754
|
+
}
|
|
36755
|
+
this._enabledModuleMacro = this._enableMacro(shaderData, this._enabledModuleMacro, enabledMacro);
|
|
36756
|
+
this._strengthCurveModeMacro = this._enableMacro(shaderData, this._strengthCurveModeMacro, strengthCurveMacro);
|
|
36757
|
+
this._strengthIsRandomTwoModeMacro = this._enableMacro(shaderData, this._strengthIsRandomTwoModeMacro, strengthIsRandomTwoMacro);
|
|
36758
|
+
this._separateAxesModeMacro = this._enableMacro(shaderData, this._separateAxesModeMacro, separateAxesMacro);
|
|
36759
|
+
};
|
|
36760
|
+
/**
|
|
36761
|
+
* @internal
|
|
36762
|
+
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
36763
|
+
this._noiseRand.reset(seed, ParticleRandomSubSeeds.Noise);
|
|
36764
|
+
};
|
|
36765
|
+
_create_class(NoiseModule, [
|
|
36766
|
+
{
|
|
36767
|
+
key: "separateAxes",
|
|
36768
|
+
get: /**
|
|
36769
|
+
* Specifies whether the strength is separate on each axis, when disabled, only `strength` is used.
|
|
36770
|
+
*/ function get() {
|
|
36771
|
+
return this._separateAxes;
|
|
36772
|
+
},
|
|
36773
|
+
set: function set(value) {
|
|
36774
|
+
if (value !== this._separateAxes) {
|
|
36775
|
+
this._separateAxes = value;
|
|
36776
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36777
|
+
}
|
|
36778
|
+
}
|
|
36779
|
+
},
|
|
36780
|
+
{
|
|
36781
|
+
key: "strengthX",
|
|
36782
|
+
get: /**
|
|
36783
|
+
* Noise strength. When `separateAxes` is disabled, applies to all axes.
|
|
36784
|
+
* When `separateAxes` is enabled, applies only to x axis.
|
|
36785
|
+
*/ function get() {
|
|
36786
|
+
return this._strengthX;
|
|
36787
|
+
},
|
|
36788
|
+
set: function set(value) {
|
|
36789
|
+
var lastValue = this._strengthX;
|
|
36790
|
+
if (value !== lastValue) {
|
|
36791
|
+
this._strengthX = value;
|
|
36792
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
36793
|
+
}
|
|
36794
|
+
}
|
|
36795
|
+
},
|
|
36796
|
+
{
|
|
36797
|
+
key: "strengthY",
|
|
36798
|
+
get: /**
|
|
36799
|
+
* Noise strength for y axis, used when `separateAxes` is enabled.
|
|
36800
|
+
*/ function get() {
|
|
36801
|
+
return this._strengthY;
|
|
36802
|
+
},
|
|
36803
|
+
set: function set(value) {
|
|
36804
|
+
var lastValue = this._strengthY;
|
|
36805
|
+
if (value !== lastValue) {
|
|
36806
|
+
this._strengthY = value;
|
|
36807
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
36808
|
+
}
|
|
36809
|
+
}
|
|
36810
|
+
},
|
|
36811
|
+
{
|
|
36812
|
+
key: "strengthZ",
|
|
36813
|
+
get: /**
|
|
36814
|
+
* Noise strength for z axis, used when `separateAxes` is enabled.
|
|
36815
|
+
*/ function get() {
|
|
36816
|
+
return this._strengthZ;
|
|
36817
|
+
},
|
|
36818
|
+
set: function set(value) {
|
|
36819
|
+
var lastValue = this._strengthZ;
|
|
36820
|
+
if (value !== lastValue) {
|
|
36821
|
+
this._strengthZ = value;
|
|
36822
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
36823
|
+
}
|
|
36824
|
+
}
|
|
36825
|
+
},
|
|
36826
|
+
{
|
|
36827
|
+
key: "frequency",
|
|
36828
|
+
get: /**
|
|
36829
|
+
* Noise spatial frequency.
|
|
36830
|
+
*/ function get() {
|
|
36831
|
+
return this._frequency;
|
|
36832
|
+
},
|
|
36833
|
+
set: function set(value) {
|
|
36834
|
+
value = Math.max(1e-6, value);
|
|
36835
|
+
if (value !== this._frequency) {
|
|
36836
|
+
this._frequency = value;
|
|
36837
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36838
|
+
}
|
|
36839
|
+
}
|
|
36840
|
+
},
|
|
36841
|
+
{
|
|
36842
|
+
key: "scrollSpeed",
|
|
36843
|
+
get: /**
|
|
36844
|
+
* Noise field scroll speed over time.
|
|
36845
|
+
*/ function get() {
|
|
36846
|
+
return this._scrollSpeed;
|
|
36847
|
+
},
|
|
36848
|
+
set: function set(value) {
|
|
36849
|
+
if (value !== this._scrollSpeed) {
|
|
36850
|
+
this._scrollSpeed = value;
|
|
36851
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36852
|
+
}
|
|
36853
|
+
}
|
|
36854
|
+
},
|
|
36855
|
+
{
|
|
36856
|
+
key: "octaveCount",
|
|
36857
|
+
get: /**
|
|
36858
|
+
* Number of noise octave layers (1-3).
|
|
36859
|
+
*/ function get() {
|
|
36860
|
+
return this._octaveCount;
|
|
36861
|
+
},
|
|
36862
|
+
set: function set(value) {
|
|
36863
|
+
value = Math.max(1, Math.min(3, Math.floor(value)));
|
|
36864
|
+
if (value !== this._octaveCount) {
|
|
36865
|
+
this._octaveCount = value;
|
|
36866
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36867
|
+
}
|
|
36868
|
+
}
|
|
36869
|
+
},
|
|
36870
|
+
{
|
|
36871
|
+
key: "octaveIntensityMultiplier",
|
|
36872
|
+
get: /**
|
|
36873
|
+
* Intensity multiplier for each successive octave, only effective when `octaveCount` > 1.
|
|
36874
|
+
* Each layer's contribution is scaled by this factor relative to the previous layer, range [0, 1].
|
|
36875
|
+
*/ function get() {
|
|
36876
|
+
return this._octaveIntensityMultiplier;
|
|
36877
|
+
},
|
|
36878
|
+
set: function set(value) {
|
|
36879
|
+
value = Math.max(0, Math.min(1, value));
|
|
36880
|
+
if (value !== this._octaveIntensityMultiplier) {
|
|
36881
|
+
this._octaveIntensityMultiplier = value;
|
|
36882
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36883
|
+
}
|
|
36884
|
+
}
|
|
36885
|
+
},
|
|
36886
|
+
{
|
|
36887
|
+
key: "octaveFrequencyMultiplier",
|
|
36888
|
+
get: /**
|
|
36889
|
+
* Frequency multiplier for each successive octave, only effective when `octaveCount` > 1.
|
|
36890
|
+
* Each layer samples at this multiple of the previous layer's frequency, range [1, 4].
|
|
36891
|
+
*/ function get() {
|
|
36892
|
+
return this._octaveFrequencyMultiplier;
|
|
36893
|
+
},
|
|
36894
|
+
set: function set(value) {
|
|
36895
|
+
value = Math.max(1, Math.min(4, value));
|
|
36896
|
+
if (value !== this._octaveFrequencyMultiplier) {
|
|
36897
|
+
this._octaveFrequencyMultiplier = value;
|
|
36898
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36899
|
+
}
|
|
36900
|
+
}
|
|
36901
|
+
},
|
|
36902
|
+
{
|
|
36903
|
+
key: "enabled",
|
|
36904
|
+
get: function get() {
|
|
36905
|
+
return this._enabled;
|
|
36906
|
+
},
|
|
36907
|
+
set: function set(value) {
|
|
36908
|
+
if (value !== this._enabled) {
|
|
36909
|
+
if (value && !this._generator._renderer.engine._hardwareRenderer.isWebGL2) {
|
|
36910
|
+
return;
|
|
36911
|
+
}
|
|
36912
|
+
this._enabled = value;
|
|
36913
|
+
this._generator._setTransformFeedback();
|
|
36914
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
36915
|
+
}
|
|
36916
|
+
}
|
|
36917
|
+
}
|
|
36918
|
+
]);
|
|
36919
|
+
return NoiseModule;
|
|
36920
|
+
}(ParticleGeneratorModule);
|
|
36921
|
+
NoiseModule._enabledMacro = ShaderMacro.getByName("RENDERER_NOISE_MODULE_ENABLED");
|
|
36922
|
+
NoiseModule._strengthCurveMacro = ShaderMacro.getByName("RENDERER_NOISE_STRENGTH_CURVE");
|
|
36923
|
+
NoiseModule._strengthIsRandomTwoMacro = ShaderMacro.getByName("RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO");
|
|
36924
|
+
NoiseModule._separateAxesMacro = ShaderMacro.getByName("RENDERER_NOISE_IS_SEPARATE");
|
|
36925
|
+
NoiseModule._noiseProperty = ShaderProperty.getByName("renderer_NoiseParams");
|
|
36926
|
+
NoiseModule._noiseOctaveProperty = ShaderProperty.getByName("renderer_NoiseOctaveParams");
|
|
36927
|
+
NoiseModule._strengthMinConstProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinConst");
|
|
36928
|
+
NoiseModule._strengthMaxCurveXProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveX");
|
|
36929
|
+
NoiseModule._strengthMaxCurveYProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveY");
|
|
36930
|
+
NoiseModule._strengthMaxCurveZProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveZ");
|
|
36931
|
+
NoiseModule._strengthMinCurveXProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveX");
|
|
36932
|
+
NoiseModule._strengthMinCurveYProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveY");
|
|
36933
|
+
NoiseModule._strengthMinCurveZProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveZ");
|
|
36934
|
+
__decorate([
|
|
36935
|
+
ignoreClone
|
|
36936
|
+
], NoiseModule.prototype, "_enabledModuleMacro", void 0);
|
|
36937
|
+
__decorate([
|
|
36938
|
+
ignoreClone
|
|
36939
|
+
], NoiseModule.prototype, "_strengthCurveModeMacro", void 0);
|
|
36940
|
+
__decorate([
|
|
36941
|
+
ignoreClone
|
|
36942
|
+
], NoiseModule.prototype, "_strengthIsRandomTwoModeMacro", void 0);
|
|
36943
|
+
__decorate([
|
|
36944
|
+
ignoreClone
|
|
36945
|
+
], NoiseModule.prototype, "_separateAxesModeMacro", void 0);
|
|
36946
|
+
__decorate([
|
|
36947
|
+
ignoreClone
|
|
36948
|
+
], NoiseModule.prototype, "_noiseRand", void 0);
|
|
36949
|
+
__decorate([
|
|
36950
|
+
ignoreClone
|
|
36951
|
+
], NoiseModule.prototype, "_noiseParams", void 0);
|
|
36952
|
+
__decorate([
|
|
36953
|
+
ignoreClone
|
|
36954
|
+
], NoiseModule.prototype, "_noiseOctaveParams", void 0);
|
|
36955
|
+
__decorate([
|
|
36956
|
+
ignoreClone
|
|
36957
|
+
], NoiseModule.prototype, "_strengthMinConst", void 0);
|
|
36958
|
+
__decorate([
|
|
36959
|
+
deepClone
|
|
36960
|
+
], NoiseModule.prototype, "_strengthX", void 0);
|
|
36961
|
+
__decorate([
|
|
36962
|
+
deepClone
|
|
36963
|
+
], NoiseModule.prototype, "_strengthY", void 0);
|
|
36964
|
+
__decorate([
|
|
36965
|
+
deepClone
|
|
36966
|
+
], NoiseModule.prototype, "_strengthZ", void 0);
|
|
36967
|
+
|
|
36231
36968
|
/**
|
|
36232
36969
|
* Velocity over lifetime module.
|
|
36233
36970
|
*/ var VelocityOverLifetimeModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
@@ -36434,6 +37171,7 @@ __decorate([
|
|
|
36434
37171
|
this.forceOverLifetime = new ForceOverLifetimeModule(this);
|
|
36435
37172
|
this.sizeOverLifetime = new SizeOverLifetimeModule(this);
|
|
36436
37173
|
this.limitVelocityOverLifetime = new LimitVelocityOverLifetimeModule(this);
|
|
37174
|
+
this.noise = new NoiseModule(this);
|
|
36437
37175
|
this.emission.enabled = true;
|
|
36438
37176
|
}
|
|
36439
37177
|
var _proto = ParticleGenerator.prototype;
|
|
@@ -36741,6 +37479,7 @@ __decorate([
|
|
|
36741
37479
|
this.sizeOverLifetime._updateShaderData(shaderData);
|
|
36742
37480
|
this.rotationOverLifetime._updateShaderData(shaderData);
|
|
36743
37481
|
this.colorOverLifetime._updateShaderData(shaderData);
|
|
37482
|
+
this.noise._updateShaderData(shaderData);
|
|
36744
37483
|
};
|
|
36745
37484
|
/**
|
|
36746
37485
|
* @internal
|
|
@@ -36754,16 +37493,19 @@ __decorate([
|
|
|
36754
37493
|
this.limitVelocityOverLifetime._resetRandomSeed(seed);
|
|
36755
37494
|
this.rotationOverLifetime._resetRandomSeed(seed);
|
|
36756
37495
|
this.colorOverLifetime._resetRandomSeed(seed);
|
|
37496
|
+
this.noise._resetRandomSeed(seed);
|
|
36757
37497
|
};
|
|
36758
37498
|
/**
|
|
36759
37499
|
* @internal
|
|
36760
|
-
*/ _proto._setTransformFeedback = function _setTransformFeedback(
|
|
36761
|
-
this.
|
|
37500
|
+
*/ _proto._setTransformFeedback = function _setTransformFeedback() {
|
|
37501
|
+
var needed = this.limitVelocityOverLifetime.enabled || this.noise.enabled;
|
|
37502
|
+
if (needed === this._useTransformFeedback) return;
|
|
37503
|
+
this._useTransformFeedback = needed;
|
|
36762
37504
|
// Switching TF mode invalidates all active particle state: feedback buffers and instance
|
|
36763
37505
|
// buffer layout are incompatible between the two paths. Clear rather than show a one-frame
|
|
36764
37506
|
// jump; new particles will fill in naturally from the next emit cycle.
|
|
36765
37507
|
this._clearActiveParticles();
|
|
36766
|
-
if (
|
|
37508
|
+
if (needed) {
|
|
36767
37509
|
if (!this._feedbackSimulator) {
|
|
36768
37510
|
this._feedbackSimulator = new ParticleTransformFeedbackSimulator(this._renderer.engine);
|
|
36769
37511
|
}
|
|
@@ -36813,9 +37555,7 @@ __decorate([
|
|
|
36813
37555
|
/**
|
|
36814
37556
|
* @internal
|
|
36815
37557
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
36816
|
-
|
|
36817
|
-
target._setTransformFeedback(true);
|
|
36818
|
-
}
|
|
37558
|
+
target._setTransformFeedback();
|
|
36819
37559
|
};
|
|
36820
37560
|
/**
|
|
36821
37561
|
* @internal
|
|
@@ -36977,10 +37717,6 @@ __decorate([
|
|
|
36977
37717
|
// Start rotation
|
|
36978
37718
|
var startRotationRand = main._startRotationRand, flipRotation = main.flipRotation;
|
|
36979
37719
|
var isFlip = flipRotation > startRotationRand.random();
|
|
36980
|
-
// @todo:None-Mesh mode should inverse the rotation, maybe should unify it
|
|
36981
|
-
if (this._renderer.renderMode !== ParticleRenderMode.Mesh) {
|
|
36982
|
-
isFlip = !isFlip;
|
|
36983
|
-
}
|
|
36984
37720
|
var rotationZ = main.startRotationZ.evaluate(undefined, startRotationRand.random());
|
|
36985
37721
|
if (main.startRotation3D) {
|
|
36986
37722
|
var rotationX = main.startRotationX.evaluate(undefined, startRotationRand.random());
|
|
@@ -37006,7 +37742,9 @@ __decorate([
|
|
|
37006
37742
|
if (colorOverLifetime.enabled && colorOverLifetime.color.mode === ParticleGradientMode.TwoGradients) {
|
|
37007
37743
|
instanceVertices[offset + 20] = colorOverLifetime._colorGradientRand.random();
|
|
37008
37744
|
}
|
|
37009
|
-
|
|
37745
|
+
if (this.noise.enabled) {
|
|
37746
|
+
instanceVertices[offset + 21] = this.noise._noiseRand.random();
|
|
37747
|
+
}
|
|
37010
37748
|
var rotationOverLifetime = this.rotationOverLifetime;
|
|
37011
37749
|
if (rotationOverLifetime.enabled && rotationOverLifetime.rotationZ.mode === ParticleCurveMode.TwoConstants) {
|
|
37012
37750
|
instanceVertices[offset + 22] = rotationOverLifetime._rotationRand.random();
|
|
@@ -37294,6 +38032,21 @@ __decorate([
|
|
|
37294
38032
|
out.transform(rotateMat);
|
|
37295
38033
|
min.add(worldOffsetMin);
|
|
37296
38034
|
max.add(worldOffsetMax);
|
|
38035
|
+
// Noise module impact: noise output is normalized to [-1, 1],
|
|
38036
|
+
// max displacement = |strength_max|
|
|
38037
|
+
var noise = this.noise;
|
|
38038
|
+
if (noise.enabled) {
|
|
38039
|
+
var noiseMaxX, noiseMaxY, noiseMaxZ;
|
|
38040
|
+
if (noise.separateAxes) {
|
|
38041
|
+
noiseMaxX = Math.abs(noise.strengthX._getMax());
|
|
38042
|
+
noiseMaxY = Math.abs(noise.strengthY._getMax());
|
|
38043
|
+
noiseMaxZ = Math.abs(noise.strengthZ._getMax());
|
|
38044
|
+
} else {
|
|
38045
|
+
noiseMaxX = noiseMaxY = noiseMaxZ = Math.abs(noise.strengthX._getMax());
|
|
38046
|
+
}
|
|
38047
|
+
min.set(min.x - noiseMaxX, min.y - noiseMaxY, min.z - noiseMaxZ);
|
|
38048
|
+
max.set(max.x + noiseMaxX, max.y + noiseMaxY, max.z + noiseMaxZ);
|
|
38049
|
+
}
|
|
37297
38050
|
min.add(worldPosition);
|
|
37298
38051
|
max.add(worldPosition);
|
|
37299
38052
|
};
|
|
@@ -37391,6 +38144,9 @@ __decorate([
|
|
|
37391
38144
|
__decorate([
|
|
37392
38145
|
deepClone
|
|
37393
38146
|
], ParticleGenerator.prototype, "textureSheetAnimation", void 0);
|
|
38147
|
+
__decorate([
|
|
38148
|
+
deepClone
|
|
38149
|
+
], ParticleGenerator.prototype, "noise", void 0);
|
|
37394
38150
|
__decorate([
|
|
37395
38151
|
ignoreClone
|
|
37396
38152
|
], ParticleGenerator.prototype, "_playTime", void 0);
|
|
@@ -39594,6 +40350,7 @@ exports.MeshRenderer = MeshRenderer;
|
|
|
39594
40350
|
exports.MeshShape = MeshShape;
|
|
39595
40351
|
exports.MeshTopology = MeshTopology;
|
|
39596
40352
|
exports.ModelMesh = ModelMesh;
|
|
40353
|
+
exports.NoiseModule = NoiseModule;
|
|
39597
40354
|
exports.OverflowMode = OverflowMode;
|
|
39598
40355
|
exports.PBRMaterial = PBRMaterial;
|
|
39599
40356
|
exports.ParticleCompositeCurve = ParticleCompositeCurve;
|