[{"data":1,"prerenderedAt":412,"buildId":413},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Finputs-compute\u002Fbuffer":3,"github-stars":320,"guide-nav":322},{"id":4,"title":5,"body":6,"categoryId":304,"categorySlug":305,"categoryTitle":306,"curated":307,"description":308,"editUrl":309,"extension":310,"group":203,"groupTitle":311,"kind":312,"meta":313,"navigation":314,"path":315,"seo":316,"sourceUrl":317,"stem":318,"wordCount":309,"__hash__":319},"primitives\u002Fdocs\u002Fprimitives\u002F41.inputs-compute\u002F1.buffer.md","buffer",{"type":7,"value":8,"toc":299},"minimark",[9,12,25,53,63,80,85,153,157,270,274,295],[10,11,5],"h1",{"id":5},[13,14,15,16,20,21,24],"p",{},"A storage buffer of ",[17,18,19],"code",{},"count"," records of a ",[17,22,23],{},"struct"," type, zero-filled.",[26,27,32],"pre",{"className":28,"code":29,"language":30,"meta":31,"style":31},"language-ts shiki shiki-themes github-dark","buffer(type: StructType, count: ScalarArg, opts: {max?: number} = {}): BufferInput\n","ts","",[17,33,34],{"__ignoreMap":31},[35,36,39,42,46,50],"span",{"class":37,"line":38},"line",1,[35,40,5],{"class":41},"svObZ",[35,43,45],{"class":44},"s95oV","(type: StructType, count: ScalarArg, opts: {max?: number} ",[35,47,49],{"class":48},"snl16","=",[35,51,52],{"class":44}," {}): BufferInput\n",[13,54,55,56,58,59,62],{},"Import ",[17,57,5],{}," from ",[17,60,61],{},"shaders\u002Fstd",".",[13,64,65,66,69,70,72,73,76,77,79],{},"Kernels name it in their WGSL to read and write it (",[17,67,68],{},"stars[index].pos","). ",[17,71,19],{}," may be a prop (with ",[17,74,75],{},"max"," the most it can grow to); only the first ",[17,78,19],{}," records are processed each frame.",[81,82,84],"h2",{"id":83},"parameters","Parameters",[86,87,88,104],"table",{},[89,90,91],"thead",{},[92,93,94,98,101],"tr",{},[95,96,97],"th",{},"Name",[95,99,100],{},"Type",[95,102,103],{},"Notes",[105,106,107,122,135],"tbody",{},[92,108,109,115,120],{},[110,111,112],"td",{},[17,113,114],{},"type",[110,116,117],{},[17,118,119],{},"StructType",[110,121],{},[92,123,124,128,133],{},[110,125,126],{},[17,127,19],{},[110,129,130],{},[17,131,132],{},"ScalarArg",[110,134],{},[92,136,137,142,147],{},[110,138,139],{},[17,140,141],{},"opts",[110,143,144],{},[17,145,146],{},"{max?: number}",[110,148,149,150,62],{},"Optional. Default ",[17,151,152],{},"{}",[81,154,156],{"id":155},"example","Example",[26,158,160],{"className":28,"code":159,"language":30,"meta":31,"style":31},"const Star = struct('Star', {pos: 'vec2f', vel: 'vec2f'})\ninputs: {\n  stars: buffer(Star, p('count'), {max: 65536}),\n  move: kernel(wgsl`stars[index].pos += stars[index].vel * dt;`, {over: 'stars'}),\n},\n",[17,161,162,198,207,237,264],{"__ignoreMap":31},[35,163,164,167,171,174,177,180,184,187,190,193,195],{"class":37,"line":38},[35,165,166],{"class":48},"const",[35,168,170],{"class":169},"sDLfK"," Star",[35,172,173],{"class":48}," =",[35,175,176],{"class":41}," struct",[35,178,179],{"class":44},"(",[35,181,183],{"class":182},"sU2Wk","'Star'",[35,185,186],{"class":44},", {pos: ",[35,188,189],{"class":182},"'vec2f'",[35,191,192],{"class":44},", vel: ",[35,194,189],{"class":182},[35,196,197],{"class":44},"})\n",[35,199,201,204],{"class":37,"line":200},2,[35,202,203],{"class":41},"inputs",[35,205,206],{"class":44},": {\n",[35,208,210,213,216,218,221,223,225,228,231,234],{"class":37,"line":209},3,[35,211,212],{"class":41},"  stars",[35,214,215],{"class":44},": ",[35,217,5],{"class":41},[35,219,220],{"class":44},"(Star, ",[35,222,13],{"class":41},[35,224,179],{"class":44},[35,226,227],{"class":182},"'count'",[35,229,230],{"class":44},"), {max: ",[35,232,233],{"class":169},"65536",[35,235,236],{"class":44},"}),\n",[35,238,240,243,245,248,250,253,256,259,262],{"class":37,"line":239},4,[35,241,242],{"class":41},"  move",[35,244,215],{"class":44},[35,246,247],{"class":41},"kernel",[35,249,179],{"class":44},[35,251,252],{"class":41},"wgsl",[35,254,255],{"class":182},"`stars[index].pos += stars[index].vel * dt;`",[35,257,258],{"class":44},", {over: ",[35,260,261],{"class":182},"'stars'",[35,263,236],{"class":44},[35,265,267],{"class":37,"line":266},5,[35,268,269],{"class":44},"},\n",[81,271,273],{"id":272},"see-also","See also",[275,276,277,287],"ul",{},[278,279,280,286],"li",{},[281,282,284],"a",{"href":283},"\u002Fdocs\u002Fprimitives\u002Finputs-compute\u002Fkernel",[17,285,247],{}," — Your own compute pass.",[278,288,289,294],{},[281,290,292],{"href":291},"\u002Fdocs\u002Fprimitives\u002Finputs-compute\u002Fstruct",[17,293,23],{}," — Declare a record type.",[296,297,298],"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 .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}",{"title":31,"searchDepth":200,"depth":200,"links":300},[301,302,303],{"id":83,"depth":200,"text":84},{"id":155,"depth":200,"text":156},{"id":272,"depth":200,"text":273},"inputs.compute","inputs-compute","Raw compute",false,"A storage buffer of `count` records of a `struct` type, zero-filled.",null,"md","Inputs","function",{},true,"\u002Fdocs\u002Fprimitives\u002Finputs-compute\u002Fbuffer",{"title":5,"description":308},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Finputs\u002Fcompute.ts#L126","docs\u002Fprimitives\u002F41.inputs-compute\u002F1.buffer","yt5TScUT_SqSETxjjs657Y0LuaDBK4tKBET0HM1Fh6Q",{"stars":321},6080,[323,327,331,335,339,343,347,351,355,359,363,367,371,375,379,383,387,392,396,400,404,408],{"path":324,"title":325,"description":326,"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":328,"title":329,"description":330,"category":17},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":332,"title":333,"description":334,"category":17},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":336,"title":337,"description":338,"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":340,"title":341,"description":342,"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":344,"title":345,"description":346,"category":17},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":348,"title":349,"description":350,"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":352,"title":353,"description":354,"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":356,"title":357,"description":358,"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":360,"title":361,"description":362,"category":17},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":364,"title":365,"description":366,"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":368,"title":369,"description":370,"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":372,"title":373,"description":374,"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":376,"title":377,"description":378,"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":380,"title":381,"description":382,"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":384,"title":385,"description":386,"category":17},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":388,"title":389,"description":390,"category":391},"\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":393,"title":394,"description":395,"category":391},"\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":397,"title":398,"description":399,"category":391},"\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":401,"title":402,"description":403,"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":405,"title":406,"description":407,"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":409,"title":410,"description":411,"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.",1796051186113,"06e02370-81a6-4d74-9931-661d71414be1"]