my dotfiles
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add blaze shader

+133 -2
+130
ghostty/blaze.glsl
··· 1 + float ease(float x) { 2 + return pow(1.0 - x, 10.0); 3 + } 4 + 5 + float sdBox(in vec2 p, in vec2 xy, in vec2 b) 6 + { 7 + vec2 d = abs(p - xy) - b; 8 + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); 9 + } 10 + 11 + float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b) 12 + { 13 + vec2 d = abs(p - xy) - b; 14 + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); 15 + } 16 + // Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/ 17 + // Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching 18 + float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) { 19 + vec2 e = b - a; 20 + vec2 w = p - a; 21 + vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0); 22 + float segd = dot(p - proj, p - proj); 23 + d = min(d, segd); 24 + 25 + float c0 = step(0.0, p.y - a.y); 26 + float c1 = 1.0 - step(0.0, p.y - b.y); 27 + float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x); 28 + float allCond = c0 * c1 * c2; 29 + float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2); 30 + float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond)); 31 + s *= flip; 32 + return d; 33 + } 34 + 35 + float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) { 36 + float s = 1.0; 37 + float d = dot(p - v0, p - v0); 38 + 39 + d = seg(p, v0, v3, s, d); 40 + d = seg(p, v1, v0, s, d); 41 + d = seg(p, v2, v1, s, d); 42 + d = seg(p, v3, v2, s, d); 43 + 44 + return s * sqrt(d); 45 + } 46 + 47 + vec2 normalize(vec2 value, float isPosition) { 48 + return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y; 49 + } 50 + 51 + float blend(float t) 52 + { 53 + float sqr = t * t; 54 + return sqr / (2.0 * (sqr - t) + 1.0); 55 + } 56 + 57 + float antialising(float distance) { 58 + return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance); 59 + } 60 + 61 + float determineStartVertexFactor(vec2 a, vec2 b) { 62 + // Conditions using step 63 + float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y 64 + float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y 65 + 66 + // If neither condition is met, return 1 (else case) 67 + return 1.0 - max(condition1, condition2); 68 + } 69 + vec2 getRectangleCenter(vec4 rectangle) { 70 + return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.)); 71 + } 72 + 73 + const vec4 TRAIL_COLOR = vec4(1.0, 0.725, 0.161, 1.0); // yellow 74 + const vec4 CURRENT_CURSOR_COLOR = TRAIL_COLOR; 75 + const vec4 PREVIOUS_CURSOR_COLOR = TRAIL_COLOR; 76 + const vec4 TRAIL_COLOR_ACCENT = vec4(1.0, 0., 0., 1.0); // red-orange 77 + const float DURATION = .5; 78 + const float OPACITY = .2; 79 + 80 + void mainImage(out vec4 fragColor, in vec2 fragCoord) 81 + { 82 + #if !defined(WEB) 83 + fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy); 84 + #endif 85 + //Normalization for fragCoord to a space of -1 to 1; 86 + vec2 vu = normalize(fragCoord, 1.); 87 + vec2 offsetFactor = vec2(-.5, 0.5); 88 + 89 + //Normalization for cursor position and size; 90 + //cursor xy has the postion in a space of -1 to 1; 91 + //zw has the width and height 92 + vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.)); 93 + vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.)); 94 + 95 + //When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor 96 + float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy); 97 + float invertedVertexFactor = 1.0 - vertexFactor; 98 + 99 + //Set every vertex of my parellogram 100 + vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w); 101 + vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y); 102 + vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y); 103 + vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w); 104 + 105 + vec4 newColor = vec4(fragColor); 106 + 107 + float progress = blend(clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1)); 108 + float easedProgress = ease(progress); 109 + 110 + //Distance between cursors determine the total length of the parallelogram; 111 + vec2 centerCC = getRectangleCenter(currentCursor); 112 + vec2 centerCP = getRectangleCenter(previousCursor); 113 + float lineLength = distance(centerCC, centerCP); 114 + float distanceToEnd = distance(vu.xy, centerCC); 115 + float alphaModifier = distanceToEnd / (lineLength * (easedProgress)); 116 + 117 + if (alphaModifier > 1.0) { // this change fixed it for me. 118 + alphaModifier = 1.0; 119 + } 120 + 121 + float sdfCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5); 122 + float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3); 123 + 124 + newColor = mix(newColor, TRAIL_COLOR_ACCENT, 1.0 - smoothstep(sdfTrail, -0.01, 0.001)); 125 + newColor = mix(newColor, TRAIL_COLOR, antialising(sdfTrail)); 126 + 127 + newColor = mix(fragColor, newColor, 1.0 - alphaModifier); 128 + fragColor = mix(newColor, fragColor, step(sdfCursor, 0)); 129 + 130 + }
+3 -2
ghostty/config
··· 7 7 8 8 # font options 9 9 font-family = "SFMono Nerd Font" 10 - #font-family = "Berkeley Mono" 10 + # font-family = "Berkeley Mono" 11 11 # font-family = "Fragment Mono" 12 12 # font-family = "MonaspiceNe NFM" 13 13 ··· 18 18 19 19 # shaders 20 20 # custom-shader = ./starfield-colors.glsl 21 - # custom-shader-animation = always 21 + custom-shader = ./blaze.glsl 22 + custom-shader-animation = always 22 23 23 24 # window 24 25 window-padding-x = 10