[{"data":1,"prerenderedAt":339,"buildId":340},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fop\u002Fkernel":3,"github-stars":247,"guide-nav":249},{"id":4,"title":5,"body":6,"categoryId":60,"categorySlug":60,"categoryTitle":232,"curated":233,"description":234,"editUrl":235,"extension":236,"group":237,"groupTitle":238,"kind":239,"meta":240,"navigation":241,"path":242,"seo":243,"sourceUrl":244,"stem":245,"wordCount":235,"__hash__":246},"primitives\u002Fdocs\u002Fprimitives\u002F47.op\u002F11.kernel.md","kernel",{"type":7,"value":8,"toc":228},"minimark",[9,12,21,55,69,111,116,171,175,224],[10,11,5],"h1",{"id":5},[13,14,15,16,20],"p",{},"Your own grid step, run once per cell: return the cell's new ",[17,18,19],"code",{},"vec4f",".",[22,23,28],"pre",{"className":24,"code":25,"language":26,"meta":27,"style":27},"language-ts shiki shiki-themes github-dark","kernel(body: WgslBody | string, opts: {iterations?: number} = {}): CellKernelOp\n","ts","",[17,29,30],{"__ignoreMap":27},[31,32,35,38,42,46,49,52],"span",{"class":33,"line":34},"line",1,[31,36,5],{"class":37},"svObZ",[31,39,41],{"class":40},"s95oV","(body: WgslBody ",[31,43,45],{"class":44},"snl16","|",[31,47,48],{"class":40}," string, opts: {iterations?: number} ",[31,50,51],{"class":44},"=",[31,53,54],{"class":40}," {}): CellKernelOp\n",[13,56,57,58,61,62,65,66,20],{},"Import ",[17,59,60],{},"op"," from ",[17,63,64],{},"shaders\u002Fstd"," and use ",[17,67,68],{},"op.kernel",[13,70,71,72,75,76,79,80,82,83,86,87,90,91,94,95,98,99,102,103,106,107,110],{},"It reads ",[17,73,74],{},"read(c)"," (any cell this step, clamped at the edges), ",[17,77,78],{},"readLinear(p)"," (the grid at any uv ",[17,81,13],{},", bilinear between cell centres: for advection, ",[17,84,85],{},"readLinear(cellUV - velocity * dt)","), ",[17,88,89],{},"readPrev(c)"," (the state at the end of the frame before), ",[17,92,93],{},"cell: vec2i",", ",[17,96,97],{},"cellUV: vec2f"," (the cell's centre), ",[17,100,101],{},"gridSize: vec2i",", plus props, built-ins (",[17,104,105],{},"dt"," is the layer clock's step, so Speed scales it), inputs and library functions. ",[17,108,109],{},"iterations"," repeats it within the frame, each pass reading the one before (Jacobi style).",[112,113,115],"h2",{"id":114},"parameters","Parameters",[117,118,119,135],"table",{},[120,121,122],"thead",{},[123,124,125,129,132],"tr",{},[126,127,128],"th",{},"Name",[126,130,131],{},"Type",[126,133,134],{},"Notes",[136,137,138,153],"tbody",{},[123,139,140,146,151],{},[141,142,143],"td",{},[17,144,145],{},"body",[141,147,148],{},[17,149,150],{},"WgslBody | string",[141,152],{},[123,154,155,160,165],{},[141,156,157],{},[17,158,159],{},"opts",[141,161,162],{},[17,163,164],{},"{iterations?: number}",[141,166,167,168,20],{},"Optional. Default ",[17,169,170],{},"{}",[112,172,174],{"id":173},"example","Example",[22,176,178],{"className":24,"code":177,"language":26,"meta":27,"style":27},"op.kernel(wgsl`\n  let c = read(cell);\n  let avg = (read(cell + vec2i(1, 0)) + read(cell - vec2i(1, 0))) * 0.5;\n  return mix(c, avg, 0.5);\n`)\n",[17,179,180,197,203,209,215],{"__ignoreMap":27},[31,181,182,185,187,190,193],{"class":33,"line":34},[31,183,184],{"class":40},"op.",[31,186,5],{"class":37},[31,188,189],{"class":40},"(",[31,191,192],{"class":37},"wgsl",[31,194,196],{"class":195},"sU2Wk","`\n",[31,198,200],{"class":33,"line":199},2,[31,201,202],{"class":195},"  let c = read(cell);\n",[31,204,206],{"class":33,"line":205},3,[31,207,208],{"class":195},"  let avg = (read(cell + vec2i(1, 0)) + read(cell - vec2i(1, 0))) * 0.5;\n",[31,210,212],{"class":33,"line":211},4,[31,213,214],{"class":195},"  return mix(c, avg, 0.5);\n",[31,216,218,221],{"class":33,"line":217},5,[31,219,220],{"class":195},"`",[31,222,223],{"class":40},")\n",[225,226,227],"style",{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}",{"title":27,"searchDepth":199,"depth":199,"links":229},[230,231],{"id":114,"depth":199,"text":115},{"id":173,"depth":199,"text":174},"Grid steps",false,"Your own grid step, run once per cell: return the cell's new `vec4f`.",null,"md","simulation","Simulation","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fop\u002Fkernel",{"title":5,"description":234},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fops.ts#L192","docs\u002Fprimitives\u002F47.op\u002F11.kernel","w3H6BFETTTqnX0oDCYe18IS9BwGay_DmoHDqpcRjG1Q",{"stars":248},6080,[250,254,258,262,266,270,274,278,282,286,290,294,298,302,306,310,314,319,323,327,331,335],{"path":251,"title":252,"description":253,"category":17},"\u002Fdocs\u002Fguide","Getting started","Shaders is a desktop app where your AI agent designs interactive effects on an infinite canvas, and you shape them by hand.",{"path":255,"title":256,"description":257,"category":17},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":259,"title":260,"description":261,"category":17},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":263,"title":264,"description":265,"category":17},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":267,"title":268,"description":269,"category":17},"\u002Fdocs\u002Fguide\u002Fprops-reactivity","Props and reactivity","Bind props to your framework's state so effects update when it changes, and animate props with an animation library.",{"path":271,"title":272,"description":273,"category":17},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":275,"title":276,"description":277,"category":17},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":279,"title":280,"description":281,"category":17},"\u002Fdocs\u002Fguide\u002Flayout-positioning","Layout and positioning","Size and place a shader in your page with CSS, as a background, a fill, or an inline block.",{"path":283,"title":284,"description":285,"category":17},"\u002Fdocs\u002Fguide\u002Fsizing-and-units","Sizing and units","Size and place layers in CSS units (px, %, vw, rem, and canvas units) that stay correct as the canvas and window resize.",{"path":287,"title":288,"description":289,"category":17},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":291,"title":292,"description":293,"category":17},"\u002Fdocs\u002Fguide\u002Fshape-effects","Shape effects","Pick the 2D, 3D or custom SVG shape that Glass, Neon, Emboss and other shape effects draw inside.",{"path":295,"title":296,"description":297,"category":17},"\u002Fdocs\u002Fguide\u002Fcolor-space","Color space","Match colors to your design tool with the output color space, and keep bright layers from clipping with tone mapping.",{"path":299,"title":300,"description":301,"category":17},"\u002Fdocs\u002Fguide\u002Fhooks-events","Hooks and events","Run code when an effect is ready to show, and show a fallback when the GPU can't run it.",{"path":303,"title":304,"description":305,"category":17},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":307,"title":308,"description":309,"category":17},"\u002Fdocs\u002Fguide\u002Fcustom-shaders","Custom components","Write your own component in TypeScript, use it like any component in the library, and write WGSL by hand when you need to.",{"path":311,"title":312,"description":313,"category":17},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":315,"title":316,"description":317,"category":318},"\u002Fdocs\u002Fguide\u002Fmcp","Working with your agent","The Shaders MCP connects your AI agent to the desktop app, so it can design shaders on your canvas and install them in your project.","workflows",{"path":320,"title":321,"description":322,"category":318},"\u002Fdocs\u002Fguide\u002Fcli","Working with the CLI","The Shaders CLI installs shaders from your projects and the Pro library into your codebase as component files, and keeps them in sync as you keep designing.",{"path":324,"title":325,"description":326,"category":318},"\u002Fdocs\u002Fguide\u002Fframeworks","Supported frameworks","Shaders runs in any web project that renders in a browser with WebGPU, with components for React, Vue, Svelte and Solid and a JavaScript API for everything else.",{"path":328,"title":329,"description":330,"category":17},"\u002Fdocs\u002Fguide\u002Fagent-skill","Agent skill for the engine","Teach your coding agent to write Shaders code with the open-source engine, for when it's working in your codebase instead of on the canvas.",{"path":332,"title":333,"description":334,"category":17},"\u002Fdocs\u002Fguide\u002Fvideo-rendering","Rendering to video","Render a shader effect to video frame by frame, from Remotion, Hyperframes or your own headless Chrome script.",{"path":336,"title":337,"description":338,"category":17},"\u002Fdocs\u002Fguide\u002Fssr","Server rendering","Render Shaders in Next.js, Nuxt, SvelteKit, SolidStart and other SSR apps by keeping each shader on the client.",1796051186211,"06e02370-81a6-4d74-9931-661d71414be1"]