/** * GLSL that effects share. An effect names what it needs in its `head`; * what several effects name is there once. */ /** * `hash( vec2 )`, `noise( vec2 )` and `fbm( vec2 )`: 0 to 1. * * The hash is one without a sine (Dave Hoskins, "Hash without Sine"): the * sine of a large number is another number on every graphics card, and * another one in WebGPU than in WebGL. */ export declare const NOISE = "\nfloat hash( vec2 p ) {\n\tvec3 q = fract( vec3( p.x, p.y, p.x ) * 0.1031 );\n\tq += dot( q, vec3( q.y, q.z, q.x ) + 33.33 );\n\treturn fract( ( q.x + q.y ) * q.z );\n}\nfloat noise( vec2 p ) {\n\tvec2 i = floor( p );\n\tvec2 f = fract( p );\n\tvec2 u = f * f * ( 3.0 - 2.0 * f );\n\treturn mix(\n\t\tmix( hash( i ), hash( i + vec2( 1.0, 0.0 ) ), u.x ),\n\t\tmix( hash( i + vec2( 0.0, 1.0 ) ), hash( i + vec2( 1.0, 1.0 ) ), u.x ),\n\t\tu.y\n\t);\n}\nfloat fbm( vec2 p ) {\n\tfloat v = 0.0;\n\tfloat a = 0.5;\n\tfor ( int i = 0; i < 5; i++ ) {\n\t\tv += a * noise( p );\n\t\tp *= 2.0;\n\t\ta *= 0.5;\n\t}\n\treturn v;\n}"; /** * `aspectUv( uv )`: uv with square pixels around the centre, so circles * are round; x runs wider than 1 on a wide quad. `fromAspect( p )`: back. */ export declare const ASPECT = "\nvec2 aspectUv( vec2 uv ) {\n\treturn ( uv - 0.5 ) * vec2( uSize.x / uSize.y, 1.0 );\n}\nvec2 fromAspect( vec2 p ) {\n\treturn p / vec2( uSize.x / uSize.y, 1.0 ) + 0.5;\n}"; /** * `near( uv, size )`: 1 under the pointer, nothing `size` heights of the * slide away from it, and nothing while the pointer is not over the slider. * `rawNear( uv, size )`: the same wherever the pointer is. */ export declare const NEAR = "\nfloat rawNear( vec2 uv, float size ) {\n\tvec2 d = ( uv - uPointer ) * vec2( uSize.x / uSize.y, 1.0 ) / size;\n\treturn exp( -3.0 * dot( d, d ) );\n}\nfloat near( vec2 uv, float size ) {\n\treturn rawNear( uv, size ) * uPointerIn;\n}"; /** `toCentre()`: how far the slide is from the middle of the view, px. */ export declare const CENTRE = "\nfloat toCentre() {\n\treturn uView.x * 0.5 - uQuad.x - uQuad.z * 0.5;\n}"; /** * `glyph( q, c )`: 1 where a character is drawn in a cell, 0 where not, * at `q` in the cell, 0 to 1. Which character is by how light `c` is, * from none to `.`, `:`, `+`, `#` and `O`: a ramp of ASCII art, made of * shapes, no font. */ export declare const GLYPH = "\nfloat glyph( vec2 q, vec3 c ) {\n\tfloat level = floor( clamp( dot( c, vec3( 0.3, 0.59, 0.11 ) ) * 1.3, 0.0, 0.999 ) * 6.0 );\n\tvec2 d = abs( q - 0.5 );\n\tfloat low = step( length( q - vec2( 0.5, 0.74 ) ), 0.11 );\n\tfloat high = step( length( q - vec2( 0.5, 0.3 ) ), 0.11 );\n\tfloat plus = max( step( d.x, 0.07 ) * step( d.y, 0.32 ), step( d.y, 0.07 ) * step( d.x, 0.32 ) );\n\tfloat grid = max( step( abs( d.x - 0.17 ), 0.06 ), step( abs( d.y - 0.17 ), 0.06 ) ) * step( d.x, 0.36 ) * step( d.y, 0.38 );\n\tfloat ring = max( step( abs( length( q - 0.5 ) - 0.3 ), 0.07 ), step( length( q - 0.5 ), 0.1 ) );\n\tfloat g = level < 0.5 ? 0.0 : low;\n\tg = level < 1.5 ? g : max( low, high );\n\tg = level < 2.5 ? g : plus;\n\tg = level < 3.5 ? g : grid;\n\treturn level < 4.5 ? g : ring;\n}";