diff --git a/assets/matrixFont.svg b/assets/matrixFont.svg index 22a9e1a..f612709 100644 --- a/assets/matrixFont.svg +++ b/assets/matrixFont.svg @@ -27,9 +27,9 @@ inkscape:document-units="mm" showgrid="true" units="px" - inkscape:zoom="7.2071955" - inkscape:cx="45.163199" - inkscape:cy="43.428821" + inkscape:zoom="3.2650549" + inkscape:cx="194.33058" + inkscape:cy="126.49098" inkscape:window-width="1920" inkscape:window-height="1131" inkscape:window-x="0" @@ -41,28 +41,139 @@ id="grid8183" empspacing="2" spacingx="4.2333333" - spacingy="4.2333333" /> + spacingy="4.2333333" + color="#cbcbff" + opacity="0.1254902" + empcolor="#ffffff" + empopacity="0.25098039" /> + id="filter972" + x="-0.014295474" + y="-0.01399304" + width="1.0285909" + height="1.0279861"> + stdDeviation="0.78384108" + id="feGaussianBlur970" /> + + + + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσΤτΥυΦφΧχΨψΩω1234567890АаБбВвГгДдЕеЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЬьЭэЮюЯя!"#$%&()*+,-/:;<=>?@©§[\]{|}~ªº¿®¬½¼¡¶ = 0 ? exp(-distToDrop/TRAIL_LENGTH) : 0, - clamp(uSizeY*distToDrop, 0, FADE_WIDTH) / FADE_WIDTH); + float distToDrop = (uProgress*2-delay)*speed - fragCoord.y; + float rainAlpha = distToDrop >= 0 ? exp(-distToDrop/TRAIL_LENGTH) : 0; + float windowAlpha = 1 - clamp(uSizeY*distToDrop, 0, FADE_WIDTH) / FADE_WIDTH; + return vec2(rainAlpha, windowAlpha); } void main() { - vec3 color = vec3(0.1,1,0.35); - - // Get a cool matrix effect. + // Get a cool matrix effect. See comments for those methods above. vec2 rain = getRain(cogl_tex_coord_in[0].st); float text = getText(cogl_tex_coord_in[0].st); // Get the window texture and fade it according to the effect mask. - float windowAlpha = 1 - rain.y; - cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st) * windowAlpha; - - float finalFade = 1-clamp((uProgress-FINAL_FADE_START_TIME)/(1-FINAL_FADE_START_TIME), 0, 1); - float textAlpha = finalFade * rain.x * BRIGHTNESS_BOOST; + cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st) * rain.y; + // This is used to fade out the remaining trails in the end. + float finalFade = 1-clamp((uProgress-FINAL_FADE_START_TIME)/ + (1-FINAL_FADE_START_TIME), 0, 1); + float rainAlpha = finalFade * rain.x; // Fade at window borders. vec2 pos = cogl_tex_coord_in[0].st * vec2(uSizeX, uSizeY); - textAlpha *= clamp(pos.x / EDGE_FADE, 0, 1); - textAlpha *= clamp(pos.y / EDGE_FADE, 0, 1); - textAlpha *= clamp((uSizeX - pos.x) / EDGE_FADE, 0, 1); - textAlpha *= clamp((uSizeY - pos.y) / EDGE_FADE, 0, 1); + rainAlpha *= clamp(pos.x / EDGE_FADE, 0, 1); + rainAlpha *= clamp(pos.y / EDGE_FADE, 0, 1); + rainAlpha *= clamp((uSizeX - pos.x) / EDGE_FADE, 0, 1); + rainAlpha *= clamp((uSizeY - pos.y) / EDGE_FADE, 0, 1); - // Add the fire to the window. - cogl_color_out.rgb += color * textAlpha * text; + // Add the matrix effect to the window. + vec3 trailColor = vec3(0.1,1,0.35); + vec3 tipColor = vec3(1,1,1); + cogl_color_out.rgb += mix(trailColor, tipColor, pow(rainAlpha, 5)) * rainAlpha * text; + + // These are pretty useful for understanding how this works. + // cogl_color_out = vec4(vec3(text), 1); + // cogl_color_out = vec4(vec3(rain.x), 1); + // cogl_color_out = vec4(vec3(rain.y), 1); } `); }; diff --git a/src/extension/shaderSnippets.js b/src/extension/shaderSnippets.js index d2191c8..93b3876 100644 --- a/src/extension/shaderSnippets.js +++ b/src/extension/shaderSnippets.js @@ -37,7 +37,7 @@ function standardUniforms() { function noise() { return ` float rand(vec2 co) { - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); + return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453); } vec2 rand2(vec2 co) {