@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.
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/cjs/tsl-textures.cjs +4749 -0
- package/dist/cjs/tsl-textures.min.cjs +2 -0
- package/dist/tsl-textures.js +4659 -0
- package/dist/tsl-textures.min.js +2 -0
- package/package.json +36 -0
- package/src/brain.js +116 -0
- package/src/bricks.js +116 -0
- package/src/camouflage.js +85 -0
- package/src/caustics.js +75 -0
- package/src/cave-art.js +83 -0
- package/src/circle-decor.js +76 -0
- package/src/circles.js +83 -0
- package/src/clouds.js +114 -0
- package/src/concrete.js +95 -0
- package/src/cork.js +104 -0
- package/src/crumpled-fabric.js +81 -0
- package/src/dalmatian-spots.js +80 -0
- package/src/darth-maul.js +84 -0
- package/src/dyson-sphere.js +144 -0
- package/src/entangled.js +75 -0
- package/src/fordite.js +69 -0
- package/src/gas-giant.js +94 -0
- package/src/grid.js +84 -0
- package/src/halftone.js +252 -0
- package/src/isolayers.js +79 -0
- package/src/isolines.js +72 -0
- package/src/karst-rock.js +67 -0
- package/src/marble.js +96 -0
- package/src/melter.js +76 -0
- package/src/neon-lights.js +107 -0
- package/src/perlin-noise.js +66 -0
- package/src/photosphere.js +73 -0
- package/src/planet.js +168 -0
- package/src/polka-dots.js +106 -0
- package/src/processed-wood.js +80 -0
- package/src/protozoa.js +110 -0
- package/src/reticular-veins.js +72 -0
- package/src/roman-paving.js +58 -0
- package/src/rotator.js +120 -0
- package/src/rough-clay.js +90 -0
- package/src/runny-eggs.js +180 -0
- package/src/rust.js +144 -0
- package/src/satin.js +69 -0
- package/src/scaler.js +111 -0
- package/src/scepter-head.js +94 -0
- package/src/scream.js +72 -0
- package/src/stars.js +72 -0
- package/src/static-noise.js +73 -0
- package/src/supersphere.js +108 -0
- package/src/tiger-fur.js +77 -0
- package/src/translator.js +116 -0
- package/src/tsl-textures.js +63 -0
- package/src/tsl-utils.js +344 -0
- package/src/turbulent-smoke.js +73 -0
- package/src/voronoi-cells.js +99 -0
- package/src/water-drops.js +96 -0
- package/src/watermelon.js +87 -0
- package/src/waves.js +150 -0
- package/src/wood.js +99 -0
- package/src/zebra-lines.js +77 -0
|
@@ -0,0 +1,4749 @@
|
|
|
1
|
+
// TSL Textures v3.0.4
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var tsl = require('three/tsl');
|
|
6
|
+
var three = require('three');
|
|
7
|
+
|
|
8
|
+
// simple vector noise, vec3->float[-1,1]
|
|
9
|
+
const vnoise = tsl.Fn( ([ v ])=>{
|
|
10
|
+
|
|
11
|
+
return v.dot( tsl.vec3( 12.9898, 78.233, -97.5123 ) ).sin().mul( 43758.5453 ).fract().mul( 2 ).sub( 1 );
|
|
12
|
+
|
|
13
|
+
} ).setLayout( {
|
|
14
|
+
name: 'vnoise',
|
|
15
|
+
type: 'float',
|
|
16
|
+
inputs: [
|
|
17
|
+
{ name: 'v', type: 'vec3' },
|
|
18
|
+
]
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// approximate normal vector given point and two neighbout points
|
|
24
|
+
const approximateNormal = tsl.Fn( ([ pos, posU, posV ])=>{
|
|
25
|
+
|
|
26
|
+
var dU = tsl.sub( posU, pos ),
|
|
27
|
+
dV = tsl.sub( posV, pos );
|
|
28
|
+
|
|
29
|
+
return tsl.transformNormalToView( tsl.cross( dU, dV ).normalize() );
|
|
30
|
+
|
|
31
|
+
} ).setLayout( {
|
|
32
|
+
name: 'approximateNormal',
|
|
33
|
+
type: 'vec3',
|
|
34
|
+
inputs: [
|
|
35
|
+
{ name: 'pos', type: 'vec3' },
|
|
36
|
+
{ name: 'posU', type: 'vec3' },
|
|
37
|
+
{ name: 'posV', type: 'vec3' },
|
|
38
|
+
]
|
|
39
|
+
} );
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// exponential version of remap
|
|
45
|
+
const remapExp = tsl.Fn( ([ x, fromMin, fromMax, toMin, toMax ]) => {
|
|
46
|
+
|
|
47
|
+
x = tsl.remap( x, fromMin, fromMax, 0, 1 );
|
|
48
|
+
x = tsl.pow( 2, tsl.mul( x, tsl.log2( toMax.div( toMin ) ) ).add( tsl.log2( toMin ) ) );
|
|
49
|
+
return x;
|
|
50
|
+
|
|
51
|
+
} ).setLayout( {
|
|
52
|
+
name: 'remapExp',
|
|
53
|
+
type: 'float',
|
|
54
|
+
inputs: [
|
|
55
|
+
{ name: 'x', type: 'float' },
|
|
56
|
+
{ name: 'fromMin', type: 'float' },
|
|
57
|
+
{ name: 'fromMax', type: 'float' },
|
|
58
|
+
{ name: 'toMin', type: 'float' },
|
|
59
|
+
{ name: 'toMax', type: 'float' },
|
|
60
|
+
]
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// show notification that
|
|
66
|
+
var banner = null;
|
|
67
|
+
var bannerCounter = 10;
|
|
68
|
+
async function showFallbackWarning( ) {
|
|
69
|
+
|
|
70
|
+
if ( navigator.gpu != undefined ) {
|
|
71
|
+
|
|
72
|
+
var adapter = await navigator.gpu.requestAdapter();
|
|
73
|
+
if ( adapter ) return;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var html = `
|
|
78
|
+
<div style="font-size:1.25em; font-weight:bold;">PLEASE, WAIT</div>
|
|
79
|
+
<div style="font-size:0.85em; font-weight:100;" >NO WEBGPU — TRYING WEBGL2</div>
|
|
80
|
+
<div id="counter"></div>
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
banner = document.createElement( 'div' );
|
|
84
|
+
banner.innerHTML = html;
|
|
85
|
+
|
|
86
|
+
banner.style.left = 'calc(50% - 8em)';
|
|
87
|
+
banner.style.width = '16em';
|
|
88
|
+
|
|
89
|
+
banner.style.fontFamily = 'Bahnschrifts, Arial';
|
|
90
|
+
banner.style.position = 'absolute';
|
|
91
|
+
banner.style.bottom = '20px';
|
|
92
|
+
banner.style.padding = '12px 6px';
|
|
93
|
+
banner.style.border = '1px solid white';
|
|
94
|
+
banner.style.borderRadius = '4px';
|
|
95
|
+
banner.style.background = 'rgba(0,0,0,0.5)';
|
|
96
|
+
banner.style.color = 'white';
|
|
97
|
+
banner.style.textAlign = 'center';
|
|
98
|
+
banner.style.opacity = '0.8';
|
|
99
|
+
banner.style.outline = 'none';
|
|
100
|
+
banner.style.zIndex = '999';
|
|
101
|
+
|
|
102
|
+
document.body.appendChild( banner );
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
function hideFallbackWarning( ) {
|
|
109
|
+
|
|
110
|
+
if ( banner ) {
|
|
111
|
+
|
|
112
|
+
if ( bannerCounter>0 )
|
|
113
|
+
bannerCounter--;
|
|
114
|
+
else {
|
|
115
|
+
|
|
116
|
+
banner.style.display = 'none';
|
|
117
|
+
banner = null;
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// helper function - convert hsl to rgb, ported to TSL from:
|
|
128
|
+
// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
|
|
129
|
+
|
|
130
|
+
const hslHelper = tsl.Fn( ([ h, s, l, n ])=>{
|
|
131
|
+
|
|
132
|
+
var k = n.add( h.mul( 12 ) ).mod( 12 );
|
|
133
|
+
var a = s.mul( tsl.min( l, tsl.sub( 1, l ) ) );
|
|
134
|
+
return l.sub( a.mul( tsl.max( -1, tsl.min( tsl.min( k.sub( 3 ), tsl.sub( 9, k ) ), 1 ) ) ) );
|
|
135
|
+
|
|
136
|
+
} ).setLayout( {
|
|
137
|
+
name: 'hslHelper',
|
|
138
|
+
type: 'float',
|
|
139
|
+
inputs: [
|
|
140
|
+
{ name: 'h', type: 'float' },
|
|
141
|
+
{ name: 's', type: 'float' },
|
|
142
|
+
{ name: 'l', type: 'float' },
|
|
143
|
+
{ name: 'n', type: 'float' },
|
|
144
|
+
]
|
|
145
|
+
} );
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
// convert from hsl to rgb
|
|
150
|
+
const hsl = tsl.Fn( ([ col ]) => {
|
|
151
|
+
|
|
152
|
+
var h = col.x.fract().add( 1 ).fract();
|
|
153
|
+
var s = col.y.clamp( 0, 1 );
|
|
154
|
+
var l = col.z.clamp( 0, 1 );
|
|
155
|
+
|
|
156
|
+
var r = hslHelper( h, s, l, 0 );
|
|
157
|
+
var g = hslHelper( h, s, l, 8 );
|
|
158
|
+
var b = hslHelper( h, s, l, 4 );
|
|
159
|
+
|
|
160
|
+
return tsl.vec3( r, g, b );
|
|
161
|
+
|
|
162
|
+
} ).setLayout( {
|
|
163
|
+
name: 'hsl',
|
|
164
|
+
type: 'vec3',
|
|
165
|
+
inputs: [
|
|
166
|
+
{ name: 'col', type: 'vec3' },
|
|
167
|
+
]
|
|
168
|
+
} );
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
// convert from rgb to hsl
|
|
173
|
+
const toHsl = tsl.Fn( ([ rgb ]) => {
|
|
174
|
+
|
|
175
|
+
var R = tsl.float( rgb.x ).toVar(),
|
|
176
|
+
G = tsl.float( rgb.y ).toVar(),
|
|
177
|
+
B = tsl.float( rgb.z ).toVar();
|
|
178
|
+
|
|
179
|
+
var mx = tsl.max( R, tsl.max( G, B ) ).toVar();
|
|
180
|
+
var mn = tsl.min( R, tsl.min( G, B ) ).toVar();
|
|
181
|
+
|
|
182
|
+
var H = tsl.float( 0 ).toVar(),
|
|
183
|
+
S = tsl.float( 0 ).toVar(),
|
|
184
|
+
L = tsl.add( mx, mn ).div( 2 );
|
|
185
|
+
|
|
186
|
+
tsl.If( mn.notEqual( mx ), ()=>{
|
|
187
|
+
|
|
188
|
+
const delta = tsl.sub( mx, mn ).toVar();
|
|
189
|
+
|
|
190
|
+
S.assign( tsl.select( L.lessThanEqual( 0.5 ), delta.div( tsl.add( mn, mx ) ), delta.div( tsl.sub( 2, tsl.add( mn, mx ) ) ) ) );
|
|
191
|
+
tsl.If( mx.equal( R ), ()=>{
|
|
192
|
+
|
|
193
|
+
H.assign( tsl.sub( G, B ).div( delta ).add( tsl.select( G.lessThanEqual( B ), 6, 0 ) ) );
|
|
194
|
+
|
|
195
|
+
} )
|
|
196
|
+
.ElseIf( mx.equal( G ), ()=>{
|
|
197
|
+
|
|
198
|
+
H.assign( tsl.sub( B, R ).div( delta ).add( 2 ) );
|
|
199
|
+
|
|
200
|
+
} )
|
|
201
|
+
.Else( ()=>{
|
|
202
|
+
|
|
203
|
+
H.assign( tsl.sub( R, G ).div( delta ).add( 4 ) );
|
|
204
|
+
|
|
205
|
+
} );
|
|
206
|
+
H.divAssign( 6 );
|
|
207
|
+
|
|
208
|
+
} );
|
|
209
|
+
return tsl.vec3( H, S, L );
|
|
210
|
+
|
|
211
|
+
} );
|
|
212
|
+
|
|
213
|
+
toHsl.setLayout( {
|
|
214
|
+
name: 'toHsl',
|
|
215
|
+
type: 'vec3',
|
|
216
|
+
inputs: [
|
|
217
|
+
{ name: 'rgb', type: 'vec3' },
|
|
218
|
+
]
|
|
219
|
+
} );
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
const spherical = tsl.Fn( ([ phi, theta ]) => {
|
|
224
|
+
|
|
225
|
+
return tsl.vec3(
|
|
226
|
+
tsl.sin( theta ).mul( tsl.sin( phi ) ),
|
|
227
|
+
tsl.cos( phi ),
|
|
228
|
+
tsl.cos( theta ).mul( tsl.sin( phi ) )
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
} ).setLayout( {
|
|
232
|
+
name: 'spherical',
|
|
233
|
+
type: 'vec3',
|
|
234
|
+
inputs: [
|
|
235
|
+
{ name: 'phi', type: 'float' },
|
|
236
|
+
{ name: 'theta', type: 'float' },
|
|
237
|
+
]
|
|
238
|
+
} );
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
const rotatePivot = tsl.Fn( ([ vector, pivot, angle ])=>{
|
|
243
|
+
|
|
244
|
+
return tsl.rotate( vector.sub( pivot ), angle ).add( pivot );
|
|
245
|
+
|
|
246
|
+
} ).setLayout( {
|
|
247
|
+
name: 'rotatePivot',
|
|
248
|
+
type: 'vec3',
|
|
249
|
+
inputs: [
|
|
250
|
+
{ name: 'vector', type: 'vec3' },
|
|
251
|
+
{ name: 'pivot', type: 'vec3' },
|
|
252
|
+
{ name: 'angle', type: 'vec3' },
|
|
253
|
+
]
|
|
254
|
+
} );
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
const selectPlanar = tsl.Fn( ([ pos, selAngles, selCenter, selWidth ])=>{
|
|
259
|
+
|
|
260
|
+
// select zone in a plane through point selCenter,
|
|
261
|
+
// rotated according to selAngles and selWidth thick
|
|
262
|
+
// result is [0,1] inside plane, 0 below plane, 1 above plane
|
|
263
|
+
|
|
264
|
+
// C is projected on segment AB
|
|
265
|
+
// result is [0,1] inside AB, 0 before A, 1 after B
|
|
266
|
+
|
|
267
|
+
/* non-optimized version
|
|
268
|
+
var s = spherical(selAngles.x,selAngles.y).mul(selWidth).toVar(),
|
|
269
|
+
c = pos,
|
|
270
|
+
a = selCenter.sub(s.div(2)),
|
|
271
|
+
b = selCenter.add(s.div(2));
|
|
272
|
+
|
|
273
|
+
var ca = a.sub(c),
|
|
274
|
+
ab = b.sub(a).toVar();
|
|
275
|
+
|
|
276
|
+
var caab = ca.dot(s),
|
|
277
|
+
abab = ab.dot(ab);
|
|
278
|
+
|
|
279
|
+
var k = caab.div(abab).negate();
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
var s = spherical( selAngles.x, selAngles.y ).mul( selWidth ).toVar();
|
|
283
|
+
|
|
284
|
+
var k = selCenter.sub( s.div( 2 ) ).sub( pos ).dot( s ).div( s.dot( s ) ).negate();
|
|
285
|
+
|
|
286
|
+
return tsl.smoothstep( 0, 1, k );
|
|
287
|
+
|
|
288
|
+
} ).setLayout( {
|
|
289
|
+
name: 'selectPlanar',
|
|
290
|
+
type: 'float',
|
|
291
|
+
inputs: [
|
|
292
|
+
{ name: 'pos', type: 'vec3' },
|
|
293
|
+
{ name: 'selAngles', type: 'vec2' },
|
|
294
|
+
{ name: 'selCenter', type: 'vec3' },
|
|
295
|
+
{ name: 'selWidth', type: 'float' },
|
|
296
|
+
]
|
|
297
|
+
} );
|
|
298
|
+
|
|
299
|
+
var defaults$P = {
|
|
300
|
+
$name: 'Brain',
|
|
301
|
+
|
|
302
|
+
position: tsl.positionGeometry,
|
|
303
|
+
scale: 2,
|
|
304
|
+
|
|
305
|
+
smooth: 0.5,
|
|
306
|
+
wave: 0.5,
|
|
307
|
+
speed: 2.5,
|
|
308
|
+
time: tsl.time,
|
|
309
|
+
|
|
310
|
+
color: new three.Color( 0xFFD0D0 ),
|
|
311
|
+
background: new three.Color( 0x500000 ),
|
|
312
|
+
|
|
313
|
+
seed: 0,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
var brainRaw = tsl.Fn( ([ position, scale, xsmooth, /*wave, speed, time,*/ color, background, seed ])=>{
|
|
319
|
+
|
|
320
|
+
var pos = position.mul( scale.div( 3 ).exp( ) ).add( seed ).toVar( 'pos' );
|
|
321
|
+
|
|
322
|
+
var octaves = xsmooth.oneMinus().mul( 2 ).exp( ).toVar( 'octaves' );
|
|
323
|
+
|
|
324
|
+
var n = tsl.mx_fractal_noise_float( pos.mul( 5 ), octaves ).add( 1 ).div( 2 ).clamp( 0, 1 ).pow( 2 );
|
|
325
|
+
|
|
326
|
+
return tsl.mix( color, background, n );
|
|
327
|
+
|
|
328
|
+
} ).setLayout( {
|
|
329
|
+
name: 'brainRaw',
|
|
330
|
+
type: 'vec3',
|
|
331
|
+
inputs: [
|
|
332
|
+
{ name: 'position', type: 'vec3' },
|
|
333
|
+
{ name: 'scale', type: 'float' },
|
|
334
|
+
{ name: 'xsmooth', type: 'float' },
|
|
335
|
+
/*{ name: 'wave', type: 'float' },*/
|
|
336
|
+
/*{ name: 'speed', type: 'float' },*/
|
|
337
|
+
/*{ name: 'time', type: 'float' },*/
|
|
338
|
+
{ name: 'color', type: 'vec3' },
|
|
339
|
+
{ name: 'background', type: 'vec3' },
|
|
340
|
+
{ name: 'seed', type: 'float' },
|
|
341
|
+
] }
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
var brainNormalRaw = tsl.Fn( ([ position, scale, xsmooth, wave, speed, time, /*color, background,*/ seed ])=>{
|
|
346
|
+
|
|
347
|
+
var pos = position.mul( scale.div( 3 ).exp( ) ).add( seed ).toVar( 'pos' );
|
|
348
|
+
|
|
349
|
+
var octaves = xsmooth.oneMinus().mul( 2 ).exp( ).toVar( 'octaves' );
|
|
350
|
+
|
|
351
|
+
const EPS = 0.01;
|
|
352
|
+
|
|
353
|
+
var n = tsl.mx_fractal_noise_float( pos.mul( 5 ), octaves ).toVar( 'n' ),
|
|
354
|
+
dx = tsl.mx_fractal_noise_float( pos.add( tsl.vec3( EPS, 0, 0 ) ).mul( 5 ), octaves ).sub( n ).div( EPS ).toVar( 'dx' ),
|
|
355
|
+
dy = tsl.mx_fractal_noise_float( pos.add( tsl.vec3( 0, EPS, 0 ) ).mul( 5 ), octaves ).sub( n ).div( EPS ).toVar( 'dy' );
|
|
356
|
+
|
|
357
|
+
var dTime = tsl.mx_noise_float( pos.mul( wave, 5 ) ).add( 1 ).div( 2 ).mul( 6.28 ).toVar( 'dTime' );
|
|
358
|
+
|
|
359
|
+
return tsl.vec3( dx, dy, time.mul( speed ).add( dTime ).sin().add( n, 1 ) ).normalize();
|
|
360
|
+
|
|
361
|
+
} ).setLayout( {
|
|
362
|
+
name: 'brainNormalRaw',
|
|
363
|
+
type: 'vec3',
|
|
364
|
+
inputs: [
|
|
365
|
+
{ name: 'position', type: 'vec3' },
|
|
366
|
+
{ name: 'scale', type: 'float' },
|
|
367
|
+
{ name: 'xsmooth', type: 'float' },
|
|
368
|
+
{ name: 'wave', type: 'float' },
|
|
369
|
+
{ name: 'speed', type: 'float' },
|
|
370
|
+
{ name: 'time', type: 'float' },
|
|
371
|
+
/*{ name: 'color', type: 'vec3' },*/
|
|
372
|
+
/*{ name: 'background', type: 'vec3' },*/
|
|
373
|
+
{ name: 'seed', type: 'float' },
|
|
374
|
+
] }
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
function brain( params={} ) {
|
|
380
|
+
|
|
381
|
+
var { position, scale, smooth, /*wave, speed, time,*/ color, background, seed } = { ...defaults$P, ...params };
|
|
382
|
+
|
|
383
|
+
return brainRaw( position, scale, smooth, /*wave, speed, time,*/ color, background, seed );
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
brain.normal = function ( params={} ) {
|
|
390
|
+
|
|
391
|
+
var { position, scale, smooth, wave, speed, time, /*color, background,*/ seed } = { ...defaults$P, ...params };
|
|
392
|
+
|
|
393
|
+
return brainNormalRaw( position, scale, smooth, wave, speed, time, /*color, background,*/ seed );
|
|
394
|
+
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
brain.defaults = defaults$P;
|
|
400
|
+
|
|
401
|
+
var defaults$O = {
|
|
402
|
+
$name: 'Camouflage',
|
|
403
|
+
|
|
404
|
+
position: tsl.positionGeometry,
|
|
405
|
+
scale: 2,
|
|
406
|
+
|
|
407
|
+
colorA: new three.Color( 0xc2bea8 ),
|
|
408
|
+
colorB: new three.Color( 0x9c895e ),
|
|
409
|
+
colorC: new three.Color( 0x92a375 ),
|
|
410
|
+
colorD: new three.Color( 0x717561 ),
|
|
411
|
+
|
|
412
|
+
seed: 0,
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
var camouflageRaw = tsl.Fn( ([ position, scale, colorA, colorB, colorC, colorD, seed ])=>{
|
|
418
|
+
|
|
419
|
+
var pos = position.mul( scale.exp( ) ).add( seed ).toVar( 'pos' );
|
|
420
|
+
|
|
421
|
+
var color = colorD.toVar( 'color' );
|
|
422
|
+
|
|
423
|
+
tsl.If( tsl.mx_noise_float( pos ).greaterThanEqual( 0.3 ), () => {
|
|
424
|
+
|
|
425
|
+
color.assign( colorA );
|
|
426
|
+
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
.ElseIf( tsl.mx_noise_float( pos.yzx ).greaterThanEqual( 0.2 ), () => {
|
|
430
|
+
|
|
431
|
+
color.assign( colorB );
|
|
432
|
+
|
|
433
|
+
}
|
|
434
|
+
)
|
|
435
|
+
.ElseIf( tsl.mx_noise_float( pos.zxy ).greaterThanEqual( 0.1 ), () => {
|
|
436
|
+
|
|
437
|
+
color.assign( colorC );
|
|
438
|
+
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
return color;
|
|
443
|
+
|
|
444
|
+
} ).setLayout( {
|
|
445
|
+
name: 'camouflageRaw',
|
|
446
|
+
type: 'vec3',
|
|
447
|
+
inputs: [
|
|
448
|
+
{ name: 'position', type: 'vec3' },
|
|
449
|
+
{ name: 'scale', type: 'float' },
|
|
450
|
+
{ name: 'colorA', type: 'vec3' },
|
|
451
|
+
{ name: 'colorB', type: 'vec3' },
|
|
452
|
+
{ name: 'colorC', type: 'vec3' },
|
|
453
|
+
{ name: 'colorD', type: 'vec3' },
|
|
454
|
+
{ name: 'seed', type: 'float' },
|
|
455
|
+
] }
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
function camouflage( params={} ) {
|
|
461
|
+
|
|
462
|
+
var { position, scale, colorA, colorB, colorC, colorD, seed } = { ...defaults$O, ...params };
|
|
463
|
+
|
|
464
|
+
return camouflageRaw( position, scale, colorA, colorB, colorC, colorD, seed );
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
camouflage.defaults = defaults$O;
|
|
471
|
+
|
|
472
|
+
var defaults$N = {
|
|
473
|
+
$name: 'Cave art',
|
|
474
|
+
|
|
475
|
+
position: tsl.positionGeometry,
|
|
476
|
+
scale: 2,
|
|
477
|
+
|
|
478
|
+
thinness: 2,
|
|
479
|
+
noise: 0.3,
|
|
480
|
+
|
|
481
|
+
color: new three.Color( 0xD34545 ),
|
|
482
|
+
background: new three.Color( 0xFFF8F0 ),
|
|
483
|
+
|
|
484
|
+
seed: 0,
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
var caveArtRaw = tsl.Fn( ([ position, scale, thinness, xnoise, color, background, seed ]) => {
|
|
490
|
+
|
|
491
|
+
var pos = position.mul( scale.exp( ) ).add( seed ).toVar( 'pos' );
|
|
492
|
+
|
|
493
|
+
thinness = tsl.float( 3 ).sub( thinness ).exp( );
|
|
494
|
+
|
|
495
|
+
var k1 = tsl.mx_noise_float( pos, 4 ).sin().toVar( 'k1' ),
|
|
496
|
+
k2 = tsl.mx_noise_float( pos.mul( 1.5 ), 4 ).cos().toVar( 'k2' ),
|
|
497
|
+
k = thinness.sub( k1.add( k2 ).abs( ).pow2( ).mul( 20 ) ).toVar( 'k' );
|
|
498
|
+
|
|
499
|
+
tsl.If( tsl.or( k1.greaterThan( k2 ), k.lessThan( 0 ) ), ()=>{
|
|
500
|
+
|
|
501
|
+
k.assign( 0 );
|
|
502
|
+
|
|
503
|
+
} );
|
|
504
|
+
|
|
505
|
+
tsl.If( k.lessThanEqual( 0 ), ()=>{
|
|
506
|
+
|
|
507
|
+
k.assign( xnoise.mul( tsl.mx_noise_float( pos.mul( 30 ) ).pow2( ) ) );
|
|
508
|
+
|
|
509
|
+
} );
|
|
510
|
+
|
|
511
|
+
return tsl.mix( background, color, k );
|
|
512
|
+
|
|
513
|
+
} ).setLayout( {
|
|
514
|
+
name: 'caveArtRaw',
|
|
515
|
+
type: 'vec3',
|
|
516
|
+
inputs: [
|
|
517
|
+
{ name: 'position', type: 'vec3' },
|
|
518
|
+
{ name: 'scale', type: 'float' },
|
|
519
|
+
{ name: 'thinness', type: 'float' },
|
|
520
|
+
{ name: 'xnoise', type: 'float' },
|
|
521
|
+
{ name: 'color', type: 'vec3' },
|
|
522
|
+
{ name: 'background', type: 'vec3' },
|
|
523
|
+
{ name: 'seed', type: 'float' },
|
|
524
|
+
] }
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
function caveArt( params={} ) {
|
|
530
|
+
|
|
531
|
+
var { position, scale, thinness, noise, color, background, seed } = { ...defaults$N, ...params };
|
|
532
|
+
|
|
533
|
+
return caveArtRaw( position, scale, thinness, noise, color, background, seed );
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
caveArt.defaults = defaults$N;
|
|
540
|
+
|
|
541
|
+
var defaults$M = {
|
|
542
|
+
$name: 'Circles',
|
|
543
|
+
|
|
544
|
+
position: tsl.positionGeometry,
|
|
545
|
+
|
|
546
|
+
scale: 2,
|
|
547
|
+
variety: 1,
|
|
548
|
+
|
|
549
|
+
color: new three.Color( 0xF0E0D0 ),
|
|
550
|
+
|
|
551
|
+
seed: 0,
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
var circlesRaw = tsl.Fn( ([ position, scale, variety, color, seed ]) => {
|
|
557
|
+
|
|
558
|
+
var pos = position.toVar();
|
|
559
|
+
|
|
560
|
+
var angle = tsl.acos( tsl.clamp( pos.y, -1, 1 ) ).mul( 20 );
|
|
561
|
+
|
|
562
|
+
var x = angle.div( 3000 ).mul( tsl.exp( scale.sub( 1 ) ) );
|
|
563
|
+
|
|
564
|
+
var k = seed.sin().mul( 100 ).toVar();
|
|
565
|
+
|
|
566
|
+
for ( var n=0; n<=10; n++ ) {
|
|
567
|
+
|
|
568
|
+
k.addAssign( tsl.sin( x.mul( 2**n ).sub( Math.PI*n/2 ) ).mul( -n*( n+1 )/2 ) );
|
|
569
|
+
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
k.assign( k.div( 200 ).clamp( -2, 2 ) );
|
|
573
|
+
|
|
574
|
+
var HSL = toHsl( color );
|
|
575
|
+
|
|
576
|
+
var hue = HSL.x.add( k.mul( variety ) ).mod( 1 ).mul( 10 );
|
|
577
|
+
|
|
578
|
+
var huei = hue.floor();
|
|
579
|
+
var huef = hue.sub( huei );
|
|
580
|
+
huef = tsl.select( huef.lessThan( 0.5 ), huef.pow( 1.5 ), huef.pow( 1/1.5 ) );
|
|
581
|
+
|
|
582
|
+
return hsl( tsl.vec3( huei.add( huef ).div( 10 ), HSL.yz ) );
|
|
583
|
+
|
|
584
|
+
} ).setLayout( {
|
|
585
|
+
name: 'circlesRaw',
|
|
586
|
+
type: 'vec3',
|
|
587
|
+
inputs: [
|
|
588
|
+
{ name: 'position', type: 'vec3' },
|
|
589
|
+
{ name: 'scale', type: 'float' },
|
|
590
|
+
{ name: 'variety', type: 'float' },
|
|
591
|
+
{ name: 'color', type: 'vec3' },
|
|
592
|
+
{ name: 'seed', type: 'float' },
|
|
593
|
+
] }
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
function circles( params={} ) {
|
|
599
|
+
|
|
600
|
+
var { position, scale, variety, color, seed } = { ...defaults$M, ...params };
|
|
601
|
+
|
|
602
|
+
return circlesRaw( position, scale, variety, color, seed );
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
circles.defaults = defaults$M;
|
|
609
|
+
|
|
610
|
+
var defaults$L = {
|
|
611
|
+
$name: 'Clouds',
|
|
612
|
+
|
|
613
|
+
position: tsl.positionGeometry,
|
|
614
|
+
scale: 2,
|
|
615
|
+
density: 0.5,
|
|
616
|
+
opacity: 1,
|
|
617
|
+
|
|
618
|
+
color: new three.Color( 0xFFFFFF ),
|
|
619
|
+
subcolor: new three.Color( 0xA0A0B0 ),
|
|
620
|
+
|
|
621
|
+
seed: 0,
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
var cloud_core = tsl.Fn( ([ position, scale, density, seed ]) => {
|
|
627
|
+
|
|
628
|
+
const pos = position.mul( tsl.exp( scale.div( 1.5 ).sub( 0.5 ) ) ).add( seed ).toVar( 'pos' );
|
|
629
|
+
|
|
630
|
+
return tsl.mx_fractal_noise_float( pos, 4 ).add( density.remap( 0, 1, -0.5, 1.5 ) );
|
|
631
|
+
|
|
632
|
+
} ).setLayout( {
|
|
633
|
+
name: 'cloud_core',
|
|
634
|
+
type: 'float',
|
|
635
|
+
inputs: [
|
|
636
|
+
{ name: 'position', type: 'vec3' },
|
|
637
|
+
{ name: 'scale', type: 'float' },
|
|
638
|
+
{ name: 'density', type: 'float' },
|
|
639
|
+
{ name: 'seed', type: 'float' },
|
|
640
|
+
] }
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
var cloudsRaw = tsl.Fn( ([ position, scale, density, /*opacity,*/color, subcolor, seed ]) => {
|
|
646
|
+
|
|
647
|
+
var k = cloud_core( position, scale, density, seed );
|
|
648
|
+
return tsl.mix( subcolor, color, k.clamp( 0, 1 ) );
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
} ).setLayout( {
|
|
652
|
+
name: 'cloudsRaw',
|
|
653
|
+
type: 'vec3',
|
|
654
|
+
inputs: [
|
|
655
|
+
{ name: 'position', type: 'vec3' },
|
|
656
|
+
{ name: 'scale', type: 'float' },
|
|
657
|
+
{ name: 'density', type: 'float' },
|
|
658
|
+
/*{ name: 'opacity', type: 'float' },*/
|
|
659
|
+
{ name: 'color', type: 'vec3' },
|
|
660
|
+
{ name: 'subcolor', type: 'vec3' },
|
|
661
|
+
{ name: 'seed', type: 'float' },
|
|
662
|
+
] }
|
|
663
|
+
);
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
var cloudsOpacityRaw = tsl.Fn( ([ position, scale, density, opacity, /*color,subcolor,*/seed ]) => {
|
|
668
|
+
|
|
669
|
+
var k = cloud_core( position, scale, density, seed );
|
|
670
|
+
return tsl.clamp( 0, 1, tsl.mul( k, 2 ).pow( 1.5 ).sub( 1 ).mul( opacity ) );
|
|
671
|
+
|
|
672
|
+
} ).setLayout( {
|
|
673
|
+
name: 'cloudsOpacityRaw',
|
|
674
|
+
type: 'float',
|
|
675
|
+
inputs: [
|
|
676
|
+
{ name: 'position', type: 'vec3' },
|
|
677
|
+
{ name: 'scale', type: 'float' },
|
|
678
|
+
{ name: 'density', type: 'float' },
|
|
679
|
+
{ name: 'opacity', type: 'float' },
|
|
680
|
+
/*{ name: 'color', type: 'vec3' },*/
|
|
681
|
+
/*{ name: 'subcolor', type: 'vec3' },*/
|
|
682
|
+
{ name: 'seed', type: 'float' },
|
|
683
|
+
] }
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
function clouds( params={} ) {
|
|
689
|
+
|
|
690
|
+
var { position, scale, density, /*opacity,*/color, subcolor, seed } = { ...defaults$L, ...params };
|
|
691
|
+
|
|
692
|
+
return cloudsRaw( position, scale, density, /*opacity,*/color, subcolor, seed );
|
|
693
|
+
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
clouds.opacity = function ( params={} ) {
|
|
699
|
+
|
|
700
|
+
var { position, scale, density, opacity, /*color,subcolor,*/seed } = { ...defaults$L, ...params };
|
|
701
|
+
|
|
702
|
+
return cloudsOpacityRaw( position, scale, density, opacity, /*color,subcolor,*/seed );
|
|
703
|
+
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
clouds.defaults = defaults$L;
|
|
709
|
+
|
|
710
|
+
var defaults$K = {
|
|
711
|
+
$name: 'Concrete',
|
|
712
|
+
$normalNode: true,
|
|
713
|
+
|
|
714
|
+
position: tsl.positionGeometry,
|
|
715
|
+
|
|
716
|
+
scale: 2,
|
|
717
|
+
density: 0.5,
|
|
718
|
+
bump: 0.5,
|
|
719
|
+
|
|
720
|
+
seed: 0,
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
var surfacePos$7 = tsl.Fn( ([ position, normal, density ]) => {
|
|
726
|
+
|
|
727
|
+
var k = tsl.mx_noise_float( position, 0.5, 0.5 ).abs().pow( density );
|
|
728
|
+
|
|
729
|
+
return position.add( normal.mul( k ) );
|
|
730
|
+
|
|
731
|
+
} ).setLayout( {
|
|
732
|
+
name: 'surfacePos',
|
|
733
|
+
type: 'vec3',
|
|
734
|
+
inputs: [
|
|
735
|
+
{ name: 'position', type: 'vec3' },
|
|
736
|
+
{ name: 'normal', type: 'vec3' },
|
|
737
|
+
{ name: 'density', type: 'float' },
|
|
738
|
+
] }
|
|
739
|
+
);
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
var concreteRaw = tsl.Fn( ([ position, normal, tangent, scale, density, bump, seed ]) => {
|
|
744
|
+
|
|
745
|
+
const EPS = 0.001;
|
|
746
|
+
|
|
747
|
+
var seed3d = tsl.vec3( 1, 2, 3 ).mul( seed ).sin().mul( 100 ).toVar( 'seed3d' );
|
|
748
|
+
|
|
749
|
+
var xposition = position.mul( tsl.exp( scale.div( 2 ).add( 2 ) ) ).add( seed3d ).toVar( 'xposition' ),
|
|
750
|
+
xnormal = normal.normalize().toVar( 'xnormal' ),
|
|
751
|
+
xtangent = tangent.normalize().mul( EPS ).toVar( 'xtangent' ),
|
|
752
|
+
xbitangent = tsl.cross( xnormal, xtangent ).normalize().mul( EPS ).toVar( 'xbitangent' );
|
|
753
|
+
|
|
754
|
+
var xdensity = tsl.remap( density, 0, 1, 10, 0.5 ).toVar( 'xdensity' );
|
|
755
|
+
|
|
756
|
+
xnormal.mulAssign( bump );
|
|
757
|
+
|
|
758
|
+
var pos = surfacePos$7( xposition, xnormal, xdensity ).toVar( 'pos' ),
|
|
759
|
+
posU = surfacePos$7( xposition.add( xtangent ), xnormal, xdensity ).toVar( 'posU' ),
|
|
760
|
+
posV = surfacePos$7( xposition.add( xbitangent ), xnormal, xdensity ).toVar( 'posV' );
|
|
761
|
+
|
|
762
|
+
return approximateNormal( pos, posU, posV );
|
|
763
|
+
|
|
764
|
+
} ).setLayout( {
|
|
765
|
+
name: 'concreteRaw',
|
|
766
|
+
type: 'vec3',
|
|
767
|
+
inputs: [
|
|
768
|
+
{ name: 'position', type: 'vec3' },
|
|
769
|
+
{ name: 'normal', type: 'vec3' },
|
|
770
|
+
{ name: 'tangent', type: 'vec3' },
|
|
771
|
+
{ name: 'scale', type: 'float' },
|
|
772
|
+
{ name: 'density', type: 'float' },
|
|
773
|
+
{ name: 'bump', type: 'float' },
|
|
774
|
+
{ name: 'seed', type: 'float' },
|
|
775
|
+
] }
|
|
776
|
+
);
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
function concrete( params={} ) {
|
|
781
|
+
|
|
782
|
+
var { position, scale, density, bump, seed } = { ...defaults$K, ...params };
|
|
783
|
+
|
|
784
|
+
return concreteRaw( position, tsl.normalLocal, tsl.tangentLocal, scale, density, bump, seed );
|
|
785
|
+
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
concrete.defaults = defaults$K;
|
|
791
|
+
|
|
792
|
+
var defaults$J = {
|
|
793
|
+
$name: 'Cork',
|
|
794
|
+
|
|
795
|
+
position: tsl.positionGeometry,
|
|
796
|
+
scale: 1,
|
|
797
|
+
straight: 1,
|
|
798
|
+
noise: 0.3,
|
|
799
|
+
|
|
800
|
+
color: new three.Color( 0xfff0c0 ),
|
|
801
|
+
background: new three.Color( 0xd08060 ),
|
|
802
|
+
|
|
803
|
+
seed: 0,
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
var corkRaw = tsl.Fn( ([ position, scale, straight, xnoise, color, background, seed ])=>{
|
|
809
|
+
|
|
810
|
+
var pos = position.mul( tsl.exp( scale.div( 1.5 ).add( 1 ) ) ).add( seed ).toVar( 'pos' );
|
|
811
|
+
|
|
812
|
+
var midCell = pos.round().toConst( 'midCell' );
|
|
813
|
+
|
|
814
|
+
var minCell = midCell.toVar( 'minCell' ),
|
|
815
|
+
minDist = tsl.float( 1 ).toVar( 'minDist' );
|
|
816
|
+
|
|
817
|
+
var cell = tsl.vec3().toVar( 'cell' ),
|
|
818
|
+
dist = tsl.float().toVar( 'dist' );
|
|
819
|
+
|
|
820
|
+
var strtaightness = straight.exp().reciprocal().toVar( 'strtaightness' );
|
|
821
|
+
|
|
822
|
+
var i=tsl.int( 0 ).toVar( 'i' ),
|
|
823
|
+
j=tsl.int( 0 ).toVar( 'j' ),
|
|
824
|
+
k=tsl.int( 0 ).toVar( 'k' );
|
|
825
|
+
|
|
826
|
+
// Loop uses hard-coded i, j, k as indices
|
|
827
|
+
tsl.Loop( 3, 3, 3, () => {
|
|
828
|
+
|
|
829
|
+
cell.assign( midCell.add( tsl.vec3( i, j, k ).sub( 1 ) ) );
|
|
830
|
+
var cellCenter = cell.add( vnoise( cell ) );
|
|
831
|
+
dist.assign( pos.distance( cellCenter ) );
|
|
832
|
+
|
|
833
|
+
dist.addAssign( tsl.mx_noise_float( pos.add( cell ), strtaightness ) );
|
|
834
|
+
|
|
835
|
+
tsl.If( dist.lessThan( minDist ), ()=>{
|
|
836
|
+
|
|
837
|
+
minDist.assign( dist );
|
|
838
|
+
minCell.assign( cell );
|
|
839
|
+
|
|
840
|
+
} );
|
|
841
|
+
|
|
842
|
+
} );
|
|
843
|
+
|
|
844
|
+
var n = tsl.mx_noise_float( minCell.mul( Math.PI ), 0.5, 0.5 ).toVar( 'n' );
|
|
845
|
+
|
|
846
|
+
var r = tsl.mx_noise_float( pos.mul( 12 ) ).toVar( 'r' );
|
|
847
|
+
r.mulAssign( r, r );
|
|
848
|
+
r.addAssign( tsl.mx_noise_float( pos.mul( 40 ), 1/3 ) );
|
|
849
|
+
|
|
850
|
+
var result = tsl.mix( color, background, n.add( r.mul( xnoise ) ) );
|
|
851
|
+
|
|
852
|
+
return result;
|
|
853
|
+
|
|
854
|
+
} ).setLayout( {
|
|
855
|
+
name: 'camouflageRaw',
|
|
856
|
+
type: 'vec3',
|
|
857
|
+
inputs: [
|
|
858
|
+
{ name: 'position', type: 'vec3' },
|
|
859
|
+
{ name: 'scale', type: 'float' },
|
|
860
|
+
{ name: 'straight', type: 'float' },
|
|
861
|
+
{ name: 'xnoise', type: 'float' },
|
|
862
|
+
{ name: 'color', type: 'vec3' },
|
|
863
|
+
{ name: 'background', type: 'vec3' },
|
|
864
|
+
{ name: 'seed', type: 'float' },
|
|
865
|
+
] }
|
|
866
|
+
);
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
function cork( params={} ) {
|
|
871
|
+
|
|
872
|
+
var { position, scale, straight, noise, color, background, seed } = { ...defaults$J, ...params };
|
|
873
|
+
|
|
874
|
+
return corkRaw( position, scale, straight, noise, color, background, seed );
|
|
875
|
+
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
cork.defaults = defaults$J;
|
|
881
|
+
|
|
882
|
+
var defaults$I = {
|
|
883
|
+
$name: 'Dalmatian spots',
|
|
884
|
+
$width: 260,
|
|
885
|
+
|
|
886
|
+
position: tsl.positionGeometry,
|
|
887
|
+
|
|
888
|
+
scale: 2,
|
|
889
|
+
density: 0.6,
|
|
890
|
+
|
|
891
|
+
color: new three.Color( 0xFFFFFF ),
|
|
892
|
+
background: new three.Color( 0x000000 ),
|
|
893
|
+
|
|
894
|
+
seed: 0,
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
var dalmatianSpotsRaw = tsl.Fn( ([ position, scale, density, color, background, seed ])=>{
|
|
900
|
+
|
|
901
|
+
var pos = position.mul( scale.exp( ) ).add( seed ).sub( 1000 ).toVar( 'pos' );
|
|
902
|
+
|
|
903
|
+
var k = tsl.float( 1 ).toVar( 'k' );
|
|
904
|
+
|
|
905
|
+
var d = tsl.float( 1.5 ).sub( density ).mul( 2 ).toVar( 'd' );
|
|
906
|
+
var count = density.mul( 5 ).add( 5 ).toVar( 'count' );
|
|
907
|
+
|
|
908
|
+
tsl.Loop( count, ()=> {
|
|
909
|
+
|
|
910
|
+
k.mulAssign( tsl.mx_noise_float( pos ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
|
|
911
|
+
pos.assign( pos.mul( 1.01 ) );
|
|
912
|
+
k.mulAssign( tsl.mx_noise_float( pos.yzx ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
|
|
913
|
+
pos.assign( pos.mul( 1.01 ) );
|
|
914
|
+
k.mulAssign( tsl.mx_noise_float( pos.zxy ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
|
|
915
|
+
pos.assign( pos.mul( 1.01 ) );
|
|
916
|
+
|
|
917
|
+
} );
|
|
918
|
+
|
|
919
|
+
return tsl.mix( background, color, k.clamp( 0, 1 ) );
|
|
920
|
+
|
|
921
|
+
} ).setLayout( {
|
|
922
|
+
name: 'dalmatianSpotsRaw',
|
|
923
|
+
type: 'vec3',
|
|
924
|
+
inputs: [
|
|
925
|
+
{ name: 'position', type: 'vec3' },
|
|
926
|
+
{ name: 'scale', type: 'float' },
|
|
927
|
+
{ name: 'density', type: 'float' },
|
|
928
|
+
{ name: 'color', type: 'vec3' },
|
|
929
|
+
{ name: 'background', type: 'vec3' },
|
|
930
|
+
{ name: 'seed', type: 'float' },
|
|
931
|
+
] }
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
function dalmatianSpots( params={} ) {
|
|
937
|
+
|
|
938
|
+
var { position, scale, density, color, background, seed } = { ...defaults$I, ...params };
|
|
939
|
+
|
|
940
|
+
return dalmatianSpotsRaw( position, scale, density, color, background, seed );
|
|
941
|
+
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
dalmatianSpots.defaults = defaults$I;
|
|
947
|
+
|
|
948
|
+
var defaults$H = {
|
|
949
|
+
$name: 'Darth Maul',
|
|
950
|
+
|
|
951
|
+
position: tsl.positionGeometry,
|
|
952
|
+
scale: 2,
|
|
953
|
+
shift: new three.Vector3( 0, 0, 0 ),
|
|
954
|
+
complexity: 0,
|
|
955
|
+
|
|
956
|
+
angle: 60,
|
|
957
|
+
distance: 1.9,
|
|
958
|
+
|
|
959
|
+
color: new three.Color( 0xF04040 ),
|
|
960
|
+
background: new three.Color( 0x000000 ),
|
|
961
|
+
balance: 0,
|
|
962
|
+
|
|
963
|
+
seed: 0,
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
var darthMaulRaw = tsl.Fn( ([ position, scale, shift, complexity, angle, distance, color, background, balance, seed ]) => {
|
|
969
|
+
|
|
970
|
+
var xposition = position.add( shift ).mul( tsl.exp( scale.div( 1.5 ).sub( 1 ) ) ).sub( shift ).mul( tsl.vec3( 1, 1/2, 1/2 ) ).toVar( );
|
|
971
|
+
|
|
972
|
+
var s = tsl.select( position.y.mul( angle.radians().cos() ).add( position.z.mul( angle.radians().sin() ) ).greaterThan( distance ), 1, 0 );
|
|
973
|
+
|
|
974
|
+
// implement symmetry
|
|
975
|
+
xposition.x.assign( xposition.x.add( shift.x ).abs() );
|
|
976
|
+
xposition.y.addAssign( seed );
|
|
977
|
+
xposition.z.mulAssign( shift.z );
|
|
978
|
+
|
|
979
|
+
var n = tsl.mx_noise_float( xposition ).toVar();
|
|
980
|
+
|
|
981
|
+
var k = n.sin().mul( n.mul( complexity.mul( 2 ).add( 1 ).exp() ).sin() ).remap( 0, 0.2, 1, -1 ).greaterThan( balance ).select( 0, 1 );
|
|
982
|
+
|
|
983
|
+
var c = tsl.select( xposition.x.greaterThan( tsl.mx_noise_float( xposition.mul( 2.3 ) ).abs().mul( 0.5 ).add( 0.02 ) ), 1, 0 );
|
|
984
|
+
|
|
985
|
+
return tsl.mix( background, color, k.mul( s ).mul( c ).clamp( 0, 1 ) );
|
|
986
|
+
|
|
987
|
+
} ).setLayout( {
|
|
988
|
+
name: 'darthMaulRaw',
|
|
989
|
+
type: 'vec3',
|
|
990
|
+
inputs: [
|
|
991
|
+
{ name: 'position', type: 'vec3' },
|
|
992
|
+
{ name: 'scale', type: 'float' },
|
|
993
|
+
{ name: 'shift', type: 'vec3' },
|
|
994
|
+
{ name: 'complexity', type: 'float' },
|
|
995
|
+
{ name: 'angle', type: 'float' },
|
|
996
|
+
{ name: 'distance', type: 'float' },
|
|
997
|
+
{ name: 'color', type: 'vec3' },
|
|
998
|
+
{ name: 'background', type: 'vec3' },
|
|
999
|
+
{ name: 'balance', type: 'float' },
|
|
1000
|
+
{ name: 'seed', type: 'float' },
|
|
1001
|
+
] }
|
|
1002
|
+
);
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
function darthMaul( params={} ) {
|
|
1007
|
+
|
|
1008
|
+
var { position, scale, shift, complexity, angle, distance, color, background, balance, seed } = { ...defaults$H, ...params };
|
|
1009
|
+
|
|
1010
|
+
return darthMaulRaw( position, scale, shift, complexity, angle, distance, color, background, balance, seed );
|
|
1011
|
+
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
darthMaul.defaults = defaults$H;
|
|
1017
|
+
|
|
1018
|
+
var defaults$G = {
|
|
1019
|
+
$name: 'Dyson sphere',
|
|
1020
|
+
|
|
1021
|
+
position: tsl.positionGeometry,
|
|
1022
|
+
scale: 2,
|
|
1023
|
+
complexity: 2,
|
|
1024
|
+
|
|
1025
|
+
variation: 0,
|
|
1026
|
+
|
|
1027
|
+
color: new three.Color( 0xc0d0ff ),
|
|
1028
|
+
background: new three.Color( 0 ),
|
|
1029
|
+
|
|
1030
|
+
seed: 0,
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
var noisea = tsl.Fn( ([ pos ])=>{
|
|
1036
|
+
|
|
1037
|
+
var p = pos.mul( 5**0.5 ).fract().toVar();
|
|
1038
|
+
p.addAssign( p.dot( p.add( tsl.vec3( 31.4159, 27.1828, 14.142 ) ) ) );
|
|
1039
|
+
return p.z.mul( p.x.add( p.y ) ).fract().mul( 2 ).sub( 1 );
|
|
1040
|
+
|
|
1041
|
+
} ).setLayout( {
|
|
1042
|
+
name: 'noisea',
|
|
1043
|
+
type: 'float',
|
|
1044
|
+
inputs: [
|
|
1045
|
+
{ name: 'pos', type: 'vec3' },
|
|
1046
|
+
] }
|
|
1047
|
+
);
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
var smoother = tsl.Fn( ([ x ])=>{
|
|
1052
|
+
|
|
1053
|
+
var t = x.oneMinus().clamp( 0, 1 ).toVar();
|
|
1054
|
+
return t.mul( t ).mul( tsl.float( 3 ).sub( t.mul( 2 ) ) );
|
|
1055
|
+
|
|
1056
|
+
} ).setLayout( {
|
|
1057
|
+
name: 'smoother',
|
|
1058
|
+
type: 'float',
|
|
1059
|
+
inputs: [
|
|
1060
|
+
{ name: 'x', type: 'float' },
|
|
1061
|
+
] }
|
|
1062
|
+
);
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
var noiseg = tsl.Fn( ([ pos ])=>{
|
|
1067
|
+
|
|
1068
|
+
var minx = pos.x.floor().toVar();
|
|
1069
|
+
var maxx = minx.add( 1 ).toVar();
|
|
1070
|
+
|
|
1071
|
+
var miny = pos.y.floor().toVar();
|
|
1072
|
+
var maxy = miny.add( 1 ).toVar();
|
|
1073
|
+
|
|
1074
|
+
var minz = pos.z.floor().toVar();
|
|
1075
|
+
var maxz = minz.add( 1 ).toVar();
|
|
1076
|
+
|
|
1077
|
+
var dx = smoother( pos.x.fract() ).toVar();
|
|
1078
|
+
var dy = smoother( pos.y.fract() ).toVar();
|
|
1079
|
+
var dz = smoother( pos.z.fract() ).toVar();
|
|
1080
|
+
|
|
1081
|
+
var mx = smoother( dx.oneMinus() ).toVar();
|
|
1082
|
+
var my = smoother( dy.oneMinus() ).toVar();
|
|
1083
|
+
var mz = smoother( dz.oneMinus() ).toVar();
|
|
1084
|
+
|
|
1085
|
+
var n000 = noisea( tsl.vec3( minx, miny, minz ) ).mul( mx ).mul( my ).mul( mz ).toVar();
|
|
1086
|
+
var n001 = noisea( tsl.vec3( minx, miny, maxz ) ).mul( mx ).mul( my ).mul( dz ).toVar();
|
|
1087
|
+
var n010 = noisea( tsl.vec3( minx, maxy, minz ) ).mul( mx ).mul( dy ).mul( mz ).toVar();
|
|
1088
|
+
var n011 = noisea( tsl.vec3( minx, maxy, maxz ) ).mul( mx ).mul( dy ).mul( dz ).toVar();
|
|
1089
|
+
var n100 = noisea( tsl.vec3( maxx, miny, minz ) ).mul( dx ).mul( my ).mul( mz ).toVar();
|
|
1090
|
+
var n101 = noisea( tsl.vec3( maxx, miny, maxz ) ).mul( dx ).mul( my ).mul( dz ).toVar();
|
|
1091
|
+
var n110 = noisea( tsl.vec3( maxx, maxy, minz ) ).mul( dx ).mul( dy ).mul( mz ).toVar();
|
|
1092
|
+
var n111 = noisea( tsl.vec3( maxx, maxy, maxz ) ).mul( dx ).mul( dy ).mul( dz ).toVar();
|
|
1093
|
+
|
|
1094
|
+
return n000.add( n001 ).add( n010 ).add( n011 ).add( n100 ).add( n101 ).add( n110 ).add( n111 );
|
|
1095
|
+
|
|
1096
|
+
} ).setLayout( {
|
|
1097
|
+
name: 'noiseg',
|
|
1098
|
+
type: 'float',
|
|
1099
|
+
inputs: [
|
|
1100
|
+
{ name: 'pos', type: 'vec3' },
|
|
1101
|
+
] }
|
|
1102
|
+
);
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
var dysonSphereRaw = tsl.Fn( ([ position, scale, complexity, color, background, seed ])=>{
|
|
1107
|
+
|
|
1108
|
+
var pos = position.mul( tsl.exp( scale.div( 2 ).add( 0.5 ) ) ).add( seed ).toVar( );
|
|
1109
|
+
|
|
1110
|
+
var res = tsl.vec3().toVar();
|
|
1111
|
+
var factor = tsl.float( 1 ).toVar();
|
|
1112
|
+
|
|
1113
|
+
tsl.Loop( complexity.add( 4 ), ()=>{
|
|
1114
|
+
|
|
1115
|
+
res.addAssign( noiseg( pos.mul( factor ) ) );
|
|
1116
|
+
factor.addAssign( factor );
|
|
1117
|
+
|
|
1118
|
+
} );
|
|
1119
|
+
|
|
1120
|
+
return tsl.mix( background, color, res.x.add( 1 ).div( 5 ) );
|
|
1121
|
+
|
|
1122
|
+
} ).setLayout( {
|
|
1123
|
+
name: 'dysonSphereRaw',
|
|
1124
|
+
type: 'vec3',
|
|
1125
|
+
inputs: [
|
|
1126
|
+
{ name: 'position', type: 'vec3' },
|
|
1127
|
+
{ name: 'scale', type: 'float' },
|
|
1128
|
+
{ name: 'complexity', type: 'float' },
|
|
1129
|
+
{ name: 'color', type: 'vec3' },
|
|
1130
|
+
{ name: 'background', type: 'vec3' },
|
|
1131
|
+
{ name: 'seed', type: 'float' },
|
|
1132
|
+
] }
|
|
1133
|
+
);
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
function dysonSphere( params={} ) {
|
|
1138
|
+
|
|
1139
|
+
var { position, scale, complexity, color, background, seed } = { ...defaults$G, ...params };
|
|
1140
|
+
|
|
1141
|
+
return dysonSphereRaw( position, scale, complexity, color, background, seed );
|
|
1142
|
+
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
dysonSphere.defaults = defaults$G;
|
|
1148
|
+
|
|
1149
|
+
var defaults$F = {
|
|
1150
|
+
$name: 'Entangled',
|
|
1151
|
+
|
|
1152
|
+
position: tsl.positionGeometry,
|
|
1153
|
+
scale: 2,
|
|
1154
|
+
density: 10,
|
|
1155
|
+
|
|
1156
|
+
color: new three.Color( 0x002040 ),
|
|
1157
|
+
background: new three.Color( 0xFFFFFF ),
|
|
1158
|
+
|
|
1159
|
+
seed: 0,
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
var entangledRaw = tsl.Fn( ([ position, scale, density, color, background, seed ]) => {
|
|
1165
|
+
|
|
1166
|
+
var xscale = tsl.exp( scale.div( 2 ) ).toVar( );
|
|
1167
|
+
var pos = position.add( seed ).toVar( );
|
|
1168
|
+
var k = tsl.float( -1e4 ).toVar( );
|
|
1169
|
+
var k1 = tsl.float( 0 ).toVar( );
|
|
1170
|
+
|
|
1171
|
+
tsl.Loop( density, ()=> {
|
|
1172
|
+
|
|
1173
|
+
k1.assign( tsl.sin( tsl.mx_noise_float( tsl.mul( pos, xscale ) ).mul( 3*Math.PI ) ) );
|
|
1174
|
+
k.assign( tsl.max( k, k1 ) );
|
|
1175
|
+
xscale.mulAssign( 1.2 );
|
|
1176
|
+
|
|
1177
|
+
} );
|
|
1178
|
+
|
|
1179
|
+
k.assign( tsl.oneMinus( tsl.pow( tsl.abs( k ), 5 ) ).mul( 6 ) );
|
|
1180
|
+
|
|
1181
|
+
return tsl.mix( color, background, k );
|
|
1182
|
+
|
|
1183
|
+
} ).setLayout( {
|
|
1184
|
+
name: 'entangled',
|
|
1185
|
+
type: 'vec3',
|
|
1186
|
+
inputs: [
|
|
1187
|
+
{ name: 'position', type: 'vec3' },
|
|
1188
|
+
{ name: 'scale', type: 'float' },
|
|
1189
|
+
{ name: 'density', type: 'int' },
|
|
1190
|
+
{ name: 'color', type: 'vec3' },
|
|
1191
|
+
{ name: 'background', type: 'vec3' },
|
|
1192
|
+
{ name: 'seed', type: 'float' },
|
|
1193
|
+
] }
|
|
1194
|
+
);
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
function entangled( params={} ) {
|
|
1199
|
+
|
|
1200
|
+
var { position, scale, density, color, background, seed } = { ...defaults$F, ...params };
|
|
1201
|
+
|
|
1202
|
+
return entangledRaw( position, scale, density, color, background, seed );
|
|
1203
|
+
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
entangled.defaults = defaults$F;
|
|
1209
|
+
|
|
1210
|
+
var defaults$E = {
|
|
1211
|
+
$name: 'Fordite',
|
|
1212
|
+
|
|
1213
|
+
position: tsl.positionGeometry,
|
|
1214
|
+
scale: 2,
|
|
1215
|
+
color: new three.Color( 0, 0, 0 ),
|
|
1216
|
+
|
|
1217
|
+
seed: 0,
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
var forditeRaw = tsl.Fn( ([ position, scale, color, seed ]) => {
|
|
1223
|
+
|
|
1224
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed ).toVar( );
|
|
1225
|
+
|
|
1226
|
+
var k = tsl.mx_noise_float(
|
|
1227
|
+
tsl.vec3(
|
|
1228
|
+
tsl.mx_noise_float( pos, 1 ),
|
|
1229
|
+
tsl.mx_noise_float( pos, 2 ),
|
|
1230
|
+
tsl.mx_noise_float( pos, 3 ),
|
|
1231
|
+
)
|
|
1232
|
+
).toVar( );
|
|
1233
|
+
|
|
1234
|
+
return hsl( tsl.vec3(
|
|
1235
|
+
k,
|
|
1236
|
+
1,
|
|
1237
|
+
tsl.sin( tsl.mul( k, Math.PI, 4 ) ).mul( 0.5 ).add( 0.5 )
|
|
1238
|
+
) ).add( color );
|
|
1239
|
+
|
|
1240
|
+
} ).setLayout( {
|
|
1241
|
+
name: 'forditeRaw',
|
|
1242
|
+
type: 'vec3',
|
|
1243
|
+
inputs: [
|
|
1244
|
+
{ name: 'position', type: 'vec3' },
|
|
1245
|
+
{ name: 'scale', type: 'float' },
|
|
1246
|
+
{ name: 'color', type: 'vec3' },
|
|
1247
|
+
{ name: 'seed', type: 'float' },
|
|
1248
|
+
] }
|
|
1249
|
+
);
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
function fordite( params={} ) {
|
|
1254
|
+
|
|
1255
|
+
var { position, scale, color, seed } = { ...defaults$E, ...params };
|
|
1256
|
+
|
|
1257
|
+
return forditeRaw( position, scale, color, seed );
|
|
1258
|
+
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
fordite.defaults = defaults$E;
|
|
1264
|
+
|
|
1265
|
+
var defaults$D = {
|
|
1266
|
+
$name: 'Gas giant',
|
|
1267
|
+
|
|
1268
|
+
position: tsl.positionGeometry,
|
|
1269
|
+
scale: 2,
|
|
1270
|
+
turbulence: 0.3,
|
|
1271
|
+
blur: 0.6,
|
|
1272
|
+
|
|
1273
|
+
colorA: new three.Color( 0xFFF8F0 ),
|
|
1274
|
+
colorB: new three.Color( 0xF0E8B0 ),
|
|
1275
|
+
colorC: new three.Color( 0xAFA0D0 ),
|
|
1276
|
+
|
|
1277
|
+
seed: 0,
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
var gasGiantRaw = tsl.Fn( ([ position, scale, turbulence, blur, colorA, colorB, colorC, seed ])=>{
|
|
1283
|
+
|
|
1284
|
+
var xscale = scale.div( 2 ).add( 1 ).toVar();
|
|
1285
|
+
var pos = position.mul( tsl.exp( xscale ) ).add( seed ).toVar( );
|
|
1286
|
+
|
|
1287
|
+
// turbulence strength
|
|
1288
|
+
var xturbulence = turbulence.mul(
|
|
1289
|
+
tsl.mx_noise_float( tsl.vec3( 0, pos.y.mul( 0.5 ), 0 ).add( 1 ) ).add(
|
|
1290
|
+
tsl.mx_noise_float( tsl.vec3( 0, pos.y.mul( 1 ), 0 ).add( 1 ) ).mul( 0.5 ),
|
|
1291
|
+
tsl.mx_noise_float( tsl.vec3( 1, pos.y.mul( 2 ), 1 ).add( 1 ) ).mul( 0.25 )
|
|
1292
|
+
)
|
|
1293
|
+
).mul( 5 ).abs().toVar();
|
|
1294
|
+
|
|
1295
|
+
var spot = tsl.mx_noise_float( pos.div( 4 ) ).add( 1 ).div( 2 ).pow( 10 ).mul( 10 ).smoothstep( 0, 1 );
|
|
1296
|
+
|
|
1297
|
+
// apply turbulence
|
|
1298
|
+
pos.addAssign( tsl.vec3( tsl.mx_noise_float( pos ), tsl.mx_noise_float( pos.yxz ), tsl.mx_noise_float( pos.yzx ) ).mul( xturbulence.mul( spot.mul( 2 ).exp() ) ) );
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
var xblur = blur.pow( 0.2 ).oneMinus().mul( xturbulence.add( 1 ) ).toVar();
|
|
1302
|
+
|
|
1303
|
+
var k = tsl.mx_noise_float( pos.mul( tsl.vec3( 0, xscale, 0 ) ) );
|
|
1304
|
+
k = k.add( tsl.mx_noise_float( pos.mul( tsl.vec3( 1, 15, 1 ) ) ).mul( xblur ) );
|
|
1305
|
+
k = k.add( -0.5 ).smoothstep( -1, 1 ).oneMinus();
|
|
1306
|
+
|
|
1307
|
+
var n = tsl.mx_noise_float( tsl.vec3( 0, pos.y.mul( 0.75 ), 0 ) ).add( 1 );
|
|
1308
|
+
|
|
1309
|
+
var HSL = toHsl( tsl.mix( colorB, colorA, n ) );
|
|
1310
|
+
var color = hsl( tsl.vec3( HSL.x.add( tsl.mx_noise_float( pos.mul( tsl.vec3( 0, xscale, 0 ) ) ).div( 4 ) ), HSL.yz ) ).toVar();
|
|
1311
|
+
|
|
1312
|
+
color.assign( tsl.mix( color, colorC, xturbulence.mul( 0.3 ) ) );
|
|
1313
|
+
|
|
1314
|
+
return color.mul( k );
|
|
1315
|
+
|
|
1316
|
+
} ).setLayout( {
|
|
1317
|
+
name: 'gasGiantRaw',
|
|
1318
|
+
type: 'vec3',
|
|
1319
|
+
inputs: [
|
|
1320
|
+
{ name: 'position', type: 'vec3' },
|
|
1321
|
+
{ name: 'scale', type: 'float' },
|
|
1322
|
+
{ name: 'turbulence', type: 'float' },
|
|
1323
|
+
{ name: 'blur', type: 'float' },
|
|
1324
|
+
{ name: 'colorA', type: 'vec3' },
|
|
1325
|
+
{ name: 'colorB', type: 'vec3' },
|
|
1326
|
+
{ name: 'colorC', type: 'vec3' },
|
|
1327
|
+
{ name: 'seed', type: 'float' },
|
|
1328
|
+
] }
|
|
1329
|
+
);
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
function gasGiant( params={} ) {
|
|
1334
|
+
|
|
1335
|
+
var { position, scale, turbulence, blur, colorA, colorB, colorC, seed } = { ...defaults$D, ...params };
|
|
1336
|
+
|
|
1337
|
+
return gasGiantRaw( position, scale, turbulence, blur, colorA, colorB, colorC, seed );
|
|
1338
|
+
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
gasGiant.defaults = defaults$D;
|
|
1344
|
+
|
|
1345
|
+
var defaults$C = {
|
|
1346
|
+
$name: 'Grid',
|
|
1347
|
+
$replaceExportUVS: tsl.screenUV,
|
|
1348
|
+
$replaceExportASP: tsl.screenSize.x.div( tsl.screenSize.y ).log2(),
|
|
1349
|
+
|
|
1350
|
+
uvs: tsl.equirectUV( tsl.positionGeometry.normalize() ),
|
|
1351
|
+
|
|
1352
|
+
countU: 32,
|
|
1353
|
+
countV: 16,
|
|
1354
|
+
|
|
1355
|
+
aspect: 1,
|
|
1356
|
+
thinness: 0.8,
|
|
1357
|
+
equirectangular: true,
|
|
1358
|
+
|
|
1359
|
+
color: new three.Color( 0x000000 ),
|
|
1360
|
+
background: new three.Color( 0xFFFFFF ),
|
|
1361
|
+
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
var gridRaw = tsl.Fn( ([ uvs, countU, countV, aspect, thinness, equirectangular, color, background ]) => {
|
|
1367
|
+
|
|
1368
|
+
var xaspect = tsl.max( tsl.exp2( aspect ), 1 );
|
|
1369
|
+
|
|
1370
|
+
var a = tsl.mul( uvs.x, xaspect, Math.PI ).toVar(),
|
|
1371
|
+
b = tsl.mul( uvs.y, Math.PI ).toVar();
|
|
1372
|
+
|
|
1373
|
+
var uTo = tsl.div( tsl.round( tsl.mul( uvs.x, countU ) ), countU ),
|
|
1374
|
+
vTo = tsl.div( tsl.round( tsl.mul( uvs.y, countV ) ), countV ),
|
|
1375
|
+
aTo = tsl.mul( uTo, xaspect, Math.PI ),
|
|
1376
|
+
bTo = tsl.mul( vTo, Math.PI );
|
|
1377
|
+
|
|
1378
|
+
var angleU = tsl.abs( tsl.sub( a, aTo ) ).mul( tsl.mix( 1, tsl.sin( b ), equirectangular ) ),
|
|
1379
|
+
angleV = tsl.abs( tsl.sub( b, bTo ) ),
|
|
1380
|
+
angle = tsl.min( angleU, angleV );
|
|
1381
|
+
|
|
1382
|
+
var treshold = tsl.mul( tsl.min( tsl.div( xaspect.mul( Math.PI ), countU ), tsl.div( Math.PI, countV ) ), tsl.remapClamp( tsl.pow( thinness, 0.5 ), 0, 1, 0.9, 0.04 ), 0.5 );
|
|
1383
|
+
var k = tsl.oneMinus( tsl.smoothstep( tsl.sub( treshold, 0.002 ), tsl.add( treshold, 0.002 ), angle ) );
|
|
1384
|
+
|
|
1385
|
+
return tsl.mix( background, color, k );
|
|
1386
|
+
|
|
1387
|
+
} ).setLayout( {
|
|
1388
|
+
name: 'gridRaw',
|
|
1389
|
+
type: 'vec3',
|
|
1390
|
+
inputs: [
|
|
1391
|
+
{ name: 'uvs', type: 'vec2' },
|
|
1392
|
+
{ name: 'countU', type: 'float' },
|
|
1393
|
+
{ name: 'countV', type: 'float' },
|
|
1394
|
+
{ name: 'aspect', type: 'float' },
|
|
1395
|
+
{ name: 'thinness', type: 'float' },
|
|
1396
|
+
{ name: 'equirectangular', type: 'int' },
|
|
1397
|
+
{ name: 'color', type: 'vec3' },
|
|
1398
|
+
{ name: 'background', type: 'vec3' },
|
|
1399
|
+
] }
|
|
1400
|
+
);
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
function grid( params={} ) {
|
|
1405
|
+
|
|
1406
|
+
var { uvs, countU, countV, aspect, thinness, equirectangular, color, background } = { ...defaults$C, ...params };
|
|
1407
|
+
|
|
1408
|
+
return gridRaw( uvs, countU, countV, aspect, thinness, equirectangular, color, background );
|
|
1409
|
+
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
grid.defaults = defaults$C;
|
|
1415
|
+
|
|
1416
|
+
var defaults$B = {
|
|
1417
|
+
$name: 'Isolines',
|
|
1418
|
+
|
|
1419
|
+
position: tsl.positionGeometry,
|
|
1420
|
+
scale: 2,
|
|
1421
|
+
density: 40,
|
|
1422
|
+
blur: 0.3,
|
|
1423
|
+
thinness: 0.6,
|
|
1424
|
+
|
|
1425
|
+
color: new three.Color( 0xFFFFFF ),
|
|
1426
|
+
background: new three.Color( 0x000000 ),
|
|
1427
|
+
|
|
1428
|
+
seed: 0,
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
var isolinesRaw = tsl.Fn( ([ position, scale, density, blur, thinness, color, background, seed ])=>{
|
|
1434
|
+
|
|
1435
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed ).toVar( );
|
|
1436
|
+
|
|
1437
|
+
var k = tsl.mx_noise_float( pos, density );
|
|
1438
|
+
|
|
1439
|
+
k = tsl.oneMinus( tsl.sin( k ) ).div( 2 );
|
|
1440
|
+
|
|
1441
|
+
k = tsl.smoothstep( tsl.sub( thinness, blur ), tsl.add( thinness, blur ), k );
|
|
1442
|
+
|
|
1443
|
+
return tsl.mix( color, background, k );
|
|
1444
|
+
|
|
1445
|
+
} ).setLayout( {
|
|
1446
|
+
name: 'isolinesRaw',
|
|
1447
|
+
type: 'vec3',
|
|
1448
|
+
inputs: [
|
|
1449
|
+
{ name: 'position', type: 'vec3' },
|
|
1450
|
+
{ name: 'scale', type: 'float' },
|
|
1451
|
+
{ name: 'density', type: 'float' },
|
|
1452
|
+
{ name: 'blur', type: 'float' },
|
|
1453
|
+
{ name: 'thinness', type: 'float' },
|
|
1454
|
+
{ name: 'color', type: 'vec3' },
|
|
1455
|
+
{ name: 'background', type: 'vec3' },
|
|
1456
|
+
{ name: 'seed', type: 'float' },
|
|
1457
|
+
] }
|
|
1458
|
+
);
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
function isolines( params={} ) {
|
|
1463
|
+
|
|
1464
|
+
var { position, scale, density, blur, thinness, color, background, seed } = { ...defaults$B, ...params };
|
|
1465
|
+
|
|
1466
|
+
return isolinesRaw( position, scale, density, blur, thinness, color, background, seed );
|
|
1467
|
+
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
isolines.defaults = defaults$B;
|
|
1473
|
+
|
|
1474
|
+
var defaults$A = {
|
|
1475
|
+
$name: 'Karst rock',
|
|
1476
|
+
|
|
1477
|
+
position: tsl.positionGeometry,
|
|
1478
|
+
scale: 2,
|
|
1479
|
+
|
|
1480
|
+
color: new three.Color( 0xFFF4F0 ),
|
|
1481
|
+
background: new three.Color( 0xD0D0D0 ),
|
|
1482
|
+
|
|
1483
|
+
seed: 0,
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
var karstRockRaw = tsl.Fn( ([ position, scale, color, background, seed ])=>{
|
|
1489
|
+
|
|
1490
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed.sin().mul( 5 ) ).toVar( );
|
|
1491
|
+
|
|
1492
|
+
var pos2 = pos.add( tsl.mx_noise_float( pos.mul( 2 ) ) ).toVar();
|
|
1493
|
+
|
|
1494
|
+
var k = tsl.mx_noise_float( pos2 ).div( tsl.mx_noise_float( pos2.mul( 1.01 ) ) ).clamp( 0, 2 ).toVar();
|
|
1495
|
+
|
|
1496
|
+
k.addAssign( tsl.mx_noise_float( pos.mul( 100 ) ).div( 3 ) );
|
|
1497
|
+
k.addAssign( tsl.mx_noise_float( pos.mul( 2 ) ).div( 2 ) );
|
|
1498
|
+
|
|
1499
|
+
return tsl.mix( background, color, k ).mul( k.pow( 0.1 ) );
|
|
1500
|
+
|
|
1501
|
+
} ).setLayout( {
|
|
1502
|
+
name: 'karstRockRaw',
|
|
1503
|
+
type: 'vec3',
|
|
1504
|
+
inputs: [
|
|
1505
|
+
{ name: 'position', type: 'vec3' },
|
|
1506
|
+
{ name: 'scale', type: 'float' },
|
|
1507
|
+
{ name: 'color', type: 'vec3' },
|
|
1508
|
+
{ name: 'background', type: 'vec3' },
|
|
1509
|
+
{ name: 'seed', type: 'float' },
|
|
1510
|
+
] }
|
|
1511
|
+
);
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
function karstRock( params={} ) {
|
|
1516
|
+
|
|
1517
|
+
var { position, scale, color, background, seed } = { ...defaults$A, ...params };
|
|
1518
|
+
|
|
1519
|
+
return karstRockRaw( position, scale, color, background, seed );
|
|
1520
|
+
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
karstRock.defaults = defaults$A;
|
|
1526
|
+
|
|
1527
|
+
var defaults$z = {
|
|
1528
|
+
$name: 'Marble',
|
|
1529
|
+
|
|
1530
|
+
position: tsl.positionGeometry,
|
|
1531
|
+
scale: 1.2,
|
|
1532
|
+
thinness: 5,
|
|
1533
|
+
noise: 0.3,
|
|
1534
|
+
|
|
1535
|
+
color: new three.Color( 0x4545D3 ),
|
|
1536
|
+
background: new three.Color( 0xF0F8FF ),
|
|
1537
|
+
|
|
1538
|
+
seed: 0,
|
|
1539
|
+
};
|
|
1540
|
+
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
var marbleRaw = tsl.Fn( ([ position, scale, thinness, xnoise, color, background, seed ]) => {
|
|
1544
|
+
|
|
1545
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed ).toVar( );
|
|
1546
|
+
|
|
1547
|
+
var k = tsl.add(
|
|
1548
|
+
tsl.mx_noise_float( pos ),
|
|
1549
|
+
tsl.mx_noise_float( pos.mul( 2 ) ).mul( 0.5 ),
|
|
1550
|
+
tsl.mx_noise_float( pos.mul( 6 ) ).mul( 0.1 )
|
|
1551
|
+
);
|
|
1552
|
+
|
|
1553
|
+
var k = tsl.oneMinus( k.abs().pow( 2.5 ) ).toVar();
|
|
1554
|
+
|
|
1555
|
+
var maxSmooth = tsl.oneMinus( tsl.pow( 0.5, thinness.add( 7 ) ) ).toVar(),
|
|
1556
|
+
minSmooth = tsl.oneMinus( tsl.pow( 0.5, thinness.add( 7 ).mul( 0.5 ) ) ).toVar();
|
|
1557
|
+
|
|
1558
|
+
tsl.If( k.greaterThan( maxSmooth ), ()=>{
|
|
1559
|
+
|
|
1560
|
+
k.assign( 1 );
|
|
1561
|
+
|
|
1562
|
+
} )
|
|
1563
|
+
.ElseIf( k.lessThan( minSmooth ), ()=>{
|
|
1564
|
+
|
|
1565
|
+
k.assign( 0 );
|
|
1566
|
+
|
|
1567
|
+
} )
|
|
1568
|
+
.Else( ()=> {
|
|
1569
|
+
|
|
1570
|
+
var a = k.sub( minSmooth );
|
|
1571
|
+
var b = maxSmooth.sub( minSmooth );
|
|
1572
|
+
k.assign( tsl.pow( tsl.div( a, b ), 5 ).mul( 0.75 ) );
|
|
1573
|
+
k.assign( k.mul( tsl.add( 0.5, tsl.mx_noise_float( pos.mul( 2 ) ).mul( 1.5 ) ) ) );
|
|
1574
|
+
|
|
1575
|
+
} );
|
|
1576
|
+
|
|
1577
|
+
k.assign( k.add( tsl.mul( xnoise, tsl.mx_noise_float( pos.mul( 150 ) ).abs().pow3() ) ) );
|
|
1578
|
+
|
|
1579
|
+
return tsl.mix( background, color, k );
|
|
1580
|
+
|
|
1581
|
+
} ).setLayout( {
|
|
1582
|
+
name: 'marbleRaw',
|
|
1583
|
+
type: 'vec3',
|
|
1584
|
+
inputs: [
|
|
1585
|
+
{ name: 'position', type: 'vec3' },
|
|
1586
|
+
{ name: 'scale', type: 'float' },
|
|
1587
|
+
{ name: 'thinness', type: 'float' },
|
|
1588
|
+
{ name: 'xnoise', type: 'float' },
|
|
1589
|
+
{ name: 'color', type: 'vec3' },
|
|
1590
|
+
{ name: 'background', type: 'vec3' },
|
|
1591
|
+
{ name: 'seed', type: 'float' },
|
|
1592
|
+
] }
|
|
1593
|
+
);
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
function marble( params={} ) {
|
|
1598
|
+
|
|
1599
|
+
var { position, scale, thinness, noise, color, background, seed } = { ...defaults$z, ...params };
|
|
1600
|
+
|
|
1601
|
+
return marbleRaw( position, scale, thinness, noise, color, background, seed );
|
|
1602
|
+
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
marble.defaults = defaults$z;
|
|
1608
|
+
|
|
1609
|
+
var defaults$y = {
|
|
1610
|
+
$name: 'Neon Lights',
|
|
1611
|
+
|
|
1612
|
+
position: tsl.positionGeometry,
|
|
1613
|
+
|
|
1614
|
+
scale: 2,
|
|
1615
|
+
thinness: 0.8,
|
|
1616
|
+
mode: 0, // 0=additive, 1=subtractive
|
|
1617
|
+
|
|
1618
|
+
colorA: new three.Color( 0xFF0000 ),
|
|
1619
|
+
colorB: new three.Color( 0x00FF00 ),
|
|
1620
|
+
colorC: new three.Color( 0x0000FF ),
|
|
1621
|
+
background: new three.Color( 0x000000 ),
|
|
1622
|
+
|
|
1623
|
+
seed: 0,
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
var neonLightsRaw = tsl.Fn( ([ position, scale, thinness, mode, colorA, colorB, colorC, background, seed ]) => {
|
|
1629
|
+
|
|
1630
|
+
var pos = position;
|
|
1631
|
+
|
|
1632
|
+
var xscale = tsl.exp( scale.remap( 0, 4, -2, 2 ) ).toVar();
|
|
1633
|
+
var xthinness = tsl.exp( thinness.remap( 0, 1, 1.5, 0 ) ).toVar();
|
|
1634
|
+
|
|
1635
|
+
var color = background.toVar();
|
|
1636
|
+
var neon = tsl.vec3( 0 ).toVar();
|
|
1637
|
+
|
|
1638
|
+
var x = tsl.mx_noise_float( pos.xyz ).toVar();
|
|
1639
|
+
var y = tsl.mx_noise_float( pos.yzx ).toVar();
|
|
1640
|
+
var z = tsl.mx_noise_float( pos.zxy ).toVar();
|
|
1641
|
+
|
|
1642
|
+
var k = tsl.mx_noise_float( tsl.vec3( x, y, z ).mul( xscale ).add( seed ) ).toVar();
|
|
1643
|
+
k.assign( tsl.oneMinus( tsl.sqrt( tsl.abs( k ) ) ).pow( 3 ) );
|
|
1644
|
+
|
|
1645
|
+
neon.assign( colorA );
|
|
1646
|
+
var HSL = toHsl( neon );
|
|
1647
|
+
neon.assign( hsl( tsl.vec3( HSL.xy, HSL.z.mul( k ) ) ) );
|
|
1648
|
+
|
|
1649
|
+
color.addAssign( tsl.select( mode.equal( 0 ), neon, neon.negate() ).mul( xthinness ) );
|
|
1650
|
+
|
|
1651
|
+
k.assign( tsl.mx_noise_float( tsl.vec3( y, z, x ).mul( xscale ).sub( seed ) ) );
|
|
1652
|
+
k.assign( tsl.oneMinus( tsl.sqrt( tsl.abs( k ) ) ).pow( 3 ) );
|
|
1653
|
+
|
|
1654
|
+
neon.assign( colorB );
|
|
1655
|
+
var HSL = toHsl( neon );
|
|
1656
|
+
neon.assign( hsl( tsl.vec3( HSL.xy, HSL.z.mul( k ) ) ) );
|
|
1657
|
+
|
|
1658
|
+
color.addAssign( tsl.select( mode.equal( 0 ), neon, neon.negate() ).mul( xthinness ) );
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
k.assign( tsl.mx_noise_float( tsl.vec3( z, x, y.negate() ).mul( xscale ).add( seed ) ) );
|
|
1662
|
+
k.assign( tsl.oneMinus( tsl.sqrt( tsl.abs( k ) ) ).pow( 3 ) );
|
|
1663
|
+
|
|
1664
|
+
neon.assign( colorC );
|
|
1665
|
+
var HSL = toHsl( neon );
|
|
1666
|
+
neon.assign( hsl( tsl.vec3( HSL.xy, HSL.z.mul( k ) ) ) );
|
|
1667
|
+
|
|
1668
|
+
color.addAssign( tsl.select( mode.equal( 0 ), neon, neon.negate() ).mul( xthinness ) );
|
|
1669
|
+
|
|
1670
|
+
return color;
|
|
1671
|
+
|
|
1672
|
+
} ).setLayout( {
|
|
1673
|
+
name: 'neonLightsRaw',
|
|
1674
|
+
type: 'vec3',
|
|
1675
|
+
inputs: [
|
|
1676
|
+
{ name: 'position', type: 'vec3' },
|
|
1677
|
+
{ name: 'scale', type: 'float' },
|
|
1678
|
+
{ name: 'thinness', type: 'float' },
|
|
1679
|
+
{ name: 'node', type: 'float' },
|
|
1680
|
+
{ name: 'colorA', type: 'vec3' },
|
|
1681
|
+
{ name: 'colorB', type: 'vec3' },
|
|
1682
|
+
{ name: 'colorC', type: 'vec3' },
|
|
1683
|
+
{ name: 'background', type: 'vec3' },
|
|
1684
|
+
{ name: 'seed', type: 'float' },
|
|
1685
|
+
] }
|
|
1686
|
+
);
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
function neonLights( params={} ) {
|
|
1691
|
+
|
|
1692
|
+
var { position, scale, thinness, mode, colorA, colorB, colorC, background, seed } = { ...defaults$y, ...params };
|
|
1693
|
+
|
|
1694
|
+
return neonLightsRaw( position, scale, thinness, mode, colorA, colorB, colorC, background, seed );
|
|
1695
|
+
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
neonLights.defaults = defaults$y;
|
|
1701
|
+
|
|
1702
|
+
var defaults$x = {
|
|
1703
|
+
$name: 'Perlin noise',
|
|
1704
|
+
|
|
1705
|
+
position: tsl.positionGeometry,
|
|
1706
|
+
scale: 2,
|
|
1707
|
+
balance: 0,
|
|
1708
|
+
contrast: 0,
|
|
1709
|
+
|
|
1710
|
+
color: new three.Color( 0xFFFFFF ),
|
|
1711
|
+
background: new three.Color( 0x000000 ),
|
|
1712
|
+
|
|
1713
|
+
seed: 0,
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
var perlinNoiseRaw = tsl.Fn( ([ position, scale, balance, contrast, color, background, seed ]) => {
|
|
1719
|
+
|
|
1720
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed );
|
|
1721
|
+
|
|
1722
|
+
var k = tsl.mx_noise_float( pos ).mul( 0.5, tsl.exp( contrast ) ).add( 0.5, balance ).min( 1 );
|
|
1723
|
+
|
|
1724
|
+
return tsl.mix( background, color, k );
|
|
1725
|
+
|
|
1726
|
+
} ).setLayout( {
|
|
1727
|
+
name: 'perlinNoiseRaw',
|
|
1728
|
+
type: 'vec3',
|
|
1729
|
+
inputs: [
|
|
1730
|
+
{ name: 'position', type: 'vec3' },
|
|
1731
|
+
{ name: 'scale', type: 'float' },
|
|
1732
|
+
{ name: 'balance', type: 'float' },
|
|
1733
|
+
{ name: 'contrast', type: 'float' },
|
|
1734
|
+
{ name: 'color', type: 'vec3' },
|
|
1735
|
+
{ name: 'background', type: 'vec3' },
|
|
1736
|
+
{ name: 'seed', type: 'float' },
|
|
1737
|
+
] }
|
|
1738
|
+
);
|
|
1739
|
+
|
|
1740
|
+
|
|
1741
|
+
|
|
1742
|
+
function perlinNoise( params={} ) {
|
|
1743
|
+
|
|
1744
|
+
var { position, scale, balance, contrast, color, background, seed } = { ...defaults$x, ...params };
|
|
1745
|
+
|
|
1746
|
+
return perlinNoiseRaw( position, scale, balance, contrast, color, background, seed );
|
|
1747
|
+
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
perlinNoise.defaults = defaults$x;
|
|
1753
|
+
|
|
1754
|
+
var defaults$w = {
|
|
1755
|
+
$name: 'Photosphere',
|
|
1756
|
+
|
|
1757
|
+
position: tsl.positionGeometry,
|
|
1758
|
+
scale: 2,
|
|
1759
|
+
|
|
1760
|
+
color: new three.Color( 0xFFFF00 ),
|
|
1761
|
+
background: new three.Color( 0xFF0000 ),
|
|
1762
|
+
|
|
1763
|
+
seed: 0,
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
var photosphereRaw = tsl.Fn( ([ position, scale, color, background, seed ]) => {
|
|
1769
|
+
|
|
1770
|
+
var xscale = tsl.exp( scale.add( 1 ) ).toVar( );
|
|
1771
|
+
var pos = position.toVar( );
|
|
1772
|
+
|
|
1773
|
+
var vec = tsl.vec3( pos ).toVar();
|
|
1774
|
+
|
|
1775
|
+
tsl.Loop( 6, () => {
|
|
1776
|
+
|
|
1777
|
+
vec.assign( tsl.rotate( vec, pos.mul( xscale ) ) );
|
|
1778
|
+
xscale.mulAssign( seed.mul( xscale ).sin().mul( 0.05 ).add( 1.1 ) );
|
|
1779
|
+
|
|
1780
|
+
} );
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
var k = tsl.mx_noise_float( vec ).add( 1 ).div( 2 );
|
|
1784
|
+
|
|
1785
|
+
return tsl.mix( background, color, k );
|
|
1786
|
+
|
|
1787
|
+
} ).setLayout( {
|
|
1788
|
+
name: 'photosphereRaw',
|
|
1789
|
+
type: 'vec3',
|
|
1790
|
+
inputs: [
|
|
1791
|
+
{ name: 'position', type: 'vec3' },
|
|
1792
|
+
{ name: 'scale', type: 'float' },
|
|
1793
|
+
{ name: 'color', type: 'vec3' },
|
|
1794
|
+
{ name: 'background', type: 'vec3' },
|
|
1795
|
+
{ name: 'seed', type: 'float' },
|
|
1796
|
+
] }
|
|
1797
|
+
);
|
|
1798
|
+
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
function photosphere( params={} ) {
|
|
1802
|
+
|
|
1803
|
+
var { position, scale, color, background, seed } = { ...defaults$w, ...params };
|
|
1804
|
+
|
|
1805
|
+
return photosphereRaw( position, scale, color, background, seed );
|
|
1806
|
+
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
photosphere.defaults = defaults$w;
|
|
1812
|
+
|
|
1813
|
+
var defaults$v = {
|
|
1814
|
+
$name: 'Planet',
|
|
1815
|
+
|
|
1816
|
+
position: tsl.positionGeometry,
|
|
1817
|
+
scale: 2,
|
|
1818
|
+
|
|
1819
|
+
iterations: 5,
|
|
1820
|
+
|
|
1821
|
+
levelSea: 0.3,
|
|
1822
|
+
levelMountain: 0.7,
|
|
1823
|
+
|
|
1824
|
+
balanceWater: 0.3,
|
|
1825
|
+
balanceSand: 0.2,
|
|
1826
|
+
balanceSnow: 0.8,
|
|
1827
|
+
|
|
1828
|
+
colorDeep: new three.Color( 0x123a59 ).convertLinearToSRGB(), // SteelBlue
|
|
1829
|
+
colorShallow: new three.Color( 0x87CEEB ).convertLinearToSRGB(), // SkyBlue
|
|
1830
|
+
colorBeach: new three.Color( 0xFFFACD ).convertLinearToSRGB(), // LemonChiffon
|
|
1831
|
+
colorGrass: new three.Color( 0x3CB371 ).convertLinearToSRGB(), // MediumSeaGreen
|
|
1832
|
+
colorForest: new three.Color( 0x003000 ).convertLinearToSRGB(), // Dark green
|
|
1833
|
+
colorSnow: new three.Color( 0xF0FFFF ).convertLinearToSRGB(), // Azure
|
|
1834
|
+
|
|
1835
|
+
seed: 0,
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
var planetRaw = tsl.Fn( ([ position, scale, iterations, levelSea, levelMountain, balanceWater, balanceSand, balanceSnow, colorDeep, colorShallow, colorBeach, colorGrass, colorForest, colorSnow, seed ])=>{
|
|
1841
|
+
|
|
1842
|
+
var k = tsl.float( 0 ).toVar(),
|
|
1843
|
+
sum = tsl.float( 0 ).toVar(),
|
|
1844
|
+
xscale = tsl.exp( scale.sub( 2 ) ).toVar(),
|
|
1845
|
+
xpower = tsl.float( 2 ).toVar();
|
|
1846
|
+
|
|
1847
|
+
tsl.Loop( iterations.add( 10 ), ()=>{
|
|
1848
|
+
|
|
1849
|
+
k.addAssign( tsl.mul( xpower, tsl.mx_noise_float( position.mul( xscale ).add( seed ) ) ) );
|
|
1850
|
+
sum.addAssign( xpower );
|
|
1851
|
+
xscale.mulAssign( 1.5 );
|
|
1852
|
+
xpower.mulAssign( 0.8 );
|
|
1853
|
+
|
|
1854
|
+
} );
|
|
1855
|
+
|
|
1856
|
+
k.assign( tsl.mul( k, k, 0.5 ).div( sum ) );
|
|
1857
|
+
|
|
1858
|
+
var levelSea = levelSea.pow( 2 ).toVar();
|
|
1859
|
+
var levelMountain = levelMountain.pow( 2 ).toVar();
|
|
1860
|
+
var levelSand = tsl.mix( levelSea, levelMountain, balanceSand ).toVar();
|
|
1861
|
+
var levelCoast = tsl.mix( levelSea, levelSand, 0.4 ).toVar();
|
|
1862
|
+
var levelGrass = tsl.mix( levelSea, levelSand, 0.6 ).toVar();
|
|
1863
|
+
|
|
1864
|
+
var color = tsl.vec3().toVar();
|
|
1865
|
+
|
|
1866
|
+
// process water
|
|
1867
|
+
tsl.If( k.lessThan( levelSea ), ()=>{
|
|
1868
|
+
|
|
1869
|
+
// deep-shallow
|
|
1870
|
+
color.assign( tsl.mix(
|
|
1871
|
+
colorDeep,
|
|
1872
|
+
colorShallow,
|
|
1873
|
+
tsl.remap( k, 0, levelSea, 0, 1 ).pow( tsl.exp( balanceWater.mul( -8 ).add( 4 ) ) )
|
|
1874
|
+
) );
|
|
1875
|
+
|
|
1876
|
+
} )
|
|
1877
|
+
.ElseIf( k.lessThan( levelCoast ), ()=>{
|
|
1878
|
+
|
|
1879
|
+
// shallow-sand
|
|
1880
|
+
color.assign( tsl.mix(
|
|
1881
|
+
colorShallow,
|
|
1882
|
+
colorBeach,
|
|
1883
|
+
tsl.remap( k, levelSea, levelCoast )
|
|
1884
|
+
) );
|
|
1885
|
+
|
|
1886
|
+
} )
|
|
1887
|
+
.ElseIf( k.lessThan( levelGrass ), ()=>{
|
|
1888
|
+
|
|
1889
|
+
// sand
|
|
1890
|
+
color.assign( colorBeach );
|
|
1891
|
+
|
|
1892
|
+
} )
|
|
1893
|
+
.ElseIf( k.lessThan( levelSand ), ()=>{
|
|
1894
|
+
|
|
1895
|
+
// shallow-sand-grass
|
|
1896
|
+
color.assign( tsl.mix(
|
|
1897
|
+
colorBeach,
|
|
1898
|
+
colorGrass,
|
|
1899
|
+
tsl.remap( k, levelGrass, levelSand )
|
|
1900
|
+
) );
|
|
1901
|
+
|
|
1902
|
+
} )
|
|
1903
|
+
.ElseIf( k.lessThan( levelMountain ), ()=>{
|
|
1904
|
+
|
|
1905
|
+
// grass-forest
|
|
1906
|
+
color.assign( tsl.mix(
|
|
1907
|
+
colorGrass,
|
|
1908
|
+
colorForest,
|
|
1909
|
+
tsl.remap( k, levelSand, levelMountain ).pow( 0.75 )
|
|
1910
|
+
) );
|
|
1911
|
+
|
|
1912
|
+
} )
|
|
1913
|
+
.Else( ()=>{
|
|
1914
|
+
|
|
1915
|
+
// forest-snow
|
|
1916
|
+
var levelSnow = tsl.mix( 1, levelMountain, balanceSnow );
|
|
1917
|
+
color.assign( tsl.mix(
|
|
1918
|
+
colorForest,
|
|
1919
|
+
colorSnow,
|
|
1920
|
+
tsl.smoothstep( tsl.mix( levelSnow, levelMountain, balanceSnow.pow( 0.5 ) ), levelSnow, k )
|
|
1921
|
+
) );
|
|
1922
|
+
|
|
1923
|
+
} );
|
|
1924
|
+
|
|
1925
|
+
return color;
|
|
1926
|
+
|
|
1927
|
+
} ).setLayout( {
|
|
1928
|
+
name: 'planetRaw',
|
|
1929
|
+
type: 'vec3',
|
|
1930
|
+
inputs: [
|
|
1931
|
+
{ name: 'position', type: 'vec3' },
|
|
1932
|
+
{ name: 'scale', type: 'float' },
|
|
1933
|
+
|
|
1934
|
+
{ name: 'iterations', type: 'int' },
|
|
1935
|
+
{ name: 'levelSea', type: 'float' },
|
|
1936
|
+
{ name: 'levelMountain', type: 'float' },
|
|
1937
|
+
{ name: 'balanceWater', type: 'float' },
|
|
1938
|
+
{ name: 'balanceSand', type: 'float' },
|
|
1939
|
+
{ name: 'balanceSnow', type: 'float' },
|
|
1940
|
+
|
|
1941
|
+
{ name: 'colorDeep', type: 'vec3' },
|
|
1942
|
+
{ name: 'colorShallow', type: 'vec3' },
|
|
1943
|
+
{ name: 'colorBeach', type: 'vec3' },
|
|
1944
|
+
{ name: 'colorGrass', type: 'vec3' },
|
|
1945
|
+
{ name: 'colorForest', type: 'vec3' },
|
|
1946
|
+
{ name: 'colorSnow', type: 'vec3' },
|
|
1947
|
+
|
|
1948
|
+
{ name: 'seed', type: 'float' },
|
|
1949
|
+
] }
|
|
1950
|
+
);
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
function planet( params={} ) {
|
|
1955
|
+
|
|
1956
|
+
var { position, scale, iterations, levelSea, levelMountain, balanceWater, balanceSand, balanceSnow, colorDeep, colorShallow, colorBeach, colorGrass, colorForest, colorSnow, seed } = { ...defaults$v, ...params };
|
|
1957
|
+
|
|
1958
|
+
return planetRaw( position, scale, iterations, levelSea, levelMountain, balanceWater, balanceSand, balanceSnow, colorDeep, colorShallow, colorBeach, colorGrass, colorForest, colorSnow, seed );
|
|
1959
|
+
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
|
|
1963
|
+
|
|
1964
|
+
planet.defaults = defaults$v;
|
|
1965
|
+
|
|
1966
|
+
var defaults$u = {
|
|
1967
|
+
$name: 'Polka dots',
|
|
1968
|
+
|
|
1969
|
+
position: tsl.positionGeometry,
|
|
1970
|
+
count: 2,
|
|
1971
|
+
size: 0.5,
|
|
1972
|
+
blur: 0.25,
|
|
1973
|
+
|
|
1974
|
+
color: new three.Color( 0x000000 ),
|
|
1975
|
+
background: new three.Color( 0xFFFFFF ),
|
|
1976
|
+
|
|
1977
|
+
flat: 0,
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
var goldenRatio = ( 1+5**0.5 )/2;
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
var polkaDotsRaw = tsl.Fn( ([ position, count, size, blur, color, background, xflat ]) => {
|
|
1987
|
+
|
|
1988
|
+
var dist = tsl.float( 1 ).toVar();
|
|
1989
|
+
|
|
1990
|
+
tsl.If( xflat.equal( 1 ), ()=>{
|
|
1991
|
+
|
|
1992
|
+
var cnt = count.pow( 2 ).sub( 0.5 ).toVar();
|
|
1993
|
+
var pos = position.xy.mul( cnt ).mul( tsl.mat2( 1, 1, -1, 1 ) );
|
|
1994
|
+
var posTo = pos.round().toVar();
|
|
1995
|
+
|
|
1996
|
+
dist.assign( pos.distance( posTo ).div( cnt ) );
|
|
1997
|
+
|
|
1998
|
+
} ).Else( ()=>{
|
|
1999
|
+
|
|
2000
|
+
var cnt = tsl.pow( 10, count ).toVar();
|
|
2001
|
+
var vec = position.normalize().toVar();
|
|
2002
|
+
|
|
2003
|
+
var besti = tsl.oneMinus( vec.y ).mul( cnt ).sub( 1 ).div( 2 );
|
|
2004
|
+
|
|
2005
|
+
var span = tsl.max( 10, cnt.pow( 0.5 ) );
|
|
2006
|
+
|
|
2007
|
+
var mini = besti.sub( span ).floor().clamp( 0, cnt );
|
|
2008
|
+
var maxi = besti.add( span ).floor().clamp( 0, cnt );
|
|
2009
|
+
|
|
2010
|
+
dist.assign( 1 ).toVar();
|
|
2011
|
+
|
|
2012
|
+
tsl.Loop( maxi.sub( mini ), ( { i } )=> {
|
|
2013
|
+
|
|
2014
|
+
var j = tsl.add( i, mini );
|
|
2015
|
+
var theta = tsl.mod( tsl.mul( 2*Math.PI/goldenRatio, j ), 2*Math.PI );
|
|
2016
|
+
var phi = tsl.acos( tsl.oneMinus( tsl.float( j ).mul( 2 ).add( 1 ).div( cnt ) ) );
|
|
2017
|
+
var pnt = spherical( phi, theta );//.normalize();
|
|
2018
|
+
dist.assign( tsl.min( dist, tsl.distance( vec, pnt ) ) );
|
|
2019
|
+
|
|
2020
|
+
} ); // Loop
|
|
2021
|
+
|
|
2022
|
+
} ); // Else
|
|
2023
|
+
|
|
2024
|
+
var xsize = tsl.exp( size.mul( 5 ).sub( 5 ) ).toVar();
|
|
2025
|
+
var xblur = blur.pow( 4 ).toVar();
|
|
2026
|
+
var k = tsl.smoothstep( xsize.sub( xblur ), xsize.add( xblur ), dist );
|
|
2027
|
+
|
|
2028
|
+
return tsl.mix( color, background, k );
|
|
2029
|
+
|
|
2030
|
+
} ).setLayout( {
|
|
2031
|
+
name: 'polkaDotsRaw',
|
|
2032
|
+
type: 'vec3',
|
|
2033
|
+
inputs: [
|
|
2034
|
+
{ name: 'position', type: 'vec3' },
|
|
2035
|
+
{ name: 'count', type: 'float' },
|
|
2036
|
+
{ name: 'size', type: 'float' },
|
|
2037
|
+
{ name: 'blur', type: 'float' },
|
|
2038
|
+
{ name: 'color', type: 'vec3' },
|
|
2039
|
+
{ name: 'background', type: 'vec3' },
|
|
2040
|
+
{ name: 'xflat', type: 'int' },
|
|
2041
|
+
] }
|
|
2042
|
+
);
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
|
|
2046
|
+
function polkaDots( params={} ) {
|
|
2047
|
+
|
|
2048
|
+
var { position, count, size, blur, color, background, flat } = { ...defaults$u, ...params };
|
|
2049
|
+
|
|
2050
|
+
return polkaDotsRaw( position, count, size, blur, color, background, flat );
|
|
2051
|
+
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
|
|
2055
|
+
|
|
2056
|
+
polkaDots.defaults = defaults$u;
|
|
2057
|
+
|
|
2058
|
+
var defaults$t = {
|
|
2059
|
+
$name: 'Processed wood',
|
|
2060
|
+
$width: 260,
|
|
2061
|
+
|
|
2062
|
+
position: tsl.positionGeometry,
|
|
2063
|
+
scale: 2,
|
|
2064
|
+
lengths: 4,
|
|
2065
|
+
strength: 0.3,
|
|
2066
|
+
angle: 0,
|
|
2067
|
+
|
|
2068
|
+
color: new three.Color( 0x702020 ),
|
|
2069
|
+
background: new three.Color( 0xF0D0A0 ),
|
|
2070
|
+
|
|
2071
|
+
seed: 0,
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
var processedWoodRaw = tsl.Fn( ([ position, scale, lengths, strength, angle, color, background, seed ])=>{
|
|
2077
|
+
|
|
2078
|
+
var angle = tsl.radians( angle ).toVar();
|
|
2079
|
+
var posLocal = tsl.vec3(
|
|
2080
|
+
tsl.sub( position.x.mul( tsl.cos( angle ) ), position.y.mul( tsl.sin( angle ) ) ),
|
|
2081
|
+
tsl.add( position.x.mul( tsl.sin( angle ) ), position.y.mul( tsl.cos( angle ) ) ),
|
|
2082
|
+
position.z,
|
|
2083
|
+
).toVar();
|
|
2084
|
+
|
|
2085
|
+
var xscale = scale.div( 2 ).add( 1 ).toVar();
|
|
2086
|
+
var pos = posLocal.mul( tsl.exp( scale ) ).add( seed ).toVar( );
|
|
2087
|
+
|
|
2088
|
+
var len = lengths.add( 5 ).reciprocal().toVar();
|
|
2089
|
+
var k = tsl.mx_noise_float( pos.mul( xscale, tsl.vec3( 1, len, len ) ) );
|
|
2090
|
+
k = k.mul( tsl.mx_noise_float( pos.mul( tsl.vec3( 25, 1, 1 ) ) ).add( -1 ).mul( 0.2 ) );
|
|
2091
|
+
k = k.add( strength.sub( 0.5 ) ).smoothstep( -0.3, 0.3 ).oneMinus();
|
|
2092
|
+
|
|
2093
|
+
return tsl.mix( color, background, k );
|
|
2094
|
+
|
|
2095
|
+
} ).setLayout( {
|
|
2096
|
+
name: 'processedWoodRaw',
|
|
2097
|
+
type: 'vec3',
|
|
2098
|
+
inputs: [
|
|
2099
|
+
{ name: 'position', type: 'vec3' },
|
|
2100
|
+
{ name: 'scale', type: 'float' },
|
|
2101
|
+
{ name: 'lengths', type: 'float' },
|
|
2102
|
+
{ name: 'strength', type: 'float' },
|
|
2103
|
+
{ name: 'angle', type: 'float' },
|
|
2104
|
+
{ name: 'color', type: 'vec3' },
|
|
2105
|
+
{ name: 'background', type: 'vec3' },
|
|
2106
|
+
{ name: 'seed', type: 'float' },
|
|
2107
|
+
] }
|
|
2108
|
+
);
|
|
2109
|
+
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
function processedWood( params={} ) {
|
|
2113
|
+
|
|
2114
|
+
var { position, scale, lengths, strength, angle, color, background, seed } = { ...defaults$t, ...params };
|
|
2115
|
+
|
|
2116
|
+
return processedWoodRaw( position, scale, lengths, strength, angle, color, background, seed );
|
|
2117
|
+
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
processedWood.defaults = defaults$t;
|
|
2123
|
+
|
|
2124
|
+
var defaults$s = {
|
|
2125
|
+
$name: 'Protozoa',
|
|
2126
|
+
|
|
2127
|
+
position: tsl.positionGeometry,
|
|
2128
|
+
matcap: tsl.matcapUV,
|
|
2129
|
+
scale: 1.5,
|
|
2130
|
+
fat: 0.7,
|
|
2131
|
+
amount: 0.4,
|
|
2132
|
+
|
|
2133
|
+
color: new three.Color( 0xA0A0A0 ),
|
|
2134
|
+
subcolor: new three.Color( 0xE0E8FF ),
|
|
2135
|
+
background: new three.Color( 0xF0F8FF ),
|
|
2136
|
+
|
|
2137
|
+
seed: 0,
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
var pnoise = tsl.Fn( ([ pos, fat ])=>{
|
|
2143
|
+
|
|
2144
|
+
return tsl.mx_noise_float( pos ).mul( fat ).clamp( -3.14, 3.14 ).cos().add( 1 ).div( 2 );
|
|
2145
|
+
|
|
2146
|
+
} ).setLayout( {
|
|
2147
|
+
name: 'pnoise',
|
|
2148
|
+
type: 'float',
|
|
2149
|
+
inputs: [
|
|
2150
|
+
{ name: 'pos', type: 'vec3' },
|
|
2151
|
+
{ name: 'fat', type: 'float' },
|
|
2152
|
+
] }
|
|
2153
|
+
);
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
var protozoaRaw = tsl.Fn( ([ position, matcap, scale, fat, amount, color, subcolor, background, seed ])=>{
|
|
2158
|
+
|
|
2159
|
+
var pos = position.mul( tsl.exp( scale.sub( 1 ) ) ).add( seed ).toVar( );
|
|
2160
|
+
|
|
2161
|
+
var xmatcap = tsl.vec3( matcap, matcap.length() ).toVar();
|
|
2162
|
+
|
|
2163
|
+
var rings1 = tsl.float( 0 ).toVar();
|
|
2164
|
+
var rings2 = tsl.float( 0 ).toVar();
|
|
2165
|
+
|
|
2166
|
+
var n1 = tsl.float( 0 ).toVar();
|
|
2167
|
+
var n2 = tsl.float( 0 ).toVar();
|
|
2168
|
+
|
|
2169
|
+
var fat = fat.add( 0.2 ).oneMinus().mul( 60 ).add( 30 ).toVar();
|
|
2170
|
+
var xscale = tsl.float( 2 ).toVar();
|
|
2171
|
+
|
|
2172
|
+
var dPos = amount.div( 2 ).add( 0.5 ).exp().toVar();
|
|
2173
|
+
|
|
2174
|
+
tsl.Loop( 10, ()=>{
|
|
2175
|
+
|
|
2176
|
+
rings1.assign( pnoise( pos.xyz.add( xmatcap ), fat ) );
|
|
2177
|
+
rings2.assign( pnoise( pos.yzx.add( xmatcap ), fat ) );
|
|
2178
|
+
|
|
2179
|
+
n1.addAssign( rings1.mul( rings2 ).mul( xscale ) );
|
|
2180
|
+
n2.addAssign( rings1.max( rings2 ).mul( xscale ) );
|
|
2181
|
+
|
|
2182
|
+
pos.assign( tsl.mix( pos.mul( dPos ), 0, 0.4 ) );
|
|
2183
|
+
|
|
2184
|
+
xscale.mulAssign( 0.9 );
|
|
2185
|
+
|
|
2186
|
+
} );
|
|
2187
|
+
|
|
2188
|
+
return tsl.mix( background, tsl.mix( color, subcolor, n2.mul( 0.1 ) ), n1 );
|
|
2189
|
+
|
|
2190
|
+
} ).setLayout( {
|
|
2191
|
+
name: 'protozoaRaw',
|
|
2192
|
+
type: 'vec3',
|
|
2193
|
+
inputs: [
|
|
2194
|
+
{ name: 'position', type: 'vec3' },
|
|
2195
|
+
{ name: 'matcap', type: 'vec2' },
|
|
2196
|
+
{ name: 'scale', type: 'float' },
|
|
2197
|
+
{ name: 'fat', type: 'float' },
|
|
2198
|
+
{ name: 'amount', type: 'float' },
|
|
2199
|
+
{ name: 'color', type: 'vec3' },
|
|
2200
|
+
{ name: 'subcolor', type: 'vec3' },
|
|
2201
|
+
{ name: 'background', type: 'vec3' },
|
|
2202
|
+
{ name: 'seed', type: 'float' },
|
|
2203
|
+
] }
|
|
2204
|
+
);
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
function protozoa( params={} ) {
|
|
2209
|
+
|
|
2210
|
+
var { position, matcap, scale, fat, amount, color, subcolor, background, seed } = { ...defaults$s, ...params };
|
|
2211
|
+
|
|
2212
|
+
return protozoaRaw( position, matcap, scale, fat, amount, color, subcolor, background, seed );
|
|
2213
|
+
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
protozoa.defaults = defaults$s;
|
|
2219
|
+
|
|
2220
|
+
var defaults$r = {
|
|
2221
|
+
$name: 'Rotator',
|
|
2222
|
+
$positionNode: true,
|
|
2223
|
+
$selectorPlanar: true,
|
|
2224
|
+
|
|
2225
|
+
angles: new three.Vector3( -0.2, 0.7, 0 ),
|
|
2226
|
+
center: new three.Vector3( 0, 0, 0 ),
|
|
2227
|
+
|
|
2228
|
+
selectorCenter: new three.Vector3( 0, 0, 0 ),
|
|
2229
|
+
selectorAngles: new three.Vector2( 0, 0 ),
|
|
2230
|
+
selectorWidth: 2,
|
|
2231
|
+
|
|
2232
|
+
};
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
var surfacePos$6 = tsl.Fn( ([ pos, angles, center, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
2237
|
+
|
|
2238
|
+
var zone = selectPlanar( pos, selectorAngles, selectorCenter, selectorWidth );
|
|
2239
|
+
|
|
2240
|
+
return rotatePivot( pos, center, angles.mul( zone ) );
|
|
2241
|
+
|
|
2242
|
+
} ).setLayout( {
|
|
2243
|
+
name: 'surfacePos',
|
|
2244
|
+
type: 'vec3',
|
|
2245
|
+
inputs: [
|
|
2246
|
+
{ name: 'pos', type: 'vec3' },
|
|
2247
|
+
{ name: 'angles', type: 'vec3' },
|
|
2248
|
+
{ name: 'center', type: 'vec3' },
|
|
2249
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
2250
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
2251
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
2252
|
+
]
|
|
2253
|
+
} );
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
var rotatorRaw = tsl.Fn( ([ angles, center, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
2258
|
+
|
|
2259
|
+
return surfacePos$6( tsl.positionGeometry, angles, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2260
|
+
|
|
2261
|
+
} ).setLayout( {
|
|
2262
|
+
name: 'rotatorRaw',
|
|
2263
|
+
type: 'vec3',
|
|
2264
|
+
inputs: [
|
|
2265
|
+
{ name: 'angles', type: 'vec3' },
|
|
2266
|
+
{ name: 'center', type: 'vec3' },
|
|
2267
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
2268
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
2269
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
2270
|
+
]
|
|
2271
|
+
} );
|
|
2272
|
+
|
|
2273
|
+
|
|
2274
|
+
|
|
2275
|
+
var rotatorNormalRaw = tsl.Fn( ([ angles, center, selectorAngles, selectorCenter, selectorWidth ]) => {
|
|
2276
|
+
|
|
2277
|
+
const EPS = 0.01;
|
|
2278
|
+
|
|
2279
|
+
var position = tsl.positionGeometry,
|
|
2280
|
+
normal = tsl.normalLocal.normalize().toVar(),
|
|
2281
|
+
tangent = tsl.tangentLocal.normalize().mul( EPS ).toVar(),
|
|
2282
|
+
bitangent = tsl.cross( normal, tangent ).normalize().mul( EPS ).toVar();
|
|
2283
|
+
|
|
2284
|
+
var pos = surfacePos$6( position, angles, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2285
|
+
var posU = surfacePos$6( position.add( tangent ), angles, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2286
|
+
var posV = surfacePos$6( position.add( bitangent ), angles, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2287
|
+
|
|
2288
|
+
return approximateNormal( pos, posU, posV );
|
|
2289
|
+
|
|
2290
|
+
} ).setLayout( {
|
|
2291
|
+
name: 'rotatorNormalRaw',
|
|
2292
|
+
type: 'vec3',
|
|
2293
|
+
inputs: [
|
|
2294
|
+
{ name: 'angles', type: 'vec3' },
|
|
2295
|
+
{ name: 'center', type: 'vec3' },
|
|
2296
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
2297
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
2298
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
2299
|
+
]
|
|
2300
|
+
} );
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
|
|
2304
|
+
function rotator( params={} ) {
|
|
2305
|
+
|
|
2306
|
+
var { angles, center, selectorAngles, selectorCenter, selectorWidth } = { ...defaults$r, ...params };
|
|
2307
|
+
|
|
2308
|
+
return rotatorRaw( angles, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2309
|
+
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
rotator.normal = function ( params={} ) {
|
|
2315
|
+
|
|
2316
|
+
var { angles, center, selectorAngles, selectorCenter, selectorWidth } = { ...defaults$r, ...params };
|
|
2317
|
+
|
|
2318
|
+
return rotatorNormalRaw( angles, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2319
|
+
|
|
2320
|
+
};
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
rotator.defaults = defaults$r;
|
|
2325
|
+
|
|
2326
|
+
var defaults$q = {
|
|
2327
|
+
$name: 'Rough clay',
|
|
2328
|
+
$normalNode: true,
|
|
2329
|
+
|
|
2330
|
+
position: tsl.positionGeometry,
|
|
2331
|
+
scale: 2,
|
|
2332
|
+
bump: 0.5,
|
|
2333
|
+
curvature: 0.2,
|
|
2334
|
+
|
|
2335
|
+
seed: 0,
|
|
2336
|
+
};
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2340
|
+
var surfacePos$5 = tsl.Fn( ([ pos, normal, curvature ]) => {
|
|
2341
|
+
|
|
2342
|
+
var k1 = tsl.mx_worley_noise_float( pos.add( tsl.mx_noise_float( pos ).mul( curvature ) ) ).add( 0.8 ).pow( 5 ).toVar();
|
|
2343
|
+
k1.addAssign( k1.pow( 0.5 ) );
|
|
2344
|
+
return pos.add( normal.mul( k1 ) );
|
|
2345
|
+
|
|
2346
|
+
} ).setLayout( {
|
|
2347
|
+
name: 'surfacePos',
|
|
2348
|
+
type: 'vec3',
|
|
2349
|
+
inputs: [
|
|
2350
|
+
{ name: 'position', type: 'vec3' },
|
|
2351
|
+
{ name: 'normal', type: 'vec3' },
|
|
2352
|
+
{ name: 'curvature', type: 'float' },
|
|
2353
|
+
] }
|
|
2354
|
+
);
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
|
|
2358
|
+
var roughClayRaw = tsl.Fn( ([ position, normal, tangent, scale, bump, curvature, seed ]) => {
|
|
2359
|
+
|
|
2360
|
+
const EPS = 0.001;
|
|
2361
|
+
|
|
2362
|
+
var xposition = position.mul( tsl.exp( scale.div( 2 ) ) ).add( seed.sin().mul( 10 ) ).toVar( ),
|
|
2363
|
+
xnormal = normal.normalize().toVar(),
|
|
2364
|
+
xtangent = tangent.normalize().mul( EPS ).toVar(),
|
|
2365
|
+
xbitangent = tsl.cross( xnormal, xtangent ).normalize().mul( EPS ).toVar();
|
|
2366
|
+
|
|
2367
|
+
xnormal.mulAssign( bump, 1/50 );
|
|
2368
|
+
|
|
2369
|
+
var pos = surfacePos$5( xposition, xnormal, curvature );
|
|
2370
|
+
var posU = surfacePos$5( xposition.add( xtangent ), xnormal, curvature );
|
|
2371
|
+
var posV = surfacePos$5( xposition.add( xbitangent ), xnormal, curvature );
|
|
2372
|
+
|
|
2373
|
+
return approximateNormal( pos, posU, posV );
|
|
2374
|
+
|
|
2375
|
+
} ).setLayout( {
|
|
2376
|
+
name: 'concreteRaw',
|
|
2377
|
+
type: 'vec3',
|
|
2378
|
+
inputs: [
|
|
2379
|
+
{ name: 'position', type: 'vec3' },
|
|
2380
|
+
{ name: 'normal', type: 'vec3' },
|
|
2381
|
+
{ name: 'tangent', type: 'vec3' },
|
|
2382
|
+
{ name: 'scale', type: 'float' },
|
|
2383
|
+
{ name: 'bump', type: 'float' },
|
|
2384
|
+
{ name: 'curvature', type: 'float' },
|
|
2385
|
+
{ name: 'seed', type: 'float' },
|
|
2386
|
+
] }
|
|
2387
|
+
);
|
|
2388
|
+
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
function roughClay( params={} ) {
|
|
2392
|
+
|
|
2393
|
+
var { position, scale, bump, curvature, seed } = { ...defaults$q, ...params };
|
|
2394
|
+
|
|
2395
|
+
return roughClayRaw( position, tsl.normalLocal, tsl.tangentLocal, scale, bump, curvature, seed );
|
|
2396
|
+
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
roughClay.defaults = defaults$q;
|
|
2402
|
+
|
|
2403
|
+
var defaults$p = {
|
|
2404
|
+
$name: 'Runny eggs',
|
|
2405
|
+
|
|
2406
|
+
position: tsl.positionGeometry,
|
|
2407
|
+
scale: 1,
|
|
2408
|
+
|
|
2409
|
+
sizeYolk: 0.2,
|
|
2410
|
+
sizeWhite: 0.7,
|
|
2411
|
+
|
|
2412
|
+
colorYolk: new three.Color( 'orange' ),
|
|
2413
|
+
colorWhite: new three.Color( 'white' ),
|
|
2414
|
+
colorBackground: new three.Color( 'lightgray' ),
|
|
2415
|
+
|
|
2416
|
+
seed: 0,
|
|
2417
|
+
};
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
var surfacePos$4 = tsl.Fn( ([ pos, normal, sizeYolk, sizeWhite ]) => {
|
|
2422
|
+
|
|
2423
|
+
var n = tsl.mx_worley_noise_float( pos ).toVar();
|
|
2424
|
+
var whites = n.add( sizeWhite ).pow( 8 ).oneMinus();
|
|
2425
|
+
var yolks = n.add( sizeYolk ).pow( 18 ).oneMinus().clamp( 0, 1 );
|
|
2426
|
+
|
|
2427
|
+
var k = tsl.mix( 0, tsl.mix( 0, 1, yolks ), whites );
|
|
2428
|
+
|
|
2429
|
+
return pos.add( normal.mul( k ) );
|
|
2430
|
+
|
|
2431
|
+
} ).setLayout( {
|
|
2432
|
+
name: 'surfacePos',
|
|
2433
|
+
type: 'vec3',
|
|
2434
|
+
inputs: [
|
|
2435
|
+
{ name: 'pos', type: 'vec3' },
|
|
2436
|
+
{ name: 'normal', type: 'vec3' },
|
|
2437
|
+
{ name: 'sizeYolk', type: 'float' },
|
|
2438
|
+
{ name: 'sizeWhite', type: 'float' },
|
|
2439
|
+
] }
|
|
2440
|
+
);
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
var runnyEggsRaw = tsl.Fn( ([ position, scale, sizeYolk, sizeWhite, colorYolk, colorWhite, colorBackground, seed ]) => {
|
|
2445
|
+
|
|
2446
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed.sin().mul( 10 ) ).toVar( );
|
|
2447
|
+
|
|
2448
|
+
var n = tsl.mx_worley_noise_float( pos ).toVar();
|
|
2449
|
+
var whites = n.add( sizeWhite.oneMinus() ).pow( 8 ).oneMinus().clamp( -0.5, 1 );
|
|
2450
|
+
var yolks = n.add( sizeYolk.oneMinus() ).pow( 18 ).oneMinus().clamp( 0, 1 ).pow( 0.4 ).clamp( 0, 1 );
|
|
2451
|
+
|
|
2452
|
+
return tsl.mix( colorBackground, tsl.mix( colorWhite, colorYolk, yolks ), whites );
|
|
2453
|
+
|
|
2454
|
+
} ).setLayout( {
|
|
2455
|
+
name: 'runnyEggsRaw',
|
|
2456
|
+
type: 'vec3',
|
|
2457
|
+
inputs: [
|
|
2458
|
+
{ name: 'pos', type: 'vec3' },
|
|
2459
|
+
{ name: 'normal', type: 'vec3' },
|
|
2460
|
+
{ name: 'sizeYolk', type: 'float' },
|
|
2461
|
+
{ name: 'sizeWhite', type: 'float' },
|
|
2462
|
+
{ name: 'colorYolk', type: 'vec3' },
|
|
2463
|
+
{ name: 'colorWhite', type: 'vec3' },
|
|
2464
|
+
{ name: 'colorBackground', type: 'vec3' },
|
|
2465
|
+
{ name: 'seed', type: 'float' },
|
|
2466
|
+
] }
|
|
2467
|
+
);
|
|
2468
|
+
|
|
2469
|
+
|
|
2470
|
+
|
|
2471
|
+
var runnyEggsNormalRaw = tsl.Fn( ([ position, normal, tangent, scale, sizeYolk, sizeWhite, /*colorYolk, colorWhite, colorBackground,*/ seed ]) => {
|
|
2472
|
+
|
|
2473
|
+
const EPS = 0.001;
|
|
2474
|
+
const BUMP = 0.05;
|
|
2475
|
+
|
|
2476
|
+
var xposition = position.mul( tsl.exp( scale ) ).add( seed.sin().mul( 10 ) ).toVar( ),
|
|
2477
|
+
xnormal = normal.normalize().toVar(),
|
|
2478
|
+
xtangent = tangent.normalize().mul( EPS ).toVar(),
|
|
2479
|
+
bitangent = tsl.cross( xnormal, xtangent ).normalize().mul( EPS ).toVar();
|
|
2480
|
+
|
|
2481
|
+
var xSizeYolk = sizeYolk.oneMinus();
|
|
2482
|
+
var xSizeWhite = sizeWhite.oneMinus();
|
|
2483
|
+
|
|
2484
|
+
xnormal.mulAssign( BUMP );
|
|
2485
|
+
|
|
2486
|
+
var pos = surfacePos$4( xposition, xnormal, xSizeYolk, xSizeWhite );
|
|
2487
|
+
var posU = surfacePos$4( xposition.add( xtangent ), xnormal, xSizeYolk, xSizeWhite );
|
|
2488
|
+
var posV = surfacePos$4( xposition.add( bitangent ), xnormal, xSizeYolk, xSizeWhite );
|
|
2489
|
+
|
|
2490
|
+
return approximateNormal( pos, posU, posV );
|
|
2491
|
+
|
|
2492
|
+
} ).setLayout( {
|
|
2493
|
+
name: 'runnyEggsNormalRaw',
|
|
2494
|
+
type: 'vec3',
|
|
2495
|
+
inputs: [
|
|
2496
|
+
{ name: 'position', type: 'vec3' },
|
|
2497
|
+
{ name: 'normal', type: 'vec3' },
|
|
2498
|
+
{ name: 'tangent', type: 'vec3' },
|
|
2499
|
+
{ name: 'scale', type: 'float' },
|
|
2500
|
+
{ name: 'sizeYolk', type: 'float' },
|
|
2501
|
+
{ name: 'sizeWhite', type: 'float' },
|
|
2502
|
+
/*{ name: 'colorYolk', type: 'vec3' },*/
|
|
2503
|
+
/*{ name: 'colorWhite', type: 'vec3' },*/
|
|
2504
|
+
/*{ name: 'colorBackground', type: 'vec3' },*/
|
|
2505
|
+
{ name: 'seed', type: 'float' },
|
|
2506
|
+
] }
|
|
2507
|
+
);
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
var runnyEggsRoughnessRaw = tsl.Fn( ([ position, scale, sizeYolk, /*sizeWhite, colorYolk, colorWhite, colorBackground,*/ seed ]) => {
|
|
2512
|
+
|
|
2513
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed.sin().mul( 10 ) ).toVar( );
|
|
2514
|
+
|
|
2515
|
+
var n = tsl.mx_worley_noise_float( pos ).toVar();
|
|
2516
|
+
var yolks = n.add( sizeYolk.oneMinus() ).pow( 18 ).clamp( 0, 1 );
|
|
2517
|
+
|
|
2518
|
+
return yolks;
|
|
2519
|
+
|
|
2520
|
+
} ).setLayout( {
|
|
2521
|
+
name: 'runnyEggsRoughnessRaw',
|
|
2522
|
+
type: 'float',
|
|
2523
|
+
inputs: [
|
|
2524
|
+
{ name: 'position', type: 'vec3' },
|
|
2525
|
+
{ name: 'scale', type: 'float' },
|
|
2526
|
+
{ name: 'sizeYolk', type: 'float' },
|
|
2527
|
+
/*{ name: 'sizeWhite', type: 'float' },*/
|
|
2528
|
+
/*{ name: 'colorYolk', type: 'vec3' },*/
|
|
2529
|
+
/*{ name: 'colorWhite', type: 'vec3' },*/
|
|
2530
|
+
/*{ name: 'colorBackground', type: 'vec3' },*/
|
|
2531
|
+
{ name: 'seed', type: 'float' },
|
|
2532
|
+
] }
|
|
2533
|
+
);
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
function runnyEggs( params={} ) {
|
|
2538
|
+
|
|
2539
|
+
var { position, scale, sizeYolk, sizeWhite, colorYolk, colorWhite, colorBackground, seed } = { ...defaults$p, ...params };
|
|
2540
|
+
|
|
2541
|
+
return runnyEggsRaw( position, scale, sizeYolk, sizeWhite, colorYolk, colorWhite, colorBackground, seed );
|
|
2542
|
+
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
runnyEggs.normal = function ( params={} ) {
|
|
2548
|
+
|
|
2549
|
+
var { position, scale, sizeYolk, sizeWhite, /*colorYolk, colorWhite, colorBackground,*/ seed } = { ...defaults$p, ...params };
|
|
2550
|
+
|
|
2551
|
+
return runnyEggsNormalRaw( position, tsl.normalLocal, tsl.tangentLocal, scale, sizeYolk, sizeWhite, /*colorYolk, colorWhite, colorBackground,*/ seed );
|
|
2552
|
+
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2555
|
+
|
|
2556
|
+
|
|
2557
|
+
runnyEggs.roughness = function ( params={} ) {
|
|
2558
|
+
|
|
2559
|
+
var { position, scale, sizeYolk, /*sizeWhite, colorYolk, colorWhite, colorBackground,*/ seed } = { ...defaults$p, ...params };
|
|
2560
|
+
|
|
2561
|
+
return runnyEggsRoughnessRaw( position, scale, sizeYolk, /*sizeWhite, colorYolk, colorWhite, colorBackground,*/ seed );
|
|
2562
|
+
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2565
|
+
|
|
2566
|
+
|
|
2567
|
+
runnyEggs.defaults = defaults$p;
|
|
2568
|
+
|
|
2569
|
+
var defaults$o = {
|
|
2570
|
+
$name: 'rust',
|
|
2571
|
+
|
|
2572
|
+
position: tsl.positionGeometry,
|
|
2573
|
+
scale: 2,
|
|
2574
|
+
iterations: 8,
|
|
2575
|
+
amount: -0.3,
|
|
2576
|
+
opacity: 0.5,
|
|
2577
|
+
noise: 0.5,
|
|
2578
|
+
noiseScale: 0.5,
|
|
2579
|
+
|
|
2580
|
+
color: new three.Color( 0xC08000 ),
|
|
2581
|
+
background: new three.Color( 0x000020 ),
|
|
2582
|
+
|
|
2583
|
+
seed: 0,
|
|
2584
|
+
};
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
var _rust = tsl.Fn( ([ position, scale, iterations, amount, seed ])=>{
|
|
2589
|
+
|
|
2590
|
+
var pos = position.mul( tsl.exp( scale.div( 4 ).add( -1 ) ) ).add( seed ).toVar( );
|
|
2591
|
+
|
|
2592
|
+
var xamount = amount.mul( tsl.mx_noise_float( pos.mul( amount.div( 2 ).add( 4 ) ) ).add( 4 ) ).toVar();
|
|
2593
|
+
|
|
2594
|
+
var k = tsl.mx_noise_float( pos ).toVar();
|
|
2595
|
+
|
|
2596
|
+
tsl.Loop( iterations, ()=>{
|
|
2597
|
+
|
|
2598
|
+
pos.mulAssign( 2 );
|
|
2599
|
+
k.addAssign( tsl.mx_noise_float( pos ) );
|
|
2600
|
+
|
|
2601
|
+
} );
|
|
2602
|
+
|
|
2603
|
+
k.subAssign( tsl.mx_noise_float( pos.mul( 2 ) ).abs() );
|
|
2604
|
+
|
|
2605
|
+
k.assign( k.sub( xamount ).clamp( 0, 15 ) );
|
|
2606
|
+
|
|
2607
|
+
return k;
|
|
2608
|
+
|
|
2609
|
+
} ).setLayout( {
|
|
2610
|
+
name: '_rust',
|
|
2611
|
+
type: 'float',
|
|
2612
|
+
inputs: [
|
|
2613
|
+
{ name: 'position', type: 'vec3' },
|
|
2614
|
+
{ name: 'scale', type: 'float' },
|
|
2615
|
+
{ name: 'iterations', type: 'int' },
|
|
2616
|
+
{ name: 'amount', type: 'float' },
|
|
2617
|
+
{ name: 'seed', type: 'float' },
|
|
2618
|
+
] }
|
|
2619
|
+
);
|
|
2620
|
+
|
|
2621
|
+
|
|
2622
|
+
var rustRaw = tsl.Fn( ([ position, scale, iterations, amount, /*opacity,*/xnoise, noiseScale, color, background, seed ])=>{
|
|
2623
|
+
|
|
2624
|
+
var k = _rust( position, scale, iterations, amount, seed ).mul( 1.25 ).pow( 0.5 );
|
|
2625
|
+
|
|
2626
|
+
var pos = position.mul( tsl.exp( scale.add( noiseScale.mul( 3 ), 2 ) ) );
|
|
2627
|
+
|
|
2628
|
+
k.addAssign( xnoise.mul( tsl.mx_noise_float( pos ).abs().add( 0.1 ).pow( 2 ) ) );
|
|
2629
|
+
|
|
2630
|
+
return tsl.mix( color, background, k );
|
|
2631
|
+
|
|
2632
|
+
} ).setLayout( {
|
|
2633
|
+
name: 'rustRaw',
|
|
2634
|
+
type: 'vec3',
|
|
2635
|
+
inputs: [
|
|
2636
|
+
{ name: 'position', type: 'vec3' },
|
|
2637
|
+
{ name: 'scale', type: 'float' },
|
|
2638
|
+
{ name: 'iterations', type: 'int' },
|
|
2639
|
+
{ name: 'amount', type: 'float' },
|
|
2640
|
+
/*{ name: 'opacity', type: 'float' },*/
|
|
2641
|
+
{ name: 'xnoise', type: 'float' },
|
|
2642
|
+
{ name: 'noiseScale', type: 'float' },
|
|
2643
|
+
{ name: 'color', type: 'vec3' },
|
|
2644
|
+
{ name: 'background', type: 'vec3' },
|
|
2645
|
+
{ name: 'seed', type: 'float' },
|
|
2646
|
+
] }
|
|
2647
|
+
);
|
|
2648
|
+
|
|
2649
|
+
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
var rustOpacityRaw = tsl.Fn( ([ position, scale, iterations, amount, opacity, /*xnoise, noiseScale, color, background,*/ seed ])=>{
|
|
2653
|
+
|
|
2654
|
+
var k = _rust( position, scale, iterations, amount, seed ).mul( opacity.add( 0.2 ) );
|
|
2655
|
+
|
|
2656
|
+
return k.oneMinus();
|
|
2657
|
+
|
|
2658
|
+
} ).setLayout( {
|
|
2659
|
+
name: 'rustOpacityRaw',
|
|
2660
|
+
type: 'float',
|
|
2661
|
+
inputs: [
|
|
2662
|
+
{ name: 'position', type: 'vec3' },
|
|
2663
|
+
{ name: 'scale', type: 'float' },
|
|
2664
|
+
{ name: 'iterations', type: 'int' },
|
|
2665
|
+
{ name: 'amount', type: 'float' },
|
|
2666
|
+
{ name: 'opacity', type: 'float' },
|
|
2667
|
+
/*{ name: 'xnoise', type: 'float' },*/
|
|
2668
|
+
/*{ name: 'noiseScale', type: 'float' },*/
|
|
2669
|
+
/*{ name: 'color', type: 'vec3' },*/
|
|
2670
|
+
/*{ name: 'background', type: 'vec3' },*/
|
|
2671
|
+
{ name: 'seed', type: 'float' },
|
|
2672
|
+
] }
|
|
2673
|
+
);
|
|
2674
|
+
|
|
2675
|
+
|
|
2676
|
+
|
|
2677
|
+
function rust( params={} ) {
|
|
2678
|
+
|
|
2679
|
+
var { position, scale, iterations, amount, /*opacity,*/ noise, noiseScale, color, background, seed } = { ...defaults$o, ...params };
|
|
2680
|
+
|
|
2681
|
+
return rustRaw( position, scale, iterations, amount, /*opacity,*/noise, noiseScale, color, background, seed );
|
|
2682
|
+
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
rust.opacity = function ( params={} ) {
|
|
2688
|
+
|
|
2689
|
+
var { position, scale, iterations, amount, opacity, /*xnoise, noiseScale, color, background,*/ seed } = { ...defaults$o, ...params };
|
|
2690
|
+
|
|
2691
|
+
return rustOpacityRaw( position, scale, iterations, amount, opacity, /*xnoise, noiseScale, color, background,*/ seed );
|
|
2692
|
+
|
|
2693
|
+
};
|
|
2694
|
+
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
rust.defaults = defaults$o;
|
|
2698
|
+
|
|
2699
|
+
var defaults$n = {
|
|
2700
|
+
$name: 'Satin',
|
|
2701
|
+
|
|
2702
|
+
position: tsl.positionGeometry,
|
|
2703
|
+
scale: 2,
|
|
2704
|
+
|
|
2705
|
+
color: new three.Color( 0x7080FF ),
|
|
2706
|
+
background: new three.Color( 0x000050 ),
|
|
2707
|
+
|
|
2708
|
+
seed: 0,
|
|
2709
|
+
};
|
|
2710
|
+
|
|
2711
|
+
|
|
2712
|
+
|
|
2713
|
+
var satinRaw = tsl.Fn( ([ position, scale, color, background, seed ]) => {
|
|
2714
|
+
|
|
2715
|
+
var pos = position.toVar( 'pos' ),
|
|
2716
|
+
scale = scale.div( 3 ).exp( ).toVar( 'xscale' );
|
|
2717
|
+
|
|
2718
|
+
var k = tsl.mx_noise_float(
|
|
2719
|
+
tsl.vec3(
|
|
2720
|
+
tsl.mx_noise_float( tsl.vec3( pos.x.mul( 2 ), pos.y, pos.z ).mul( scale ) ),
|
|
2721
|
+
tsl.mx_noise_float( tsl.vec3( pos.x, pos.y.mul( 2 ), pos.z ).mul( scale ) ),
|
|
2722
|
+
tsl.mx_noise_float( tsl.vec3( pos.x, pos.y, pos.z.mul( 2 ) ).mul( scale ) ),
|
|
2723
|
+
).mul( scale ).add( seed )
|
|
2724
|
+
).abs().pow( 3 ).mul( 20 ).toVar( 'k' );
|
|
2725
|
+
|
|
2726
|
+
return tsl.mix( background, color, k );
|
|
2727
|
+
|
|
2728
|
+
} ).setLayout( {
|
|
2729
|
+
name: 'satinRaw',
|
|
2730
|
+
type: 'vec3',
|
|
2731
|
+
inputs: [
|
|
2732
|
+
{ name: 'position', type: 'vec3' },
|
|
2733
|
+
{ name: 'scale', type: 'float' },
|
|
2734
|
+
{ name: 'color', type: 'vec3' },
|
|
2735
|
+
{ name: 'background', type: 'vec3' },
|
|
2736
|
+
{ name: 'seed', type: 'float' },
|
|
2737
|
+
] }
|
|
2738
|
+
);
|
|
2739
|
+
|
|
2740
|
+
|
|
2741
|
+
|
|
2742
|
+
function satin( params={} ) {
|
|
2743
|
+
|
|
2744
|
+
var { position, scale, color, background, seed } = { ...defaults$n, ...params };
|
|
2745
|
+
|
|
2746
|
+
return satinRaw( position, scale, color, background, seed );
|
|
2747
|
+
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
satin.defaults = defaults$n;
|
|
2753
|
+
|
|
2754
|
+
var defaults$m = {
|
|
2755
|
+
$name: 'Scaler',
|
|
2756
|
+
$positionNode: true,
|
|
2757
|
+
$selectorPlanar: true,
|
|
2758
|
+
|
|
2759
|
+
scales: new three.Vector3( 0.01, 0.9, 1.7 ),
|
|
2760
|
+
center: new three.Vector3( 0, 0, 0 ),
|
|
2761
|
+
|
|
2762
|
+
selectorCenter: new three.Vector3( 0, 0, 0 ),
|
|
2763
|
+
selectorAngles: new three.Vector2( 0, 0 ),
|
|
2764
|
+
selectorWidth: 2,
|
|
2765
|
+
|
|
2766
|
+
};
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
|
|
2770
|
+
var surfacePos$3 = tsl.Fn( ([ pos, scales, center, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
2771
|
+
|
|
2772
|
+
var zone = selectPlanar( pos, selectorAngles, selectorCenter, selectorWidth );
|
|
2773
|
+
|
|
2774
|
+
var S = tsl.mix( tsl.vec3( 1, 1, 1 ), scales, zone );
|
|
2775
|
+
|
|
2776
|
+
return pos.sub( center ).mul( S ).add( center );
|
|
2777
|
+
|
|
2778
|
+
} );
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
var scalerRaw = tsl.Fn( ([ scales, center, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
2783
|
+
|
|
2784
|
+
return surfacePos$3( tsl.positionGeometry, scales, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2785
|
+
|
|
2786
|
+
} ).setLayout( {
|
|
2787
|
+
name: 'scalerRaw',
|
|
2788
|
+
type: 'vec3',
|
|
2789
|
+
inputs: [
|
|
2790
|
+
{ name: 'scales', type: 'vec3' },
|
|
2791
|
+
{ name: 'center', type: 'vec3' },
|
|
2792
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
2793
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
2794
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
2795
|
+
]
|
|
2796
|
+
} );
|
|
2797
|
+
|
|
2798
|
+
|
|
2799
|
+
|
|
2800
|
+
var scalerNormalRaw = tsl.Fn( ([ scales, center, selectorAngles, selectorCenter, selectorWidth ]) => {
|
|
2801
|
+
|
|
2802
|
+
var EPS = 0.01;
|
|
2803
|
+
|
|
2804
|
+
var position = tsl.positionGeometry,
|
|
2805
|
+
normal = tsl.normalLocal.normalize().toVar(),
|
|
2806
|
+
tangent = tsl.tangentLocal.normalize().mul( EPS ).toVar(),
|
|
2807
|
+
bitangent = tsl.cross( normal, tangent ).normalize().mul( EPS ).toVar();
|
|
2808
|
+
|
|
2809
|
+
var pos = surfacePos$3( position, scales, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2810
|
+
var posU = surfacePos$3( position.add( tangent ), scales, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2811
|
+
var posV = surfacePos$3( position.add( bitangent ), scales, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2812
|
+
|
|
2813
|
+
return approximateNormal( pos, posU, posV );
|
|
2814
|
+
|
|
2815
|
+
} ).setLayout( {
|
|
2816
|
+
name: 'scalerNormalRaw',
|
|
2817
|
+
type: 'vec3',
|
|
2818
|
+
inputs: [
|
|
2819
|
+
{ name: 'scales', type: 'vec3' },
|
|
2820
|
+
{ name: 'center', type: 'vec3' },
|
|
2821
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
2822
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
2823
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
2824
|
+
]
|
|
2825
|
+
} );
|
|
2826
|
+
|
|
2827
|
+
|
|
2828
|
+
|
|
2829
|
+
function scaler( params={} ) {
|
|
2830
|
+
|
|
2831
|
+
var { scales, center, selectorAngles, selectorCenter, selectorWidth } = { ...defaults$m, ...params };
|
|
2832
|
+
|
|
2833
|
+
return scalerRaw( scales, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2834
|
+
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
|
|
2838
|
+
|
|
2839
|
+
scaler.normal = function ( params={} ) {
|
|
2840
|
+
|
|
2841
|
+
var { scales, center, selectorAngles, selectorCenter, selectorWidth } = { ...defaults$m, ...params };
|
|
2842
|
+
|
|
2843
|
+
return scalerNormalRaw( scales, center, selectorAngles, selectorCenter, selectorWidth );
|
|
2844
|
+
|
|
2845
|
+
};
|
|
2846
|
+
|
|
2847
|
+
|
|
2848
|
+
|
|
2849
|
+
scaler.defaults = defaults$m;
|
|
2850
|
+
|
|
2851
|
+
var defaults$l = {
|
|
2852
|
+
$name: 'Scepter head',
|
|
2853
|
+
|
|
2854
|
+
position: tsl.positionGeometry,
|
|
2855
|
+
|
|
2856
|
+
xFactor: 10,
|
|
2857
|
+
yFactor: 22,
|
|
2858
|
+
zFactor: 10,
|
|
2859
|
+
|
|
2860
|
+
colorRim: new three.Color( 0xFFFFFF ),
|
|
2861
|
+
colorA: new three.Color( 0x70E0FF ),
|
|
2862
|
+
colorB: new three.Color( 0x3000FF ),
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
|
|
2867
|
+
var scepterHeadRaw = tsl.Fn( ([ position, xFactor, yFactor, zFactor, colorRim, colorA, colorB ]) => {
|
|
2868
|
+
|
|
2869
|
+
var pos = position.toVar( 'pos' );
|
|
2870
|
+
|
|
2871
|
+
var fx = pos.x.mul( remapExp( xFactor, 0, 100, 1.35, 30 ) ).toVar( 'fx' ),
|
|
2872
|
+
fy = pos.y.mul( remapExp( yFactor, 0, 100, 1.35, 30 ) ).toVar( 'fy' ),
|
|
2873
|
+
fz = pos.z.mul( remapExp( zFactor, 0, 100, 1.35, 30 ) ).toVar( 'fz' );
|
|
2874
|
+
|
|
2875
|
+
var cosX = tsl.cos( fx ),
|
|
2876
|
+
cosY = tsl.cos( fy ),
|
|
2877
|
+
cosZ = tsl.cos( fz );
|
|
2878
|
+
|
|
2879
|
+
var k = tsl.mx_noise_float( tsl.vec3( pos.x.div( cosX ), pos.y.div( cosY ), pos.z.div( cosZ ) ) );
|
|
2880
|
+
|
|
2881
|
+
k = tsl.sign( k ).mul( tsl.abs( k ).pow( 0.75 ) );
|
|
2882
|
+
|
|
2883
|
+
var dx = tsl.abs( tsl.mul( fx, tsl.tan( fx ) ).add( 1 ).div( cosX ) ),
|
|
2884
|
+
dy = tsl.abs( tsl.mul( fy, tsl.tan( fy ) ).add( 1 ).div( cosY ) ),
|
|
2885
|
+
dz = tsl.abs( tsl.mul( fz, tsl.tan( fz ) ).add( 1 ).div( cosZ ) );
|
|
2886
|
+
|
|
2887
|
+
var HSL = tsl.vec3().toVar();
|
|
2888
|
+
|
|
2889
|
+
var indexX = ( tsl.abs( tsl.floor( ( fx.mul( 2/Math.PI ).add( 1 ) ).div( 2 ) ) ) ),
|
|
2890
|
+
indexY = ( tsl.abs( tsl.floor( ( fy.mul( 2/Math.PI ).add( 1 ) ).div( 2 ) ) ) ),
|
|
2891
|
+
indexZ = ( tsl.abs( tsl.floor( ( fz.mul( 2/Math.PI ).add( 1 ) ).div( 2 ) ) ) );
|
|
2892
|
+
|
|
2893
|
+
var index = tsl.mod( ( tsl.add( indexX, indexY, indexZ ) ), 2 );
|
|
2894
|
+
|
|
2895
|
+
HSL.assign( toHsl( tsl.mix( colorA, colorB, index ) ) );
|
|
2896
|
+
var color1 = hsl( tsl.vec3( HSL.xy, HSL.z.mul( k ) ) ).toVar( 'color1' );
|
|
2897
|
+
|
|
2898
|
+
HSL.assign( toHsl( colorRim ) );
|
|
2899
|
+
var color2 = hsl( tsl.vec3( HSL.xy, tsl.mul( 2, k, HSL.z ) ) ).toVar( 'color2' );
|
|
2900
|
+
|
|
2901
|
+
return tsl.mix( color1, color2, tsl.remapClamp( tsl.max( dx, tsl.max( dy, dz ) ), 55-10, 55+10 ) );
|
|
2902
|
+
|
|
2903
|
+
} ).setLayout( {
|
|
2904
|
+
name: 'scepterHeadRaw',
|
|
2905
|
+
type: 'vec3',
|
|
2906
|
+
inputs: [
|
|
2907
|
+
{ name: 'position', type: 'vec3' },
|
|
2908
|
+
{ name: 'xFactor', type: 'float' },
|
|
2909
|
+
{ name: 'yFactor', type: 'float' },
|
|
2910
|
+
{ name: 'zFactor', type: 'float' },
|
|
2911
|
+
{ name: 'colorRim', type: 'vec3' },
|
|
2912
|
+
{ name: 'colorA', type: 'vec3' },
|
|
2913
|
+
{ name: 'colorB', type: 'vec3' },
|
|
2914
|
+
] }
|
|
2915
|
+
);
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
function scepterHead( params={} ) {
|
|
2920
|
+
|
|
2921
|
+
var { position, xFactor, yFactor, zFactor, colorRim, colorA, colorB } = { ...defaults$l, ...params };
|
|
2922
|
+
|
|
2923
|
+
return scepterHeadRaw( position, xFactor, yFactor, zFactor, colorRim, colorA, colorB );
|
|
2924
|
+
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
|
|
2928
|
+
|
|
2929
|
+
scepterHead.defaults = defaults$l;
|
|
2930
|
+
|
|
2931
|
+
var defaults$k = {
|
|
2932
|
+
$name: 'Scream',
|
|
2933
|
+
|
|
2934
|
+
position: tsl.positionGeometry,
|
|
2935
|
+
scale: 2,
|
|
2936
|
+
variety: 1,
|
|
2937
|
+
|
|
2938
|
+
color: new three.Color( 0xF0F060 ),
|
|
2939
|
+
background: new three.Color( 0xD09090 ),
|
|
2940
|
+
|
|
2941
|
+
seed: 0,
|
|
2942
|
+
};
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
|
|
2946
|
+
var screamRaw = tsl.Fn( ([ position, scale, variety, color, background, seed ]) => {
|
|
2947
|
+
|
|
2948
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed ).toVar( 'pos' );
|
|
2949
|
+
|
|
2950
|
+
var k = tsl.mx_noise_float( tsl.add( tsl.sin( pos.xyz ), tsl.cos( pos.yzx ) ) );
|
|
2951
|
+
|
|
2952
|
+
pos.assign( position.mul( tsl.exp( scale ).mul( k ) ).add( seed ) );
|
|
2953
|
+
|
|
2954
|
+
var k = tsl.mx_noise_float( tsl.add( tsl.sin( pos.xyz ), tsl.cos( pos.yzx ) ).mul( 2 ) );
|
|
2955
|
+
|
|
2956
|
+
var col = tsl.mix( background, color, k ).toVar( 'col' );
|
|
2957
|
+
|
|
2958
|
+
var HSL = toHsl( col ).toVar( 'HSL' );
|
|
2959
|
+
|
|
2960
|
+
return hsl( tsl.vec3( tsl.add( HSL.x, variety.mul( tsl.sin( k.mul( Math.PI ) ) ).mul( 0.5 ) ), HSL.yz ) );
|
|
2961
|
+
|
|
2962
|
+
} ).setLayout( {
|
|
2963
|
+
name: 'satinRaw',
|
|
2964
|
+
type: 'vec3',
|
|
2965
|
+
inputs: [
|
|
2966
|
+
{ name: 'position', type: 'vec3' },
|
|
2967
|
+
{ name: 'scale', type: 'float' },
|
|
2968
|
+
{ name: 'variety', type: 'float' },
|
|
2969
|
+
{ name: 'color', type: 'vec3' },
|
|
2970
|
+
{ name: 'background', type: 'vec3' },
|
|
2971
|
+
{ name: 'seed', type: 'float' },
|
|
2972
|
+
] }
|
|
2973
|
+
);
|
|
2974
|
+
|
|
2975
|
+
|
|
2976
|
+
|
|
2977
|
+
function scream( params={} ) {
|
|
2978
|
+
|
|
2979
|
+
var { position, scale, variety, color, background, seed } = { ...defaults$k, ...params };
|
|
2980
|
+
|
|
2981
|
+
return screamRaw( position, scale, variety, color, background, seed );
|
|
2982
|
+
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
|
|
2986
|
+
|
|
2987
|
+
scream.defaults = defaults$k;
|
|
2988
|
+
|
|
2989
|
+
var defaults$j = {
|
|
2990
|
+
$name: 'Stars',
|
|
2991
|
+
|
|
2992
|
+
position: tsl.positionGeometry,
|
|
2993
|
+
scale: 2,
|
|
2994
|
+
density: 2,
|
|
2995
|
+
variation: 0,
|
|
2996
|
+
|
|
2997
|
+
color: new three.Color( 0xfff5f0 ),
|
|
2998
|
+
background: new three.Color( 0x000060 ),
|
|
2999
|
+
|
|
3000
|
+
seed: 0,
|
|
3001
|
+
};
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
|
|
3005
|
+
var starsRaw = tsl.Fn( ([ position, scale, density, variation, color, background, seed ]) => {
|
|
3006
|
+
|
|
3007
|
+
var pos = position.mul( tsl.exp( scale.div( 2 ).add( 3 ) ) ).add( seed ).toVar( );
|
|
3008
|
+
|
|
3009
|
+
var k = tsl.abs( tsl.mx_noise_float( pos ) ).pow( 10 ).mul( 10 );
|
|
3010
|
+
|
|
3011
|
+
k = k.mul( tsl.exp( density.sub( 2 ) ) );
|
|
3012
|
+
|
|
3013
|
+
var dS = tsl.select( k.greaterThan( 0.1 ), variation.mul( tsl.mx_noise_float( pos ) ), 0 );
|
|
3014
|
+
|
|
3015
|
+
var col = toHsl( tsl.mix( background, color, k ) );
|
|
3016
|
+
|
|
3017
|
+
return hsl( tsl.vec3( tsl.add( col.x, dS ), col.yz ) );
|
|
3018
|
+
|
|
3019
|
+
} ).setLayout( {
|
|
3020
|
+
name: 'starsRaw',
|
|
3021
|
+
type: 'vec3',
|
|
3022
|
+
inputs: [
|
|
3023
|
+
{ name: 'position', type: 'vec3' },
|
|
3024
|
+
{ name: 'scale', type: 'float' },
|
|
3025
|
+
{ name: 'density', type: 'float' },
|
|
3026
|
+
{ name: 'variation', type: 'float' },
|
|
3027
|
+
{ name: 'color', type: 'vec3' },
|
|
3028
|
+
{ name: 'background', type: 'vec3' },
|
|
3029
|
+
{ name: 'seed', type: 'float' },
|
|
3030
|
+
] }
|
|
3031
|
+
);
|
|
3032
|
+
|
|
3033
|
+
|
|
3034
|
+
|
|
3035
|
+
function stars( params={} ) {
|
|
3036
|
+
|
|
3037
|
+
var { position, scale, density, variation, color, background, seed } = { ...defaults$j, ...params };
|
|
3038
|
+
|
|
3039
|
+
return starsRaw( position, scale, density, variation, color, background, seed );
|
|
3040
|
+
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
|
|
3044
|
+
|
|
3045
|
+
stars.defaults = defaults$j;
|
|
3046
|
+
|
|
3047
|
+
var defaults$i = {
|
|
3048
|
+
$name: 'Static noise',
|
|
3049
|
+
|
|
3050
|
+
position: tsl.screenCoordinate,
|
|
3051
|
+
time: tsl.time,
|
|
3052
|
+
|
|
3053
|
+
scale: 2,
|
|
3054
|
+
balance: 0,
|
|
3055
|
+
contrast: 0,
|
|
3056
|
+
|
|
3057
|
+
delay: 0,
|
|
3058
|
+
|
|
3059
|
+
seed: 0,
|
|
3060
|
+
};
|
|
3061
|
+
|
|
3062
|
+
|
|
3063
|
+
|
|
3064
|
+
var staticNoiseRaw = tsl.Fn( ([ position, time, scale, balance, contrast, delay, seed ]) => {
|
|
3065
|
+
|
|
3066
|
+
var pos = position.div( tsl.exp( scale ) ).add( seed );
|
|
3067
|
+
|
|
3068
|
+
var speed = delay.sub( 1 ).mul( 5 ).exp(),
|
|
3069
|
+
t = time.div( speed ).round().mul( speed );
|
|
3070
|
+
|
|
3071
|
+
var offset = vnoise( t.sin() ).mul( 1000 );
|
|
3072
|
+
|
|
3073
|
+
var k = tsl.mx_noise_float( pos.add( offset ) ).min( 1 );
|
|
3074
|
+
|
|
3075
|
+
k = k.mul( 0.5, tsl.exp( contrast ) ).add( 0.5, balance );
|
|
3076
|
+
|
|
3077
|
+
return tsl.vec3( k );
|
|
3078
|
+
|
|
3079
|
+
} ).setLayout( {
|
|
3080
|
+
name: 'staticNoiseRaw',
|
|
3081
|
+
type: 'vec3',
|
|
3082
|
+
inputs: [
|
|
3083
|
+
{ name: 'position', type: 'vec2' },
|
|
3084
|
+
{ name: 'time', type: 'float' },
|
|
3085
|
+
{ name: 'scale', type: 'float' },
|
|
3086
|
+
{ name: 'balance', type: 'float' },
|
|
3087
|
+
{ name: 'contrast', type: 'float' },
|
|
3088
|
+
{ name: 'delay', type: 'float' },
|
|
3089
|
+
{ name: 'seed', type: 'float' },
|
|
3090
|
+
] }
|
|
3091
|
+
);
|
|
3092
|
+
|
|
3093
|
+
|
|
3094
|
+
|
|
3095
|
+
function staticNoise( params={} ) {
|
|
3096
|
+
|
|
3097
|
+
var { position, time, scale, balance, contrast, delay, seed } = { ...defaults$i, ...params };
|
|
3098
|
+
|
|
3099
|
+
return staticNoiseRaw( position, time, scale, balance, contrast, delay, seed );
|
|
3100
|
+
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
|
|
3104
|
+
|
|
3105
|
+
staticNoise.defaults = defaults$i;
|
|
3106
|
+
|
|
3107
|
+
var defaults$h = {
|
|
3108
|
+
$name: 'Supersphere',
|
|
3109
|
+
$positionNode: true,
|
|
3110
|
+
|
|
3111
|
+
exponent: 3,
|
|
3112
|
+
|
|
3113
|
+
};
|
|
3114
|
+
|
|
3115
|
+
|
|
3116
|
+
|
|
3117
|
+
var surfacePos$2 = tsl.Fn( ([ pos, exponent ])=>{
|
|
3118
|
+
|
|
3119
|
+
var xexponent = tsl.float( 2 ).pow( exponent );
|
|
3120
|
+
var equPos = pos.div( pos.length() ).toVar();
|
|
3121
|
+
var equPos2 = equPos.abs().pow( xexponent ).toVar();
|
|
3122
|
+
|
|
3123
|
+
var p = equPos2.x
|
|
3124
|
+
.add( equPos2.y )
|
|
3125
|
+
.add( equPos2.z )
|
|
3126
|
+
.pow( xexponent.reciprocal( ) );
|
|
3127
|
+
|
|
3128
|
+
return equPos.div( p );
|
|
3129
|
+
|
|
3130
|
+
} ).setLayout( {
|
|
3131
|
+
name: 'surfacePos',
|
|
3132
|
+
type: 'vec3',
|
|
3133
|
+
inputs: [
|
|
3134
|
+
{ name: 'pos', type: 'vec3' },
|
|
3135
|
+
{ name: 'exponent', type: 'float' },
|
|
3136
|
+
]
|
|
3137
|
+
} );
|
|
3138
|
+
|
|
3139
|
+
|
|
3140
|
+
|
|
3141
|
+
var supersphereRaw = tsl.Fn( ([ exponent ])=>{
|
|
3142
|
+
|
|
3143
|
+
return surfacePos$2( tsl.positionGeometry, exponent );
|
|
3144
|
+
|
|
3145
|
+
} ).setLayout( {
|
|
3146
|
+
name: 'supersphereRaw',
|
|
3147
|
+
type: 'vec3',
|
|
3148
|
+
inputs: [
|
|
3149
|
+
{ name: 'exponent', type: 'float' },
|
|
3150
|
+
]
|
|
3151
|
+
} );
|
|
3152
|
+
|
|
3153
|
+
|
|
3154
|
+
|
|
3155
|
+
var supersphereNormalRaw = tsl.Fn( ([ exponent ]) => {
|
|
3156
|
+
|
|
3157
|
+
const EPS = 0.01;
|
|
3158
|
+
|
|
3159
|
+
var position = tsl.positionGeometry,
|
|
3160
|
+
normal = tsl.normalLocal.normalize().toVar(),
|
|
3161
|
+
tangent = tsl.tangentLocal.normalize().mul( EPS ).toVar(),
|
|
3162
|
+
bitangent = tsl.cross( normal, tangent ).normalize().mul( EPS ).toVar();
|
|
3163
|
+
|
|
3164
|
+
var pos = surfacePos$2( position, exponent );
|
|
3165
|
+
var posU = surfacePos$2( position.add( tangent ), exponent );
|
|
3166
|
+
var posV = surfacePos$2( position.add( bitangent ), exponent );
|
|
3167
|
+
|
|
3168
|
+
return approximateNormal( pos, posU, posV );
|
|
3169
|
+
|
|
3170
|
+
} ).setLayout( {
|
|
3171
|
+
name: 'supersphereRaw',
|
|
3172
|
+
type: 'vec3',
|
|
3173
|
+
inputs: [
|
|
3174
|
+
{ name: 'exponent', type: 'float' },
|
|
3175
|
+
]
|
|
3176
|
+
} );
|
|
3177
|
+
|
|
3178
|
+
|
|
3179
|
+
|
|
3180
|
+
function supersphere( params={} ) {
|
|
3181
|
+
|
|
3182
|
+
var { exponent } = { ...defaults$h, ...params };
|
|
3183
|
+
|
|
3184
|
+
return supersphereRaw( exponent );
|
|
3185
|
+
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
supersphere.normal = function ( params={} ) {
|
|
3191
|
+
|
|
3192
|
+
var { exponent } = { ...defaults$h, ...params };
|
|
3193
|
+
|
|
3194
|
+
return supersphereNormalRaw( exponent );
|
|
3195
|
+
|
|
3196
|
+
};
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
supersphere.defaults = defaults$h;
|
|
3201
|
+
|
|
3202
|
+
var defaults$g = {
|
|
3203
|
+
$name: 'Tiger fur',
|
|
3204
|
+
|
|
3205
|
+
position: tsl.positionGeometry,
|
|
3206
|
+
scale: 2,
|
|
3207
|
+
lengths: 4,
|
|
3208
|
+
blur: 0.3,
|
|
3209
|
+
strength: 0.3,
|
|
3210
|
+
hairs: 0.5,
|
|
3211
|
+
|
|
3212
|
+
color: new three.Color( 0xFFAA00 ),
|
|
3213
|
+
bottomColor: new three.Color( 0xFFFFEE ),
|
|
3214
|
+
|
|
3215
|
+
seed: 0,
|
|
3216
|
+
};
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
|
|
3220
|
+
var tigerFurRaw = tsl.Fn( ([ position, scale, lengths, blur, strength, hairs, color, bottomColor, seed ])=>{
|
|
3221
|
+
|
|
3222
|
+
var xscale = scale.div( 2 ).add( 1 ).toVar();
|
|
3223
|
+
var pos = position.mul( tsl.exp( xscale ) ).add( seed ).toVar( );
|
|
3224
|
+
|
|
3225
|
+
var len = lengths.add( 5 ).reciprocal().toVar();
|
|
3226
|
+
var hairs = hairs.mul( 0.3 ).toVar();
|
|
3227
|
+
var k = tsl.mx_noise_float( pos.mul( xscale, tsl.vec3( 1, len, len ) ) );
|
|
3228
|
+
k = k.add( tsl.mx_noise_float( pos.mul( tsl.vec3( 25, 1, 1 ) ) ).add( 1 ).mul( hairs ) );
|
|
3229
|
+
k = k.add( strength.sub( 0.5 ) ).smoothstep( blur.negate(), blur ).oneMinus();
|
|
3230
|
+
|
|
3231
|
+
var n = position.y.add( hairs.sub( 0.5 ) ).smoothstep( -1, 0.5 );
|
|
3232
|
+
|
|
3233
|
+
return tsl.mix( bottomColor, color, n ).mul( k );
|
|
3234
|
+
|
|
3235
|
+
} ).setLayout( {
|
|
3236
|
+
name: 'tigerFurRaw',
|
|
3237
|
+
type: 'vec3',
|
|
3238
|
+
inputs: [
|
|
3239
|
+
{ name: 'position', type: 'vec3' },
|
|
3240
|
+
{ name: 'scale', type: 'float' },
|
|
3241
|
+
{ name: 'lengths', type: 'float' },
|
|
3242
|
+
{ name: 'blur', type: 'float' },
|
|
3243
|
+
{ name: 'strength', type: 'float' },
|
|
3244
|
+
{ name: 'hairs', type: 'float' },
|
|
3245
|
+
{ name: 'color', type: 'vec3' },
|
|
3246
|
+
{ name: 'bottomColor', type: 'vec3' },
|
|
3247
|
+
{ name: 'seed', type: 'float' },
|
|
3248
|
+
] }
|
|
3249
|
+
);
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
function tigerFur( params={} ) {
|
|
3254
|
+
|
|
3255
|
+
var { position, scale, lengths, blur, strength, hairs, color, bottomColor, seed } = { ...defaults$g, ...params };
|
|
3256
|
+
|
|
3257
|
+
return tigerFurRaw( position, scale, lengths, blur, strength, hairs, color, bottomColor, seed );
|
|
3258
|
+
|
|
3259
|
+
}
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
tigerFur.defaults = defaults$g;
|
|
3264
|
+
|
|
3265
|
+
var defaults$f = {
|
|
3266
|
+
$name: 'Translator',
|
|
3267
|
+
$positionNode: true,
|
|
3268
|
+
$selectorPlanar: true,
|
|
3269
|
+
|
|
3270
|
+
distance: new three.Vector3( -0.5, 0, 0.2 ),
|
|
3271
|
+
|
|
3272
|
+
selectorCenter: new three.Vector3( 0, 0, 0 ),
|
|
3273
|
+
selectorAngles: new three.Vector2( 0, 0 ),
|
|
3274
|
+
selectorWidth: 0.7,
|
|
3275
|
+
|
|
3276
|
+
};
|
|
3277
|
+
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
var surfacePos$1 = tsl.Fn( ([ pos, distance, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
3281
|
+
|
|
3282
|
+
var zone = selectPlanar( pos, selectorAngles, selectorCenter, selectorWidth );
|
|
3283
|
+
|
|
3284
|
+
return pos.add( distance.mul( zone ) );
|
|
3285
|
+
|
|
3286
|
+
} ).setLayout( {
|
|
3287
|
+
name: 'surfacePos',
|
|
3288
|
+
type: 'vec3',
|
|
3289
|
+
inputs: [
|
|
3290
|
+
{ name: 'pos', type: 'vec3' },
|
|
3291
|
+
{ name: 'distance', type: 'vec3' },
|
|
3292
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
3293
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
3294
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
3295
|
+
]
|
|
3296
|
+
} );
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
var translatorRaw = tsl.Fn( ([ distance, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
3301
|
+
|
|
3302
|
+
return surfacePos$1( tsl.positionGeometry, distance, selectorAngles, selectorCenter, selectorWidth );
|
|
3303
|
+
|
|
3304
|
+
} ).setLayout( {
|
|
3305
|
+
name: 'translatorRaw',
|
|
3306
|
+
type: 'vec3',
|
|
3307
|
+
inputs: [
|
|
3308
|
+
{ name: 'distance', type: 'vec3' },
|
|
3309
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
3310
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
3311
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
3312
|
+
]
|
|
3313
|
+
} );
|
|
3314
|
+
|
|
3315
|
+
|
|
3316
|
+
|
|
3317
|
+
var translatorNormalRaw = tsl.Fn( ([ distance, selectorAngles, selectorCenter, selectorWidth ])=>{
|
|
3318
|
+
|
|
3319
|
+
var EPS = 0.01;
|
|
3320
|
+
|
|
3321
|
+
var position = tsl.positionGeometry,
|
|
3322
|
+
normal = tsl.normalLocal.normalize().toVar(),
|
|
3323
|
+
tangent = tsl.tangentLocal.normalize().mul( EPS ).toVar(),
|
|
3324
|
+
bitangent = tsl.cross( normal, tangent ).normalize().mul( EPS ).toVar();
|
|
3325
|
+
|
|
3326
|
+
var pos = surfacePos$1( position, distance, selectorAngles, selectorCenter, selectorWidth );
|
|
3327
|
+
var posU = surfacePos$1( position.add( tangent ), distance, selectorAngles, selectorCenter, selectorWidth );
|
|
3328
|
+
var posV = surfacePos$1( position.add( bitangent ), distance, selectorAngles, selectorCenter, selectorWidth );
|
|
3329
|
+
|
|
3330
|
+
return approximateNormal( pos, posU, posV );
|
|
3331
|
+
|
|
3332
|
+
} ).setLayout( {
|
|
3333
|
+
name: 'translatorNormalRaw',
|
|
3334
|
+
type: 'vec3',
|
|
3335
|
+
inputs: [
|
|
3336
|
+
{ name: 'distance', type: 'vec3' },
|
|
3337
|
+
{ name: 'selectorAngles', type: 'vec2' },
|
|
3338
|
+
{ name: 'selectorCenter', type: 'vec3' },
|
|
3339
|
+
{ name: 'selectorWidth', type: 'float' },
|
|
3340
|
+
]
|
|
3341
|
+
} );
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
|
|
3345
|
+
function translator( params={} ) {
|
|
3346
|
+
|
|
3347
|
+
var { distance, selectorAngles, selectorCenter, selectorWidth } = { ...defaults$f, ...params };
|
|
3348
|
+
|
|
3349
|
+
return translatorRaw( distance, selectorAngles, selectorCenter, selectorWidth );
|
|
3350
|
+
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
|
|
3354
|
+
|
|
3355
|
+
translator.normal = function ( params={} ) {
|
|
3356
|
+
|
|
3357
|
+
var { distance, selectorAngles, selectorCenter, selectorWidth } = { ...defaults$f, ...params };
|
|
3358
|
+
|
|
3359
|
+
return translatorNormalRaw( distance, selectorAngles, selectorCenter, selectorWidth );
|
|
3360
|
+
|
|
3361
|
+
};
|
|
3362
|
+
|
|
3363
|
+
|
|
3364
|
+
|
|
3365
|
+
translator.defaults = defaults$f;
|
|
3366
|
+
|
|
3367
|
+
var defaults$e = {
|
|
3368
|
+
$name: 'Voronoi cells',
|
|
3369
|
+
|
|
3370
|
+
position: tsl.positionGeometry,
|
|
3371
|
+
scale: 2,
|
|
3372
|
+
variation: 0,
|
|
3373
|
+
facet: 0,
|
|
3374
|
+
|
|
3375
|
+
color: new three.Color( 0 ),
|
|
3376
|
+
background: new three.Color( 0xc0d0ff ),
|
|
3377
|
+
|
|
3378
|
+
seed: 0,
|
|
3379
|
+
};
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
var voronoiCellsRaw = tsl.Fn( ([ position, scale, variation, facet, color, background, seed ])=>{
|
|
3384
|
+
|
|
3385
|
+
var pos = position.mul( tsl.exp( scale.div( 2 ).add( 0.5 ) ) ).add( seed ).toVar( );
|
|
3386
|
+
|
|
3387
|
+
var midCell = pos.round().toVar();
|
|
3388
|
+
|
|
3389
|
+
var minCell = midCell.toVar();
|
|
3390
|
+
var minDist = tsl.float( 1 ).toVar();
|
|
3391
|
+
|
|
3392
|
+
var cell = tsl.vec3().toVar();
|
|
3393
|
+
var dist = tsl.float().toVar();
|
|
3394
|
+
|
|
3395
|
+
var i=tsl.int( 0 ).toVar( 'i' ),
|
|
3396
|
+
j=tsl.int( 0 ).toVar( 'j' ),
|
|
3397
|
+
k=tsl.int( 0 ).toVar( 'k' );
|
|
3398
|
+
|
|
3399
|
+
// Loop uses hard-coded i, j, k as indices
|
|
3400
|
+
tsl.Loop( 3, 3, 3, () => {
|
|
3401
|
+
|
|
3402
|
+
cell.assign( midCell.add( tsl.vec3( i, j, k ).sub( 1 ) ) );
|
|
3403
|
+
//var cellCenter = cell.add( noise( cell.mul( Math.PI ) ) ); // too slow on WebGL2
|
|
3404
|
+
var cellCenter = cell.add( vnoise( cell.mul( Math.PI*2 ) ).div( 2 ) );
|
|
3405
|
+
dist.assign( pos.distance( cellCenter ) );
|
|
3406
|
+
|
|
3407
|
+
tsl.If( dist.lessThan( minDist ), ()=>{
|
|
3408
|
+
|
|
3409
|
+
minDist.assign( dist );
|
|
3410
|
+
minCell.assign( cell );
|
|
3411
|
+
|
|
3412
|
+
} );
|
|
3413
|
+
|
|
3414
|
+
} );
|
|
3415
|
+
|
|
3416
|
+
var n = tsl.mx_noise_float( minCell.mul( Math.PI ) ).toVar();
|
|
3417
|
+
var m = tsl.mix( minDist, n.add( 1 ).div( 2 ), facet );
|
|
3418
|
+
|
|
3419
|
+
var color = tsl.mix( color, background, m ).toVar();
|
|
3420
|
+
var randomColor = tsl.vec3( n.mul( 16.8 ), n.mul( 31.4159 ), n.mul( 27.1828 ) ).sin().add( 1 ).div( 2 );
|
|
3421
|
+
|
|
3422
|
+
return tsl.mix( color, tsl.mix( color, randomColor, variation ), variation );
|
|
3423
|
+
|
|
3424
|
+
} ).setLayout( {
|
|
3425
|
+
name: 'voronoiCellsRaw',
|
|
3426
|
+
type: 'vec3',
|
|
3427
|
+
inputs: [
|
|
3428
|
+
{ name: 'position', type: 'vec3' },
|
|
3429
|
+
{ name: 'scale', type: 'float' },
|
|
3430
|
+
{ name: 'variation', type: 'float' },
|
|
3431
|
+
{ name: 'facet', type: 'float' },
|
|
3432
|
+
{ name: 'color', type: 'vec3' },
|
|
3433
|
+
{ name: 'background', type: 'vec3' },
|
|
3434
|
+
{ name: 'seed', type: 'float' },
|
|
3435
|
+
] }
|
|
3436
|
+
);
|
|
3437
|
+
|
|
3438
|
+
|
|
3439
|
+
|
|
3440
|
+
function voronoiCells( params={} ) {
|
|
3441
|
+
|
|
3442
|
+
var { position, scale, variation, facet, color, background, seed } = { ...defaults$e, ...params };
|
|
3443
|
+
|
|
3444
|
+
return voronoiCellsRaw( position, scale, variation, facet, color, background, seed );
|
|
3445
|
+
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
voronoiCells.defaults = defaults$e;
|
|
3451
|
+
|
|
3452
|
+
var defaults$d = {
|
|
3453
|
+
$name: 'Water Drops',
|
|
3454
|
+
$normalNode: true,
|
|
3455
|
+
|
|
3456
|
+
position: tsl.positionGeometry,
|
|
3457
|
+
|
|
3458
|
+
scale: 1.4,
|
|
3459
|
+
density: 0.5,
|
|
3460
|
+
bump: 0.6,
|
|
3461
|
+
|
|
3462
|
+
seed: 0,
|
|
3463
|
+
};
|
|
3464
|
+
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
var surfacePos = tsl.Fn( ([ pos, normal, density ]) => {
|
|
3468
|
+
|
|
3469
|
+
var k = tsl.mx_noise_float( pos, 1, density ).clamp( 0, 1 );
|
|
3470
|
+
k = tsl.cos( k.mul( Math.PI ) ).add( 1 ).pow( 0.5 ).toVar();
|
|
3471
|
+
|
|
3472
|
+
return pos.add( normal.mul( k ) );
|
|
3473
|
+
|
|
3474
|
+
} ).setLayout( {
|
|
3475
|
+
name: 'surfacePos',
|
|
3476
|
+
type: 'vec3',
|
|
3477
|
+
inputs: [
|
|
3478
|
+
{ name: 'position', type: 'vec3' },
|
|
3479
|
+
{ name: 'normal', type: 'vec3' },
|
|
3480
|
+
{ name: 'density', type: 'float' },
|
|
3481
|
+
] }
|
|
3482
|
+
);
|
|
3483
|
+
|
|
3484
|
+
|
|
3485
|
+
|
|
3486
|
+
var waterDropsRaw = tsl.Fn( ([ position, normal, tangent, scale, density, bump, seed ]) => {
|
|
3487
|
+
|
|
3488
|
+
var EPS = 0.001;
|
|
3489
|
+
|
|
3490
|
+
var seed3d = tsl.vec3( 1, 2, 3 ).mul( seed ).sin().mul( 100 ).toVar( );
|
|
3491
|
+
|
|
3492
|
+
var xposition = position.mul( tsl.exp( scale.div( 1 ).add( 1 ) ) ).add( seed3d ).toVar( ),
|
|
3493
|
+
xnormal = normal.normalize().toVar(),
|
|
3494
|
+
xtangent = tangent.normalize().mul( EPS ).toVar(),
|
|
3495
|
+
xbitangent = tsl.cross( xnormal, xtangent ).normalize().mul( EPS ).toVar();
|
|
3496
|
+
|
|
3497
|
+
var xdensity = tsl.remap( density, 0, 1, 1.5, 0.7 ).toVar();
|
|
3498
|
+
|
|
3499
|
+
xnormal.mulAssign( bump );
|
|
3500
|
+
|
|
3501
|
+
var pos = surfacePos( xposition, xnormal, xdensity ),
|
|
3502
|
+
posU = surfacePos( xposition.add( xtangent ), xnormal, xdensity ),
|
|
3503
|
+
posV = surfacePos( xposition.add( xbitangent ), xnormal, xdensity );
|
|
3504
|
+
|
|
3505
|
+
return approximateNormal( pos, posU, posV );
|
|
3506
|
+
|
|
3507
|
+
} ).setLayout( {
|
|
3508
|
+
name: 'waterDropsRaw',
|
|
3509
|
+
type: 'vec3',
|
|
3510
|
+
inputs: [
|
|
3511
|
+
{ name: 'position', type: 'vec3' },
|
|
3512
|
+
{ name: 'normal', type: 'vec3' },
|
|
3513
|
+
{ name: 'tangent', type: 'vec3' },
|
|
3514
|
+
{ name: 'scale', type: 'float' },
|
|
3515
|
+
{ name: 'density', type: 'float' },
|
|
3516
|
+
{ name: 'bump', type: 'float' },
|
|
3517
|
+
{ name: 'seed', type: 'float' },
|
|
3518
|
+
] }
|
|
3519
|
+
);
|
|
3520
|
+
|
|
3521
|
+
|
|
3522
|
+
|
|
3523
|
+
function waterDrops( params={} ) {
|
|
3524
|
+
|
|
3525
|
+
var { position, scale, density, bump, seed } = { ...defaults$d, ...params };
|
|
3526
|
+
|
|
3527
|
+
return waterDropsRaw( position, tsl.normalLocal, tsl.tangentLocal, scale, density, bump, seed );
|
|
3528
|
+
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
|
|
3533
|
+
waterDrops.defaults = defaults$d;
|
|
3534
|
+
|
|
3535
|
+
var defaults$c = {
|
|
3536
|
+
$name: 'Watermelon',
|
|
3537
|
+
$replaceExportUVS: tsl.screenUV,
|
|
3538
|
+
|
|
3539
|
+
position: tsl.positionGeometry,
|
|
3540
|
+
uvs: tsl.equirectUV( tsl.positionGeometry.normalize() ),
|
|
3541
|
+
|
|
3542
|
+
scale: 2,
|
|
3543
|
+
stripes: 12,
|
|
3544
|
+
variation: 0.5,
|
|
3545
|
+
noise: 0.25,
|
|
3546
|
+
|
|
3547
|
+
color: new three.Color( 'yellowgreen' ),
|
|
3548
|
+
background: new three.Color( 'darkgreen' ),
|
|
3549
|
+
|
|
3550
|
+
seed: 0,
|
|
3551
|
+
};
|
|
3552
|
+
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
var watermelonRaw = tsl.Fn( ([ position, uvs, scale, stripes, variation, xnoise, color, background, seed ])=>{
|
|
3556
|
+
|
|
3557
|
+
var pos = position.mul( tsl.exp( scale.div( 4 ).add( 2 ) ) ).add( seed ).toVar( );
|
|
3558
|
+
|
|
3559
|
+
var a = uvs.x.mul( stripes, 2*Math.PI ).add( tsl.mx_noise_float( pos.mul( tsl.vec3( 1, 0.3, 1 ) ) ).mul( 2 ) );
|
|
3560
|
+
|
|
3561
|
+
var k = a.sin().add( 0.5 ).div( 2 ).mul( uvs.y.remap( 0, 1, -Math.PI, Math.PI ).cos().add( 1.2 ).clamp( 0, 1 ) )
|
|
3562
|
+
.add( variation.mul( 2, tsl.mx_noise_float( pos.mul( 1.5 ) ).div( 2 ) ) )
|
|
3563
|
+
.add( variation.mul( 2, tsl.mx_noise_float( pos.mul( 4 ) ).div( 6 ) ) )
|
|
3564
|
+
.toVar();
|
|
3565
|
+
|
|
3566
|
+
k.assign(
|
|
3567
|
+
k.mix( k.round(), 0.75 )
|
|
3568
|
+
.add( tsl.mx_noise_float( pos.mul( 2 ) ).mul( xnoise, 0.5 ) )
|
|
3569
|
+
.add( tsl.mx_noise_float( pos.mul( 3 ) ).mul( xnoise, 1 ) )
|
|
3570
|
+
.add( tsl.mx_noise_float( pos.mul( 15 ) ).mul( xnoise, 0.2 ) )
|
|
3571
|
+
.clamp( 0, 1 )
|
|
3572
|
+
);
|
|
3573
|
+
|
|
3574
|
+
var color = tsl.mix( background, color, k ).toVar();
|
|
3575
|
+
|
|
3576
|
+
return color;
|
|
3577
|
+
|
|
3578
|
+
} ).setLayout( {
|
|
3579
|
+
name: 'watermelonRaw',
|
|
3580
|
+
type: 'vec3',
|
|
3581
|
+
inputs: [
|
|
3582
|
+
{ name: 'position', type: 'vec3' },
|
|
3583
|
+
{ name: 'uvs', type: 'vec2' },
|
|
3584
|
+
{ name: 'scale', type: 'float' },
|
|
3585
|
+
{ name: 'stripes', type: 'int' },
|
|
3586
|
+
{ name: 'variation', type: 'float' },
|
|
3587
|
+
{ name: 'xnoise', type: 'float' },
|
|
3588
|
+
{ name: 'color', type: 'vec3' },
|
|
3589
|
+
{ name: 'background', type: 'vec3' },
|
|
3590
|
+
{ name: 'seed', type: 'float' },
|
|
3591
|
+
] }
|
|
3592
|
+
);
|
|
3593
|
+
|
|
3594
|
+
|
|
3595
|
+
|
|
3596
|
+
function watermelon( params={} ) {
|
|
3597
|
+
|
|
3598
|
+
var { position, uvs, scale, stripes, variation, noise, color, background, seed } = { ...defaults$c, ...params };
|
|
3599
|
+
|
|
3600
|
+
return watermelonRaw( position, uvs, scale, stripes, variation, noise, color, background, seed );
|
|
3601
|
+
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
|
|
3605
|
+
|
|
3606
|
+
watermelon.defaults = defaults$c;
|
|
3607
|
+
|
|
3608
|
+
var defaults$b = {
|
|
3609
|
+
$name: 'Waves',
|
|
3610
|
+
|
|
3611
|
+
position: tsl.positionGeometry,
|
|
3612
|
+
scale: 2,
|
|
3613
|
+
speed: 0,
|
|
3614
|
+
time: tsl.time,
|
|
3615
|
+
level: -0.4,
|
|
3616
|
+
rough: 10,
|
|
3617
|
+
height: 0.5,
|
|
3618
|
+
|
|
3619
|
+
foamSize: 0.2,
|
|
3620
|
+
foamEdge: 0.5,
|
|
3621
|
+
|
|
3622
|
+
color: new three.Color( 0xFFFFFF ),
|
|
3623
|
+
background: new three.Color( 0x2060FF ),
|
|
3624
|
+
|
|
3625
|
+
seed: 0,
|
|
3626
|
+
};
|
|
3627
|
+
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
var waves_core = tsl.Fn( ([ position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ seed ]) => {
|
|
3631
|
+
|
|
3632
|
+
const xscale = tsl.exp( scale.sub( 1 ) ).toVar();
|
|
3633
|
+
const pos = position.mul( xscale ).add( seed ).toVar( 'pos' );
|
|
3634
|
+
const xtime = time.mul( speed.exp() );
|
|
3635
|
+
|
|
3636
|
+
var posXZ = tsl.vec3( pos.x, 0, pos.z ).div( 3 );
|
|
3637
|
+
|
|
3638
|
+
const xfoamSize = foamSize.mul( tsl.mx_fractal_noise_float( pos, rough.div( 2 ) ).div( 2 ).add( 1 ).div( 2 ) );
|
|
3639
|
+
|
|
3640
|
+
var xheight = height.div( xscale, 0.8 ).toVar();
|
|
3641
|
+
|
|
3642
|
+
var wave = position.y.sub( level )
|
|
3643
|
+
.add( tsl.mx_fractal_noise_float( posXZ, 1 ).mul( 2*3.14 ).add( xtime ).sin().div( 2 ).mul( xheight ) )
|
|
3644
|
+
.sub( tsl.mx_fractal_noise_float( pos, rough ).mul( 2*3.14 ).add( xtime.mul( 2 ) ).sin().sub( 1 ).div( 5 ).mul( xheight ) )
|
|
3645
|
+
.smoothstep( tsl.float( 0.5 ).sub( xfoamSize ), tsl.float( 0.5 ).add( xfoamSize ) )
|
|
3646
|
+
.toVar();
|
|
3647
|
+
|
|
3648
|
+
return wave;
|
|
3649
|
+
|
|
3650
|
+
} ).setLayout( {
|
|
3651
|
+
name: 'waves_core',
|
|
3652
|
+
type: 'float',
|
|
3653
|
+
inputs: [
|
|
3654
|
+
{ name: 'position', type: 'vec3' },
|
|
3655
|
+
{ name: 'scale', type: 'float' },
|
|
3656
|
+
{ name: 'speed', type: 'float' },
|
|
3657
|
+
{ name: 'time', type: 'float' },
|
|
3658
|
+
{ name: 'level', type: 'float' },
|
|
3659
|
+
{ name: 'rough', type: 'float' },
|
|
3660
|
+
{ name: 'height', type: 'float' },
|
|
3661
|
+
{ name: 'foamSize', type: 'float' },
|
|
3662
|
+
/*{ name: 'foamEdge', type: 'float' },*/
|
|
3663
|
+
{ name: 'seed', type: 'float' },
|
|
3664
|
+
] }
|
|
3665
|
+
);
|
|
3666
|
+
|
|
3667
|
+
|
|
3668
|
+
|
|
3669
|
+
var wavesRaw = tsl.Fn( ([ position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ color, background, seed ]) => {
|
|
3670
|
+
|
|
3671
|
+
var k = waves_core( position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ seed );
|
|
3672
|
+
return tsl.mix( background, color, k.clamp( 0, 1 ) );
|
|
3673
|
+
|
|
3674
|
+
|
|
3675
|
+
} ).setLayout( {
|
|
3676
|
+
name: 'wavesRaw',
|
|
3677
|
+
type: 'vec3',
|
|
3678
|
+
inputs: [
|
|
3679
|
+
{ name: 'position', type: 'vec3' },
|
|
3680
|
+
{ name: 'scale', type: 'float' },
|
|
3681
|
+
{ name: 'speed', type: 'float' },
|
|
3682
|
+
{ name: 'time', type: 'float' },
|
|
3683
|
+
{ name: 'level', type: 'float' },
|
|
3684
|
+
{ name: 'rough', type: 'float' },
|
|
3685
|
+
{ name: 'height', type: 'float' },
|
|
3686
|
+
{ name: 'foamSize', type: 'float' },
|
|
3687
|
+
/*{ name: 'foamEdge', type: 'float' },*/
|
|
3688
|
+
{ name: 'color', type: 'vec3' },
|
|
3689
|
+
{ name: 'background', type: 'vec3' },
|
|
3690
|
+
{ name: 'seed', type: 'float' },
|
|
3691
|
+
] }
|
|
3692
|
+
);
|
|
3693
|
+
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
var wavesOpacityRaw = tsl.Fn( ([ position, scale, speed, time, level, rough, height, foamSize, foamEdge, /*color,background,*/ seed ]) => {
|
|
3697
|
+
|
|
3698
|
+
var k = waves_core( position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ seed ).oneMinus();
|
|
3699
|
+
|
|
3700
|
+
return k.smoothstep( 0, foamEdge.oneMinus().div( 10 ) );
|
|
3701
|
+
|
|
3702
|
+
} ).setLayout( {
|
|
3703
|
+
name: 'wavesOpacityRaw',
|
|
3704
|
+
type: 'float',
|
|
3705
|
+
inputs: [
|
|
3706
|
+
{ name: 'position', type: 'vec3' },
|
|
3707
|
+
{ name: 'scale', type: 'float' },
|
|
3708
|
+
{ name: 'speed', type: 'float' },
|
|
3709
|
+
{ name: 'time', type: 'float' },
|
|
3710
|
+
{ name: 'level', type: 'float' },
|
|
3711
|
+
{ name: 'rough', type: 'float' },
|
|
3712
|
+
{ name: 'height', type: 'float' },
|
|
3713
|
+
{ name: 'foamSize', type: 'float' },
|
|
3714
|
+
{ name: 'foamEdge', type: 'float' },
|
|
3715
|
+
/*{ name: 'color', type: 'vec3' },*/
|
|
3716
|
+
/*{ name: 'subcolor', type: 'vec3' },*/
|
|
3717
|
+
{ name: 'seed', type: 'float' },
|
|
3718
|
+
] }
|
|
3719
|
+
);
|
|
3720
|
+
|
|
3721
|
+
|
|
3722
|
+
|
|
3723
|
+
function waves( params={} ) {
|
|
3724
|
+
|
|
3725
|
+
var { position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ color, background, seed } = { ...defaults$b, ...params };
|
|
3726
|
+
|
|
3727
|
+
return wavesRaw( position, scale, speed, time, level, rough, height, foamSize, /*foamEdge,*/ color, background, seed );
|
|
3728
|
+
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
|
|
3732
|
+
|
|
3733
|
+
waves.opacity = function ( params={} ) {
|
|
3734
|
+
|
|
3735
|
+
var { position, scale, speed, time, level, rough, height, foamSize, foamEdge, /*color,background,*/seed } = { ...defaults$b, ...params };
|
|
3736
|
+
|
|
3737
|
+
return wavesOpacityRaw( position, scale, speed, time, level, rough, height, foamSize, foamEdge, /*color,background,*/seed );
|
|
3738
|
+
|
|
3739
|
+
};
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
waves.defaults = defaults$b;
|
|
3744
|
+
|
|
3745
|
+
var defaults$a = {
|
|
3746
|
+
$name: 'Wood',
|
|
3747
|
+
|
|
3748
|
+
position: tsl.positionGeometry,
|
|
3749
|
+
scale: 2.5,
|
|
3750
|
+
|
|
3751
|
+
rings: 4.5,
|
|
3752
|
+
lengths: 1,
|
|
3753
|
+
angle: 0,
|
|
3754
|
+
|
|
3755
|
+
fibers: 0.3,
|
|
3756
|
+
fibersDensity: 10,
|
|
3757
|
+
|
|
3758
|
+
color: new three.Color( 0.8, 0.4, 0 ),
|
|
3759
|
+
background: new three.Color( 0.4, 0.1, 0 ),
|
|
3760
|
+
|
|
3761
|
+
seed: 0,
|
|
3762
|
+
};
|
|
3763
|
+
|
|
3764
|
+
|
|
3765
|
+
|
|
3766
|
+
var woodRaw = tsl.Fn( ([ position, scale, rings, lengths, angle, fibers, fibersDensity, color, background, seed ]) => {
|
|
3767
|
+
|
|
3768
|
+
var angle = tsl.radians( angle ).toVar();
|
|
3769
|
+
var posLocal = tsl.vec3(
|
|
3770
|
+
tsl.sub( position.x.mul( tsl.cos( angle ) ), position.y.mul( tsl.sin( angle ) ) ),
|
|
3771
|
+
tsl.add( position.x.mul( tsl.sin( angle ) ), position.y.mul( tsl.cos( angle ) ) ),
|
|
3772
|
+
position.z,
|
|
3773
|
+
).toVar();
|
|
3774
|
+
|
|
3775
|
+
|
|
3776
|
+
// main pattern with rings
|
|
3777
|
+
var pos = posLocal.mul( tsl.exp( scale.sub( 3 ) ).mul( tsl.vec3( tsl.reciprocal( lengths ), 4, tsl.reciprocal( lengths ) ) ) ).add( seed ).toVar( );
|
|
3778
|
+
var k = tsl.mx_noise_float( pos ).add( 1 ).mul( 10 ).mul( rings );
|
|
3779
|
+
k = k.add( k.cos() ).cos().add( 1 ).div( 2 );
|
|
3780
|
+
|
|
3781
|
+
var kk = tsl.float( 0 ).toVar(),
|
|
3782
|
+
sum = tsl.float( 0 ).toVar(),
|
|
3783
|
+
scale = tsl.exp( scale.sub( 2 ) ).mul( tsl.vec3( 1, fibersDensity, 1 ) ).toVar(),
|
|
3784
|
+
power = tsl.float( 2 ).toVar();
|
|
3785
|
+
|
|
3786
|
+
tsl.Loop( 10, ()=>{
|
|
3787
|
+
|
|
3788
|
+
kk.addAssign( tsl.mul( power, tsl.mx_noise_float( posLocal.mul( scale ).add( seed ) ) ) );
|
|
3789
|
+
sum.addAssign( power );
|
|
3790
|
+
scale.mulAssign( 1.8 );
|
|
3791
|
+
power.mulAssign( 0.6 );
|
|
3792
|
+
|
|
3793
|
+
} );
|
|
3794
|
+
|
|
3795
|
+
kk.assign( tsl.mul( kk, 5 ).div( sum ).mul( 10 ).sin().add( 1 ).div( 2 ) );
|
|
3796
|
+
|
|
3797
|
+
return tsl.mix( color, background, tsl.mix( k, kk, fibers ) );
|
|
3798
|
+
|
|
3799
|
+
} ).setLayout( {
|
|
3800
|
+
name: 'woodRaw',
|
|
3801
|
+
type: 'vec3',
|
|
3802
|
+
inputs: [
|
|
3803
|
+
{ name: 'position', type: 'vec3' },
|
|
3804
|
+
{ name: 'scale', type: 'float' },
|
|
3805
|
+
{ name: 'rings', type: 'float' },
|
|
3806
|
+
{ name: 'lengths', type: 'float' },
|
|
3807
|
+
{ name: 'angle', type: 'float' },
|
|
3808
|
+
{ name: 'fibers', type: 'float' },
|
|
3809
|
+
{ name: 'fibersDensity', type: 'float' },
|
|
3810
|
+
{ name: 'color', type: 'vec3' },
|
|
3811
|
+
{ name: 'background', type: 'vec3' },
|
|
3812
|
+
{ name: 'seed', type: 'float' },
|
|
3813
|
+
] }
|
|
3814
|
+
);
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
|
|
3818
|
+
function wood( params={} ) {
|
|
3819
|
+
|
|
3820
|
+
var { position, scale, rings, lengths, angle, fibers, fibersDensity, color, background, seed } = { ...defaults$a, ...params };
|
|
3821
|
+
|
|
3822
|
+
return woodRaw( position, scale, rings, lengths, angle, fibers, fibersDensity, color, background, seed );
|
|
3823
|
+
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
|
|
3827
|
+
|
|
3828
|
+
wood.defaults = defaults$a;
|
|
3829
|
+
|
|
3830
|
+
var defaults$9 = {
|
|
3831
|
+
$name: 'Zebra lines',
|
|
3832
|
+
|
|
3833
|
+
position: tsl.positionGeometry,
|
|
3834
|
+
scale: 2,
|
|
3835
|
+
thinness: 0.5,
|
|
3836
|
+
phi: 0,
|
|
3837
|
+
theta: 0,
|
|
3838
|
+
|
|
3839
|
+
color: new three.Color( 0x0 ),
|
|
3840
|
+
background: new three.Color( 0xFFFFFF ),
|
|
3841
|
+
|
|
3842
|
+
flat: 0,
|
|
3843
|
+
// no seed for zebra lines
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
|
|
3847
|
+
|
|
3848
|
+
var zebraLinesRaw = tsl.Fn( ([ position, scale, thinness, phi, theta, color, background, xflat ]) => {
|
|
3849
|
+
|
|
3850
|
+
var pos = tsl.select( xflat, position, position.normalize() ).toVar( );
|
|
3851
|
+
|
|
3852
|
+
var dir = tsl.select( xflat, tsl.vec2( tsl.cos( phi ), tsl.sin( phi ) ), spherical( phi, theta ) ).toVar();
|
|
3853
|
+
|
|
3854
|
+
var angle = tsl.select( xflat, tsl.clamp( dir.dot( pos ), -2, 2 ), tsl.acos( tsl.clamp( dir.dot( pos ), -1, 1 ) ) ).toVar();
|
|
3855
|
+
|
|
3856
|
+
var scale = tsl.exp( scale.add( 1 ) ).toVar();
|
|
3857
|
+
|
|
3858
|
+
var k = tsl.sin( angle.mul( scale ) ).sub( thinness.sub( 0.5 ).mul( 2 ) );
|
|
3859
|
+
|
|
3860
|
+
k = tsl.clamp( k.mul( 1000 ).div( scale ), -1, 1 ).mul( 0.5 ).add( 0.5 );
|
|
3861
|
+
|
|
3862
|
+
return tsl.mix( background, color, k );
|
|
3863
|
+
|
|
3864
|
+
} ).setLayout( {
|
|
3865
|
+
name: 'zebraLinesRaw',
|
|
3866
|
+
type: 'vec3',
|
|
3867
|
+
inputs: [
|
|
3868
|
+
{ name: 'position', type: 'vec3' },
|
|
3869
|
+
{ name: 'scale', type: 'float' },
|
|
3870
|
+
{ name: 'thinness', type: 'float' },
|
|
3871
|
+
{ name: 'phi', type: 'float' },
|
|
3872
|
+
{ name: 'theta', type: 'float' },
|
|
3873
|
+
{ name: 'color', type: 'vec3' },
|
|
3874
|
+
{ name: 'background', type: 'vec3' },
|
|
3875
|
+
{ name: 'xflat', type: 'int' },
|
|
3876
|
+
] }
|
|
3877
|
+
);
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
function zebraLines( params={} ) {
|
|
3882
|
+
|
|
3883
|
+
var { position, scale, thinness, phi, theta, color, background, flat } = { ...defaults$9, ...params };
|
|
3884
|
+
|
|
3885
|
+
return zebraLinesRaw( position, scale, thinness, phi, theta, color, background, flat );
|
|
3886
|
+
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
|
|
3890
|
+
|
|
3891
|
+
zebraLines.defaults = defaults$9;
|
|
3892
|
+
|
|
3893
|
+
var defaults$8 = {
|
|
3894
|
+
$name: 'Circle decor',
|
|
3895
|
+
|
|
3896
|
+
position: tsl.positionGeometry,
|
|
3897
|
+
scale: 2,
|
|
3898
|
+
grains: 0.2,
|
|
3899
|
+
|
|
3900
|
+
complexity: 1,
|
|
3901
|
+
blur: 0.2,
|
|
3902
|
+
|
|
3903
|
+
color: new three.Color( 0x0 ),
|
|
3904
|
+
background: new three.Color( 0xFFFFFF ),
|
|
3905
|
+
|
|
3906
|
+
seed: 0,
|
|
3907
|
+
};
|
|
3908
|
+
|
|
3909
|
+
|
|
3910
|
+
|
|
3911
|
+
var circleDecorRaw = tsl.Fn( ([ position, scale, grains, complexity, blur, color, background, seed ])=>{
|
|
3912
|
+
|
|
3913
|
+
var pos = position.mul( tsl.exp( scale.div( 4 ) ) ).add( seed ).toVar( 'pos' );
|
|
3914
|
+
var subpos = pos.mul( 2 ).toVar( 'subpos' );
|
|
3915
|
+
|
|
3916
|
+
var k1 = tsl.mx_worley_noise_float( pos );
|
|
3917
|
+
var k2 = tsl.mx_worley_noise_float( subpos );
|
|
3918
|
+
var k3 = tsl.mx_worley_noise_float( pos.mul( grains.mul( 4 ).add( 2 ) ) ).mul( 2 );
|
|
3919
|
+
|
|
3920
|
+
var compScale = tsl.mx_noise_float( pos ).div( 2 ).add( 1 );
|
|
3921
|
+
|
|
3922
|
+
var k = k1.min( k2, k3 ).clamp( 0, 1 ).mul( complexity.add( 2 ).exp(), compScale, Math.PI ).sin().smoothstep( blur.negate(), blur );
|
|
3923
|
+
|
|
3924
|
+
return tsl.mix( color, background, k.oneMinus() );
|
|
3925
|
+
|
|
3926
|
+
} ).setLayout( {
|
|
3927
|
+
name: 'camouflageRaw',
|
|
3928
|
+
type: 'vec3',
|
|
3929
|
+
inputs: [
|
|
3930
|
+
{ name: 'position', type: 'vec3' },
|
|
3931
|
+
{ name: 'scale', type: 'float' },
|
|
3932
|
+
{ name: 'grains', type: 'float' },
|
|
3933
|
+
{ name: 'complexity', type: 'float' },
|
|
3934
|
+
{ name: 'blur', type: 'float' },
|
|
3935
|
+
{ name: 'color', type: 'vec3' },
|
|
3936
|
+
{ name: 'background', type: 'vec3' },
|
|
3937
|
+
{ name: 'seed', type: 'float' },
|
|
3938
|
+
] }
|
|
3939
|
+
);
|
|
3940
|
+
|
|
3941
|
+
|
|
3942
|
+
|
|
3943
|
+
function circleDecor( params={} ) {
|
|
3944
|
+
|
|
3945
|
+
var { position, scale, grains, complexity, blur, color, background, seed } = { ...defaults$8, ...params };
|
|
3946
|
+
|
|
3947
|
+
return circleDecorRaw( position, scale, grains, complexity, blur, color, background, seed );
|
|
3948
|
+
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
|
|
3952
|
+
|
|
3953
|
+
circleDecor.defaults = defaults$8;
|
|
3954
|
+
|
|
3955
|
+
var defaults$7 = {
|
|
3956
|
+
$name: 'Reticular veins',
|
|
3957
|
+
|
|
3958
|
+
position: tsl.positionGeometry,
|
|
3959
|
+
scale: 2,
|
|
3960
|
+
reticulation: 5,
|
|
3961
|
+
strength: 0.2,
|
|
3962
|
+
organelles: 0.2,
|
|
3963
|
+
|
|
3964
|
+
color: new three.Color( 0xFFFFF0 ),
|
|
3965
|
+
background: new three.Color( 0x208020 ),
|
|
3966
|
+
|
|
3967
|
+
seed: 0,
|
|
3968
|
+
};
|
|
3969
|
+
|
|
3970
|
+
|
|
3971
|
+
|
|
3972
|
+
var reticularVeinsRaw = tsl.Fn( ([ position, scale, reticulation, strength, organelles, color, background, seed ])=>{
|
|
3973
|
+
|
|
3974
|
+
var pos = position.mul( tsl.exp( scale.div( 2 ).add( 0.5 ) ) ).add( seed ).toVar( );
|
|
3975
|
+
|
|
3976
|
+
var k1 = tsl.mx_worley_noise_float( pos );
|
|
3977
|
+
var k2 = tsl.mx_worley_noise_float( pos.add( 100 ).mul( reticulation ) ).mul( strength );
|
|
3978
|
+
var dots = tsl.mx_noise_float( pos.mul( 100 ) ).mul( strength, organelles );
|
|
3979
|
+
|
|
3980
|
+
var k = k1.add( k2 ).add( dots );
|
|
3981
|
+
|
|
3982
|
+
return tsl.mix( background, color, k );
|
|
3983
|
+
|
|
3984
|
+
} ).setLayout( {
|
|
3985
|
+
name: 'reticularVeinsRaw',
|
|
3986
|
+
type: 'vec3',
|
|
3987
|
+
inputs: [
|
|
3988
|
+
{ name: 'position', type: 'vec3' },
|
|
3989
|
+
{ name: 'scale', type: 'float' },
|
|
3990
|
+
{ name: 'reticulation', type: 'float' },
|
|
3991
|
+
{ name: 'strength', type: 'float' },
|
|
3992
|
+
{ name: 'organelles', type: 'float' },
|
|
3993
|
+
{ name: 'color', type: 'vec3' },
|
|
3994
|
+
{ name: 'background', type: 'vec3' },
|
|
3995
|
+
{ name: 'seed', type: 'float' },
|
|
3996
|
+
] }
|
|
3997
|
+
);
|
|
3998
|
+
|
|
3999
|
+
|
|
4000
|
+
|
|
4001
|
+
function reticularVeins( params={} ) {
|
|
4002
|
+
|
|
4003
|
+
var { position, scale, reticulation, strength, organelles, color, background, seed } = { ...defaults$7, ...params };
|
|
4004
|
+
|
|
4005
|
+
return reticularVeinsRaw( position, scale, reticulation, strength, organelles, color, background, seed );
|
|
4006
|
+
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
|
|
4010
|
+
|
|
4011
|
+
reticularVeins.defaults = defaults$7;
|
|
4012
|
+
|
|
4013
|
+
var defaults$6 = {
|
|
4014
|
+
$name: 'Roman paving',
|
|
4015
|
+
|
|
4016
|
+
position: tsl.positionGeometry,
|
|
4017
|
+
scale: 2,
|
|
4018
|
+
depth: 0.5,
|
|
4019
|
+
|
|
4020
|
+
seed: 0,
|
|
4021
|
+
};
|
|
4022
|
+
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
var romanPavingRaw = tsl.Fn( ([ position, scale, depth, seed ])=>{
|
|
4026
|
+
|
|
4027
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed ).toVar( );
|
|
4028
|
+
|
|
4029
|
+
var k = tsl.mx_worley_noise_vec2( pos ).toVar();
|
|
4030
|
+
|
|
4031
|
+
return k.y.sub( k.x ).pow( depth.mul( 3 ).sub( 3 ).exp() ).smoothstep( 0, 1 );
|
|
4032
|
+
|
|
4033
|
+
} ).setLayout( {
|
|
4034
|
+
name: 'romanPavingRaw',
|
|
4035
|
+
type: 'vec3',
|
|
4036
|
+
inputs: [
|
|
4037
|
+
{ name: 'position', type: 'vec3' },
|
|
4038
|
+
{ name: 'scale', type: 'float' },
|
|
4039
|
+
{ name: 'depth', type: 'float' },
|
|
4040
|
+
{ name: 'seed', type: 'float' },
|
|
4041
|
+
] }
|
|
4042
|
+
);
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
function romanPaving( params={} ) {
|
|
4047
|
+
|
|
4048
|
+
var { position, scale, depth, seed } = { ...defaults$6, ...params };
|
|
4049
|
+
|
|
4050
|
+
return romanPavingRaw( position, scale, depth, seed );
|
|
4051
|
+
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
romanPaving.defaults = defaults$6;
|
|
4057
|
+
|
|
4058
|
+
var defaults$5 = {
|
|
4059
|
+
$name: 'Crumpled fabric',
|
|
4060
|
+
$width: 260,
|
|
4061
|
+
|
|
4062
|
+
position: tsl.positionGeometry,
|
|
4063
|
+
scale: 2,
|
|
4064
|
+
pinch: 0.5,
|
|
4065
|
+
|
|
4066
|
+
color: new three.Color( 0xB0F0FF ),
|
|
4067
|
+
subcolor: new three.Color( 0x4040F0 ),
|
|
4068
|
+
background: new three.Color( 0x003000 ),
|
|
4069
|
+
|
|
4070
|
+
seed: 0,
|
|
4071
|
+
};
|
|
4072
|
+
|
|
4073
|
+
|
|
4074
|
+
|
|
4075
|
+
var crumpledFabricRaw = tsl.Fn( ([ position, scale, pinch, color, subcolor, background, seed ])=>{
|
|
4076
|
+
|
|
4077
|
+
var pos = position.mul( tsl.exp( scale.sub( 0.5 ) ) ).add( seed ).toVar( );
|
|
4078
|
+
|
|
4079
|
+
tsl.Loop( 4, ()=>{
|
|
4080
|
+
|
|
4081
|
+
var x = tsl.mx_noise_float( pos.xyz );
|
|
4082
|
+
var y = tsl.mx_noise_float( pos.yzx );
|
|
4083
|
+
var z = tsl.mx_noise_float( pos.zxy );
|
|
4084
|
+
|
|
4085
|
+
pos.addAssign( tsl.vec3( x, y, z ).mul( pinch ) );
|
|
4086
|
+
|
|
4087
|
+
} );
|
|
4088
|
+
|
|
4089
|
+
var k = tsl.mx_noise_float( pos ).add( 1 ).div( 2 ).clamp( 0, 1 );
|
|
4090
|
+
|
|
4091
|
+
var color1 = color.mul( k.mul( 2 ).sub( 1 ).abs().oneMinus() );
|
|
4092
|
+
var color2 = subcolor.mul( k ).pow( 2 );
|
|
4093
|
+
var color3 = background.mul( k.oneMinus().pow( 2 ) );
|
|
4094
|
+
|
|
4095
|
+
return color1.add( color2 ).add( color3 );
|
|
4096
|
+
|
|
4097
|
+
} ).setLayout( {
|
|
4098
|
+
name: 'crumpledFabricRaw',
|
|
4099
|
+
type: 'vec3',
|
|
4100
|
+
inputs: [
|
|
4101
|
+
{ name: 'position', type: 'vec3' },
|
|
4102
|
+
{ name: 'scale', type: 'float' },
|
|
4103
|
+
{ name: 'pinch', type: 'float' },
|
|
4104
|
+
{ name: 'color', type: 'vec3' },
|
|
4105
|
+
{ name: 'subcolor', type: 'vec3' },
|
|
4106
|
+
{ name: 'background', type: 'vec3' },
|
|
4107
|
+
{ name: 'seed', type: 'float' },
|
|
4108
|
+
] }
|
|
4109
|
+
);
|
|
4110
|
+
|
|
4111
|
+
|
|
4112
|
+
|
|
4113
|
+
function crumpledFabric( params={} ) {
|
|
4114
|
+
|
|
4115
|
+
var { position, scale, pinch, color, subcolor, background, seed } = { ...defaults$5, ...params };
|
|
4116
|
+
|
|
4117
|
+
return crumpledFabricRaw( position, scale, pinch, color, subcolor, background, seed );
|
|
4118
|
+
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4121
|
+
|
|
4122
|
+
|
|
4123
|
+
crumpledFabric.defaults = defaults$5;
|
|
4124
|
+
|
|
4125
|
+
var defaults$4 = {
|
|
4126
|
+
$name: 'Isolayers',
|
|
4127
|
+
|
|
4128
|
+
position: tsl.positionGeometry,
|
|
4129
|
+
scale: 2,
|
|
4130
|
+
layers: 10,
|
|
4131
|
+
edge: 0.5,
|
|
4132
|
+
darkness: 0,
|
|
4133
|
+
|
|
4134
|
+
color: new three.Color( 0xFFFFF0 ),
|
|
4135
|
+
background: new three.Color( 0xFF4040 ),
|
|
4136
|
+
|
|
4137
|
+
seed: 0,
|
|
4138
|
+
};
|
|
4139
|
+
|
|
4140
|
+
|
|
4141
|
+
|
|
4142
|
+
var isolayersRaw = tsl.Fn( ([ position, scale, layers, edge, darkness, color, background, seed ])=>{
|
|
4143
|
+
|
|
4144
|
+
var pos = position.mul( tsl.exp( scale.sub( 1 ) ) ).add( seed ).toVar( );
|
|
4145
|
+
|
|
4146
|
+
var depth = edge.remap( 0, 1, 40, 10 );
|
|
4147
|
+
|
|
4148
|
+
var k = tsl.mx_noise_float( pos, 1.2, 1 ).div( 2 );
|
|
4149
|
+
|
|
4150
|
+
var i = k.mul( layers ).round().div( layers ).clamp( 0, 1 );
|
|
4151
|
+
var f = k.sub( tsl.float( 0.5+0.03 ).div( layers ) )
|
|
4152
|
+
.mul( layers ).fract()
|
|
4153
|
+
.mul( tsl.float( 2 ).pow( depth.reciprocal() ) )
|
|
4154
|
+
.pow( depth ).sub( 1 ).abs().oneMinus();
|
|
4155
|
+
|
|
4156
|
+
var hslColor = tsl.mix( toHsl( background ), toHsl( color ), i ).toVar();
|
|
4157
|
+
hslColor.z.mulAssign( tsl.mix( 1, i.mul( 1.5 ), darkness ).clamp( 0, 1 ) );
|
|
4158
|
+
|
|
4159
|
+
return hsl( hslColor ).sub( f );
|
|
4160
|
+
|
|
4161
|
+
} ).setLayout( {
|
|
4162
|
+
name: 'isolayersRaw',
|
|
4163
|
+
type: 'vec3',
|
|
4164
|
+
inputs: [
|
|
4165
|
+
{ name: 'position', type: 'vec3' },
|
|
4166
|
+
{ name: 'scale', type: 'float' },
|
|
4167
|
+
{ name: 'layers', type: 'int' },
|
|
4168
|
+
{ name: 'edge', type: 'float' },
|
|
4169
|
+
{ name: 'darkness', type: 'float' },
|
|
4170
|
+
{ name: 'color', type: 'vec3' },
|
|
4171
|
+
{ name: 'background', type: 'vec3' },
|
|
4172
|
+
{ name: 'seed', type: 'float' },
|
|
4173
|
+
] }
|
|
4174
|
+
);
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
function isolayers( params={} ) {
|
|
4179
|
+
|
|
4180
|
+
var { position, scale, layers, edge, darkness, color, background, seed } = { ...defaults$4, ...params };
|
|
4181
|
+
|
|
4182
|
+
return isolayersRaw( position, scale, layers, edge, darkness, color, background, seed );
|
|
4183
|
+
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
|
|
4188
|
+
isolayers.defaults = defaults$4;
|
|
4189
|
+
|
|
4190
|
+
var defaults$3 = {
|
|
4191
|
+
$name: 'Turbulent smoke',
|
|
4192
|
+
$width: 260,
|
|
4193
|
+
|
|
4194
|
+
position: tsl.positionGeometry,
|
|
4195
|
+
scale: 2,
|
|
4196
|
+
speed: 0,
|
|
4197
|
+
details: 5,
|
|
4198
|
+
time: tsl.time,
|
|
4199
|
+
|
|
4200
|
+
seed: 0,
|
|
4201
|
+
};
|
|
4202
|
+
|
|
4203
|
+
|
|
4204
|
+
|
|
4205
|
+
var turbulentSmokeRaw = tsl.Fn( ([ position, scale, speed, details, time, seed ])=>{
|
|
4206
|
+
|
|
4207
|
+
var pos = position.mul( tsl.exp( scale.sub( 1 ) ) ).add( seed ).toVar( );
|
|
4208
|
+
|
|
4209
|
+
var t = time.mul( speed.sub( 1 ).exp() );
|
|
4210
|
+
|
|
4211
|
+
var q = pos.add( tsl.vec3(
|
|
4212
|
+
tsl.mx_fractal_noise_float( pos.add( tsl.vec3( 1, t.sin(), -1 ) ) ),
|
|
4213
|
+
tsl.mx_fractal_noise_float( pos.add( tsl.vec3( t.add( 2*Math.PI/3 ).sin(), 1, -1 ) ) ),
|
|
4214
|
+
tsl.mx_fractal_noise_float( pos.add( tsl.vec3( 1, -1, t.add( 4*Math.PI/3 ).sin() ) ) ),
|
|
4215
|
+
) );
|
|
4216
|
+
|
|
4217
|
+
var p = tsl.mx_fractal_noise_vec3( q, details );
|
|
4218
|
+
|
|
4219
|
+
var k = tsl.mx_worley_noise_float( pos.add( p.div( 2 ) ) ).pow( 4 ).mul( 4 ).oneMinus();
|
|
4220
|
+
|
|
4221
|
+
return k;
|
|
4222
|
+
|
|
4223
|
+
} ).setLayout( {
|
|
4224
|
+
name: 'turbulentSmokeRaw',
|
|
4225
|
+
type: 'vec3',
|
|
4226
|
+
inputs: [
|
|
4227
|
+
{ name: 'position', type: 'vec3' },
|
|
4228
|
+
{ name: 'scale', type: 'float' },
|
|
4229
|
+
{ name: 'speed', type: 'float' },
|
|
4230
|
+
{ name: 'details', type: 'int' },
|
|
4231
|
+
{ name: 'time', type: 'float' },
|
|
4232
|
+
{ name: 'seed', type: 'float' },
|
|
4233
|
+
] }
|
|
4234
|
+
);
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
function turbulentSmoke( params={} ) {
|
|
4239
|
+
|
|
4240
|
+
var { position, scale, speed, details, time, seed } = { ...defaults$3, ...params };
|
|
4241
|
+
|
|
4242
|
+
return turbulentSmokeRaw( position, scale, speed, details, time, seed );
|
|
4243
|
+
|
|
4244
|
+
}
|
|
4245
|
+
|
|
4246
|
+
|
|
4247
|
+
|
|
4248
|
+
turbulentSmoke.defaults = defaults$3;
|
|
4249
|
+
|
|
4250
|
+
var defaults$2 = {
|
|
4251
|
+
$name: 'Caustics',
|
|
4252
|
+
|
|
4253
|
+
position: tsl.positionGeometry,
|
|
4254
|
+
scale: 2,
|
|
4255
|
+
speed: 0,
|
|
4256
|
+
time: tsl.time,
|
|
4257
|
+
|
|
4258
|
+
color: new three.Color( 0x50A8C0 ),
|
|
4259
|
+
|
|
4260
|
+
seed: 0,
|
|
4261
|
+
};
|
|
4262
|
+
|
|
4263
|
+
|
|
4264
|
+
|
|
4265
|
+
var causticsRaw = tsl.Fn( ([ position, scale, speed, time, color, seed ])=>{
|
|
4266
|
+
|
|
4267
|
+
var pos = position.mul( tsl.exp( scale.sub( 1 ) ) ).add( seed ).toVar( );
|
|
4268
|
+
|
|
4269
|
+
var t = time.mul( speed.sub( 1 ).exp() )
|
|
4270
|
+
.add( tsl.vec3( 0, 2*Math.PI/3, 4*Math.PI/3 ) )
|
|
4271
|
+
.sin();
|
|
4272
|
+
|
|
4273
|
+
var p = tsl.mx_worley_noise_vec3(
|
|
4274
|
+
pos.add( tsl.vec3(
|
|
4275
|
+
tsl.mx_worley_noise_float( pos.add( t.xyz ) ),
|
|
4276
|
+
tsl.mx_worley_noise_float( pos.add( t.yzx ) ),
|
|
4277
|
+
tsl.mx_worley_noise_float( pos.add( t.zxy ) ),
|
|
4278
|
+
) ) );
|
|
4279
|
+
|
|
4280
|
+
var k = p.length().div( Math.sqrt( 3 ) );
|
|
4281
|
+
|
|
4282
|
+
return k.add( color.sub( 0.5 ).mul( 2 ) );
|
|
4283
|
+
|
|
4284
|
+
} ).setLayout( {
|
|
4285
|
+
name: 'causticsRaw',
|
|
4286
|
+
type: 'vec3',
|
|
4287
|
+
inputs: [
|
|
4288
|
+
{ name: 'position', type: 'vec3' },
|
|
4289
|
+
{ name: 'scale', type: 'float' },
|
|
4290
|
+
{ name: 'speed', type: 'float' },
|
|
4291
|
+
{ name: 'time', type: 'float' },
|
|
4292
|
+
{ name: 'color', type: 'vec3' },
|
|
4293
|
+
{ name: 'seed', type: 'float' },
|
|
4294
|
+
] }
|
|
4295
|
+
);
|
|
4296
|
+
|
|
4297
|
+
|
|
4298
|
+
|
|
4299
|
+
function caustics( params={} ) {
|
|
4300
|
+
|
|
4301
|
+
var { position, scale, speed, time, color, seed } = { ...defaults$2, ...params };
|
|
4302
|
+
|
|
4303
|
+
return causticsRaw( position, scale, speed, time, color, seed );
|
|
4304
|
+
|
|
4305
|
+
}
|
|
4306
|
+
|
|
4307
|
+
|
|
4308
|
+
|
|
4309
|
+
caustics.defaults = defaults$2;
|
|
4310
|
+
|
|
4311
|
+
var defaults$1 = {
|
|
4312
|
+
$name: 'Bricks',
|
|
4313
|
+
|
|
4314
|
+
position: tsl.positionGeometry,
|
|
4315
|
+
scale: 2,
|
|
4316
|
+
|
|
4317
|
+
brickSize: new three.Vector3( 2, 1, 2 ),
|
|
4318
|
+
brickShift: 2,
|
|
4319
|
+
|
|
4320
|
+
jointSize: 0.05,
|
|
4321
|
+
jointSpan: 0.5,
|
|
4322
|
+
jointJitter: 0.5,
|
|
4323
|
+
jointBlur: 0.03,
|
|
4324
|
+
|
|
4325
|
+
noiseSize: 0.5,
|
|
4326
|
+
noiseStrength: 0.2,
|
|
4327
|
+
|
|
4328
|
+
colorShade: 0.5,
|
|
4329
|
+
|
|
4330
|
+
color: new three.Color( 0xFF4000 ),
|
|
4331
|
+
additional: new three.Color( 0xD0A030 ),
|
|
4332
|
+
background: new three.Color( 0xAAAAAA ),
|
|
4333
|
+
|
|
4334
|
+
|
|
4335
|
+
seed: 0,
|
|
4336
|
+
};
|
|
4337
|
+
|
|
4338
|
+
|
|
4339
|
+
|
|
4340
|
+
var bricksRaw = tsl.Fn( ([ position, scale, brickSize, brickShift, jointSize, jointSpan, jointJitter, jointBlur, noiseSize, noiseStrength, colorShade, color, additional, background, seed ])=>{
|
|
4341
|
+
|
|
4342
|
+
var pos = position.mul( tsl.exp( scale ) ).add( seed ).toVar( );
|
|
4343
|
+
|
|
4344
|
+
var size = brickSize;
|
|
4345
|
+
|
|
4346
|
+
var floor = pos.div( size ).floor().div( brickShift );
|
|
4347
|
+
|
|
4348
|
+
var offset = tsl.vec3( floor.y, 0, floor.y ).toVar();
|
|
4349
|
+
|
|
4350
|
+
var p = pos.div( size ).fract().add( offset ).fract().toVar();
|
|
4351
|
+
|
|
4352
|
+
var n = tsl.mx_fractal_noise_vec3( pos.mul( remapExp( jointSpan, 0, 1, 20, 0.2 ) ) ).div( remapExp( jointJitter, 0, 1, 500, 1 ) ).toVar();
|
|
4353
|
+
|
|
4354
|
+
var border = tsl.mul(
|
|
4355
|
+
p.mul( size ).add( n.z ).smoothstep( size.y.sub( jointSize, jointBlur ), size.y.sub( jointSize ) ).y.oneMinus(),
|
|
4356
|
+
p.mul( size ).add( n.y ).smoothstep( jointSize, jointSize.add( jointBlur ) ).y,
|
|
4357
|
+
|
|
4358
|
+
p.mul( size ).add( n.y ).smoothstep( size.x.sub( jointSize, jointBlur ), size.x.sub( jointSize ) ).x.oneMinus(),
|
|
4359
|
+
p.mul( size ).add( n.x ).smoothstep( jointSize, jointSize.add( jointBlur ) ).x,
|
|
4360
|
+
|
|
4361
|
+
p.mul( size ).add( n.x ).smoothstep( size.z.sub( jointSize, jointBlur ), size.z.sub( jointSize ) ).z.oneMinus(),
|
|
4362
|
+
p.mul( size ).add( n.z ).smoothstep( jointSize, jointSize.add( jointBlur ) ).z,
|
|
4363
|
+
).clamp( 0, 1 );
|
|
4364
|
+
|
|
4365
|
+
var shade = tsl.mix( tsl.float( 1 ), tsl.mx_noise_float( tsl.mx_noise_float( pos.xyz.div( size ).add( offset ).floor().zxy.mul( 100 ).add( Math.PI ) ).mul( 10 ) ).add( 2 ).div( 2 ).pow( 4 ).clamp( 0, 1 ), colorShade );
|
|
4366
|
+
|
|
4367
|
+
var ns = tsl.mx_noise_float( pos.mul( remapExp( noiseSize, 0, 1, 5, 250 ) ) ).mul( noiseStrength ).add( 1 );
|
|
4368
|
+
|
|
4369
|
+
var brickNoise = tsl.mx_noise_float( tsl.mx_noise_float( pos.xyz.div( size ).add( offset ).floor().zxy.mul( 200 ).add( Math.PI ) ).mul( 10 ) ).add( 1 ).div( 1 );
|
|
4370
|
+
var brickColor = tsl.mix( color, additional, brickNoise.pow( 2 ) );
|
|
4371
|
+
|
|
4372
|
+
return tsl.mix( background, shade.mul( brickColor, border ), border ).mul( ns );
|
|
4373
|
+
|
|
4374
|
+
} ).setLayout( {
|
|
4375
|
+
name: 'bricksRaw',
|
|
4376
|
+
type: 'vec3',
|
|
4377
|
+
inputs: [
|
|
4378
|
+
{ name: 'position', type: 'vec3' },
|
|
4379
|
+
{ name: 'scale', type: 'float' },
|
|
4380
|
+
|
|
4381
|
+
{ name: 'brickSize', type: 'vec3' },
|
|
4382
|
+
{ name: 'brickShift', type: 'float' },
|
|
4383
|
+
{ name: 'jointSize', type: 'float' },
|
|
4384
|
+
{ name: 'jointSpan', type: 'float' },
|
|
4385
|
+
{ name: 'jointJitter', type: 'float' },
|
|
4386
|
+
{ name: 'jointBlur', type: 'float' },
|
|
4387
|
+
{ name: 'noiseSize', type: 'float' },
|
|
4388
|
+
{ name: 'noiseStrength', type: 'float' },
|
|
4389
|
+
{ name: 'colorShade', type: 'float' },
|
|
4390
|
+
|
|
4391
|
+
{ name: 'color', type: 'vec3' },
|
|
4392
|
+
{ name: 'additional', type: 'vec3' },
|
|
4393
|
+
{ name: 'background', type: 'vec3' },
|
|
4394
|
+
|
|
4395
|
+
{ name: 'seed', type: 'float' },
|
|
4396
|
+
] }
|
|
4397
|
+
);
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
function bricks( params={} ) {
|
|
4402
|
+
|
|
4403
|
+
var { position, scale, brickSize, brickShift, jointSize, jointSpan, jointJitter, jointBlur, noiseSize, noiseStrength, colorShade, color, additional, background, seed } = { ...defaults$1, ...params };
|
|
4404
|
+
|
|
4405
|
+
return bricksRaw( position, scale, brickSize, brickShift, jointSize, jointSpan, jointJitter, jointBlur, noiseSize, noiseStrength, colorShade, color, additional, background, seed );
|
|
4406
|
+
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
|
|
4410
|
+
|
|
4411
|
+
bricks.defaults = defaults$1;
|
|
4412
|
+
|
|
4413
|
+
var defaults = {
|
|
4414
|
+
$name: 'Halftone',
|
|
4415
|
+
|
|
4416
|
+
position: tsl.screenCoordinate,
|
|
4417
|
+
scale: 2,
|
|
4418
|
+
radius: 0.5,
|
|
4419
|
+
pattern: 1,
|
|
4420
|
+
|
|
4421
|
+
attenuation: 0,
|
|
4422
|
+
near: 6,
|
|
4423
|
+
far: 14,
|
|
4424
|
+
|
|
4425
|
+
color: tsl.vertexColor(),
|
|
4426
|
+
|
|
4427
|
+
positionView: tsl.positionView,
|
|
4428
|
+
|
|
4429
|
+
};
|
|
4430
|
+
|
|
4431
|
+
|
|
4432
|
+
|
|
4433
|
+
// square grid of circles
|
|
4434
|
+
var halftoneGridRaw = tsl.Fn( ([ position, scale, radius, attenuation, far, near, color, positionView ]) => {
|
|
4435
|
+
|
|
4436
|
+
var xscale = tsl.float( 5 ).sub( scale ).exp().toVar(),
|
|
4437
|
+
pos = position.toVar(),
|
|
4438
|
+
xradius = radius.div( Math.sqrt( 2 ) ).toVar();
|
|
4439
|
+
|
|
4440
|
+
var center = pos.div( xscale ).round().mul( xscale );
|
|
4441
|
+
|
|
4442
|
+
|
|
4443
|
+
tsl.If( attenuation.notEqual( 0 ), ()=>{
|
|
4444
|
+
|
|
4445
|
+
xradius.mulAssign( positionView.z.mul( -1 ).smoothstep( far, near ).pow( 1/2 ) );
|
|
4446
|
+
|
|
4447
|
+
} );
|
|
4448
|
+
|
|
4449
|
+
tsl.If( pos.distance( center ).greaterThan( xscale.mul( xradius ) ), ()=>tsl.Discard() );
|
|
4450
|
+
|
|
4451
|
+
return color;
|
|
4452
|
+
|
|
4453
|
+
} ).setLayout( {
|
|
4454
|
+
name: 'halftoneGridRaw',
|
|
4455
|
+
type: 'vec3',
|
|
4456
|
+
inputs: [
|
|
4457
|
+
{ name: 'position', type: 'vec3' },
|
|
4458
|
+
{ name: 'scale', type: 'float' },
|
|
4459
|
+
{ name: 'radius', type: 'float' },
|
|
4460
|
+
{ name: 'attenuation', type: 'int' },
|
|
4461
|
+
{ name: 'far', type: 'float' },
|
|
4462
|
+
{ name: 'near', type: 'float' },
|
|
4463
|
+
{ name: 'color', type: 'vec3' },
|
|
4464
|
+
{ name: 'positionView', type: 'vec3' },
|
|
4465
|
+
] }
|
|
4466
|
+
);
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4470
|
+
// diagonal geid of circles
|
|
4471
|
+
var halftoneDiagRaw = tsl.Fn( ([ position, scale, radius, attenuation, far, near, color, positionView ]) => {
|
|
4472
|
+
|
|
4473
|
+
var xscale = tsl.float( 5 ).sub( scale ).exp().toVar(),
|
|
4474
|
+
pos = position.toVar(),
|
|
4475
|
+
xradius = radius.div( Math.sqrt( 2 ) ).toVar();
|
|
4476
|
+
|
|
4477
|
+
var shift = pos.y.div( xscale ).round().mod( 2 );
|
|
4478
|
+
|
|
4479
|
+
var centerA = pos.div( xscale ).round().mulAssign( xscale ).toVar();
|
|
4480
|
+
|
|
4481
|
+
tsl.If( shift.equal( 0 ), ()=>{
|
|
4482
|
+
|
|
4483
|
+
centerA.x.addAssign( xscale.mul( 0.5 ) );
|
|
4484
|
+
|
|
4485
|
+
} );
|
|
4486
|
+
var centerB = tsl.vec2( centerA.x.sub( xscale ), centerA.y ).toVar();
|
|
4487
|
+
|
|
4488
|
+
|
|
4489
|
+
tsl.If( attenuation.notEqual( 0 ), ()=>{
|
|
4490
|
+
|
|
4491
|
+
xradius.mulAssign( positionView.z.mul( -1 ).smoothstep( far, near ).pow( 1/2 ) );
|
|
4492
|
+
|
|
4493
|
+
} );
|
|
4494
|
+
|
|
4495
|
+
tsl.If( tsl.min( pos.distance( centerA ), pos.distance( centerB ) ).greaterThan( xscale.mul( xradius ) ), ()=>tsl.Discard() );
|
|
4496
|
+
|
|
4497
|
+
return color;
|
|
4498
|
+
|
|
4499
|
+
} ).setLayout( {
|
|
4500
|
+
name: 'halftoneDiagRaw',
|
|
4501
|
+
type: 'vec3',
|
|
4502
|
+
inputs: [
|
|
4503
|
+
{ name: 'position', type: 'vec3' },
|
|
4504
|
+
{ name: 'scale', type: 'float' },
|
|
4505
|
+
{ name: 'radius', type: 'float' },
|
|
4506
|
+
{ name: 'attenuation', type: 'int' },
|
|
4507
|
+
{ name: 'far', type: 'float' },
|
|
4508
|
+
{ name: 'near', type: 'float' },
|
|
4509
|
+
{ name: 'color', type: 'vec3' },
|
|
4510
|
+
{ name: 'positionView', type: 'vec3' },
|
|
4511
|
+
] }
|
|
4512
|
+
);
|
|
4513
|
+
|
|
4514
|
+
|
|
4515
|
+
|
|
4516
|
+
// trigonetric pattern
|
|
4517
|
+
var halftoneTrigRaw = tsl.Fn( ([ position, scale, radius, pattern, attenuation, far, near, color, positionView ]) => {
|
|
4518
|
+
|
|
4519
|
+
var pos = position.mul( scale.sub( 3.5 ).exp() ).sin().add( 1 ).div( 2 ).toVar(),
|
|
4520
|
+
x = pos.x,
|
|
4521
|
+
y = pos.y,
|
|
4522
|
+
xradius = radius.div( Math.sqrt( 2 ) ).toVar();
|
|
4523
|
+
|
|
4524
|
+
var dist = tsl.float( 0 );
|
|
4525
|
+
|
|
4526
|
+
tsl.Switch( pattern )
|
|
4527
|
+
.Case( 2, ()=>{
|
|
4528
|
+
|
|
4529
|
+
dist.assign( x.add( y ).div( 2 ) );
|
|
4530
|
+
|
|
4531
|
+
} )
|
|
4532
|
+
.Case( 3, ()=>{
|
|
4533
|
+
|
|
4534
|
+
dist.assign( x.sub( y ).abs().oneMinus() );
|
|
4535
|
+
|
|
4536
|
+
} )
|
|
4537
|
+
.Case( 10, ()=>{
|
|
4538
|
+
|
|
4539
|
+
dist.assign( x.sub( y ).abs() );
|
|
4540
|
+
|
|
4541
|
+
} )
|
|
4542
|
+
.Case( 4, ()=>{
|
|
4543
|
+
|
|
4544
|
+
dist.assign( x.mul( y ).oneMinus() );
|
|
4545
|
+
|
|
4546
|
+
} )
|
|
4547
|
+
.Case( 9, ()=>{
|
|
4548
|
+
|
|
4549
|
+
dist.assign( x.mul( y ) );
|
|
4550
|
+
|
|
4551
|
+
} )
|
|
4552
|
+
.Case( 5, ()=>{
|
|
4553
|
+
|
|
4554
|
+
dist.assign( x.max( y ) );
|
|
4555
|
+
|
|
4556
|
+
} )
|
|
4557
|
+
.Case( 6, ()=>{
|
|
4558
|
+
|
|
4559
|
+
dist.assign( x.min( y ) );
|
|
4560
|
+
|
|
4561
|
+
} )
|
|
4562
|
+
.Case( 7, ()=>{
|
|
4563
|
+
|
|
4564
|
+
dist.assign( x );
|
|
4565
|
+
|
|
4566
|
+
} )
|
|
4567
|
+
.Case( 8, ()=>{
|
|
4568
|
+
|
|
4569
|
+
dist.assign( y );
|
|
4570
|
+
|
|
4571
|
+
} );
|
|
4572
|
+
|
|
4573
|
+
tsl.If( attenuation.notEqual( 0 ), ()=>{
|
|
4574
|
+
|
|
4575
|
+
xradius.mulAssign( positionView.z.mul( -1 ).smoothstep( far, near ).pow( 1/2 ) );
|
|
4576
|
+
|
|
4577
|
+
} );
|
|
4578
|
+
|
|
4579
|
+
tsl.If( dist.greaterThan( xradius ), ()=>tsl.Discard() );
|
|
4580
|
+
|
|
4581
|
+
return color;
|
|
4582
|
+
|
|
4583
|
+
} ).setLayout( {
|
|
4584
|
+
name: 'halftoneTrigRaw',
|
|
4585
|
+
type: 'vec3',
|
|
4586
|
+
inputs: [
|
|
4587
|
+
{ name: 'position', type: 'vec3' },
|
|
4588
|
+
{ name: 'scale', type: 'float' },
|
|
4589
|
+
{ name: 'radius', type: 'float' },
|
|
4590
|
+
{ name: 'pattern', type: 'int' },
|
|
4591
|
+
{ name: 'attenuation', type: 'int' },
|
|
4592
|
+
{ name: 'far', type: 'float' },
|
|
4593
|
+
{ name: 'near', type: 'float' },
|
|
4594
|
+
{ name: 'color', type: 'vec3' },
|
|
4595
|
+
{ name: 'positionView', type: 'vec3' },
|
|
4596
|
+
] }
|
|
4597
|
+
);
|
|
4598
|
+
|
|
4599
|
+
|
|
4600
|
+
|
|
4601
|
+
var halftoneRaw = tsl.Fn( ([ position, scale, radius, pattern, attenuation, far, near, color, positionView ]) => {
|
|
4602
|
+
|
|
4603
|
+
var result = tsl.vec3( 0 ).toVar();
|
|
4604
|
+
|
|
4605
|
+
tsl.Switch( pattern )
|
|
4606
|
+
.Case( 0, ()=>{
|
|
4607
|
+
|
|
4608
|
+
result.assign( halftoneGridRaw( position, scale, radius, attenuation, far, near, color, positionView ) );
|
|
4609
|
+
|
|
4610
|
+
} )
|
|
4611
|
+
.Case( 1, ()=>{
|
|
4612
|
+
|
|
4613
|
+
result.assign( halftoneDiagRaw( position, scale, radius, attenuation, far, near, color, positionView ) );
|
|
4614
|
+
|
|
4615
|
+
} )
|
|
4616
|
+
.Default( ()=>{
|
|
4617
|
+
|
|
4618
|
+
result.assign( halftoneTrigRaw( position, scale, radius, pattern, attenuation, far, near, color, positionView ) );
|
|
4619
|
+
|
|
4620
|
+
} );
|
|
4621
|
+
|
|
4622
|
+
return result;
|
|
4623
|
+
|
|
4624
|
+
} ).setLayout( {
|
|
4625
|
+
name: 'halftoneRaw',
|
|
4626
|
+
type: 'vec3',
|
|
4627
|
+
inputs: [
|
|
4628
|
+
{ name: 'position', type: 'vec3' },
|
|
4629
|
+
{ name: 'scale', type: 'float' },
|
|
4630
|
+
{ name: 'radius', type: 'float' },
|
|
4631
|
+
{ name: 'pattern', type: 'int' },
|
|
4632
|
+
{ name: 'attenuation', type: 'int' },
|
|
4633
|
+
{ name: 'far', type: 'float' },
|
|
4634
|
+
{ name: 'near', type: 'float' },
|
|
4635
|
+
{ name: 'color', type: 'vec3' },
|
|
4636
|
+
{ name: 'positionView', type: 'vec3' },
|
|
4637
|
+
] }
|
|
4638
|
+
);
|
|
4639
|
+
|
|
4640
|
+
|
|
4641
|
+
function halftone( params={} ) {
|
|
4642
|
+
|
|
4643
|
+
var { position, scale, radius, pattern, attenuation, far, near, color, positionView } = { ...defaults, ...params };
|
|
4644
|
+
|
|
4645
|
+
return halftoneRaw( position, scale, radius, pattern, attenuation, far, near, color, positionView );
|
|
4646
|
+
|
|
4647
|
+
}
|
|
4648
|
+
|
|
4649
|
+
|
|
4650
|
+
|
|
4651
|
+
halftone.defaults = defaults;
|
|
4652
|
+
|
|
4653
|
+
if ( typeof window !== 'undefined' ) {
|
|
4654
|
+
|
|
4655
|
+
window.__TSL_TEXTURES__ = 3.0;
|
|
4656
|
+
|
|
4657
|
+
}
|
|
4658
|
+
//export { aaa } from './aaa.js';
|
|
4659
|
+
|
|
4660
|
+
Object.defineProperty(exports, "fractal", {
|
|
4661
|
+
enumerable: true,
|
|
4662
|
+
get: function () { return tsl.mx_fractal_noise_float; }
|
|
4663
|
+
});
|
|
4664
|
+
Object.defineProperty(exports, "fractal3", {
|
|
4665
|
+
enumerable: true,
|
|
4666
|
+
get: function () { return tsl.mx_fractal_noise_vec3; }
|
|
4667
|
+
});
|
|
4668
|
+
Object.defineProperty(exports, "noise", {
|
|
4669
|
+
enumerable: true,
|
|
4670
|
+
get: function () { return tsl.mx_noise_float; }
|
|
4671
|
+
});
|
|
4672
|
+
Object.defineProperty(exports, "noise3", {
|
|
4673
|
+
enumerable: true,
|
|
4674
|
+
get: function () { return tsl.mx_noise_vec3; }
|
|
4675
|
+
});
|
|
4676
|
+
Object.defineProperty(exports, "voronoi", {
|
|
4677
|
+
enumerable: true,
|
|
4678
|
+
get: function () { return tsl.mx_worley_noise_float; }
|
|
4679
|
+
});
|
|
4680
|
+
Object.defineProperty(exports, "voronoi2", {
|
|
4681
|
+
enumerable: true,
|
|
4682
|
+
get: function () { return tsl.mx_worley_noise_vec2; }
|
|
4683
|
+
});
|
|
4684
|
+
Object.defineProperty(exports, "voronoi3", {
|
|
4685
|
+
enumerable: true,
|
|
4686
|
+
get: function () { return tsl.mx_worley_noise_vec3; }
|
|
4687
|
+
});
|
|
4688
|
+
exports.approximateNormal = approximateNormal;
|
|
4689
|
+
exports.brain = brain;
|
|
4690
|
+
exports.bricks = bricks;
|
|
4691
|
+
exports.camouflage = camouflage;
|
|
4692
|
+
exports.caustics = caustics;
|
|
4693
|
+
exports.caveArt = caveArt;
|
|
4694
|
+
exports.circleDecor = circleDecor;
|
|
4695
|
+
exports.circles = circles;
|
|
4696
|
+
exports.clouds = clouds;
|
|
4697
|
+
exports.concrete = concrete;
|
|
4698
|
+
exports.cork = cork;
|
|
4699
|
+
exports.crumpledFabric = crumpledFabric;
|
|
4700
|
+
exports.dalmatianSpots = dalmatianSpots;
|
|
4701
|
+
exports.darthMaul = darthMaul;
|
|
4702
|
+
exports.dysonSphere = dysonSphere;
|
|
4703
|
+
exports.entangled = entangled;
|
|
4704
|
+
exports.fordite = fordite;
|
|
4705
|
+
exports.gasGiant = gasGiant;
|
|
4706
|
+
exports.grid = grid;
|
|
4707
|
+
exports.halftone = halftone;
|
|
4708
|
+
exports.hideFallbackWarning = hideFallbackWarning;
|
|
4709
|
+
exports.hsl = hsl;
|
|
4710
|
+
exports.isolayers = isolayers;
|
|
4711
|
+
exports.isolines = isolines;
|
|
4712
|
+
exports.karstRock = karstRock;
|
|
4713
|
+
exports.marble = marble;
|
|
4714
|
+
exports.neonLights = neonLights;
|
|
4715
|
+
exports.perlinNoise = perlinNoise;
|
|
4716
|
+
exports.photosphere = photosphere;
|
|
4717
|
+
exports.planet = planet;
|
|
4718
|
+
exports.polkaDots = polkaDots;
|
|
4719
|
+
exports.processedWood = processedWood;
|
|
4720
|
+
exports.protozoa = protozoa;
|
|
4721
|
+
exports.remapExp = remapExp;
|
|
4722
|
+
exports.reticularVeins = reticularVeins;
|
|
4723
|
+
exports.romanPaving = romanPaving;
|
|
4724
|
+
exports.rotatePivot = rotatePivot;
|
|
4725
|
+
exports.rotator = rotator;
|
|
4726
|
+
exports.roughClay = roughClay;
|
|
4727
|
+
exports.runnyEggs = runnyEggs;
|
|
4728
|
+
exports.rust = rust;
|
|
4729
|
+
exports.satin = satin;
|
|
4730
|
+
exports.scaler = scaler;
|
|
4731
|
+
exports.scepterHead = scepterHead;
|
|
4732
|
+
exports.scream = scream;
|
|
4733
|
+
exports.selectPlanar = selectPlanar;
|
|
4734
|
+
exports.showFallbackWarning = showFallbackWarning;
|
|
4735
|
+
exports.spherical = spherical;
|
|
4736
|
+
exports.stars = stars;
|
|
4737
|
+
exports.staticNoise = staticNoise;
|
|
4738
|
+
exports.supersphere = supersphere;
|
|
4739
|
+
exports.tigerFur = tigerFur;
|
|
4740
|
+
exports.toHsl = toHsl;
|
|
4741
|
+
exports.translator = translator;
|
|
4742
|
+
exports.turbulentSmoke = turbulentSmoke;
|
|
4743
|
+
exports.vnoise = vnoise;
|
|
4744
|
+
exports.voronoiCells = voronoiCells;
|
|
4745
|
+
exports.waterDrops = waterDrops;
|
|
4746
|
+
exports.watermelon = watermelon;
|
|
4747
|
+
exports.waves = waves;
|
|
4748
|
+
exports.wood = wood;
|
|
4749
|
+
exports.zebraLines = zebraLines;
|