@@ -22,7 +22,6 @@ uniform float size_div;
22
22
uniform float far_grain;
23
23
uniform float close_grain;
24
24
uniform float blur_size;
25
- uniform vec2 spawn;
26
25
uniform vec2 start;
27
26
uniform vec2 size;
28
27
@@ -112,7 +111,6 @@ vec3 get_uv_clr (vec2 uv) {
112
111
}
113
112
114
113
void main() {
115
- // vec2 uv = vTexCoord;
116
114
vec2 uv = vec2((gl_FragCoord.x - start.x) / size.x, gl_FragCoord.y / size.y);
117
115
uv.x = uv.x * size_div;
118
116
uv.xy = uv.xy * 0.9;
@@ -152,7 +150,7 @@ function rand(_min: number, _max: number) {
152
150
return _min * ( 1 - t ) + _max * t ;
153
151
}
154
152
155
- function randCoors ( ) : [ number , number ] {
153
+ function randCoords ( ) : [ number , number ] {
156
154
return [ rand ( 0.1 , 0.9 ) , rand ( 0.1 , 0.9 ) ] ;
157
155
}
158
156
@@ -238,7 +236,6 @@ export function drawGradients(
238
236
239
237
// Prepare uniform variables
240
238
const size_div = gl . getUniformLocation ( progDraw , "size_div" ) ;
241
- const spawn = gl . getUniformLocation ( progDraw , "spawn" ) ;
242
239
const blur_size = gl . getUniformLocation ( progDraw , "blur_size" ) ;
243
240
const far_grain = gl . getUniformLocation ( progDraw , "far_grain" ) ;
244
241
const close_grain = gl . getUniformLocation ( progDraw , "close_grain" ) ;
@@ -250,6 +247,7 @@ export function drawGradients(
250
247
const g2_coords = gl . getUniformLocation ( progDraw , "g2_coords" ) ;
251
248
const g3_clr = gl . getUniformLocation ( progDraw , "g3_clr" ) ;
252
249
const g3_coords = gl . getUniformLocation ( progDraw , "g3_coords" ) ;
250
+ const inPos = gl . getAttribLocation ( progDraw , "aPosition" ) ;
253
251
gl . useProgram ( progDraw ) ;
254
252
255
253
gl . enable ( gl . DEPTH_TEST ) ;
@@ -288,17 +286,16 @@ export function drawGradients(
288
286
gl . DYNAMIC_DRAW ,
289
287
) ;
290
288
291
- gl . enableVertexAttribArray ( 0 ) ;
292
- gl . vertexAttribPointer ( 0 , 2 , gl . FLOAT , false , 0 , 0 ) ;
289
+ gl . enableVertexAttribArray ( inPos ) ;
290
+ gl . vertexAttribPointer ( inPos , 2 , gl . FLOAT , false , 0 , 0 ) ;
293
291
294
292
// Set uniform variable values
295
293
const chosen_clrs = shuffle ( allColors ) . slice ( 0 , 3 ) ;
296
- const g1 = { clr : chosen_clrs [ 0 ] , coords : randCoors ( ) } ;
297
- const g2 = { clr : chosen_clrs [ 1 ] , coords : randCoors ( ) } ;
298
- const g3 = { clr : chosen_clrs [ 2 ] , coords : randCoors ( ) } ;
294
+ const g1 = { clr : chosen_clrs [ 0 ] , coords : randCoords ( ) } ;
295
+ const g2 = { clr : chosen_clrs [ 1 ] , coords : randCoords ( ) } ;
296
+ const g3 = { clr : chosen_clrs [ 2 ] , coords : randCoords ( ) } ;
299
297
300
298
gl . uniform1f ( size_div , w / h ) ; // to normalize coords in case canvas is rectangle
301
- gl . uniform2f ( spawn , Math . random ( ) * 1000 , Math . random ( ) * 1000 ) ; // random coordinate shift on simplex field
302
299
gl . uniform1f ( blur_size , 0.09 ) ; // read the name
303
300
gl . uniform1f ( far_grain , 0.3 ) ; // grain for inner parts of shapes
304
301
gl . uniform1f ( close_grain , 0.09 ) ; // grain for smoothing shapes between lines
0 commit comments