| 1 |
// based on https://www.shadertoy.com/view/4d2XzG# |
| 2 |
|
| 3 |
vec2 getNewUV( vec2 uv, vec2 pos, float radius, float strength, out float dist) |
| 4 |
{ |
| 5 |
vec2 fromUVToPoint = pos - uv; |
| 6 |
dist = length( fromUVToPoint ); |
| 7 |
|
| 8 |
float mag = (1.0 - (dist / radius)) * strength; |
| 9 |
mag *= step( dist, radius ); |
| 10 |
|
| 11 |
return uv + (mag * fromUVToPoint); |
| 12 |
} |
| 13 |
|
| 14 |
vec4 proceduralTexture2D( vec2 uv, vec2 resolution ) |
| 15 |
{ |
| 16 |
vec2 fragCoord = (uv * resolution.x ); |
| 17 |
vec3 brightColor = vec3( 1.0, 1.0, 1.0 ); |
| 18 |
vec3 darkColor = vec3( 0.0, 0.0, 0.0 ); |
| 19 |
vec2 p = floor( (fragCoord.xy / resolution.x) * 10.0 ); |
| 20 |
|
| 21 |
|
| 22 |
float t = mod(p.x + p.y, 2.0) * 10.0; |
| 23 |
vec3 color = mix( darkColor, brightColor, t); |
| 24 |
return vec4( color, 1.0 ); |
| 25 |
} |
| 26 |
|
| 27 |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) |
| 28 |
{ |
| 29 |
vec2 uv = (fragCoord.xy / iResolution.xy) * 2.0 - 1.0; |
| 30 |
uv.x *= iResolution.x / iResolution.y; |
| 31 |
|
| 32 |
float radius = 0.50; |
| 33 |
|
| 34 |
float ct = cos( iTime / 3.0 ); |
| 35 |
float st0 = sin( iTime / 3.0 ); |
| 36 |
float st1 = sin( iTime ); |
| 37 |
|
| 38 |
vec2 origin = vec2( 0.0, 0.0 ); |
| 39 |
float x = origin.x + ( ct * st0) * 2.70; |
| 40 |
float y = origin.y + ( st1 ) * 0.50; |
| 41 |
vec2 pos = vec2(x,y); |
| 42 |
|
| 43 |
|
| 44 |
float dist = 0.0; |
| 45 |
vec2 newUV = getNewUV( uv, pos, radius, 0.5, dist); |
| 46 |
|
| 47 |
float start = 0.42; |
| 48 |
float glowT = sin(iTime)*0.5 + 0.5; |
| 49 |
float outlineRadius = radius + (1.0-glowT)*0.01 + (glowT * 0.08); |
| 50 |
vec4 highlight = vec4( 0.00, 0.00, 0.00, 1.0 ); |
| 51 |
float t = (outlineRadius - start) / max( (dist - start), 0.01); |
| 52 |
highlight = mix( vec4( 0.00, 0.00, 0.00, 1.0 ), vec4( 0.00, 0.50, 0.80, 1.0 ), t); |
| 53 |
|
| 54 |
vec4 color = proceduralTexture2D( newUV, iResolution.xy ) + highlight; |
| 55 |
color.a = 1.0; |
| 56 |
|
| 57 |
fragColor = color; |
| 58 |
|
| 59 |
} |