1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327 |
- // Three.js Transpiler
- // https://raw.githubusercontent.com/AcademySoftwareFoundation/MaterialX/main/libraries/stdlib/genglsl/lib/mx_noise.glsl
- import { int, uint, float, vec3, bool, uvec3, vec2, vec4, If, tslFn } from '../../shadernode/ShaderNode.js';
- import { cond } from '../../math/CondNode.js';
- import { sub, mul } from '../../math/OperatorNode.js';
- import { floor, abs, max, dot, min, sqrt } from '../../math/MathNode.js';
- import { overloadingFn } from '../../utils/FunctionOverloadingNode.js';
- import { loop } from '../../utils/LoopNode.js';
- export const mx_select = /*#__PURE__*/ tslFn( ( [ b_immutable, t_immutable, f_immutable ] ) => {
- const f = float( f_immutable ).toVar();
- const t = float( t_immutable ).toVar();
- const b = bool( b_immutable ).toVar();
- return cond( b, t, f );
- } ).setLayout( {
- name: 'mx_select',
- type: 'float',
- inputs: [
- { name: 'b', type: 'bool' },
- { name: 't', type: 'float' },
- { name: 'f', type: 'float' }
- ]
- } );
- export const mx_negate_if = /*#__PURE__*/ tslFn( ( [ val_immutable, b_immutable ] ) => {
- const b = bool( b_immutable ).toVar();
- const val = float( val_immutable ).toVar();
- return cond( b, val.negate(), val );
- } ).setLayout( {
- name: 'mx_negate_if',
- type: 'float',
- inputs: [
- { name: 'val', type: 'float' },
- { name: 'b', type: 'bool' }
- ]
- } );
- export const mx_floor = /*#__PURE__*/ tslFn( ( [ x_immutable ] ) => {
- const x = float( x_immutable ).toVar();
- return int( floor( x ) );
- } ).setLayout( {
- name: 'mx_floor',
- type: 'int',
- inputs: [
- { name: 'x', type: 'float' }
- ]
- } );
- export const mx_floorfrac = /*#__PURE__*/ tslFn( ( [ x_immutable, i ] ) => {
- const x = float( x_immutable ).toVar();
- i.assign( mx_floor( x ) );
- return x.sub( float( i ) );
- } );
- export const mx_bilerp_0 = /*#__PURE__*/ tslFn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => {
- const t = float( t_immutable ).toVar();
- const s = float( s_immutable ).toVar();
- const v3 = float( v3_immutable ).toVar();
- const v2 = float( v2_immutable ).toVar();
- const v1 = float( v1_immutable ).toVar();
- const v0 = float( v0_immutable ).toVar();
- const s1 = float( sub( 1.0, s ) ).toVar();
- return sub( 1.0, t ).mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) );
- } ).setLayout( {
- name: 'mx_bilerp_0',
- type: 'float',
- inputs: [
- { name: 'v0', type: 'float' },
- { name: 'v1', type: 'float' },
- { name: 'v2', type: 'float' },
- { name: 'v3', type: 'float' },
- { name: 's', type: 'float' },
- { name: 't', type: 'float' }
- ]
- } );
- export const mx_bilerp_1 = /*#__PURE__*/ tslFn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => {
- const t = float( t_immutable ).toVar();
- const s = float( s_immutable ).toVar();
- const v3 = vec3( v3_immutable ).toVar();
- const v2 = vec3( v2_immutable ).toVar();
- const v1 = vec3( v1_immutable ).toVar();
- const v0 = vec3( v0_immutable ).toVar();
- const s1 = float( sub( 1.0, s ) ).toVar();
- return sub( 1.0, t ).mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) );
- } ).setLayout( {
- name: 'mx_bilerp_1',
- type: 'vec3',
- inputs: [
- { name: 'v0', type: 'vec3' },
- { name: 'v1', type: 'vec3' },
- { name: 'v2', type: 'vec3' },
- { name: 'v3', type: 'vec3' },
- { name: 's', type: 'float' },
- { name: 't', type: 'float' }
- ]
- } );
- export const mx_bilerp = /*#__PURE__*/ overloadingFn( [ mx_bilerp_0, mx_bilerp_1 ] );
- export const mx_trilerp_0 = /*#__PURE__*/ tslFn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, v4_immutable, v5_immutable, v6_immutable, v7_immutable, s_immutable, t_immutable, r_immutable ] ) => {
- const r = float( r_immutable ).toVar();
- const t = float( t_immutable ).toVar();
- const s = float( s_immutable ).toVar();
- const v7 = float( v7_immutable ).toVar();
- const v6 = float( v6_immutable ).toVar();
- const v5 = float( v5_immutable ).toVar();
- const v4 = float( v4_immutable ).toVar();
- const v3 = float( v3_immutable ).toVar();
- const v2 = float( v2_immutable ).toVar();
- const v1 = float( v1_immutable ).toVar();
- const v0 = float( v0_immutable ).toVar();
- const s1 = float( sub( 1.0, s ) ).toVar();
- const t1 = float( sub( 1.0, t ) ).toVar();
- const r1 = float( sub( 1.0, r ) ).toVar();
- return r1.mul( t1.mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) ) ).add( r.mul( t1.mul( v4.mul( s1 ).add( v5.mul( s ) ) ).add( t.mul( v6.mul( s1 ).add( v7.mul( s ) ) ) ) ) );
- } ).setLayout( {
- name: 'mx_trilerp_0',
- type: 'float',
- inputs: [
- { name: 'v0', type: 'float' },
- { name: 'v1', type: 'float' },
- { name: 'v2', type: 'float' },
- { name: 'v3', type: 'float' },
- { name: 'v4', type: 'float' },
- { name: 'v5', type: 'float' },
- { name: 'v6', type: 'float' },
- { name: 'v7', type: 'float' },
- { name: 's', type: 'float' },
- { name: 't', type: 'float' },
- { name: 'r', type: 'float' }
- ]
- } );
- export const mx_trilerp_1 = /*#__PURE__*/ tslFn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, v4_immutable, v5_immutable, v6_immutable, v7_immutable, s_immutable, t_immutable, r_immutable ] ) => {
- const r = float( r_immutable ).toVar();
- const t = float( t_immutable ).toVar();
- const s = float( s_immutable ).toVar();
- const v7 = vec3( v7_immutable ).toVar();
- const v6 = vec3( v6_immutable ).toVar();
- const v5 = vec3( v5_immutable ).toVar();
- const v4 = vec3( v4_immutable ).toVar();
- const v3 = vec3( v3_immutable ).toVar();
- const v2 = vec3( v2_immutable ).toVar();
- const v1 = vec3( v1_immutable ).toVar();
- const v0 = vec3( v0_immutable ).toVar();
- const s1 = float( sub( 1.0, s ) ).toVar();
- const t1 = float( sub( 1.0, t ) ).toVar();
- const r1 = float( sub( 1.0, r ) ).toVar();
- return r1.mul( t1.mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) ) ).add( r.mul( t1.mul( v4.mul( s1 ).add( v5.mul( s ) ) ).add( t.mul( v6.mul( s1 ).add( v7.mul( s ) ) ) ) ) );
- } ).setLayout( {
- name: 'mx_trilerp_1',
- type: 'vec3',
- inputs: [
- { name: 'v0', type: 'vec3' },
- { name: 'v1', type: 'vec3' },
- { name: 'v2', type: 'vec3' },
- { name: 'v3', type: 'vec3' },
- { name: 'v4', type: 'vec3' },
- { name: 'v5', type: 'vec3' },
- { name: 'v6', type: 'vec3' },
- { name: 'v7', type: 'vec3' },
- { name: 's', type: 'float' },
- { name: 't', type: 'float' },
- { name: 'r', type: 'float' }
- ]
- } );
- export const mx_trilerp = /*#__PURE__*/ overloadingFn( [ mx_trilerp_0, mx_trilerp_1 ] );
- export const mx_gradient_float_0 = /*#__PURE__*/ tslFn( ( [ hash_immutable, x_immutable, y_immutable ] ) => {
- const y = float( y_immutable ).toVar();
- const x = float( x_immutable ).toVar();
- const hash = uint( hash_immutable ).toVar();
- const h = uint( hash.bitAnd( uint( 7 ) ) ).toVar();
- const u = float( mx_select( h.lessThan( uint( 4 ) ), x, y ) ).toVar();
- const v = float( mul( 2.0, mx_select( h.lessThan( uint( 4 ) ), y, x ) ) ).toVar();
- return mx_negate_if( u, bool( h.bitAnd( uint( 1 ) ) ) ).add( mx_negate_if( v, bool( h.bitAnd( uint( 2 ) ) ) ) );
- } ).setLayout( {
- name: 'mx_gradient_float_0',
- type: 'float',
- inputs: [
- { name: 'hash', type: 'uint' },
- { name: 'x', type: 'float' },
- { name: 'y', type: 'float' }
- ]
- } );
- export const mx_gradient_float_1 = /*#__PURE__*/ tslFn( ( [ hash_immutable, x_immutable, y_immutable, z_immutable ] ) => {
- const z = float( z_immutable ).toVar();
- const y = float( y_immutable ).toVar();
- const x = float( x_immutable ).toVar();
- const hash = uint( hash_immutable ).toVar();
- const h = uint( hash.bitAnd( uint( 15 ) ) ).toVar();
- const u = float( mx_select( h.lessThan( uint( 8 ) ), x, y ) ).toVar();
- const v = float( mx_select( h.lessThan( uint( 4 ) ), y, mx_select( h.equal( uint( 12 ) ).or( h.equal( uint( 14 ) ) ), x, z ) ) ).toVar();
- return mx_negate_if( u, bool( h.bitAnd( uint( 1 ) ) ) ).add( mx_negate_if( v, bool( h.bitAnd( uint( 2 ) ) ) ) );
- } ).setLayout( {
- name: 'mx_gradient_float_1',
- type: 'float',
- inputs: [
- { name: 'hash', type: 'uint' },
- { name: 'x', type: 'float' },
- { name: 'y', type: 'float' },
- { name: 'z', type: 'float' }
- ]
- } );
- export const mx_gradient_float = /*#__PURE__*/ overloadingFn( [ mx_gradient_float_0, mx_gradient_float_1 ] );
- export const mx_gradient_vec3_0 = /*#__PURE__*/ tslFn( ( [ hash_immutable, x_immutable, y_immutable ] ) => {
- const y = float( y_immutable ).toVar();
- const x = float( x_immutable ).toVar();
- const hash = uvec3( hash_immutable ).toVar();
- return vec3( mx_gradient_float( hash.x, x, y ), mx_gradient_float( hash.y, x, y ), mx_gradient_float( hash.z, x, y ) );
- } ).setLayout( {
- name: 'mx_gradient_vec3_0',
- type: 'vec3',
- inputs: [
- { name: 'hash', type: 'uvec3' },
- { name: 'x', type: 'float' },
- { name: 'y', type: 'float' }
- ]
- } );
- export const mx_gradient_vec3_1 = /*#__PURE__*/ tslFn( ( [ hash_immutable, x_immutable, y_immutable, z_immutable ] ) => {
- const z = float( z_immutable ).toVar();
- const y = float( y_immutable ).toVar();
- const x = float( x_immutable ).toVar();
- const hash = uvec3( hash_immutable ).toVar();
- return vec3( mx_gradient_float( hash.x, x, y, z ), mx_gradient_float( hash.y, x, y, z ), mx_gradient_float( hash.z, x, y, z ) );
- } ).setLayout( {
- name: 'mx_gradient_vec3_1',
- type: 'vec3',
- inputs: [
- { name: 'hash', type: 'uvec3' },
- { name: 'x', type: 'float' },
- { name: 'y', type: 'float' },
- { name: 'z', type: 'float' }
- ]
- } );
- export const mx_gradient_vec3 = /*#__PURE__*/ overloadingFn( [ mx_gradient_vec3_0, mx_gradient_vec3_1 ] );
- export const mx_gradient_scale2d_0 = /*#__PURE__*/ tslFn( ( [ v_immutable ] ) => {
- const v = float( v_immutable ).toVar();
- return mul( 0.6616, v );
- } ).setLayout( {
- name: 'mx_gradient_scale2d_0',
- type: 'float',
- inputs: [
- { name: 'v', type: 'float' }
- ]
- } );
- export const mx_gradient_scale3d_0 = /*#__PURE__*/ tslFn( ( [ v_immutable ] ) => {
- const v = float( v_immutable ).toVar();
- return mul( 0.9820, v );
- } ).setLayout( {
- name: 'mx_gradient_scale3d_0',
- type: 'float',
- inputs: [
- { name: 'v', type: 'float' }
- ]
- } );
- export const mx_gradient_scale2d_1 = /*#__PURE__*/ tslFn( ( [ v_immutable ] ) => {
- const v = vec3( v_immutable ).toVar();
- return mul( 0.6616, v );
- } ).setLayout( {
- name: 'mx_gradient_scale2d_1',
- type: 'vec3',
- inputs: [
- { name: 'v', type: 'vec3' }
- ]
- } );
- export const mx_gradient_scale2d = /*#__PURE__*/ overloadingFn( [ mx_gradient_scale2d_0, mx_gradient_scale2d_1 ] );
- export const mx_gradient_scale3d_1 = /*#__PURE__*/ tslFn( ( [ v_immutable ] ) => {
- const v = vec3( v_immutable ).toVar();
- return mul( 0.9820, v );
- } ).setLayout( {
- name: 'mx_gradient_scale3d_1',
- type: 'vec3',
- inputs: [
- { name: 'v', type: 'vec3' }
- ]
- } );
- export const mx_gradient_scale3d = /*#__PURE__*/ overloadingFn( [ mx_gradient_scale3d_0, mx_gradient_scale3d_1 ] );
- export const mx_rotl32 = /*#__PURE__*/ tslFn( ( [ x_immutable, k_immutable ] ) => {
- const k = int( k_immutable ).toVar();
- const x = uint( x_immutable ).toVar();
- return x.shiftLeft( k ).bitOr( x.shiftRight( int( 32 ).sub( k ) ) );
- } ).setLayout( {
- name: 'mx_rotl32',
- type: 'uint',
- inputs: [
- { name: 'x', type: 'uint' },
- { name: 'k', type: 'int' }
- ]
- } );
- export const mx_bjmix = /*#__PURE__*/ tslFn( ( [ a, b, c ] ) => {
- a.subAssign( c );
- a.bitXorAssign( mx_rotl32( c, int( 4 ) ) );
- c.addAssign( b );
- b.subAssign( a );
- b.bitXorAssign( mx_rotl32( a, int( 6 ) ) );
- a.addAssign( c );
- c.subAssign( b );
- c.bitXorAssign( mx_rotl32( b, int( 8 ) ) );
- b.addAssign( a );
- a.subAssign( c );
- a.bitXorAssign( mx_rotl32( c, int( 16 ) ) );
- c.addAssign( b );
- b.subAssign( a );
- b.bitXorAssign( mx_rotl32( a, int( 19 ) ) );
- a.addAssign( c );
- c.subAssign( b );
- c.bitXorAssign( mx_rotl32( b, int( 4 ) ) );
- b.addAssign( a );
- } );
- export const mx_bjfinal = /*#__PURE__*/ tslFn( ( [ a_immutable, b_immutable, c_immutable ] ) => {
- const c = uint( c_immutable ).toVar();
- const b = uint( b_immutable ).toVar();
- const a = uint( a_immutable ).toVar();
- c.bitXorAssign( b );
- c.subAssign( mx_rotl32( b, int( 14 ) ) );
- a.bitXorAssign( c );
- a.subAssign( mx_rotl32( c, int( 11 ) ) );
- b.bitXorAssign( a );
- b.subAssign( mx_rotl32( a, int( 25 ) ) );
- c.bitXorAssign( b );
- c.subAssign( mx_rotl32( b, int( 16 ) ) );
- a.bitXorAssign( c );
- a.subAssign( mx_rotl32( c, int( 4 ) ) );
- b.bitXorAssign( a );
- b.subAssign( mx_rotl32( a, int( 14 ) ) );
- c.bitXorAssign( b );
- c.subAssign( mx_rotl32( b, int( 24 ) ) );
- return c;
- } ).setLayout( {
- name: 'mx_bjfinal',
- type: 'uint',
- inputs: [
- { name: 'a', type: 'uint' },
- { name: 'b', type: 'uint' },
- { name: 'c', type: 'uint' }
- ]
- } );
- export const mx_bits_to_01 = /*#__PURE__*/ tslFn( ( [ bits_immutable ] ) => {
- const bits = uint( bits_immutable ).toVar();
- return float( bits ).div( float( uint( int( 0xffffffff ) ) ) );
- } ).setLayout( {
- name: 'mx_bits_to_01',
- type: 'float',
- inputs: [
- { name: 'bits', type: 'uint' }
- ]
- } );
- export const mx_fade = /*#__PURE__*/ tslFn( ( [ t_immutable ] ) => {
- const t = float( t_immutable ).toVar();
- return t.mul( t ).mul( t ).mul( t.mul( t.mul( 6.0 ).sub( 15.0 ) ).add( 10.0 ) );
- } ).setLayout( {
- name: 'mx_fade',
- type: 'float',
- inputs: [
- { name: 't', type: 'float' }
- ]
- } );
- export const mx_hash_int_0 = /*#__PURE__*/ tslFn( ( [ x_immutable ] ) => {
- const x = int( x_immutable ).toVar();
- const len = uint( uint( 1 ) ).toVar();
- const seed = uint( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ).toVar();
- return mx_bjfinal( seed.add( uint( x ) ), seed, seed );
- } ).setLayout( {
- name: 'mx_hash_int_0',
- type: 'uint',
- inputs: [
- { name: 'x', type: 'int' }
- ]
- } );
- export const mx_hash_int_1 = /*#__PURE__*/ tslFn( ( [ x_immutable, y_immutable ] ) => {
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const len = uint( uint( 2 ) ).toVar();
- const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
- a.addAssign( uint( x ) );
- b.addAssign( uint( y ) );
- return mx_bjfinal( a, b, c );
- } ).setLayout( {
- name: 'mx_hash_int_1',
- type: 'uint',
- inputs: [
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' }
- ]
- } );
- export const mx_hash_int_2 = /*#__PURE__*/ tslFn( ( [ x_immutable, y_immutable, z_immutable ] ) => {
- const z = int( z_immutable ).toVar();
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const len = uint( uint( 3 ) ).toVar();
- const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
- a.addAssign( uint( x ) );
- b.addAssign( uint( y ) );
- c.addAssign( uint( z ) );
- return mx_bjfinal( a, b, c );
- } ).setLayout( {
- name: 'mx_hash_int_2',
- type: 'uint',
- inputs: [
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' },
- { name: 'z', type: 'int' }
- ]
- } );
- export const mx_hash_int_3 = /*#__PURE__*/ tslFn( ( [ x_immutable, y_immutable, z_immutable, xx_immutable ] ) => {
- const xx = int( xx_immutable ).toVar();
- const z = int( z_immutable ).toVar();
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const len = uint( uint( 4 ) ).toVar();
- const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
- a.addAssign( uint( x ) );
- b.addAssign( uint( y ) );
- c.addAssign( uint( z ) );
- mx_bjmix( a, b, c );
- a.addAssign( uint( xx ) );
- return mx_bjfinal( a, b, c );
- } ).setLayout( {
- name: 'mx_hash_int_3',
- type: 'uint',
- inputs: [
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' },
- { name: 'z', type: 'int' },
- { name: 'xx', type: 'int' }
- ]
- } );
- export const mx_hash_int_4 = /*#__PURE__*/ tslFn( ( [ x_immutable, y_immutable, z_immutable, xx_immutable, yy_immutable ] ) => {
- const yy = int( yy_immutable ).toVar();
- const xx = int( xx_immutable ).toVar();
- const z = int( z_immutable ).toVar();
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const len = uint( uint( 5 ) ).toVar();
- const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
- a.addAssign( uint( x ) );
- b.addAssign( uint( y ) );
- c.addAssign( uint( z ) );
- mx_bjmix( a, b, c );
- a.addAssign( uint( xx ) );
- b.addAssign( uint( yy ) );
- return mx_bjfinal( a, b, c );
- } ).setLayout( {
- name: 'mx_hash_int_4',
- type: 'uint',
- inputs: [
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' },
- { name: 'z', type: 'int' },
- { name: 'xx', type: 'int' },
- { name: 'yy', type: 'int' }
- ]
- } );
- export const mx_hash_int = /*#__PURE__*/ overloadingFn( [ mx_hash_int_0, mx_hash_int_1, mx_hash_int_2, mx_hash_int_3, mx_hash_int_4 ] );
- export const mx_hash_vec3_0 = /*#__PURE__*/ tslFn( ( [ x_immutable, y_immutable ] ) => {
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const h = uint( mx_hash_int( x, y ) ).toVar();
- const result = uvec3().toVar();
- result.x.assign( h.bitAnd( int( 0xFF ) ) );
- result.y.assign( h.shiftRight( int( 8 ) ).bitAnd( int( 0xFF ) ) );
- result.z.assign( h.shiftRight( int( 16 ) ).bitAnd( int( 0xFF ) ) );
- return result;
- } ).setLayout( {
- name: 'mx_hash_vec3_0',
- type: 'uvec3',
- inputs: [
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' }
- ]
- } );
- export const mx_hash_vec3_1 = /*#__PURE__*/ tslFn( ( [ x_immutable, y_immutable, z_immutable ] ) => {
- const z = int( z_immutable ).toVar();
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const h = uint( mx_hash_int( x, y, z ) ).toVar();
- const result = uvec3().toVar();
- result.x.assign( h.bitAnd( int( 0xFF ) ) );
- result.y.assign( h.shiftRight( int( 8 ) ).bitAnd( int( 0xFF ) ) );
- result.z.assign( h.shiftRight( int( 16 ) ).bitAnd( int( 0xFF ) ) );
- return result;
- } ).setLayout( {
- name: 'mx_hash_vec3_1',
- type: 'uvec3',
- inputs: [
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' },
- { name: 'z', type: 'int' }
- ]
- } );
- export const mx_hash_vec3 = /*#__PURE__*/ overloadingFn( [ mx_hash_vec3_0, mx_hash_vec3_1 ] );
- export const mx_perlin_noise_float_0 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec2( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar();
- const fx = float( mx_floorfrac( p.x, X ) ).toVar();
- const fy = float( mx_floorfrac( p.y, Y ) ).toVar();
- const u = float( mx_fade( fx ) ).toVar();
- const v = float( mx_fade( fy ) ).toVar();
- const result = float( mx_bilerp( mx_gradient_float( mx_hash_int( X, Y ), fx, fy ), mx_gradient_float( mx_hash_int( X.add( int( 1 ) ), Y ), fx.sub( 1.0 ), fy ), mx_gradient_float( mx_hash_int( X, Y.add( int( 1 ) ) ), fx, fy.sub( 1.0 ) ), mx_gradient_float( mx_hash_int( X.add( int( 1 ) ), Y.add( int( 1 ) ) ), fx.sub( 1.0 ), fy.sub( 1.0 ) ), u, v ) ).toVar();
- return mx_gradient_scale2d( result );
- } ).setLayout( {
- name: 'mx_perlin_noise_float_0',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec2' }
- ]
- } );
- export const mx_perlin_noise_float_1 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec3( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
- const fx = float( mx_floorfrac( p.x, X ) ).toVar();
- const fy = float( mx_floorfrac( p.y, Y ) ).toVar();
- const fz = float( mx_floorfrac( p.z, Z ) ).toVar();
- const u = float( mx_fade( fx ) ).toVar();
- const v = float( mx_fade( fy ) ).toVar();
- const w = float( mx_fade( fz ) ).toVar();
- const result = float( mx_trilerp( mx_gradient_float( mx_hash_int( X, Y, Z ), fx, fy, fz ), mx_gradient_float( mx_hash_int( X.add( int( 1 ) ), Y, Z ), fx.sub( 1.0 ), fy, fz ), mx_gradient_float( mx_hash_int( X, Y.add( int( 1 ) ), Z ), fx, fy.sub( 1.0 ), fz ), mx_gradient_float( mx_hash_int( X.add( int( 1 ) ), Y.add( int( 1 ) ), Z ), fx.sub( 1.0 ), fy.sub( 1.0 ), fz ), mx_gradient_float( mx_hash_int( X, Y, Z.add( int( 1 ) ) ), fx, fy, fz.sub( 1.0 ) ), mx_gradient_float( mx_hash_int( X.add( int( 1 ) ), Y, Z.add( int( 1 ) ) ), fx.sub( 1.0 ), fy, fz.sub( 1.0 ) ), mx_gradient_float( mx_hash_int( X, Y.add( int( 1 ) ), Z.add( int( 1 ) ) ), fx, fy.sub( 1.0 ), fz.sub( 1.0 ) ), mx_gradient_float( mx_hash_int( X.add( int( 1 ) ), Y.add( int( 1 ) ), Z.add( int( 1 ) ) ), fx.sub( 1.0 ), fy.sub( 1.0 ), fz.sub( 1.0 ) ), u, v, w ) ).toVar();
- return mx_gradient_scale3d( result );
- } ).setLayout( {
- name: 'mx_perlin_noise_float_1',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec3' }
- ]
- } );
- export const mx_perlin_noise_float = /*#__PURE__*/ overloadingFn( [ mx_perlin_noise_float_0, mx_perlin_noise_float_1 ] );
- export const mx_perlin_noise_vec3_0 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec2( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar();
- const fx = float( mx_floorfrac( p.x, X ) ).toVar();
- const fy = float( mx_floorfrac( p.y, Y ) ).toVar();
- const u = float( mx_fade( fx ) ).toVar();
- const v = float( mx_fade( fy ) ).toVar();
- const result = vec3( mx_bilerp( mx_gradient_vec3( mx_hash_vec3( X, Y ), fx, fy ), mx_gradient_vec3( mx_hash_vec3( X.add( int( 1 ) ), Y ), fx.sub( 1.0 ), fy ), mx_gradient_vec3( mx_hash_vec3( X, Y.add( int( 1 ) ) ), fx, fy.sub( 1.0 ) ), mx_gradient_vec3( mx_hash_vec3( X.add( int( 1 ) ), Y.add( int( 1 ) ) ), fx.sub( 1.0 ), fy.sub( 1.0 ) ), u, v ) ).toVar();
- return mx_gradient_scale2d( result );
- } ).setLayout( {
- name: 'mx_perlin_noise_vec3_0',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec2' }
- ]
- } );
- export const mx_perlin_noise_vec3_1 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec3( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
- const fx = float( mx_floorfrac( p.x, X ) ).toVar();
- const fy = float( mx_floorfrac( p.y, Y ) ).toVar();
- const fz = float( mx_floorfrac( p.z, Z ) ).toVar();
- const u = float( mx_fade( fx ) ).toVar();
- const v = float( mx_fade( fy ) ).toVar();
- const w = float( mx_fade( fz ) ).toVar();
- const result = vec3( mx_trilerp( mx_gradient_vec3( mx_hash_vec3( X, Y, Z ), fx, fy, fz ), mx_gradient_vec3( mx_hash_vec3( X.add( int( 1 ) ), Y, Z ), fx.sub( 1.0 ), fy, fz ), mx_gradient_vec3( mx_hash_vec3( X, Y.add( int( 1 ) ), Z ), fx, fy.sub( 1.0 ), fz ), mx_gradient_vec3( mx_hash_vec3( X.add( int( 1 ) ), Y.add( int( 1 ) ), Z ), fx.sub( 1.0 ), fy.sub( 1.0 ), fz ), mx_gradient_vec3( mx_hash_vec3( X, Y, Z.add( int( 1 ) ) ), fx, fy, fz.sub( 1.0 ) ), mx_gradient_vec3( mx_hash_vec3( X.add( int( 1 ) ), Y, Z.add( int( 1 ) ) ), fx.sub( 1.0 ), fy, fz.sub( 1.0 ) ), mx_gradient_vec3( mx_hash_vec3( X, Y.add( int( 1 ) ), Z.add( int( 1 ) ) ), fx, fy.sub( 1.0 ), fz.sub( 1.0 ) ), mx_gradient_vec3( mx_hash_vec3( X.add( int( 1 ) ), Y.add( int( 1 ) ), Z.add( int( 1 ) ) ), fx.sub( 1.0 ), fy.sub( 1.0 ), fz.sub( 1.0 ) ), u, v, w ) ).toVar();
- return mx_gradient_scale3d( result );
- } ).setLayout( {
- name: 'mx_perlin_noise_vec3_1',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec3' }
- ]
- } );
- export const mx_perlin_noise_vec3 = /*#__PURE__*/ overloadingFn( [ mx_perlin_noise_vec3_0, mx_perlin_noise_vec3_1 ] );
- export const mx_cell_noise_float_0 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = float( p_immutable ).toVar();
- const ix = int( mx_floor( p ) ).toVar();
- return mx_bits_to_01( mx_hash_int( ix ) );
- } ).setLayout( {
- name: 'mx_cell_noise_float_0',
- type: 'float',
- inputs: [
- { name: 'p', type: 'float' }
- ]
- } );
- export const mx_cell_noise_float_1 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec2( p_immutable ).toVar();
- const ix = int( mx_floor( p.x ) ).toVar();
- const iy = int( mx_floor( p.y ) ).toVar();
- return mx_bits_to_01( mx_hash_int( ix, iy ) );
- } ).setLayout( {
- name: 'mx_cell_noise_float_1',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec2' }
- ]
- } );
- export const mx_cell_noise_float_2 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec3( p_immutable ).toVar();
- const ix = int( mx_floor( p.x ) ).toVar();
- const iy = int( mx_floor( p.y ) ).toVar();
- const iz = int( mx_floor( p.z ) ).toVar();
- return mx_bits_to_01( mx_hash_int( ix, iy, iz ) );
- } ).setLayout( {
- name: 'mx_cell_noise_float_2',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec3' }
- ]
- } );
- export const mx_cell_noise_float_3 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec4( p_immutable ).toVar();
- const ix = int( mx_floor( p.x ) ).toVar();
- const iy = int( mx_floor( p.y ) ).toVar();
- const iz = int( mx_floor( p.z ) ).toVar();
- const iw = int( mx_floor( p.w ) ).toVar();
- return mx_bits_to_01( mx_hash_int( ix, iy, iz, iw ) );
- } ).setLayout( {
- name: 'mx_cell_noise_float_3',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec4' }
- ]
- } );
- export const mx_cell_noise_float = /*#__PURE__*/ overloadingFn( [ mx_cell_noise_float_0, mx_cell_noise_float_1, mx_cell_noise_float_2, mx_cell_noise_float_3 ] );
- export const mx_cell_noise_vec3_0 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = float( p_immutable ).toVar();
- const ix = int( mx_floor( p ) ).toVar();
- return vec3( mx_bits_to_01( mx_hash_int( ix, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, int( 2 ) ) ) );
- } ).setLayout( {
- name: 'mx_cell_noise_vec3_0',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'float' }
- ]
- } );
- export const mx_cell_noise_vec3_1 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec2( p_immutable ).toVar();
- const ix = int( mx_floor( p.x ) ).toVar();
- const iy = int( mx_floor( p.y ) ).toVar();
- return vec3( mx_bits_to_01( mx_hash_int( ix, iy, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, int( 2 ) ) ) );
- } ).setLayout( {
- name: 'mx_cell_noise_vec3_1',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec2' }
- ]
- } );
- export const mx_cell_noise_vec3_2 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec3( p_immutable ).toVar();
- const ix = int( mx_floor( p.x ) ).toVar();
- const iy = int( mx_floor( p.y ) ).toVar();
- const iz = int( mx_floor( p.z ) ).toVar();
- return vec3( mx_bits_to_01( mx_hash_int( ix, iy, iz, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, int( 2 ) ) ) );
- } ).setLayout( {
- name: 'mx_cell_noise_vec3_2',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec3' }
- ]
- } );
- export const mx_cell_noise_vec3_3 = /*#__PURE__*/ tslFn( ( [ p_immutable ] ) => {
- const p = vec4( p_immutable ).toVar();
- const ix = int( mx_floor( p.x ) ).toVar();
- const iy = int( mx_floor( p.y ) ).toVar();
- const iz = int( mx_floor( p.z ) ).toVar();
- const iw = int( mx_floor( p.w ) ).toVar();
- return vec3( mx_bits_to_01( mx_hash_int( ix, iy, iz, iw, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, iw, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, iw, int( 2 ) ) ) );
- } ).setLayout( {
- name: 'mx_cell_noise_vec3_3',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec4' }
- ]
- } );
- export const mx_cell_noise_vec3 = /*#__PURE__*/ overloadingFn( [ mx_cell_noise_vec3_0, mx_cell_noise_vec3_1, mx_cell_noise_vec3_2, mx_cell_noise_vec3_3 ] );
- export const mx_fractal_noise_float = /*#__PURE__*/ tslFn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
- const diminish = float( diminish_immutable ).toVar();
- const lacunarity = float( lacunarity_immutable ).toVar();
- const octaves = int( octaves_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const result = float( 0.0 ).toVar();
- const amplitude = float( 1.0 ).toVar();
- loop( { start: int( 0 ), end: octaves }, ( { i } ) => {
- result.addAssign( amplitude.mul( mx_perlin_noise_float( p ) ) );
- amplitude.mulAssign( diminish );
- p.mulAssign( lacunarity );
- } );
- return result;
- } ).setLayout( {
- name: 'mx_fractal_noise_float',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'octaves', type: 'int' },
- { name: 'lacunarity', type: 'float' },
- { name: 'diminish', type: 'float' }
- ]
- } );
- export const mx_fractal_noise_vec3 = /*#__PURE__*/ tslFn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
- const diminish = float( diminish_immutable ).toVar();
- const lacunarity = float( lacunarity_immutable ).toVar();
- const octaves = int( octaves_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const result = vec3( 0.0 ).toVar();
- const amplitude = float( 1.0 ).toVar();
- loop( { start: int( 0 ), end: octaves }, ( { i } ) => {
- result.addAssign( amplitude.mul( mx_perlin_noise_vec3( p ) ) );
- amplitude.mulAssign( diminish );
- p.mulAssign( lacunarity );
- } );
- return result;
- } ).setLayout( {
- name: 'mx_fractal_noise_vec3',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'octaves', type: 'int' },
- { name: 'lacunarity', type: 'float' },
- { name: 'diminish', type: 'float' }
- ]
- } );
- export const mx_fractal_noise_vec2 = /*#__PURE__*/ tslFn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
- const diminish = float( diminish_immutable ).toVar();
- const lacunarity = float( lacunarity_immutable ).toVar();
- const octaves = int( octaves_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- return vec2( mx_fractal_noise_float( p, octaves, lacunarity, diminish ), mx_fractal_noise_float( p.add( vec3( int( 19 ), int( 193 ), int( 17 ) ) ), octaves, lacunarity, diminish ) );
- } ).setLayout( {
- name: 'mx_fractal_noise_vec2',
- type: 'vec2',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'octaves', type: 'int' },
- { name: 'lacunarity', type: 'float' },
- { name: 'diminish', type: 'float' }
- ]
- } );
- export const mx_fractal_noise_vec4 = /*#__PURE__*/ tslFn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
- const diminish = float( diminish_immutable ).toVar();
- const lacunarity = float( lacunarity_immutable ).toVar();
- const octaves = int( octaves_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const c = vec3( mx_fractal_noise_vec3( p, octaves, lacunarity, diminish ) ).toVar();
- const f = float( mx_fractal_noise_float( p.add( vec3( int( 19 ), int( 193 ), int( 17 ) ) ), octaves, lacunarity, diminish ) ).toVar();
- return vec4( c, f );
- } ).setLayout( {
- name: 'mx_fractal_noise_vec4',
- type: 'vec4',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'octaves', type: 'int' },
- { name: 'lacunarity', type: 'float' },
- { name: 'diminish', type: 'float' }
- ]
- } );
- export const mx_worley_distance_0 = /*#__PURE__*/ tslFn( ( [ p_immutable, x_immutable, y_immutable, xoff_immutable, yoff_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const yoff = int( yoff_immutable ).toVar();
- const xoff = int( xoff_immutable ).toVar();
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const p = vec2( p_immutable ).toVar();
- const tmp = vec3( mx_cell_noise_vec3( vec2( x.add( xoff ), y.add( yoff ) ) ) ).toVar();
- const off = vec2( tmp.x, tmp.y ).toVar();
- off.subAssign( 0.5 );
- off.mulAssign( jitter );
- off.addAssign( 0.5 );
- const cellpos = vec2( vec2( float( x ), float( y ) ).add( off ) ).toVar();
- const diff = vec2( cellpos.sub( p ) ).toVar();
- If( metric.equal( int( 2 ) ), () => {
- return abs( diff.x ).add( abs( diff.y ) );
- } );
- If( metric.equal( int( 3 ) ), () => {
- return max( abs( diff.x ), abs( diff.y ) );
- } );
- return dot( diff, diff );
- } ).setLayout( {
- name: 'mx_worley_distance_0',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec2' },
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' },
- { name: 'xoff', type: 'int' },
- { name: 'yoff', type: 'int' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_distance_1 = /*#__PURE__*/ tslFn( ( [ p_immutable, x_immutable, y_immutable, z_immutable, xoff_immutable, yoff_immutable, zoff_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const zoff = int( zoff_immutable ).toVar();
- const yoff = int( yoff_immutable ).toVar();
- const xoff = int( xoff_immutable ).toVar();
- const z = int( z_immutable ).toVar();
- const y = int( y_immutable ).toVar();
- const x = int( x_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const off = vec3( mx_cell_noise_vec3( vec3( x.add( xoff ), y.add( yoff ), z.add( zoff ) ) ) ).toVar();
- off.subAssign( 0.5 );
- off.mulAssign( jitter );
- off.addAssign( 0.5 );
- const cellpos = vec3( vec3( float( x ), float( y ), float( z ) ).add( off ) ).toVar();
- const diff = vec3( cellpos.sub( p ) ).toVar();
- If( metric.equal( int( 2 ) ), () => {
- return abs( diff.x ).add( abs( diff.y ) ).add( abs( diff.z ) );
- } );
- If( metric.equal( int( 3 ) ), () => {
- return max( max( abs( diff.x ), abs( diff.y ) ), abs( diff.z ) );
- } );
- return dot( diff, diff );
- } ).setLayout( {
- name: 'mx_worley_distance_1',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'x', type: 'int' },
- { name: 'y', type: 'int' },
- { name: 'z', type: 'int' },
- { name: 'xoff', type: 'int' },
- { name: 'yoff', type: 'int' },
- { name: 'zoff', type: 'int' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_distance = /*#__PURE__*/ overloadingFn( [ mx_worley_distance_0, mx_worley_distance_1 ] );
- export const mx_worley_noise_float_0 = /*#__PURE__*/ tslFn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const p = vec2( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar();
- const localpos = vec2( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ) ).toVar();
- const sqdist = float( 1e6 ).toVar();
- loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
- const dist = float( mx_worley_distance( localpos, x, y, X, Y, jitter, metric ) ).toVar();
- sqdist.assign( min( sqdist, dist ) );
- } );
- } );
- If( metric.equal( int( 0 ) ), () => {
- sqdist.assign( sqrt( sqdist ) );
- } );
- return sqdist;
- } ).setLayout( {
- name: 'mx_worley_noise_float_0',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec2' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_noise_vec2_0 = /*#__PURE__*/ tslFn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const p = vec2( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar();
- const localpos = vec2( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ) ).toVar();
- const sqdist = vec2( 1e6, 1e6 ).toVar();
- loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
- const dist = float( mx_worley_distance( localpos, x, y, X, Y, jitter, metric ) ).toVar();
- If( dist.lessThan( sqdist.x ), () => {
- sqdist.y.assign( sqdist.x );
- sqdist.x.assign( dist );
- } ).elseif( dist.lessThan( sqdist.y ), () => {
- sqdist.y.assign( dist );
- } );
- } );
- } );
- If( metric.equal( int( 0 ) ), () => {
- sqdist.assign( sqrt( sqdist ) );
- } );
- return sqdist;
- } ).setLayout( {
- name: 'mx_worley_noise_vec2_0',
- type: 'vec2',
- inputs: [
- { name: 'p', type: 'vec2' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_noise_vec3_0 = /*#__PURE__*/ tslFn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const p = vec2( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar();
- const localpos = vec2( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ) ).toVar();
- const sqdist = vec3( 1e6, 1e6, 1e6 ).toVar();
- loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
- const dist = float( mx_worley_distance( localpos, x, y, X, Y, jitter, metric ) ).toVar();
- If( dist.lessThan( sqdist.x ), () => {
- sqdist.z.assign( sqdist.y );
- sqdist.y.assign( sqdist.x );
- sqdist.x.assign( dist );
- } ).elseif( dist.lessThan( sqdist.y ), () => {
- sqdist.z.assign( sqdist.y );
- sqdist.y.assign( dist );
- } ).elseif( dist.lessThan( sqdist.z ), () => {
- sqdist.z.assign( dist );
- } );
- } );
- } );
- If( metric.equal( int( 0 ) ), () => {
- sqdist.assign( sqrt( sqdist ) );
- } );
- return sqdist;
- } ).setLayout( {
- name: 'mx_worley_noise_vec3_0',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec2' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_noise_float_1 = /*#__PURE__*/ tslFn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
- const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
- const sqdist = float( 1e6 ).toVar();
- loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
- const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
- sqdist.assign( min( sqdist, dist ) );
- } );
- } );
- } );
- If( metric.equal( int( 0 ) ), () => {
- sqdist.assign( sqrt( sqdist ) );
- } );
- return sqdist;
- } ).setLayout( {
- name: 'mx_worley_noise_float_1',
- type: 'float',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_noise_float = /*#__PURE__*/ overloadingFn( [ mx_worley_noise_float_0, mx_worley_noise_float_1 ] );
- export const mx_worley_noise_vec2_1 = /*#__PURE__*/ tslFn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
- const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
- const sqdist = vec2( 1e6, 1e6 ).toVar();
- loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
- const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
- If( dist.lessThan( sqdist.x ), () => {
- sqdist.y.assign( sqdist.x );
- sqdist.x.assign( dist );
- } ).elseif( dist.lessThan( sqdist.y ), () => {
- sqdist.y.assign( dist );
- } );
- } );
- } );
- } );
- If( metric.equal( int( 0 ) ), () => {
- sqdist.assign( sqrt( sqdist ) );
- } );
- return sqdist;
- } ).setLayout( {
- name: 'mx_worley_noise_vec2_1',
- type: 'vec2',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_noise_vec2 = /*#__PURE__*/ overloadingFn( [ mx_worley_noise_vec2_0, mx_worley_noise_vec2_1 ] );
- export const mx_worley_noise_vec3_1 = /*#__PURE__*/ tslFn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
- const metric = int( metric_immutable ).toVar();
- const jitter = float( jitter_immutable ).toVar();
- const p = vec3( p_immutable ).toVar();
- const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
- const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
- const sqdist = vec3( 1e6, 1e6, 1e6 ).toVar();
- loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
- loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
- const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
- If( dist.lessThan( sqdist.x ), () => {
- sqdist.z.assign( sqdist.y );
- sqdist.y.assign( sqdist.x );
- sqdist.x.assign( dist );
- } ).elseif( dist.lessThan( sqdist.y ), () => {
- sqdist.z.assign( sqdist.y );
- sqdist.y.assign( dist );
- } ).elseif( dist.lessThan( sqdist.z ), () => {
- sqdist.z.assign( dist );
- } );
- } );
- } );
- } );
- If( metric.equal( int( 0 ) ), () => {
- sqdist.assign( sqrt( sqdist ) );
- } );
- return sqdist;
- } ).setLayout( {
- name: 'mx_worley_noise_vec3_1',
- type: 'vec3',
- inputs: [
- { name: 'p', type: 'vec3' },
- { name: 'jitter', type: 'float' },
- { name: 'metric', type: 'int' }
- ]
- } );
- export const mx_worley_noise_vec3 = /*#__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] );
|