[{"data":1,"prerenderedAt":435,"buildId":436},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Finputs-rasterize\u002Frasterize":3,"github-stars":343,"guide-nav":345},{"id":4,"title":5,"body":6,"categoryId":328,"categorySlug":329,"categoryTitle":330,"curated":331,"description":15,"editUrl":332,"extension":333,"group":268,"groupTitle":334,"kind":335,"meta":336,"navigation":337,"path":338,"seo":339,"sourceUrl":340,"stem":341,"wordCount":332,"__hash__":342},"primitives\u002Fdocs\u002Fprimitives\u002F42.inputs-rasterize\u002F1.rasterize.md","rasterize",{"type":7,"value":8,"toc":324},"minimark",[9,12,16,75,85,142,147,201,205,320],[10,11,5],"h1",{"id":5},[13,14,15],"p",{},"Draw a grid's cells as a sheet of triangles into a texture.",[17,18,23],"pre",{"className":19,"code":20,"language":21,"meta":22,"style":22},"language-ts shiki shiki-themes github-dark","rasterize(\n  grid: GridSim | InputNode,\n  opts: {scale?: number; holes?: string} = {},\n): RasterizeInput\n","ts","",[24,25,26,38,51,69],"code",{"__ignoreMap":22},[27,28,31,34],"span",{"class":29,"line":30},"line",1,[27,32,5],{"class":33},"svObZ",[27,35,37],{"class":36},"s95oV","(\n",[27,39,41,44,48],{"class":29,"line":40},2,[27,42,43],{"class":36},"  grid: GridSim ",[27,45,47],{"class":46},"snl16","|",[27,49,50],{"class":36}," InputNode,\n",[27,52,54,57,60,63,66],{"class":29,"line":53},3,[27,55,56],{"class":36},"  opts: {scale?: number; holes",[27,58,59],{"class":46},"?:",[27,61,62],{"class":36}," string} ",[27,64,65],{"class":46},"=",[27,67,68],{"class":36}," {},\n",[27,70,72],{"class":29,"line":71},4,[27,73,74],{"class":36},"): RasterizeInput\n",[13,76,77,78,80,81,84],{},"Import ",[24,79,5],{}," from ",[24,82,83],{},"shaders\u002Fstd",".",[13,86,87,88,91,92,95,96,99,100,103,104,106,107,110,111,114,115,117,118,121,122,125,126,129,130,133,134,137,138,141],{},"Each cell of ",[24,89,90],{},"grid"," holds a position: ",[24,93,94],{},".xy"," in uv, ",[24,97,98],{},".z"," depth (0 nearest, 1 farthest). Read ",[24,101,102],{},"name(uv)",": ",[24,105,94],{}," the sheet's own coordinate at this pixel (0–1 across the grid: cell ",[24,108,109],{},"c"," sits at ",[24,112,113],{},"vec2f(c) \u002F vec2f(gridSize - 1)","), ",[24,116,98],{}," depth, ",[24,119,120],{},".w"," 1 where the sheet covers the pixel; and ",[24,123,124],{},"name.normal(uv).xyz",", the facing direction (toward the viewer, in true proportions on any frame shape). Give the grid ",[24,127,128],{},"precision: 'full'"," when cells hold positions: half precision rounds a cloth's small per-frame moves to nothing. ",[24,131,132],{},"holes"," is WGSL returning false for cells to leave out (tears, cut-outs; it sees ",[24,135,136],{},"cell"," and ",[24,139,140],{},"cellUV",").",[143,144,146],"h2",{"id":145},"parameters","Parameters",[148,149,150,166],"table",{},[151,152,153],"thead",{},[154,155,156,160,163],"tr",{},[157,158,159],"th",{},"Name",[157,161,162],{},"Type",[157,164,165],{},"Notes",[167,168,169,183],"tbody",{},[154,170,171,176,181],{},[172,173,174],"td",{},[24,175,90],{},[172,177,178],{},[24,179,180],{},"GridSim | InputNode",[172,182],{},[154,184,185,190,195],{},[172,186,187],{},[24,188,189],{},"opts",[172,191,192],{},[24,193,194],{},"{scale?: number; holes?: string}",[172,196,197,198,84],{},"Optional. Default ",[24,199,200],{},"{}",[143,202,204],{"id":203},"example","Example",[17,206,208],{"className":19,"code":207,"language":21,"meta":22,"style":22},"const cloth = simulate.grid({resolution: [64, 48], history: 2, init: wgsl`return vec4f(cellUV, 0.5, 0.0);`, step: [op.kernel(verlet)]})\ninputs: {cloth, sheet: rasterize(cloth)},\neffect: wgsl`\n  let s = sheet(uv);\n  if (s.w \u003C 0.5) { return vec4f(0.0); }\n  return textureSample(childTexture, childSampler, s.xy);\n`,\n",[24,209,210,264,282,294,299,305,311],{"__ignoreMap":22},[27,211,212,215,219,222,225,227,230,233,236,239,242,245,248,251,255,258,261],{"class":29,"line":30},[27,213,214],{"class":46},"const",[27,216,218],{"class":217},"sDLfK"," cloth",[27,220,221],{"class":46}," =",[27,223,224],{"class":36}," simulate.",[27,226,90],{"class":33},[27,228,229],{"class":36},"({resolution: [",[27,231,232],{"class":217},"64",[27,234,235],{"class":36},", ",[27,237,238],{"class":217},"48",[27,240,241],{"class":36},"], history: ",[27,243,244],{"class":217},"2",[27,246,247],{"class":36},", init: ",[27,249,250],{"class":33},"wgsl",[27,252,254],{"class":253},"sU2Wk","`return vec4f(cellUV, 0.5, 0.0);`",[27,256,257],{"class":36},", step: [op.",[27,259,260],{"class":33},"kernel",[27,262,263],{"class":36},"(verlet)]})\n",[27,265,266,269,272,275,277,279],{"class":29,"line":40},[27,267,268],{"class":33},"inputs",[27,270,271],{"class":36},": {cloth, ",[27,273,274],{"class":33},"sheet",[27,276,103],{"class":36},[27,278,5],{"class":33},[27,280,281],{"class":36},"(cloth)},\n",[27,283,284,287,289,291],{"class":29,"line":53},[27,285,286],{"class":33},"effect",[27,288,103],{"class":36},[27,290,250],{"class":33},[27,292,293],{"class":253},"`\n",[27,295,296],{"class":29,"line":71},[27,297,298],{"class":253},"  let s = sheet(uv);\n",[27,300,302],{"class":29,"line":301},5,[27,303,304],{"class":253},"  if (s.w \u003C 0.5) { return vec4f(0.0); }\n",[27,306,308],{"class":29,"line":307},6,[27,309,310],{"class":253},"  return textureSample(childTexture, childSampler, s.xy);\n",[27,312,314,317],{"class":29,"line":313},7,[27,315,316],{"class":253},"`",[27,318,319],{"class":36},",\n",[321,322,323],"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":22,"searchDepth":40,"depth":40,"links":325},[326,327],{"id":145,"depth":40,"text":146},{"id":203,"depth":40,"text":204},"inputs.rasterize","inputs-rasterize","Sheets",false,null,"md","Inputs","function",{},true,"\u002Fdocs\u002Fprimitives\u002Finputs-rasterize\u002Frasterize",{"title":5,"description":15},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Finputs\u002Frasterize.ts#L92","docs\u002Fprimitives\u002F42.inputs-rasterize\u002F1.rasterize","8lCW5XrKKS-Uxsq20VGZuil6C_MeYUbDpRQHQcmMajo",{"stars":344},6080,[346,350,354,358,362,366,370,374,378,382,386,390,394,398,402,406,410,415,419,423,427,431],{"path":347,"title":348,"description":349,"category":24},"\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":351,"title":352,"description":353,"category":24},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":355,"title":356,"description":357,"category":24},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":359,"title":360,"description":361,"category":24},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":363,"title":364,"description":365,"category":24},"\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":367,"title":368,"description":369,"category":24},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":371,"title":372,"description":373,"category":24},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":375,"title":376,"description":377,"category":24},"\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":379,"title":380,"description":381,"category":24},"\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":383,"title":384,"description":385,"category":24},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":387,"title":388,"description":389,"category":24},"\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":391,"title":392,"description":393,"category":24},"\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":395,"title":396,"description":397,"category":24},"\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":399,"title":400,"description":401,"category":24},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":403,"title":404,"description":405,"category":24},"\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":407,"title":408,"description":409,"category":24},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":411,"title":412,"description":413,"category":414},"\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":416,"title":417,"description":418,"category":414},"\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":420,"title":421,"description":422,"category":414},"\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":424,"title":425,"description":426,"category":24},"\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":428,"title":429,"description":430,"category":24},"\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":432,"title":433,"description":434,"category":24},"\u002Fdocs\u002Fguide\u002Fssr","Server rendering","Render Shaders in Next.js, Nuxt, SvelteKit, SolidStart and other SSR apps by keeping each shader on the client.",1796051186136,"06e02370-81a6-4d74-9931-661d71414be1"]