@@ -3,49 +3,48 @@ import { vertex, wgslVertex } from '../defaults';
3
3
import fragment from './simplex.frag' ;
4
4
import source from './simplex.wgsl' ;
5
5
6
-
7
6
/** Options for the SimplexNoiseFilter constructor. */
8
7
export interface SimplexNoiseFilterOptions
9
8
{
10
9
/**
11
10
* Noise map strength.
12
11
* @default 0.5
13
12
*/
14
- strength ?: 0.5 ;
13
+ strength ?: number ;
15
14
/**
16
15
* Noise map scale.
17
- * @default 10
16
+ * @default 10.0
18
17
*/
19
- noiseScale ?: 10 ;
18
+ noiseScale ?: number ;
20
19
/**
21
- * Horizontal offset for the noise map.
20
+ * Horizontal offset for the noise map.
22
21
* @default 0
23
22
*/
24
- offsetX ?: 0 ;
23
+ offsetX ?: number ;
25
24
/**
26
25
* Vertical offset for the noise map.
27
26
* @default 0
28
27
*/
29
- offsetY ?: 0 ;
28
+ offsetY ?: number ;
30
29
/**
31
30
* Depth offset for the noise map.
32
31
* @default 0
33
32
*/
34
- offsetZ ?: 0 ;
33
+ offsetZ ?: number ;
35
34
/**
36
35
* The threshold used with the step function to create a blocky effect in the noise pattern.
37
- * When this is greater than 0, the step function is used to compare the noise value to this threshold.
36
+ * When this is greater than 0, the step function is used to compare the noise value to this threshold.
38
37
* @default -1
39
38
*/
40
- step ?: - 1 ;
39
+ step ?: number ;
41
40
}
42
41
43
42
/**
44
43
* The SimplexNoiseFilter multiplies simplex noise with the current texture data. <br>
45
44
*
46
- *
47
45
* @class
48
46
* @extends Filter
47
+ * @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters }
49
48
*/
50
49
export class SimplexNoiseFilter extends Filter
51
50
{
@@ -88,32 +87,57 @@ export class SimplexNoiseFilter extends Filter
88
87
glProgram,
89
88
resources : {
90
89
simplexUniforms : {
91
- uStrength : { value : options . strength ?? 0 , type : 'f32' } ,
92
- uNoiseScale : { value : options . noiseScale ?? 0 , type : 'f32' } ,
93
- uOffsetX : { value : options . offsetX ?? 0 , type : 'f32' } ,
94
- uOffsetY : { value : options . offsetY ?? 0 , type : 'f32' } ,
95
- uOffsetZ : { value : options . offsetZ ?? 0 , type : 'f32' } ,
96
- uStep : { value : options . step ?? 0 , type : 'f32' } ,
90
+ uStrength : { value : options ? .strength ?? 0 , type : 'f32' } ,
91
+ uNoiseScale : { value : options ? .noiseScale ?? 0 , type : 'f32' } ,
92
+ uOffsetX : { value : options ? .offsetX ?? 0 , type : 'f32' } ,
93
+ uOffsetY : { value : options ? .offsetY ?? 0 , type : 'f32' } ,
94
+ uOffsetZ : { value : options ? .offsetZ ?? 0 , type : 'f32' } ,
95
+ uStep : { value : options ? .step ?? 0 , type : 'f32' } ,
97
96
}
98
97
}
99
98
} ) ;
100
99
}
101
100
101
+ /**
102
+ * Strength of the noise (color = (noiseMap + strength) * texture)
103
+ * @default 0.5
104
+ */
102
105
get strength ( ) : number { return this . resources . simplexUniforms . uniforms . uStrength ; }
103
106
set strength ( value : number ) { this . resources . simplexUniforms . uniforms . uStrength = value ; }
104
107
108
+ /**
109
+ * Noise map scale.
110
+ * @default 10
111
+ */
105
112
get noiseScale ( ) : number { return this . resources . simplexUniforms . uniforms . uNoiseScale ; }
106
113
set noiseScale ( value : number ) { this . resources . simplexUniforms . uniforms . uNoiseScale = value ; }
107
114
115
+ /**
116
+ * Horizontal offset for the noise map.
117
+ * @default 0
118
+ */
108
119
get offsetX ( ) : number { return this . resources . simplexUniforms . uniforms . uOffsetX ; }
109
120
set offsetX ( value : number ) { this . resources . simplexUniforms . uniforms . uOffsetX = value ; }
110
121
122
+ /**
123
+ * Vertical offset for the noise map.
124
+ * @default 0
125
+ */
111
126
get offsetY ( ) : number { return this . resources . simplexUniforms . uniforms . uOffsetY ; }
112
127
set offsetY ( value : number ) { this . resources . simplexUniforms . uniforms . uOffsetY = value ; }
113
128
129
+ /**
130
+ * Depth offset for the noise map.
131
+ * @default 0
132
+ */
114
133
get offsetZ ( ) : number { return this . resources . simplexUniforms . uniforms . uOffsetZ ; }
115
134
set offsetZ ( value : number ) { this . resources . simplexUniforms . uniforms . uOffsetZ = value ; }
116
135
136
+ /**
137
+ * The threshold used with the step function to create a blocky effect in the noise pattern.
138
+ * When this is greater than 0, the step function is used to compare the noise value to this threshold.
139
+ * @default -1
140
+ */
117
141
get step ( ) : number { return this . resources . simplexUniforms . uniforms . uStep ; }
118
142
set step ( value : number ) { this . resources . simplexUniforms . uniforms . uStep = value ; }
119
143
}
0 commit comments