diff --git a/pubspec.lock b/pubspec.lock index c131bb3..a3eb588 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "5aaf60d96c4cd00fe7f21594b5ad6a1b699c80a27420f8a837f4d68473ef09e3" + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" url: "https://pub.dev" source: hosted - version: "68.0.0" - _macros: - dependency: transitive - description: dart - source: sdk - version: "0.1.5" + version: "67.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "21f1d3720fd1c70316399d5e2bccaebb415c434592d778cce8acb967b8578808" + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" url: "https://pub.dev" source: hosted - version: "6.5.0" + version: "6.4.1" archive: dependency: transitive description: @@ -294,14 +289,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" - macros: - dependency: transitive - description: - name: macros - sha256: a8403c89b36483b4cbf9f1fcd24562f483cb34a5c9bf101cf2b0d8a083cf1239 - url: "https://pub.dev" - source: hosted - version: "0.1.0-main.5" markdown: dependency: transitive description: @@ -675,10 +662,10 @@ packages: dependency: transitive description: name: win32 - sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4 + sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" url: "https://pub.dev" source: hosted - version: "5.5.1" + version: "5.5.0" xml: dependency: transitive description: @@ -696,4 +683,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.4.0 <4.0.0" + dart: ">=3.3.0 <4.0.0" diff --git a/source/shaders/glow-stuff/index.md b/source/shaders/glow-stuff/index.md new file mode 100644 index 0000000..eb7cff0 --- /dev/null +++ b/source/shaders/glow-stuff/index.md @@ -0,0 +1,104 @@ +--- +description: Glowing text, image and eve rive animations with a shader. +shader: + title: Glow stuff + description: A glowing effect that can plug into actual flutter layouts and create a mesmerizing effect + screenshot: space.png + video: scrolling.mp4 +directory: shaders/glow-stuff/ +--- + + +```glsl +// Directional glow GLSL fragment shader. +// Based on the "Let it Glow!" pen by "Selman Ay" (https://codepen.io/selmanays/pen/yLVmEqY) +// Functioning example at: https://github.com/renancaraujo/glow_stuff_with_flutter +precision highp float; + +// Float uniforms +uniform float width; // Width of the canvas +uniform float height; // Height of the canvas +uniform float sourceX; // X position of the light source +uniform float scrollFraction; // Scroll fraction of the page in relation to the canvas +uniform float density; // Density of the "smoke" effect +uniform float lightStrength; // Strength of the light +uniform float weight; // Weight of the "smoke" effect + +// Sampler uniforms +uniform sampler2D tInput; // Input texture (the application canvas) +uniform sampler2D tNoise; // Some texture + +out vec4 fragColor; + +float sourceY = scrollFraction; +vec2 resolution = vec2(width, height); +vec2 lightSource = vec2(sourceX, sourceY); + +const int samples = 20; // The number of "copies" of the canvas made to emulate the "smoke" effect +const float decay = 0.88; // Decay of the light in each sample +const float exposure = .9; // The exposure to the light + + +float random2d(vec2 uv) { + uv /= 256.; + vec4 tex = texture(tNoise, uv); + return mix(tex.r, tex.g, tex.a); +} + +float random(vec3 xyz){ + return fract(sin(dot(xyz, vec3(12.9898, 78.233, 151.7182))) * 43758.5453); +} + +vec4 sampleTexture(vec2 uv) { + vec4 textColor = texture(tInput, uv); + return textColor; +} + +vec4 occlusion(vec2 uv, vec2 lightpos, vec4 objects) { + return (1. - smoothstep(0.0, lightStrength, length(lightpos - uv))) * (objects); +} + + +vec4 fragment(vec2 uv, vec2 fragCoord) { + vec3 colour = vec3(0); + + vec4 obj = sampleTexture(uv); + vec4 map = occlusion(uv, lightSource, obj); + + float random = random(vec3(fragCoord, 1.0));; + + float exposure = exposure + (sin(random) * .5 + 1.) * .05; + + vec2 _uv = uv; + vec2 distance = (_uv - lightSource) * (1. / float(samples) * density); + + float illumination_decay = 1.; + for (int i=0; i