From edb1aadf046eaf3645d8aeb083dccf3aa994c7c7 Mon Sep 17 00:00:00 2001 From: Dongho Kim Date: Tue, 9 Dec 2025 21:46:46 +0100 Subject: [PATCH] update --- .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 235 bytes .../__pycache__/security.cpython-311.pyc | Bin 0 -> 1691 bytes .../__pycache__/security.cpython-312.pyc | Bin 1143 -> 1466 bytes app/security/security.py | 6 + app/static/js/noise_letter.js | 180 ++++++++++++++++++ app/static/shaders/fragment.glsl | 58 ++++++ app/static/shaders/vertex.glsl | 7 + app/templates/noise_letter.html | 64 +++++++ 8 files changed, 315 insertions(+) create mode 100644 app/security/__pycache__/__init__.cpython-311.pyc create mode 100644 app/security/__pycache__/security.cpython-311.pyc create mode 100644 app/static/js/noise_letter.js create mode 100644 app/static/shaders/fragment.glsl create mode 100644 app/static/shaders/vertex.glsl create mode 100644 app/templates/noise_letter.html diff --git a/app/security/__pycache__/__init__.cpython-311.pyc b/app/security/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1d332e23071c7e1bb9d19b968ce09749d8bddacd GIT binary patch literal 235 zcmZ3^%ge<81UCJ;nQB1#F^B^LOi;#WAs}NqLkdF*V-7lIY~;;_lhPbtkwwJYKP8VGVg Xu`H1Iz|6?Vc!NRp0yb2{22=q68reSc literal 0 HcmV?d00001 diff --git a/app/security/__pycache__/security.cpython-311.pyc b/app/security/__pycache__/security.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c5c0e6cfb8db5d55ecefede5116a76ad9e4395ac GIT binary patch literal 1691 zcmcIjy>Amq6rY)0J9g~g;0xju(2-LvkzA1F(t!997eN6?xl`_FEKaM9cf205U(AdN zwkRS&!F6=Bsd7X~kw1Zw(ngkuwn93cbk`Y$ii$UDubl{|pkQ|A?b~_p_ujnU%=>#{ zVjRJ^_SYqLK||;t^^**}uN<7k2)#r$vayRiT*e+L6RiG;t9g1^$A}<`ZOzslyqnr0 z2<^b^jdBWXx}Dw~+kz-NF#GFin%W#o{tkcb%u!D}OG%a3DU z{~|*6*a#CNBb@jm!nj@d9hD~kSGy{aDErHAw^xF?q&ym1p%3d+$P$hUcbNacTKt20 zp=(Jhnps28N}V&=h%$)==yb?wl|7DhX*nXw%ETW+WNpT2MFzal%owXYSQjb<@1>{= zScP4rVLpX3&L+TfQB5 zreF6~DPO2b&y94oR?>J50Fmxn9*r`Uz?amQVw>=+TAoa5U!fuld_lKy>@U=AWMt7hD!Voe62;V?O1>ijxgHLNfkEDV%|uo2BB8+3z;<(d`V2xZ`KE37q4 zh)I1%*7y`8%fJ*DK>P>K2KqNQ^)5H}HaE9FdAjw(<=53W)z+Ik33vNj z7Jf2LWcCuprSsFUgV8llA9gk$F;TZ%*6fu#4JdWs$Cmr^vE?q8a?x1T64DA8SDnDs z=|;u=(n7y6neXtFG8B>?HhJ9py*sZtRK`~>W}d74Y@?XY_`p78u6lu8cjc^@B8AJ7p2WBdk^;Rw~9;c;!>x$v{Bg4pLzc4=2|Pi*v>C@ z@{1eUZW@u3@9@-HJoTd7#xor}(FmoT{6XT2hi)G<^!}fuJiIweVkpxg7v!5pS zJnVa4|3mUS|}!$S5)){xYK~Sa3!9 UCkCM0XJ!T_wT~cGMG8P&0N1`yQ2+n{ delta 119 zcmdnR{hfpFG%qg~0}w2%G0iMun#d=?xM8CDMwUumO}@; NM 0.95) { + charW = 0.95; + charH = charW * screenAspect / currentAspect; + } + + charX = 0.5 - charW / 2; + charY = 0.5 - charH / 2; + } + window.addEventListener('resize', resize); + resize(); + + function render(time) { + time *= 0.001; // Seconds + + gl.uniform1f(uTime, time); + gl.uniform2f(uRes, canvas.width, canvas.height); + + gl.uniform2f(uCharPos, charX, charY); // uniform needs bottom-left + gl.uniform2f(uCharSize, charW, charH); + + gl.drawArrays(gl.TRIANGLES, 0, 6); + requestAnimationFrame(render); + } + requestAnimationFrame(render); +} + +main(); diff --git a/app/static/shaders/fragment.glsl b/app/static/shaders/fragment.glsl new file mode 100644 index 0000000..c475fa6 --- /dev/null +++ b/app/static/shaders/fragment.glsl @@ -0,0 +1,58 @@ +precision mediump float; + +uniform float u_time; +uniform vec2 u_resolution; +uniform sampler2D u_charTexture; +uniform vec2 u_charPos; // Normalized 0-1 (Bottom-Left) +uniform vec2 u_charSize; // Normalized 0-1 (Width, Height) + +varying vec2 vUv; + +// reliable pseudo-random hash +float random(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); +} + +void main() { + // Correct UV for aspect ratio if needed, but here we work in screen space mostly + + // Background Noise + // Use floor to ensure we are sampling integer grid, making it purely pixel-noise + vec2 gridPos = floor(gl_FragCoord.xy); + float bgNoise = random(gridPos); + float val = step(0.5, bgNoise); + + // Character Composition + vec2 charEnd = u_charPos + u_charSize; + bool inBox = (vUv.x >= u_charPos.x && vUv.x <= charEnd.x && + vUv.y >= u_charPos.y && vUv.y <= charEnd.y); + + if (inBox) { + vec2 texUv = (vUv - u_charPos) / u_charSize; + texUv.y = 1.0 - texUv.y; + + vec4 texColor = texture2D(u_charTexture, texUv); + + // Hard threshold to avoid any smooth edges revealing the shape + if (texColor.a > 0.5) { + // Inner Character Noise - Scrolls Down + float scrollSpeed = 200.0; + // Calculate scrolled position + vec2 scrollCoords = gl_FragCoord.xy; + scrollCoords.y += u_time * scrollSpeed; + + // IMPORTANT: Floor the scrolled coordinates! + // This ensures the noise "pixels" look exactly like the background "pixels" in size and sharpness. + // If we don't floor, we get sub-pixel sampling which might look different (smooth/shimmering). + vec2 charGridPos = floor(scrollCoords); + + // Use different seed offset to distinguish content, but same distribution + float charNoise = random(charGridPos + vec2(42.0, 99.0)); + val = step(0.5, charNoise); + } + } + + gl_FragColor = vec4(vec3(1.0 - val), 1.0); +} diff --git a/app/static/shaders/vertex.glsl b/app/static/shaders/vertex.glsl new file mode 100644 index 0000000..48262e1 --- /dev/null +++ b/app/static/shaders/vertex.glsl @@ -0,0 +1,7 @@ +attribute vec2 position; +varying vec2 vUv; + +void main() { + vUv = position * 0.5 + 0.5; + gl_Position = vec4(position, 0.0, 1.0); +} diff --git a/app/templates/noise_letter.html b/app/templates/noise_letter.html new file mode 100644 index 0000000..ad80d66 --- /dev/null +++ b/app/templates/noise_letter.html @@ -0,0 +1,64 @@ +{% extends "base.html" %} + +{% block title %}Noise Letter{% endblock %} + +{% block css %} + +{% endblock %} + +{% block content %} +
+
+ + +
+
+ +
+

Visualizing text as noise signal

+
+{% endblock %} + +{% block js %} + +{% endblock %} \ No newline at end of file