Library / Shader / RAG answer 36 of 41
RAG answer
A question lands among a field of document pages; the three closest pages light up and are pulled in around it, and an answer page beside them writes itself line by line from those three, each part ending in a citation mark.
= 35.0 || q.y < 0.0 || q.y >= 56.4) return 0.0;
float lc = floor(q.x / 7.0); float lk = floor(q.y / 9.4);
float hs = hash(vec2(lc + s * 5.0, lk + s));
float v = mix(0.13, 0.28, lit) + 0.05 * sin(ph + hs * 40.0);
if (lk < 0.5) { if (lc < 2.0 + floor(2.0 * hash(vec2(s, 1.0)))) v = mix(0.45, 1.1, lit); }
else if (lk > 1.5) { if (lc < 2.0 + floor(3.6 * hash(vec2(s, lk)))) v = mix(0.3, 0.72, lit) + 0.4 * hot; }
return v;
}
// The question: a speech bubble 9 columns by 4 cells, two lines of words inside its rim, a tail under its left end.
float bubble(vec2 p, vec2 c, float k) {
vec2 q = p - c + vec2(31.5, 18.8);
if (q.x < 0.0 || q.x >= 63.0 || q.y < 0.0 || q.y >= 47.0) return 0.0;
float lc = floor(q.x / 7.0); float lk = floor(q.y / 9.4);
float side = (lc < 0.5 || lc > 7.5) ? 1.0 : 0.0;
float v = 0.0;
if (lk < 3.5) {
if (lk < 0.5 || lk > 2.5) v = side > 0.5 ? 0.0 : 0.45;
else if (side > 0.5) v = 0.45;
else if (lk < 1.5 || lc < 5.5) v = 1.15;
} else if (lc > 0.5 && lc < 2.5) v = 0.45;
return v * k;
}
float field(vec2 p, float t) {
if (p.x < 24.0 || p.x > 696.0 || p.y < 24.0 || p.y > 436.0) return 0.0;
float ph = TAU * t / T;
float v = 0.0;
// the rest of the field, idle
v = max(v, page(p, vec2(70.0, 78.0), 4.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(150.0, 58.0), 5.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(250.0, 60.0), 6.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(390.0, 64.0), 7.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(452.0, 108.0), 8.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(90.0, 162.0), 9.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(404.0, 182.0), 10.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(62.0, 310.0), 11.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(134.0, 360.0), 12.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(204.0, 404.0), 13.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(392.0, 330.0), 14.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(352.0, 404.0), 15.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(450.0, 380.0), 16.0, 0.0, 0.0, ph));
v = max(v, page(p, vec2(66.0, 400.0), 17.0, 0.0, 0.0, ph));
// the three nearest: let go as the next question comes in, lit as the ring reaches them, pulled in, read and sent
{
float g = t < 1.5 ? 1.0 - ease((t - 0.3) / 0.6) : ease((t - 1.850) / 0.65);
float lit = t < 1.0 ? 1.0 - sm(0.3, 0.75, t) : sm(1.379, 1.499, t);
float hot = exp(-pow(t - 2.590, 2.0) / 0.006);
v = max(v, page(p, mix(vec2(165.0, 175.0), vec2(220.0, 182.0), g), 1.0, lit, hot, ph));
}
{
float g = t < 1.5 ? 1.0 - ease((t - 0.3) / 0.6) : ease((t - 1.910) / 0.65);
float lit = t < 1.0 ? 1.0 - sm(0.3, 0.75, t) : sm(1.459, 1.579, t);
float hot = exp(-pow(t - 2.840, 2.0) / 0.006);
v = max(v, page(p, mix(vec2(300.0, 350.0), vec2(262.0, 302.0), g), 2.0, lit, hot, ph));
}
{
float g = t < 1.5 ? 1.0 - ease((t - 0.3) / 0.6) : ease((t - 1.970) / 0.65);
float lit = t < 1.0 ? 1.0 - sm(0.3, 0.75, t) : sm(1.587, 1.707, t);
float hot = exp(-pow(t - 3.090, 2.0) / 0.006);
v = max(v, page(p, mix(vec2(335.0, 125.0), vec2(282.0, 180.0), g), 3.0, lit, hot, ph));
}
// the question: the last one fades as the next comes in along the lane and lands
v = max(v, bubble(p, vec2(250.0, 238.0), 1.0 - sm(0.3, 0.5, t)));
v = max(v, bubble(p, mix(vec2(40.0, 238.0), vec2(250.0, 238.0), ease((t - 0.3) / 0.8)), sm(0.3, 0.45, t)));
{
float u = clamp((t - 0.3) / 0.8, 0.0, 1.0);
float sp = (u > 0.0 && u < 1.0) ? sin(3.14159 * u) : 0.0;
vec2 b = mix(vec2(40.0, 238.0), vec2(250.0, 238.0), ease(u));
for (int s = 1; s <= 3; s++) v += blob(p, b - vec2(32.0 + 13.0 * float(s), 0.0), 9.0 - 1.5 * float(s), sp * (0.5 - 0.12 * float(s)));
}
// the search ring
if (t > 1.100 && t < 1.750) {
float u = (t - 1.100) / 0.650;
float R = 14.0 + 136.0 * (1.0 - (1.0 - u) * (1.0 - u));
v += 0.5 * (1.0 - u) * exp(-pow(length((p - vec2(250.0, 238.0)) * vec2(1.0, 1.0)) - R, 2.0) / 90.0);
}
// the line to the answer: dotted, on one row of cells; each part runs down it with a short tail
if (abs(p.y - 238.500) < 1.0 && p.x > 290.0 && p.x < 535.0 && mod(floor((p.x - 4.0) / 7.0 + 0.5), 2.0) < 0.5) v = max(v, 0.3);
{
float u = clamp((t - 2.650) / 0.4, 0.0, 1.0);
if (u > 0.0 && u < 1.0) { float x = mix(304.0, 520.0, ease(u)); float k = sm(0.0, 0.1, u) * (1.0 - sm(0.85, 1.0, u)); v += blob(p, vec2(x, 238.500), 9.0, 1.2 * k) + blob(p, vec2(x - 14.0, 238.500), 6.0, 0.45 * k); }
}
{
float u = clamp((t - 2.900) / 0.4, 0.0, 1.0);
if (u > 0.0 && u < 1.0) { float x = mix(304.0, 520.0, ease(u)); float k = sm(0.0, 0.1, u) * (1.0 - sm(0.85, 1.0, u)); v += blob(p, vec2(x, 238.500), 9.0, 1.2 * k) + blob(p, vec2(x - 14.0, 238.500), 6.0, 0.45 * k); }
}
{
float u = clamp((t - 3.150) / 0.4, 0.0, 1.0);
if (u > 0.0 && u < 1.0) { float x = mix(304.0, 520.0, ease(u)); float k = sm(0.0, 0.1, u) * (1.0 - sm(0.85, 1.0, u)); v += blob(p, vec2(x, 238.500), 9.0, 1.2 * k) + blob(p, vec2(x - 14.0, 238.500), 6.0, 0.45 * k); }
}
// the answer page: faint paper; six lines, each written left to right by a hot head; a citation mark after each part
{
vec2 q = p - vec2(556.0, 177.0);
if (q.x >= 0.0 && q.x < 105.0 && q.y >= 0.0 && q.y < 122.2) {
float lc = floor(q.x / 7.0); float lk = floor(q.y / 9.4);
float a = 0.15 + 0.04 * sin(ph + hash(vec2(lc, lk)) * 40.0);
float clear = 1.0 - sm(0.3, 0.6, t);
for (int j = 0; j < 6; j++) {
float fj = float(j);
float w = fj < 0.5 ? 3.050 : fj < 1.5 ? 3.210 : fj < 2.5 ? 3.370 : fj < 3.5 ? 3.530 : fj < 4.5 ? 3.690 : 3.850;
float len = fj < 0.5 ? 13.0 : fj < 1.5 ? 11.0 : fj < 2.5 ? 12.0 : fj < 3.5 ? 9.0 : fj < 4.5 ? 12.0 : 7.0;
if (abs(lk - 1.0 - 2.0 * fj) < 0.5) {
float hc = min(len, 1.0 + floor(len * clamp((t - w) / 0.160, 0.0, 1.0)));
float on = t < 1.0 ? clear : step(w, t) * step(lc, hc);
if (lc >= 1.0 && lc < 1.0 + len) a = max(a, 0.72 * on);
if (t > w && t < w + 0.160 && abs(lc - hc) < 0.5) a = max(a, 1.2);
// the citation mark, two cells after a part's last line
if (mod(fj, 2.0) > 0.5 && abs(lc - len - 2.0) < 0.5) a = max(a, 1.15 * (t < 1.0 ? clear : sm(w + 0.160, w + 0.220, t)));
}
}
v = max(v, a);
}
}
return v;
}]]>
Light Dark ReplayNot quite it? Ask for a variation
Install Writes one React component and its WebGL runtime into components/illos. Nothing else to install.
The live field draws with WebGL and comes with the one-line add. The SVG you copy or download is its still frame and its labels.
CLI Manual
$ npx shadcn@latest add https://illos.dev/r/shader/rag.jsonOr hand it to your agent Claude Code, Cursor, Codex and any other coding agent can add it from the prompt.
How it moves a question lands in a field of document pages. the three closest pages light up and are pulled in around it. the answer writes itself from them, each part ending in a citation. Where it fits For AI search, support assistants and knowledge base products: a features card on answers from your own docs, a docs page on retrieval, or a landing page section on grounded answers. A question landing among document pages, the three closest lighting up, and the answer writing itself with a citation after each part shows why the answer can be trusted: it says where it came from. As a spot it fits a feature card or a short paragraph. It is free to copy and pairs with Vector search, Embeddings and Search ranking.
Pairs well with Vector search , Embeddings , Search ranking and Context window .
For developers
File size 5.9 KB gzipped
Motion Plays once, 4.5 s, then holds
Reduced motion Shows a still
File rag.svg