[{"data":1,"prerenderedAt":341,"buildId":342},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fsim-grids\u002Fstage-publish":3,"github-stars":249,"guide-nav":251},{"id":4,"title":5,"body":6,"categoryId":233,"categorySlug":234,"categoryTitle":235,"curated":236,"description":16,"editUrl":237,"extension":238,"group":239,"groupTitle":240,"kind":241,"meta":242,"navigation":243,"path":244,"seo":245,"sourceUrl":246,"stem":247,"wordCount":237,"__hash__":248},"primitives\u002Fdocs\u002Fprimitives\u002F48.sim-grids\u002F5.stage-publish.md","stage.publish",{"type":7,"value":8,"toc":226},"minimark",[9,13,17,63,78,81,86,123,127,176,180,207,211,222],[10,11,5],"h1",{"id":12},"stagepublish",[14,15,16],"p",{},"The last stage: write the state into the texture the layer samples.",[18,19,24],"pre",{"className":20,"code":21,"language":22,"meta":23,"style":23},"language-ts shiki shiki-themes github-dark","stage.publish(step: (f: GridFrame) => ComputeStep): GridStage\n","ts","",[25,26,27],"code",{"__ignoreMap":23},[28,29,32,36,40,43,47,51,54,57,60],"span",{"class":30,"line":31},"line",1,[28,33,35],{"class":34},"s95oV","stage.",[28,37,39],{"class":38},"svObZ","publish",[28,41,42],{"class":34},"(step: (",[28,44,46],{"class":45},"s9osk","f",[28,48,50],{"class":49},"snl16",":",[28,52,53],{"class":38}," GridFrame",[28,55,56],{"class":34},") ",[28,58,59],{"class":49},"=>",[28,61,62],{"class":34}," ComputeStep): GridStage\n",[14,64,65,66,69,70,73,74,77],{},"Import ",[25,67,68],{},"sim"," from ",[25,71,72],{},"shaders\u002Fstd"," and use ",[25,75,76],{},"sim.grids.stage.publish",".",[14,79,80],{},"Chosen per frame so it can follow whichever buffer holds the current result.",[82,83,85],"h2",{"id":84},"parameters","Parameters",[87,88,89,105],"table",{},[90,91,92],"thead",{},[93,94,95,99,102],"tr",{},[96,97,98],"th",{},"Name",[96,100,101],{},"Type",[96,103,104],{},"Notes",[106,107,108],"tbody",{},[93,109,110,116,121],{},[111,112,113],"td",{},[25,114,115],{},"step",[111,117,118],{},[25,119,120],{},"(f: GridFrame) => ComputeStep",[111,122],{},[82,124,126],{"id":125},"example","Example",[18,128,130],{"className":20,"code":129,"language":22,"meta":23,"style":23},"stage.publish(() => outputPass.with(sort.side() === 'A' ? outputBgA : outputBgB))\n",[25,131,132],{"__ignoreMap":23},[28,133,134,136,138,141,143,146,149,152,155,158,161,165,168,171,173],{"class":30,"line":31},[28,135,35],{"class":34},[28,137,39],{"class":38},[28,139,140],{"class":34},"(() ",[28,142,59],{"class":49},[28,144,145],{"class":34}," outputPass.",[28,147,148],{"class":38},"with",[28,150,151],{"class":34},"(sort.",[28,153,154],{"class":38},"side",[28,156,157],{"class":34},"() ",[28,159,160],{"class":49},"===",[28,162,164],{"class":163},"sU2Wk"," 'A'",[28,166,167],{"class":49}," ?",[28,169,170],{"class":34}," outputBgA ",[28,172,50],{"class":49},[28,174,175],{"class":34}," outputBgB))\n",[82,177,179],{"id":178},"see-also","See also",[181,182,183,194],"ul",{},[184,185,186,193],"li",{},[187,188,190],"a",{"href":189},"\u002Fdocs\u002Fprimitives\u002Fsim-grids\u002Fstage-pass",[25,191,192],{},"stage.pass"," — One GPU pass, the same every frame.",[184,195,196,202,203,206],{},[187,197,199],{"href":198},"\u002Fdocs\u002Fprimitives\u002Fsim-grids\u002Fstage-sortpass",[25,200,201],{},"stage.sortPass"," — A compare-and-swap sort that converges a little more every frame: ",[25,204,205],{},"passes"," swaps per frame, alternating odd and even pairs and the two buffers.",[82,208,210],{"id":209},"used-by","Used by",[14,212,213,217,218],{},[187,214,216],{"href":215},"\u002Fdocs\u002Fcomponents\u002Fpixelsort","PixelSort",", ",[187,219,221],{"href":220},"\u002Fdocs\u002Fcomponents\u002Freactiondiffusion","ReactionDiffusion",[223,224,225],"style",{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}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":23,"searchDepth":227,"depth":227,"links":228},2,[229,230,231,232],{"id":84,"depth":227,"text":85},{"id":125,"depth":227,"text":126},{"id":178,"depth":227,"text":179},{"id":209,"depth":227,"text":210},"sim.grids","sim-grids","Grid programs",false,null,"md","simulation","Simulation","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fsim-grids\u002Fstage-publish",{"title":5,"description":16},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fsim\u002Fgrids.ts#L302","docs\u002Fprimitives\u002F48.sim-grids\u002F5.stage-publish","9hhQygLVn1a9INESy1JRF26j7wZ9VAjrk8rJlMUs5kw",{"stars":250},6080,[252,256,260,264,268,272,276,280,284,288,292,296,300,304,308,312,316,321,325,329,333,337],{"path":253,"title":254,"description":255,"category":25},"\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":257,"title":258,"description":259,"category":25},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":261,"title":262,"description":263,"category":25},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":265,"title":266,"description":267,"category":25},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":269,"title":270,"description":271,"category":25},"\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":273,"title":274,"description":275,"category":25},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":277,"title":278,"description":279,"category":25},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":281,"title":282,"description":283,"category":25},"\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":285,"title":286,"description":287,"category":25},"\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":289,"title":290,"description":291,"category":25},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":293,"title":294,"description":295,"category":25},"\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":297,"title":298,"description":299,"category":25},"\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":301,"title":302,"description":303,"category":25},"\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":305,"title":306,"description":307,"category":25},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":309,"title":310,"description":311,"category":25},"\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":313,"title":314,"description":315,"category":25},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":317,"title":318,"description":319,"category":320},"\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":322,"title":323,"description":324,"category":320},"\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":326,"title":327,"description":328,"category":320},"\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":330,"title":331,"description":332,"category":25},"\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":334,"title":335,"description":336,"category":25},"\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":338,"title":339,"description":340,"category":25},"\u002Fdocs\u002Fguide\u002Fssr","Server rendering","Render Shaders in Next.js, Nuxt, SvelteKit, SolidStart and other SSR apps by keeping each shader on the client.",1796051187323,"06e02370-81a6-4d74-9931-661d71414be1"]