@dailies-studio/tsl-textures 3.0.4

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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -0
  3. package/dist/cjs/tsl-textures.cjs +4749 -0
  4. package/dist/cjs/tsl-textures.min.cjs +2 -0
  5. package/dist/tsl-textures.js +4659 -0
  6. package/dist/tsl-textures.min.js +2 -0
  7. package/package.json +36 -0
  8. package/src/brain.js +116 -0
  9. package/src/bricks.js +116 -0
  10. package/src/camouflage.js +85 -0
  11. package/src/caustics.js +75 -0
  12. package/src/cave-art.js +83 -0
  13. package/src/circle-decor.js +76 -0
  14. package/src/circles.js +83 -0
  15. package/src/clouds.js +114 -0
  16. package/src/concrete.js +95 -0
  17. package/src/cork.js +104 -0
  18. package/src/crumpled-fabric.js +81 -0
  19. package/src/dalmatian-spots.js +80 -0
  20. package/src/darth-maul.js +84 -0
  21. package/src/dyson-sphere.js +144 -0
  22. package/src/entangled.js +75 -0
  23. package/src/fordite.js +69 -0
  24. package/src/gas-giant.js +94 -0
  25. package/src/grid.js +84 -0
  26. package/src/halftone.js +252 -0
  27. package/src/isolayers.js +79 -0
  28. package/src/isolines.js +72 -0
  29. package/src/karst-rock.js +67 -0
  30. package/src/marble.js +96 -0
  31. package/src/melter.js +76 -0
  32. package/src/neon-lights.js +107 -0
  33. package/src/perlin-noise.js +66 -0
  34. package/src/photosphere.js +73 -0
  35. package/src/planet.js +168 -0
  36. package/src/polka-dots.js +106 -0
  37. package/src/processed-wood.js +80 -0
  38. package/src/protozoa.js +110 -0
  39. package/src/reticular-veins.js +72 -0
  40. package/src/roman-paving.js +58 -0
  41. package/src/rotator.js +120 -0
  42. package/src/rough-clay.js +90 -0
  43. package/src/runny-eggs.js +180 -0
  44. package/src/rust.js +144 -0
  45. package/src/satin.js +69 -0
  46. package/src/scaler.js +111 -0
  47. package/src/scepter-head.js +94 -0
  48. package/src/scream.js +72 -0
  49. package/src/stars.js +72 -0
  50. package/src/static-noise.js +73 -0
  51. package/src/supersphere.js +108 -0
  52. package/src/tiger-fur.js +77 -0
  53. package/src/translator.js +116 -0
  54. package/src/tsl-textures.js +63 -0
  55. package/src/tsl-utils.js +344 -0
  56. package/src/turbulent-smoke.js +73 -0
  57. package/src/voronoi-cells.js +99 -0
  58. package/src/water-drops.js +96 -0
  59. package/src/watermelon.js +87 -0
  60. package/src/waves.js +150 -0
  61. package/src/wood.js +99 -0
  62. package/src/zebra-lines.js +77 -0
@@ -0,0 +1,72 @@
1
+ 
2
+ // TSL-Textures: Voronoi Cells
3
+
4
+
5
+
6
+ import { Color } from 'three';
7
+ import { exp, Fn, mix, positionGeometry } from 'three/tsl';
8
+ import { noise, voronoi } from './tsl-utils.js';
9
+
10
+
11
+
12
+ var defaults = {
13
+ $name: 'Reticular veins',
14
+
15
+ position: positionGeometry,
16
+ scale: 2,
17
+ reticulation: 5,
18
+ strength: 0.2,
19
+ organelles: 0.2,
20
+
21
+ color: new Color( 0xFFFFF0 ),
22
+ background: new Color( 0x208020 ),
23
+
24
+ seed: 0,
25
+ };
26
+
27
+
28
+
29
+ var reticularVeinsRaw = Fn( ([ position, scale, reticulation, strength, organelles, color, background, seed ])=>{
30
+
31
+ var pos = position.mul( exp( scale.div( 2 ).add( 0.5 ) ) ).add( seed ).toVar( );
32
+
33
+ var k1 = voronoi( pos );
34
+ var k2 = voronoi( pos.add( 100 ).mul( reticulation ) ).mul( strength );
35
+ var dots = noise( pos.mul( 100 ) ).mul( strength, organelles );
36
+
37
+ var k = k1.add( k2 ).add( dots );
38
+
39
+ return mix( background, color, k );
40
+
41
+ } ).setLayout( {
42
+ name: 'reticularVeinsRaw',
43
+ type: 'vec3',
44
+ inputs: [
45
+ { name: 'position', type: 'vec3' },
46
+ { name: 'scale', type: 'float' },
47
+ { name: 'reticulation', type: 'float' },
48
+ { name: 'strength', type: 'float' },
49
+ { name: 'organelles', type: 'float' },
50
+ { name: 'color', type: 'vec3' },
51
+ { name: 'background', type: 'vec3' },
52
+ { name: 'seed', type: 'float' },
53
+ ] }
54
+ );
55
+
56
+
57
+
58
+ function reticularVeins( params={} ) {
59
+
60
+ var { position, scale, reticulation, strength, organelles, color, background, seed } = { ...defaults, ...params };
61
+
62
+ return reticularVeinsRaw( position, scale, reticulation, strength, organelles, color, background, seed );
63
+
64
+ }
65
+
66
+
67
+
68
+ reticularVeins.defaults = defaults;
69
+
70
+
71
+
72
+ export { reticularVeins };
@@ -0,0 +1,58 @@
1
+ 
2
+ // TSL-Textures: Roman paving
3
+
4
+
5
+
6
+ import { exp, Fn, positionGeometry } from 'three/tsl';
7
+ import { voronoi2 } from './tsl-utils.js';
8
+
9
+
10
+
11
+ var defaults = {
12
+ $name: 'Roman paving',
13
+
14
+ position: positionGeometry,
15
+ scale: 2,
16
+ depth: 0.5,
17
+
18
+ seed: 0,
19
+ };
20
+
21
+
22
+
23
+ var romanPavingRaw = Fn( ([ position, scale, depth, seed ])=>{
24
+
25
+ var pos = position.mul( exp( scale ) ).add( seed ).toVar( );
26
+
27
+ var k = voronoi2( pos ).toVar();
28
+
29
+ return k.y.sub( k.x ).pow( depth.mul( 3 ).sub( 3 ).exp() ).smoothstep( 0, 1 );
30
+
31
+ } ).setLayout( {
32
+ name: 'romanPavingRaw',
33
+ type: 'vec3',
34
+ inputs: [
35
+ { name: 'position', type: 'vec3' },
36
+ { name: 'scale', type: 'float' },
37
+ { name: 'depth', type: 'float' },
38
+ { name: 'seed', type: 'float' },
39
+ ] }
40
+ );
41
+
42
+
43
+
44
+ function romanPaving( params={} ) {
45
+
46
+ var { position, scale, depth, seed } = { ...defaults, ...params };
47
+
48
+ return romanPavingRaw( position, scale, depth, seed );
49
+
50
+ }
51
+
52
+
53
+
54
+ romanPaving.defaults = defaults;
55
+
56
+
57
+
58
+ export { romanPaving };
package/src/rotator.js ADDED
@@ -0,0 +1,120 @@
1
+ 
2
+ // TSL-Textures: Rotator
3
+
4
+
5
+
6
+ import { Vector2, Vector3 } from "three";
7
+ import { cross, Fn, normalLocal, positionGeometry, tangentLocal } from 'three/tsl';
8
+ import { approximateNormal, rotatePivot, selectPlanar, } from './tsl-utils.js';
9
+
10
+
11
+
12
+ var defaults = {
13
+ $name: 'Rotator',
14
+ $positionNode: true,
15
+ $selectorPlanar: true,
16
+
17
+ angles: new Vector3( -0.2, 0.7, 0 ),
18
+ center: new Vector3( 0, 0, 0 ),
19
+
20
+ selectorCenter: new Vector3( 0, 0, 0 ),
21
+ selectorAngles: new Vector2( 0, 0 ),
22
+ selectorWidth: 2,
23
+
24
+ };
25
+
26
+
27
+
28
+ var surfacePos = Fn( ([ pos, angles, center, selectorAngles, selectorCenter, selectorWidth ])=>{
29
+
30
+ var zone = selectPlanar( pos, selectorAngles, selectorCenter, selectorWidth );
31
+
32
+ return rotatePivot( pos, center, angles.mul( zone ) );
33
+
34
+ } ).setLayout( {
35
+ name: 'surfacePos',
36
+ type: 'vec3',
37
+ inputs: [
38
+ { name: 'pos', type: 'vec3' },
39
+ { name: 'angles', type: 'vec3' },
40
+ { name: 'center', type: 'vec3' },
41
+ { name: 'selectorAngles', type: 'vec2' },
42
+ { name: 'selectorCenter', type: 'vec3' },
43
+ { name: 'selectorWidth', type: 'float' },
44
+ ]
45
+ } );
46
+
47
+
48
+
49
+ var rotatorRaw = Fn( ([ angles, center, selectorAngles, selectorCenter, selectorWidth ])=>{
50
+
51
+ return surfacePos( positionGeometry, angles, center, selectorAngles, selectorCenter, selectorWidth );
52
+
53
+ } ).setLayout( {
54
+ name: 'rotatorRaw',
55
+ type: 'vec3',
56
+ inputs: [
57
+ { name: 'angles', type: 'vec3' },
58
+ { name: 'center', type: 'vec3' },
59
+ { name: 'selectorAngles', type: 'vec2' },
60
+ { name: 'selectorCenter', type: 'vec3' },
61
+ { name: 'selectorWidth', type: 'float' },
62
+ ]
63
+ } );
64
+
65
+
66
+
67
+ var rotatorNormalRaw = Fn( ([ angles, center, selectorAngles, selectorCenter, selectorWidth ]) => {
68
+
69
+ const EPS = 0.01;
70
+
71
+ var position = positionGeometry,
72
+ normal = normalLocal.normalize().toVar(),
73
+ tangent = tangentLocal.normalize().mul( EPS ).toVar(),
74
+ bitangent = cross( normal, tangent ).normalize().mul( EPS ).toVar();
75
+
76
+ var pos = surfacePos( position, angles, center, selectorAngles, selectorCenter, selectorWidth );
77
+ var posU = surfacePos( position.add( tangent ), angles, center, selectorAngles, selectorCenter, selectorWidth );
78
+ var posV = surfacePos( position.add( bitangent ), angles, center, selectorAngles, selectorCenter, selectorWidth );
79
+
80
+ return approximateNormal( pos, posU, posV );
81
+
82
+ } ).setLayout( {
83
+ name: 'rotatorNormalRaw',
84
+ type: 'vec3',
85
+ inputs: [
86
+ { name: 'angles', type: 'vec3' },
87
+ { name: 'center', type: 'vec3' },
88
+ { name: 'selectorAngles', type: 'vec2' },
89
+ { name: 'selectorCenter', type: 'vec3' },
90
+ { name: 'selectorWidth', type: 'float' },
91
+ ]
92
+ } );
93
+
94
+
95
+
96
+ function rotator( params={} ) {
97
+
98
+ var { angles, center, selectorAngles, selectorCenter, selectorWidth } = { ...defaults, ...params };
99
+
100
+ return rotatorRaw( angles, center, selectorAngles, selectorCenter, selectorWidth );
101
+
102
+ }
103
+
104
+
105
+
106
+ rotator.normal = function ( params={} ) {
107
+
108
+ var { angles, center, selectorAngles, selectorCenter, selectorWidth } = { ...defaults, ...params };
109
+
110
+ return rotatorNormalRaw( angles, center, selectorAngles, selectorCenter, selectorWidth );
111
+
112
+ };
113
+
114
+
115
+
116
+ rotator.defaults = defaults;
117
+
118
+
119
+
120
+ export { rotator };
@@ -0,0 +1,90 @@
1
+ 
2
+ // TSL-Textures: Rough clay
3
+
4
+
5
+
6
+ import { cross, exp, Fn, normalLocal, positionGeometry, tangentLocal } from 'three/tsl';
7
+ import { approximateNormal, noise, voronoi } from './tsl-utils.js';
8
+
9
+
10
+
11
+ var defaults = {
12
+ $name: 'Rough clay',
13
+ $normalNode: true,
14
+
15
+ position: positionGeometry,
16
+ scale: 2,
17
+ bump: 0.5,
18
+ curvature: 0.2,
19
+
20
+ seed: 0,
21
+ };
22
+
23
+
24
+
25
+ var surfacePos = Fn( ([ pos, normal, curvature ]) => {
26
+
27
+ var k1 = voronoi( pos.add( noise( pos ).mul( curvature ) ) ).add( 0.8 ).pow( 5 ).toVar();
28
+ k1.addAssign( k1.pow( 0.5 ) );
29
+ return pos.add( normal.mul( k1 ) );
30
+
31
+ } ).setLayout( {
32
+ name: 'surfacePos',
33
+ type: 'vec3',
34
+ inputs: [
35
+ { name: 'position', type: 'vec3' },
36
+ { name: 'normal', type: 'vec3' },
37
+ { name: 'curvature', type: 'float' },
38
+ ] }
39
+ );
40
+
41
+
42
+
43
+ var roughClayRaw = Fn( ([ position, normal, tangent, scale, bump, curvature, seed ]) => {
44
+
45
+ const EPS = 0.001;
46
+
47
+ var xposition = position.mul( exp( scale.div( 2 ) ) ).add( seed.sin().mul( 10 ) ).toVar( ),
48
+ xnormal = normal.normalize().toVar(),
49
+ xtangent = tangent.normalize().mul( EPS ).toVar(),
50
+ xbitangent = cross( xnormal, xtangent ).normalize().mul( EPS ).toVar();
51
+
52
+ xnormal.mulAssign( bump, 1/50 );
53
+
54
+ var pos = surfacePos( xposition, xnormal, curvature );
55
+ var posU = surfacePos( xposition.add( xtangent ), xnormal, curvature );
56
+ var posV = surfacePos( xposition.add( xbitangent ), xnormal, curvature );
57
+
58
+ return approximateNormal( pos, posU, posV );
59
+
60
+ } ).setLayout( {
61
+ name: 'concreteRaw',
62
+ type: 'vec3',
63
+ inputs: [
64
+ { name: 'position', type: 'vec3' },
65
+ { name: 'normal', type: 'vec3' },
66
+ { name: 'tangent', type: 'vec3' },
67
+ { name: 'scale', type: 'float' },
68
+ { name: 'bump', type: 'float' },
69
+ { name: 'curvature', type: 'float' },
70
+ { name: 'seed', type: 'float' },
71
+ ] }
72
+ );
73
+
74
+
75
+
76
+ function roughClay( params={} ) {
77
+
78
+ var { position, scale, bump, curvature, seed } = { ...defaults, ...params };
79
+
80
+ return roughClayRaw( position, normalLocal, tangentLocal, scale, bump, curvature, seed );
81
+
82
+ }
83
+
84
+
85
+
86
+ roughClay.defaults = defaults;
87
+
88
+
89
+
90
+ export { roughClay };
@@ -0,0 +1,180 @@
1
+ 
2
+ // TSL-Textures: Runny eggs
3
+
4
+
5
+
6
+ import { Color } from 'three';
7
+ import { cross, exp, Fn, mix, normalLocal, positionGeometry, tangentLocal } from 'three/tsl';
8
+ import { approximateNormal, voronoi } from './tsl-utils.js';
9
+
10
+
11
+
12
+ var defaults = {
13
+ $name: 'Runny eggs',
14
+
15
+ position: positionGeometry,
16
+ scale: 1,
17
+
18
+ sizeYolk: 0.2,
19
+ sizeWhite: 0.7,
20
+
21
+ colorYolk: new Color( 'orange' ),
22
+ colorWhite: new Color( 'white' ),
23
+ colorBackground: new Color( 'lightgray' ),
24
+
25
+ seed: 0,
26
+ };
27
+
28
+
29
+
30
+ var surfacePos = Fn( ([ pos, normal, sizeYolk, sizeWhite ]) => {
31
+
32
+ var n = voronoi( pos ).toVar();
33
+ var whites = n.add( sizeWhite ).pow( 8 ).oneMinus();
34
+ var yolks = n.add( sizeYolk ).pow( 18 ).oneMinus().clamp( 0, 1 );
35
+
36
+ var k = mix( 0, mix( 0, 1, yolks ), whites );
37
+
38
+ return pos.add( normal.mul( k ) );
39
+
40
+ } ).setLayout( {
41
+ name: 'surfacePos',
42
+ type: 'vec3',
43
+ inputs: [
44
+ { name: 'pos', type: 'vec3' },
45
+ { name: 'normal', type: 'vec3' },
46
+ { name: 'sizeYolk', type: 'float' },
47
+ { name: 'sizeWhite', type: 'float' },
48
+ ] }
49
+ );
50
+
51
+
52
+
53
+ var runnyEggsRaw = Fn( ([ position, scale, sizeYolk, sizeWhite, colorYolk, colorWhite, colorBackground, seed ]) => {
54
+
55
+ var pos = position.mul( exp( scale ) ).add( seed.sin().mul( 10 ) ).toVar( );
56
+
57
+ var n = voronoi( pos ).toVar();
58
+ var whites = n.add( sizeWhite.oneMinus() ).pow( 8 ).oneMinus().clamp( -0.5, 1 );
59
+ var yolks = n.add( sizeYolk.oneMinus() ).pow( 18 ).oneMinus().clamp( 0, 1 ).pow( 0.4 ).clamp( 0, 1 );
60
+
61
+ return mix( colorBackground, mix( colorWhite, colorYolk, yolks ), whites );
62
+
63
+ } ).setLayout( {
64
+ name: 'runnyEggsRaw',
65
+ type: 'vec3',
66
+ inputs: [
67
+ { name: 'pos', type: 'vec3' },
68
+ { name: 'normal', type: 'vec3' },
69
+ { name: 'sizeYolk', type: 'float' },
70
+ { name: 'sizeWhite', type: 'float' },
71
+ { name: 'colorYolk', type: 'vec3' },
72
+ { name: 'colorWhite', type: 'vec3' },
73
+ { name: 'colorBackground', type: 'vec3' },
74
+ { name: 'seed', type: 'float' },
75
+ ] }
76
+ );
77
+
78
+
79
+
80
+ var runnyEggsNormalRaw = Fn( ([ position, normal, tangent, scale, sizeYolk, sizeWhite, /*colorYolk, colorWhite, colorBackground,*/ seed ]) => {
81
+
82
+ const EPS = 0.001;
83
+ const BUMP = 0.05;
84
+
85
+ var xposition = position.mul( exp( scale ) ).add( seed.sin().mul( 10 ) ).toVar( ),
86
+ xnormal = normal.normalize().toVar(),
87
+ xtangent = tangent.normalize().mul( EPS ).toVar(),
88
+ bitangent = cross( xnormal, xtangent ).normalize().mul( EPS ).toVar();
89
+
90
+ var xSizeYolk = sizeYolk.oneMinus();
91
+ var xSizeWhite = sizeWhite.oneMinus();
92
+
93
+ xnormal.mulAssign( BUMP );
94
+
95
+ var pos = surfacePos( xposition, xnormal, xSizeYolk, xSizeWhite );
96
+ var posU = surfacePos( xposition.add( xtangent ), xnormal, xSizeYolk, xSizeWhite );
97
+ var posV = surfacePos( xposition.add( bitangent ), xnormal, xSizeYolk, xSizeWhite );
98
+
99
+ return approximateNormal( pos, posU, posV );
100
+
101
+ } ).setLayout( {
102
+ name: 'runnyEggsNormalRaw',
103
+ type: 'vec3',
104
+ inputs: [
105
+ { name: 'position', type: 'vec3' },
106
+ { name: 'normal', type: 'vec3' },
107
+ { name: 'tangent', type: 'vec3' },
108
+ { name: 'scale', type: 'float' },
109
+ { name: 'sizeYolk', type: 'float' },
110
+ { name: 'sizeWhite', type: 'float' },
111
+ /*{ name: 'colorYolk', type: 'vec3' },*/
112
+ /*{ name: 'colorWhite', type: 'vec3' },*/
113
+ /*{ name: 'colorBackground', type: 'vec3' },*/
114
+ { name: 'seed', type: 'float' },
115
+ ] }
116
+ );
117
+
118
+
119
+
120
+ var runnyEggsRoughnessRaw = Fn( ([ position, scale, sizeYolk, /*sizeWhite, colorYolk, colorWhite, colorBackground,*/ seed ]) => {
121
+
122
+ var pos = position.mul( exp( scale ) ).add( seed.sin().mul( 10 ) ).toVar( );
123
+
124
+ var n = voronoi( pos ).toVar();
125
+ var yolks = n.add( sizeYolk.oneMinus() ).pow( 18 ).clamp( 0, 1 );
126
+
127
+ return yolks;
128
+
129
+ } ).setLayout( {
130
+ name: 'runnyEggsRoughnessRaw',
131
+ type: 'float',
132
+ inputs: [
133
+ { name: 'position', type: 'vec3' },
134
+ { name: 'scale', type: 'float' },
135
+ { name: 'sizeYolk', type: 'float' },
136
+ /*{ name: 'sizeWhite', type: 'float' },*/
137
+ /*{ name: 'colorYolk', type: 'vec3' },*/
138
+ /*{ name: 'colorWhite', type: 'vec3' },*/
139
+ /*{ name: 'colorBackground', type: 'vec3' },*/
140
+ { name: 'seed', type: 'float' },
141
+ ] }
142
+ );
143
+
144
+
145
+
146
+ function runnyEggs( params={} ) {
147
+
148
+ var { position, scale, sizeYolk, sizeWhite, colorYolk, colorWhite, colorBackground, seed } = { ...defaults, ...params };
149
+
150
+ return runnyEggsRaw( position, scale, sizeYolk, sizeWhite, colorYolk, colorWhite, colorBackground, seed );
151
+
152
+ }
153
+
154
+
155
+
156
+ runnyEggs.normal = function ( params={} ) {
157
+
158
+ var { position, scale, sizeYolk, sizeWhite, /*colorYolk, colorWhite, colorBackground,*/ seed } = { ...defaults, ...params };
159
+
160
+ return runnyEggsNormalRaw( position, normalLocal, tangentLocal, scale, sizeYolk, sizeWhite, /*colorYolk, colorWhite, colorBackground,*/ seed );
161
+
162
+ };
163
+
164
+
165
+
166
+ runnyEggs.roughness = function ( params={} ) {
167
+
168
+ var { position, scale, sizeYolk, /*sizeWhite, colorYolk, colorWhite, colorBackground,*/ seed } = { ...defaults, ...params };
169
+
170
+ return runnyEggsRoughnessRaw( position, scale, sizeYolk, /*sizeWhite, colorYolk, colorWhite, colorBackground,*/ seed );
171
+
172
+ };
173
+
174
+
175
+
176
+ runnyEggs.defaults = defaults;
177
+
178
+
179
+
180
+ export { runnyEggs };
package/src/rust.js ADDED
@@ -0,0 +1,144 @@
1
+ 
2
+ // TSL-Textures: Voronoi Cells
3
+
4
+
5
+
6
+ import { Color } from 'three';
7
+ import { exp, Fn, Loop, mix, positionGeometry } from 'three/tsl';
8
+ import { noise } from './tsl-utils.js';
9
+
10
+
11
+
12
+ var defaults = {
13
+ $name: 'rust',
14
+
15
+ position: positionGeometry,
16
+ scale: 2,
17
+ iterations: 8,
18
+ amount: -0.3,
19
+ opacity: 0.5,
20
+ noise: 0.5,
21
+ noiseScale: 0.5,
22
+
23
+ color: new Color( 0xC08000 ),
24
+ background: new Color( 0x000020 ),
25
+
26
+ seed: 0,
27
+ };
28
+
29
+
30
+
31
+ var _rust = Fn( ([ position, scale, iterations, amount, seed ])=>{
32
+
33
+ var pos = position.mul( exp( scale.div( 4 ).add( -1 ) ) ).add( seed ).toVar( );
34
+
35
+ var xamount = amount.mul( noise( pos.mul( amount.div( 2 ).add( 4 ) ) ).add( 4 ) ).toVar();
36
+
37
+ var k = noise( pos ).toVar();
38
+
39
+ Loop( iterations, ()=>{
40
+
41
+ pos.mulAssign( 2 );
42
+ k.addAssign( noise( pos ) );
43
+
44
+ } );
45
+
46
+ k.subAssign( noise( pos.mul( 2 ) ).abs() );
47
+
48
+ k.assign( k.sub( xamount ).clamp( 0, 15 ) );
49
+
50
+ return k;
51
+
52
+ } ).setLayout( {
53
+ name: '_rust',
54
+ type: 'float',
55
+ inputs: [
56
+ { name: 'position', type: 'vec3' },
57
+ { name: 'scale', type: 'float' },
58
+ { name: 'iterations', type: 'int' },
59
+ { name: 'amount', type: 'float' },
60
+ { name: 'seed', type: 'float' },
61
+ ] }
62
+ );
63
+
64
+
65
+ var rustRaw = Fn( ([ position, scale, iterations, amount, /*opacity,*/xnoise, noiseScale, color, background, seed ])=>{
66
+
67
+ var k = _rust( position, scale, iterations, amount, seed ).mul( 1.25 ).pow( 0.5 );
68
+
69
+ var pos = position.mul( exp( scale.add( noiseScale.mul( 3 ), 2 ) ) );
70
+
71
+ k.addAssign( xnoise.mul( noise( pos ).abs().add( 0.1 ).pow( 2 ) ) );
72
+
73
+ return mix( color, background, k );
74
+
75
+ } ).setLayout( {
76
+ name: 'rustRaw',
77
+ type: 'vec3',
78
+ inputs: [
79
+ { name: 'position', type: 'vec3' },
80
+ { name: 'scale', type: 'float' },
81
+ { name: 'iterations', type: 'int' },
82
+ { name: 'amount', type: 'float' },
83
+ /*{ name: 'opacity', type: 'float' },*/
84
+ { name: 'xnoise', type: 'float' },
85
+ { name: 'noiseScale', type: 'float' },
86
+ { name: 'color', type: 'vec3' },
87
+ { name: 'background', type: 'vec3' },
88
+ { name: 'seed', type: 'float' },
89
+ ] }
90
+ );
91
+
92
+
93
+
94
+
95
+ var rustOpacityRaw = Fn( ([ position, scale, iterations, amount, opacity, /*xnoise, noiseScale, color, background,*/ seed ])=>{
96
+
97
+ var k = _rust( position, scale, iterations, amount, seed ).mul( opacity.add( 0.2 ) );
98
+
99
+ return k.oneMinus();
100
+
101
+ } ).setLayout( {
102
+ name: 'rustOpacityRaw',
103
+ type: 'float',
104
+ inputs: [
105
+ { name: 'position', type: 'vec3' },
106
+ { name: 'scale', type: 'float' },
107
+ { name: 'iterations', type: 'int' },
108
+ { name: 'amount', type: 'float' },
109
+ { name: 'opacity', type: 'float' },
110
+ /*{ name: 'xnoise', type: 'float' },*/
111
+ /*{ name: 'noiseScale', type: 'float' },*/
112
+ /*{ name: 'color', type: 'vec3' },*/
113
+ /*{ name: 'background', type: 'vec3' },*/
114
+ { name: 'seed', type: 'float' },
115
+ ] }
116
+ );
117
+
118
+
119
+
120
+ function rust( params={} ) {
121
+
122
+ var { position, scale, iterations, amount, /*opacity,*/ noise, noiseScale, color, background, seed } = { ...defaults, ...params };
123
+
124
+ return rustRaw( position, scale, iterations, amount, /*opacity,*/noise, noiseScale, color, background, seed );
125
+
126
+ }
127
+
128
+
129
+
130
+ rust.opacity = function ( params={} ) {
131
+
132
+ var { position, scale, iterations, amount, opacity, /*xnoise, noiseScale, color, background,*/ seed } = { ...defaults, ...params };
133
+
134
+ return rustOpacityRaw( position, scale, iterations, amount, opacity, /*xnoise, noiseScale, color, background,*/ seed );
135
+
136
+ };
137
+
138
+
139
+
140
+ rust.defaults = defaults;
141
+
142
+
143
+
144
+ export { rust };