tsl-textures 1.9.0 → 1.11.0
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/README.md +58 -0
- package/package.json +204 -33
- package/src/camouflage.js +21 -19
- package/src/cave-art.js +3 -1
- package/src/circles.js +6 -4
- package/src/clouds.js +7 -3
- package/src/concrete.js +3 -1
- package/src/cork.js +3 -1
- package/src/dalmatian-spots.js +5 -3
- package/src/darth-maul.js +58 -0
- package/src/dyson-sphere.js +3 -0
- package/src/entangled.js +6 -4
- package/src/fordite.js +3 -1
- package/src/gas-giant.js +3 -1
- package/src/grid.js +4 -1
- package/src/isolines.js +3 -1
- package/src/karst-rock.js +3 -1
- package/src/marble.js +13 -11
- package/src/neon-lights.js +3 -1
- package/src/photosphere.js +3 -1
- package/src/planet.js +3 -1
- package/src/polka-dots.js +5 -3
- package/src/processed-wood.js +3 -1
- package/src/protozoa.js +3 -1
- package/src/rotator.js +5 -1
- package/src/rough-clay.js +3 -1
- package/src/runny-eggs.js +7 -0
- package/src/rust.js +7 -3
- package/src/satin.js +3 -1
- package/src/scaler.js +5 -1
- package/src/scepter-head.js +3 -1
- package/src/scream.js +3 -1
- package/src/simplex-noise.js +3 -1
- package/src/stars.js +5 -2
- package/src/supersphere.js +5 -0
- package/src/tiger-fur.js +3 -1
- package/src/translator.js +5 -1
- package/src/tsl-utils.js +89 -2
- package/src/voronoi-cells.js +3 -1
- package/src/water-drops.js +3 -1
- package/src/watermelon.js +3 -1
- package/src/wood.js +3 -1
- package/src/zebra-lines.js +3 -1
package/README.md
CHANGED
|
@@ -5,6 +5,15 @@ these are online real-time procedural generators of 3D textures.
|
|
|
5
5
|
Pick a texture from the [Project home page](https://boytchev.github.io/tsl-textures/).
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-planet.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-planet.html)
|
|
9
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-normal-map.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-normal-map.html)
|
|
10
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-wooden-toys.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-wooden-toys.html)
|
|
11
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-protozoa.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-protozoa.html)
|
|
12
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-neck-massage.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-neck-massage.html)
|
|
13
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-watermelon-supersphere.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-watermelon-supersphere.html)
|
|
14
|
+
[<img src="https://boytchev.github.io/tsl-textures/examples/example-texture-in-motion.jpg" width="200">](https://boytchev.github.io/tsl-textures/examples/example-texture-in-motion.html)
|
|
15
|
+
|
|
16
|
+
<!--
|
|
8
17
|
#### Example "Planet"
|
|
9
18
|
|
|
10
19
|
Uses [planet.js](https://boytchev.github.io/tsl-textures/docs/planet.html)
|
|
@@ -79,3 +88,52 @@ via a TSL function. Click on the image for a live demo. (Note: non-WebGPU browse
|
|
|
79
88
|
might need 30+ seconds to start up.)
|
|
80
89
|
|
|
81
90
|
[<img src="https://boytchev.github.io/tsl-textures/examples/example-texture-in-motion.jpg">](https://boytchev.github.io/tsl-textures/examples/example-texture-in-motion.html)
|
|
91
|
+
-->
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
### Use with NPM
|
|
96
|
+
|
|
97
|
+
**Install**
|
|
98
|
+
```bat
|
|
99
|
+
npm install three tsl-textures
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Use in a javascript file**
|
|
103
|
+
```js
|
|
104
|
+
// Important: Use `webgpu` version of Three.js
|
|
105
|
+
import * as THREE from 'three/webgpu';
|
|
106
|
+
|
|
107
|
+
// Import your desired texture
|
|
108
|
+
import { polkaDots } from 'tsl-textures/polka-dots';
|
|
109
|
+
|
|
110
|
+
// Create the renderer. Important: Use `WebGPURenderer`
|
|
111
|
+
renderer = new THREE.WebGPURenderer({antialias: true});
|
|
112
|
+
|
|
113
|
+
// ... Create your Three.js scene, camera, lights, etc.
|
|
114
|
+
|
|
115
|
+
// Create geometry
|
|
116
|
+
const objectGeometry = new THREE.IcosahedronGeometry(1, 12)
|
|
117
|
+
|
|
118
|
+
// Create material: Important: Use `Node` Material
|
|
119
|
+
objectMaterial = new THREE.MeshStandardNodeMaterial({
|
|
120
|
+
color: 0xCCCCCC,
|
|
121
|
+
roughness: 0.5,
|
|
122
|
+
metalness: 0.0,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Apply texture to the material's `colorNode` property
|
|
126
|
+
objectMaterial.colorNode = polkaDots ( {
|
|
127
|
+
count: 2,
|
|
128
|
+
size: 0.6,
|
|
129
|
+
blur: 0.22,
|
|
130
|
+
color: new THREE.Color(0),
|
|
131
|
+
background: new THREE.Color(16777215)
|
|
132
|
+
} );
|
|
133
|
+
|
|
134
|
+
// Assign Geometry and Material to a Mesh
|
|
135
|
+
object = new THREE.Mesh(objectGeometry, objectMaterial);
|
|
136
|
+
|
|
137
|
+
// Render
|
|
138
|
+
renderer.render( scene, camera );
|
|
139
|
+
```
|
package/package.json
CHANGED
|
@@ -1,33 +1,204 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tsl-textures",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A collection of Three.js Shading Language (TSL) textures ",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "tsl-textures",
|
|
3
|
+
"version": "1.11.0",
|
|
4
|
+
"description": "A collection of Three.js Shading Language (TSL) textures ",
|
|
5
|
+
"main": "./src/tsl-utils.js",
|
|
6
|
+
"module": "./src/tsl-utils.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./src/tsl-utils.js",
|
|
10
|
+
"import": "./src/tsl-utils.js"
|
|
11
|
+
},
|
|
12
|
+
"./camouflage": {
|
|
13
|
+
"require": "./src/camouflage.js",
|
|
14
|
+
"import": "./src/camouflage.js"
|
|
15
|
+
},
|
|
16
|
+
"./cave-art": {
|
|
17
|
+
"require": "./src/cave-art.js",
|
|
18
|
+
"import": "./src/cave-art.js"
|
|
19
|
+
},
|
|
20
|
+
"./circles": {
|
|
21
|
+
"require": "./src/circles.js",
|
|
22
|
+
"import": "./src/circles.js"
|
|
23
|
+
},
|
|
24
|
+
"./clouds": {
|
|
25
|
+
"require": "./src/clouds.js",
|
|
26
|
+
"import": "./src/clouds.js"
|
|
27
|
+
},
|
|
28
|
+
"./concrete": {
|
|
29
|
+
"require": "./src/concrete.js",
|
|
30
|
+
"import": "./src/concrete.js"
|
|
31
|
+
},
|
|
32
|
+
"./cork": {
|
|
33
|
+
"require": "./src/cork.js",
|
|
34
|
+
"import": "./src/cork.js"
|
|
35
|
+
},
|
|
36
|
+
"./dalmatian-spots": {
|
|
37
|
+
"require": "./src/dalmatian-spots.js",
|
|
38
|
+
"import": "./src/dalmatian-spots.js"
|
|
39
|
+
},
|
|
40
|
+
"./darth-maul": {
|
|
41
|
+
"require": "./src/darth-maul.js",
|
|
42
|
+
"import": "./src/darth-maul.js"
|
|
43
|
+
},
|
|
44
|
+
"./dyson-sphere": {
|
|
45
|
+
"require": "./src/dyson-sphere.js",
|
|
46
|
+
"import": "./src/dyson-sphere.js"
|
|
47
|
+
},
|
|
48
|
+
"./entangled": {
|
|
49
|
+
"require": "./src/entangled.js",
|
|
50
|
+
"import": "./src/entangled.js"
|
|
51
|
+
},
|
|
52
|
+
"./fordite": {
|
|
53
|
+
"require": "./src/fordite.js",
|
|
54
|
+
"import": "./src/fordite.js"
|
|
55
|
+
},
|
|
56
|
+
"./gas-giant": {
|
|
57
|
+
"require": "./src/gas-giant.js",
|
|
58
|
+
"import": "./src/gas-giant.js"
|
|
59
|
+
},
|
|
60
|
+
"./grid": {
|
|
61
|
+
"require": "./src/grid.js",
|
|
62
|
+
"import": "./src/grid.js"
|
|
63
|
+
},
|
|
64
|
+
"./isolines": {
|
|
65
|
+
"require": "./src/isolines.js",
|
|
66
|
+
"import": "./src/isolines.js"
|
|
67
|
+
},
|
|
68
|
+
"./karst-rock": {
|
|
69
|
+
"require": "./src/karst-rock.js",
|
|
70
|
+
"import": "./src/karst-rock.js"
|
|
71
|
+
},
|
|
72
|
+
"./marble": {
|
|
73
|
+
"require": "./src/marble.js",
|
|
74
|
+
"import": "./src/marble.js"
|
|
75
|
+
},
|
|
76
|
+
"./neon-lights": {
|
|
77
|
+
"require": "./src/neon-lights.js",
|
|
78
|
+
"import": "./src/neon-lights.js"
|
|
79
|
+
},
|
|
80
|
+
"./photosphere": {
|
|
81
|
+
"require": "./src/photosphere.js",
|
|
82
|
+
"import": "./src/photosphere.js"
|
|
83
|
+
},
|
|
84
|
+
"./planet": {
|
|
85
|
+
"require": "./src/planet.js",
|
|
86
|
+
"import": "./src/planet.js"
|
|
87
|
+
},
|
|
88
|
+
"./polka-dots": {
|
|
89
|
+
"require": "./src/polka-dots.js",
|
|
90
|
+
"import": "./src/polka-dots.js"
|
|
91
|
+
},
|
|
92
|
+
"./processed-wood": {
|
|
93
|
+
"require": "./src/processed-wood.js",
|
|
94
|
+
"import": "./src/processed-wood.js"
|
|
95
|
+
},
|
|
96
|
+
"./protozoa": {
|
|
97
|
+
"require": "./src/protozoa.js",
|
|
98
|
+
"import": "./src/protozoa.js"
|
|
99
|
+
},
|
|
100
|
+
"./rotator": {
|
|
101
|
+
"require": "./src/rotator.js",
|
|
102
|
+
"import": "./src/rotator.js"
|
|
103
|
+
},
|
|
104
|
+
"./rough-clay": {
|
|
105
|
+
"require": "./src/rough-clay.js",
|
|
106
|
+
"import": "./src/rough-clay.js"
|
|
107
|
+
},
|
|
108
|
+
"./runny-eggs": {
|
|
109
|
+
"require": "./src/runny-eggs.js",
|
|
110
|
+
"import": "./src/runny-eggs.js"
|
|
111
|
+
},
|
|
112
|
+
"./rust": {
|
|
113
|
+
"require": "./src/rust.js",
|
|
114
|
+
"import": "./src/rust.js"
|
|
115
|
+
},
|
|
116
|
+
"./satin": {
|
|
117
|
+
"require": "./src/satin.js",
|
|
118
|
+
"import": "./src/satin.js"
|
|
119
|
+
},
|
|
120
|
+
"./scaler": {
|
|
121
|
+
"require": "./src/scaler.js",
|
|
122
|
+
"import": "./src/scaler.js"
|
|
123
|
+
},
|
|
124
|
+
"./scepter-head": {
|
|
125
|
+
"require": "./src/scepter-head.js",
|
|
126
|
+
"import": "./src/scepter-head.js"
|
|
127
|
+
},
|
|
128
|
+
"./scream": {
|
|
129
|
+
"require": "./src/scream.js",
|
|
130
|
+
"import": "./src/scream.js"
|
|
131
|
+
},
|
|
132
|
+
"./simplex-noise": {
|
|
133
|
+
"require": "./src/simplex-noise.js",
|
|
134
|
+
"import": "./src/simplex-noise.js"
|
|
135
|
+
},
|
|
136
|
+
"./stars": {
|
|
137
|
+
"require": "./src/stars.js",
|
|
138
|
+
"import": "./src/stars.js"
|
|
139
|
+
},
|
|
140
|
+
"./supersphere": {
|
|
141
|
+
"require": "./src/supersphere.js",
|
|
142
|
+
"import": "./src/supersphere.js"
|
|
143
|
+
},
|
|
144
|
+
"./tiger-fur": {
|
|
145
|
+
"require": "./src/tiger-fur.js",
|
|
146
|
+
"import": "./src/tiger-fur.js"
|
|
147
|
+
},
|
|
148
|
+
"./translator": {
|
|
149
|
+
"require": "./src/translator.js",
|
|
150
|
+
"import": "./src/translator.js"
|
|
151
|
+
},
|
|
152
|
+
"./tsl-utils": {
|
|
153
|
+
"require": "./src/tsl-utils.js",
|
|
154
|
+
"import": "./src/tsl-utils.js"
|
|
155
|
+
},
|
|
156
|
+
"./voronoi-cells": {
|
|
157
|
+
"require": "./src/voronoi-cells.js",
|
|
158
|
+
"import": "./src/voronoi-cells.js"
|
|
159
|
+
},
|
|
160
|
+
"./water-drops": {
|
|
161
|
+
"require": "./src/water-drops.js",
|
|
162
|
+
"import": "./src/water-drops.js"
|
|
163
|
+
},
|
|
164
|
+
"./watermelon": {
|
|
165
|
+
"require": "./src/watermelon.js",
|
|
166
|
+
"import": "./src/watermelon.js"
|
|
167
|
+
},
|
|
168
|
+
"./wood": {
|
|
169
|
+
"require": "./src/wood.js",
|
|
170
|
+
"import": "./src/wood.js"
|
|
171
|
+
},
|
|
172
|
+
"./zebra-lines": {
|
|
173
|
+
"require": "./src/zebra-lines.js",
|
|
174
|
+
"import": "./src/zebra-lines.js"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"repository": {
|
|
178
|
+
"type": "git",
|
|
179
|
+
"url": "git+https://github.com/boytchev/tsl-textures.git"
|
|
180
|
+
},
|
|
181
|
+
"scripts": {
|
|
182
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
183
|
+
},
|
|
184
|
+
"keywords": [
|
|
185
|
+
"texture",
|
|
186
|
+
"tsl",
|
|
187
|
+
"three.js"
|
|
188
|
+
],
|
|
189
|
+
"homepage": "https://boytchev.github.io/tsl-textures/",
|
|
190
|
+
"author": "Pavel Boytchev",
|
|
191
|
+
"files": [
|
|
192
|
+
"LICENSE",
|
|
193
|
+
"package.json",
|
|
194
|
+
"README.md",
|
|
195
|
+
"src"
|
|
196
|
+
],
|
|
197
|
+
"license": "MIT",
|
|
198
|
+
"devDependencies": {
|
|
199
|
+
"@eslint/js": "^9.4.0",
|
|
200
|
+
"eslint": "^9.4.0",
|
|
201
|
+
"eslint-plugin-html": "^8.1.1",
|
|
202
|
+
"globals": "^15.4.0"
|
|
203
|
+
}
|
|
204
|
+
}
|
package/src/camouflage.js
CHANGED
|
@@ -5,43 +5,45 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from 'three';
|
|
7
7
|
import { exp, Fn, If, positionGeometry, round, vec3 } from 'three/tsl';
|
|
8
|
-
import { noise } from 'tsl-
|
|
8
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var camouflage = Fn( ( params )=>{
|
|
13
13
|
|
|
14
|
+
params = prepare( { ...camouflage.defaults, ...params } );
|
|
15
|
+
|
|
14
16
|
var pos = positionGeometry.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
15
17
|
|
|
16
18
|
var color = vec3( 0, 0, 0 ).toVar( );
|
|
17
19
|
|
|
18
|
-
If( round( noise( pos, 1, 0.2 ) ).greaterThanEqual( 1 ), () => {
|
|
19
|
-
|
|
20
|
-
color.assign( params.colorA );
|
|
21
|
-
|
|
20
|
+
If( round( noise( pos, 1, 0.2 ) ).greaterThanEqual( 1 ), () => {
|
|
21
|
+
|
|
22
|
+
color.assign( params.colorA );
|
|
23
|
+
|
|
22
24
|
}
|
|
23
25
|
)
|
|
24
|
-
.ElseIf( round( noise( pos.yzx, 1, 0.3 ) ).greaterThanEqual( 1 ), () => {
|
|
25
|
-
|
|
26
|
-
color.assign( params.colorB );
|
|
27
|
-
|
|
26
|
+
.ElseIf( round( noise( pos.yzx, 1, 0.3 ) ).greaterThanEqual( 1 ), () => {
|
|
27
|
+
|
|
28
|
+
color.assign( params.colorB );
|
|
29
|
+
|
|
28
30
|
}
|
|
29
31
|
)
|
|
30
|
-
.ElseIf( round( noise( pos.zxy, 1, 0.4 ) ).greaterThanEqual( 1 ), () => {
|
|
31
|
-
|
|
32
|
-
color.assign( params.colorC );
|
|
33
|
-
|
|
32
|
+
.ElseIf( round( noise( pos.zxy, 1, 0.4 ) ).greaterThanEqual( 1 ), () => {
|
|
33
|
+
|
|
34
|
+
color.assign( params.colorC );
|
|
35
|
+
|
|
34
36
|
}
|
|
35
37
|
)
|
|
36
|
-
.Else( () => {
|
|
37
|
-
|
|
38
|
-
color.assign( params.colorD );
|
|
39
|
-
|
|
38
|
+
.Else( () => {
|
|
39
|
+
|
|
40
|
+
color.assign( params.colorD );
|
|
41
|
+
|
|
40
42
|
}
|
|
41
43
|
);
|
|
42
44
|
|
|
43
45
|
return color;
|
|
44
|
-
|
|
46
|
+
|
|
45
47
|
} );
|
|
46
48
|
|
|
47
49
|
|
|
@@ -61,4 +63,4 @@ camouflage.defaults = {
|
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
|
|
64
|
-
export { camouflage };
|
|
66
|
+
export { camouflage };
|
package/src/cave-art.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from "three";
|
|
7
7
|
import { abs, add, exp, float, Fn, If, mix, or, positionGeometry, pow2, sub } from 'three/tsl';
|
|
8
|
-
import { noise } from 'tsl-
|
|
8
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var caveArt = Fn( ( params ) => {
|
|
12
12
|
|
|
13
|
+
params = prepare( { ...caveArt.defaults, ...params } );
|
|
14
|
+
|
|
13
15
|
var pos = positionGeometry.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
14
16
|
|
|
15
17
|
var k1 = noise( pos, 4 ).sin().toVar();
|
package/src/circles.js
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from "three";
|
|
7
7
|
import { acos, clamp, exp, float, Fn, positionGeometry, select, sin } from 'three/tsl';
|
|
8
|
-
import { hsl, toHsl } from 'tsl-
|
|
8
|
+
import { hsl, prepare, toHsl } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var circles = Fn( ( params ) => {
|
|
13
13
|
|
|
14
|
+
params = prepare( { ...circles.defaults, ...params } );
|
|
15
|
+
|
|
14
16
|
var pos = positionGeometry.normalize().toVar( );
|
|
15
17
|
|
|
16
18
|
var angle = acos( clamp( pos.y, -1, 1 ) ).mul( 20 );
|
|
@@ -21,10 +23,10 @@ var circles = Fn( ( params ) => {
|
|
|
21
23
|
|
|
22
24
|
var k = float( params.seed.sin().mul( 100 ) ).toVar();
|
|
23
25
|
|
|
24
|
-
for ( var n=0; n<=10; n++ ) {
|
|
26
|
+
for ( var n=0; n<=10; n++ ) {
|
|
25
27
|
|
|
26
28
|
k.addAssign( sin( x.mul( 2**n ).sub( Math.PI*n/2 ) ).mul( -n*( n+1 )/2 ) );
|
|
27
|
-
|
|
29
|
+
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
k.assign( k.div( 200 ).clamp( -2, 2 ) );
|
|
@@ -39,7 +41,7 @@ var circles = Fn( ( params ) => {
|
|
|
39
41
|
hue.assign( huei.add( huef ) );
|
|
40
42
|
|
|
41
43
|
return hsl( hue.div( 10 ), HSL.y, HSL.z );
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
} );
|
|
44
46
|
|
|
45
47
|
|
package/src/clouds.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from "three";
|
|
7
7
|
import { clamp, exp, Fn, min, mix, mul, positionGeometry, vec4 } from 'three/tsl';
|
|
8
|
-
import { noise } from 'tsl-
|
|
8
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -23,20 +23,24 @@ var _clouds = Fn( ( params ) => {
|
|
|
23
23
|
var a = clamp( 0, 1, mul( k, 2 ).pow( 1.5 ).sub( 1 ).mul( params.opacity ) ).toVar();
|
|
24
24
|
|
|
25
25
|
return vec4( mix( params.subcolor, params.color, min( 1, k ) ), a );
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
} );
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
var clouds = Fn( ( params ) => {
|
|
31
31
|
|
|
32
|
+
params = prepare( { ...clouds.defaults, ...params } );
|
|
33
|
+
|
|
32
34
|
return _clouds( params ).rgb;
|
|
33
|
-
|
|
35
|
+
|
|
34
36
|
} );
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
clouds.opacity = Fn( ( params ) => {
|
|
39
41
|
|
|
42
|
+
params = prepare( { ...clouds.defaults, ...params } );
|
|
43
|
+
|
|
40
44
|
return _clouds( params ).a;
|
|
41
45
|
|
|
42
46
|
} );
|
package/src/concrete.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
import { abs, cos, cross, exp, Fn, normalLocal, positionGeometry, pow, remap, sin, sub, tangentLocal, transformNormalToView, vec3 } from 'three/tsl';
|
|
7
|
-
import { noise } from 'tsl-
|
|
7
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -20,6 +20,8 @@ var surfacePos = Fn( ([ pos, normal, bump, density, seed ]) => {
|
|
|
20
20
|
|
|
21
21
|
var concrete = Fn( ( params ) => {
|
|
22
22
|
|
|
23
|
+
params = prepare( { ...concrete.defaults, ...params } );
|
|
24
|
+
|
|
23
25
|
var eps = 0.001;
|
|
24
26
|
|
|
25
27
|
var position = positionGeometry.mul( exp( params.scale.div( 2 ).add( 2 ) ) ).toVar( ),
|
package/src/cork.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from 'three';
|
|
7
7
|
import { exp, float, Fn, If, Loop, mix, positionGeometry, vec3 } from 'three/tsl';
|
|
8
|
-
import { noise, vnoise } from 'tsl-
|
|
8
|
+
import { noise, prepare, vnoise } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -18,6 +18,8 @@ var cellCenter = Fn( ([ cell ])=>{
|
|
|
18
18
|
|
|
19
19
|
var cork = Fn( ( params )=>{
|
|
20
20
|
|
|
21
|
+
params = prepare( { ...cork.defaults, ...params } );
|
|
22
|
+
|
|
21
23
|
var pos = positionGeometry.mul( exp( params.scale.div( 1.5 ).add( 1 ) ) ).add( params.seed ).toVar( );
|
|
22
24
|
|
|
23
25
|
var midCell = pos.round().toVar();
|
package/src/dalmatian-spots.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from "three";
|
|
7
7
|
import { exp, float, Fn, Loop, mix, positionGeometry } from 'three/tsl';
|
|
8
|
-
import { noise } from 'tsl-
|
|
8
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var dalmatianSpots = Fn( ( params )=>{
|
|
12
12
|
|
|
13
|
+
params = prepare( { ...dalmatianSpots.defaults, ...params } );
|
|
14
|
+
|
|
13
15
|
var pos = positionGeometry.mul( exp( params.scale ) ).add( params.seed ).sub( 1000 ).toVar( );
|
|
14
16
|
|
|
15
17
|
var k = float( 1 ).toVar();
|
|
@@ -17,7 +19,7 @@ var dalmatianSpots = Fn( ( params )=>{
|
|
|
17
19
|
var d = float( 1.5 ).sub( params.density ).mul( 2 ).toVar();
|
|
18
20
|
var count = params.density.mul( 5 ).add( 5 ).toVar();
|
|
19
21
|
|
|
20
|
-
Loop( count, ()=> {
|
|
22
|
+
Loop( count, ()=> {
|
|
21
23
|
|
|
22
24
|
k.mulAssign( noise( pos ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
|
|
23
25
|
pos.assign( pos.mul( 1.01 ) );
|
|
@@ -25,7 +27,7 @@ var dalmatianSpots = Fn( ( params )=>{
|
|
|
25
27
|
pos.assign( pos.mul( 1.01 ) );
|
|
26
28
|
k.mulAssign( noise( pos.zxy ).abs().pow( d ).mul( 100 ).sub( 50 ).clamp( 0, 1 ).oneMinus() );
|
|
27
29
|
pos.assign( pos.mul( 1.01 ) );
|
|
28
|
-
|
|
30
|
+
|
|
29
31
|
} );
|
|
30
32
|
|
|
31
33
|
return mix( params.background, params.color, k.clamp( 0, 1 ) );
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
// TSL-Textures: Darth Maul
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { Color, Vector3 } from "three";
|
|
7
|
+
import { abs, exp, Fn, mix, positionGeometry, pow, select, vec3 } from 'three/tsl';
|
|
8
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var darthMaul = Fn( ( params ) => {
|
|
13
|
+
|
|
14
|
+
params = prepare( { ...darthMaul.defaults, ...params } );
|
|
15
|
+
|
|
16
|
+
var dX = vec3( params.shift.x, 0, 0 );
|
|
17
|
+
|
|
18
|
+
var position = positionGeometry.add( params.shift ).mul( exp( params.scale.div( 1.5 ).sub( 1 ) ) ).sub( params.shift ).mul( vec3( 1, 1/2, 1/2 ) ).toVar( );
|
|
19
|
+
|
|
20
|
+
var s = select( positionGeometry.y.mul( params.angle.radians().cos() ).add( positionGeometry.z.mul( params.angle.radians().sin() ) ).greaterThan( params.distance ), 1, 0 );
|
|
21
|
+
|
|
22
|
+
// implement symmetry
|
|
23
|
+
position.x.assign( position.x.add( params.shift.x ).abs() );
|
|
24
|
+
position.y.addAssign( params.seed );
|
|
25
|
+
position.z.mulAssign( params.shift.z );
|
|
26
|
+
|
|
27
|
+
var n = noise( position ).toVar();
|
|
28
|
+
|
|
29
|
+
var k = n.sin().mul( n.mul( params.complexity.mul( 2 ).add( 1 ).exp() ).sin() ).remap( 0, 0.2, 1, -1 ).greaterThan( params.balance ).select( 0, 1 );
|
|
30
|
+
|
|
31
|
+
var c = select( position.x.greaterThan( noise( position.mul( 2.3 ) ).abs().mul( 0.5 ).add( 0.02 ) ), 1, 0 );
|
|
32
|
+
|
|
33
|
+
return mix( params.background, params.color, k.mul( s ).mul( c ).clamp( 0, 1 ) );
|
|
34
|
+
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
darthMaul.defaults = {
|
|
40
|
+
$name: 'Darth Maul',
|
|
41
|
+
|
|
42
|
+
scale: 2,
|
|
43
|
+
shift: new Vector3( 0, 0, 0 ),
|
|
44
|
+
complexity: 0,
|
|
45
|
+
|
|
46
|
+
angle: 60,
|
|
47
|
+
distance: 1.9,
|
|
48
|
+
|
|
49
|
+
color: new Color( 0xD02020 ),
|
|
50
|
+
background: new Color( 0x000000 ),
|
|
51
|
+
balance: 0,
|
|
52
|
+
|
|
53
|
+
seed: 0,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export { darthMaul };
|
package/src/dyson-sphere.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from 'three';
|
|
7
7
|
import { exp, float, Fn, Loop, mix, positionGeometry, vec3 } from 'three/tsl';
|
|
8
|
+
import { prepare } from './tsl-utils.js';
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -61,6 +62,8 @@ var noiseg = Fn( ([ pos ])=>{
|
|
|
61
62
|
|
|
62
63
|
var dysonSphere = Fn( ( params )=>{
|
|
63
64
|
|
|
65
|
+
params = prepare( { ...dysonSphere.defaults, ...params } );
|
|
66
|
+
|
|
64
67
|
var pos = positionGeometry.mul( exp( params.scale.div( 2 ).add( 0.5 ) ) ).add( params.seed ).toVar( );
|
|
65
68
|
|
|
66
69
|
var res = vec3().toVar();
|
package/src/entangled.js
CHANGED
|
@@ -5,29 +5,31 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from "three";
|
|
7
7
|
import { abs, exp, float, floor, Fn, Loop, max, mix, mul, oneMinus, positionGeometry, pow, sin } from 'three/tsl';
|
|
8
|
-
import { noise } from 'tsl-
|
|
8
|
+
import { noise, prepare } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var entangled = Fn( ( params ) => {
|
|
13
13
|
|
|
14
|
+
params = prepare( { ...entangled.defaults, ...params } );
|
|
15
|
+
|
|
14
16
|
var scale = exp( params.scale.div( 2 ) ).toVar( );
|
|
15
17
|
var pos = positionGeometry.add( params.seed ).toVar( );
|
|
16
18
|
var k = float( -10000 ).toVar( );
|
|
17
19
|
var k1 = float( 0 ).toVar( );
|
|
18
20
|
|
|
19
|
-
Loop( floor( float( params.density ) ), ()=> {
|
|
21
|
+
Loop( floor( float( params.density ) ), ()=> {
|
|
20
22
|
|
|
21
23
|
k1.assign( sin( noise( mul( pos, scale ) ).mul( 3*Math.PI ) ) );
|
|
22
24
|
k.assign( max( k, k1 ) );
|
|
23
25
|
scale.mulAssign( 1.2 );
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
} );
|
|
26
28
|
|
|
27
29
|
k.assign( oneMinus( pow( abs( k ), 5 ) ).mul( 6 ) );
|
|
28
30
|
|
|
29
31
|
return mix( params.color, params.background, k );
|
|
30
|
-
|
|
32
|
+
|
|
31
33
|
} );
|
|
32
34
|
|
|
33
35
|
|
package/src/fordite.js
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from 'three';
|
|
7
7
|
import { exp, Fn, mul, positionGeometry, sin, vec3 } from 'three/tsl';
|
|
8
|
-
import { hsl, noise } from 'tsl-
|
|
8
|
+
import { hsl, noise, prepare } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var fordite = Fn( ( params ) => {
|
|
13
13
|
|
|
14
|
+
params = prepare( { ...fordite.defaults, ...params } );
|
|
15
|
+
|
|
14
16
|
var pos = positionGeometry.mul( exp( params.scale ) ).add( params.seed ).toVar( );
|
|
15
17
|
|
|
16
18
|
var k = noise(
|
package/src/gas-giant.js
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { Color } from "three";
|
|
7
7
|
import { exp, Fn, mix, positionGeometry, vec3 } from 'three/tsl';
|
|
8
|
-
import { hsl, noise, toHsl } from 'tsl-
|
|
8
|
+
import { hsl, noise, prepare, toHsl } from './tsl-utils.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var gasGiant = Fn( ( params )=>{
|
|
13
13
|
|
|
14
|
+
params = prepare( { ...gasGiant.defaults, ...params } );
|
|
15
|
+
|
|
14
16
|
var scale = params.scale.div( 2 ).add( 1 ).toVar();
|
|
15
17
|
var pos = positionGeometry.mul( exp( scale ) ).add( params.seed ).toVar( );
|
|
16
18
|
|