[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"github-stars":3,"guide-nav":5,"doc-\u002Fdocs\u002Fprimitives\u002Fdefine\u002Fwgsl":129},{"stars":4},5507,[6,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,72,76,80,84,88,93,97,101,105,109,113,117,121,125],{"path":7,"title":8,"description":9,"category":10},"\u002Fdocs\u002Fguide","Getting started","Shaders is a library of GPU effect components for Vue, React, Svelte, Solid, JavaScript and Framer, with a design editor for building with them.","code",{"path":12,"title":13,"description":14,"category":10},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":16,"title":17,"description":18,"category":10},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":20,"title":21,"description":22,"category":10},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":24,"title":25,"description":26,"category":10},"\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":28,"title":29,"description":30,"category":10},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":32,"title":33,"description":34,"category":10},"\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":36,"title":37,"description":38,"category":10},"\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":40,"title":41,"description":42,"category":10},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":44,"title":45,"description":46,"category":10},"\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":48,"title":49,"description":50,"category":10},"\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":52,"title":53,"description":54,"category":10},"\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":56,"title":57,"description":58,"category":10},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":60,"title":61,"description":62,"category":10},"\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":64,"title":65,"description":66,"category":10},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":68,"title":69,"description":70,"category":71},"\u002Fdocs\u002Fguide\u002Fmcp","Shaders MCP","Connect your AI coding agent to Shaders so it can find, install and edit effects in your codebase.","workflows",{"path":73,"title":74,"description":75,"category":71},"\u002Fdocs\u002Fguide\u002Fcli","Shaders CLI","Install your own shaders and Pro shaders into your codebase as component files, and keep them in sync with the design editor.",{"path":77,"title":78,"description":79,"category":71},"\u002Fdocs\u002Fguide\u002Fagent-skill","Agent skill","Give your coding agent a skill that teaches it to build with Shaders components, the CLI and Pro shaders.",{"path":81,"title":82,"description":83,"category":10},"\u002Fdocs\u002Fguide\u002Fvideo-rendering","Rendering to video","Turn a shader effect into a video file, from the design editor or from a frame-by-frame pipeline such as Remotion, Hyperframes or Puppeteer.",{"path":85,"title":86,"description":87,"category":10},"\u002Fdocs\u002Fguide\u002Fssr","Server rendering","Render Shaders in Next.js, Nuxt, SvelteKit, SolidStart and other SSR apps by keeping each shader on the client.",{"path":89,"title":90,"description":91,"category":92},"\u002Fdocs\u002Fguide\u002Fquick-tour-of-the-design-editor","Quick tour of the design editor","A short walkthrough of the full Shaders workflow, from designing on the infinite canvas to exporting code.","editor",{"path":94,"title":95,"description":96,"category":92},"\u002Fdocs\u002Fguide\u002Fintro-to-the-interface","Intro to the interface","A tour of the design editor interface: the canvas, layers, the Properties panel, and the ways to share and export.",{"path":98,"title":99,"description":100,"category":92},"\u002Fdocs\u002Fguide\u002Fcomposing-your-first-shader-effect","Composing your first shader effect","Building a first shader effect in the design editor by stacking and nesting components as layers.",{"path":102,"title":103,"description":104,"category":92},"\u002Fdocs\u002Fguide\u002Fmasking-and-blending","Masking and blending","How blend modes and masks combine components in the design editor.",{"path":106,"title":107,"description":108,"category":92},"\u002Fdocs\u002Fguide\u002Fdynamic-prop-mapping","Dynamic prop mapping","Turning static props into dynamic ones in the design editor: mapping one layer's output into another's prop, following the cursor, or animating automatically.",{"path":110,"title":111,"description":112,"category":92},"\u002Fdocs\u002Fguide\u002Fcustom-media-and-transformations","Custom media and transformations","Uploading images, videos, and SVG files to the media gallery, adding them to a composition, and placing them with transformations.",{"path":114,"title":115,"description":116,"category":92},"\u002Fdocs\u002Fguide\u002Finstalling-a-shader-via-mcp","Installing a shader via MCP","Installing a shader from the design editor into a hero section with the Shaders MCP.",{"path":118,"title":119,"description":120,"category":92},"\u002Fdocs\u002Fguide\u002Fexploring-shape-effects","Exploring shape effects","Applying shape effects such as liquid glass, liquid metal, and glowing edges to built-in shapes and your own SVG.",{"path":122,"title":123,"description":124,"category":92},"\u002Fdocs\u002Fguide\u002Fglass-component-spotlight","Component spotlight: Glass","A short look at the Glass component and the liquid-glass look it creates.",{"path":126,"title":127,"description":128,"category":92},"\u002Fdocs\u002Fguide\u002Fdigital-looks-component-spotlight","Component spotlight: Digital looks","A look at the digital stylization components for glitchy, futuristic, or technical effects.",{"id":130,"title":131,"body":132,"categoryId":488,"categorySlug":488,"categoryTitle":489,"curated":490,"description":491,"editUrl":492,"extension":493,"group":488,"groupTitle":494,"kind":495,"meta":496,"navigation":497,"path":498,"seo":499,"sourceUrl":500,"stem":501,"wordCount":492,"__hash__":502},"primitives\u002Fdocs\u002Fprimitives\u002F1.define\u002F2.wgsl.md","wgsl",{"type":133,"value":134,"toc":483},"minimark",[135,138,146,190,200,265,280,285,322,326,360,397,426,430,479],[136,137,131],"h1",{"id":131},[139,140,141,142,145],"p",{},"Write the per-pixel math by hand, as one WGSL function body that returns a ",[10,143,144],{},"vec4f"," color.",[147,148,153],"pre",{"className":149,"code":150,"language":151,"meta":152,"style":152},"language-ts shiki shiki-themes github-dark","wgsl(spec: WgslSpec): WgslBody\nwgsl(body: string): WgslBody\nwgsl(strings: TemplateStringsArray, ...values: unknown[]): WgslBody\n","ts","",[10,154,155,167,175],{"__ignoreMap":152},[156,157,160,163],"span",{"class":158,"line":159},"line",1,[156,161,131],{"class":162},"svObZ",[156,164,166],{"class":165},"s95oV","(spec: WgslSpec): WgslBody\n",[156,168,170,172],{"class":158,"line":169},2,[156,171,131],{"class":162},[156,173,174],{"class":165},"(body: string): WgslBody\n",[156,176,178,180,183,187],{"class":158,"line":177},3,[156,179,131],{"class":162},[156,181,182],{"class":165},"(strings: TemplateStringsArray, ",[156,184,186],{"class":185},"snl16","...",[156,188,189],{"class":165},"values: unknown[]): WgslBody\n",[139,191,192,193,195,196,199],{},"Import ",[10,194,131],{}," from ",[10,197,198],{},"shaders\u002Fstd",".",[139,201,202,203,206,207,210,211,213,214,217,218,221,222,225,226,229,230,233,234,237,238,241,242,245,246,248,249,252,253,256,257,260,261,264],{},"Put it in ",[10,204,205],{},"paint:"," for a generator or ",[10,208,209],{},"effect:"," for a filter. Every name the body uses is bound for you. The definition's props come by name: colors as ",[10,212,144],{}," in linear RGB with alpha, positions as ",[10,215,216],{},"vec2f"," in uv, numbers and booleans as ",[10,219,220],{},"f32",", select props as their numeric value. The context comes as ",[10,223,224],{},"uv"," (0–1 across the canvas, y down), ",[10,227,228],{},"time"," (seconds; the layer's own clock when ",[10,231,232],{},"animatedTime"," is declared, paused at speed 0), ",[10,235,236],{},"aspect"," (width \u002F height), ",[10,239,240],{},"viewport"," (the frame size in device pixels) and ",[10,243,244],{},"pointer"," (the mouse in uv). In an ",[10,247,209],{}," body ",[10,250,251],{},"child"," is the color of the layer inside at this pixel. Sample ",[10,254,255],{},"childTexture"," with ",[10,258,259],{},"childSampler"," instead when you need neighbouring pixels (a blur, a displacement): that gives the filter its own render pass and hands you premultiplied color, which is unpremultiplied for you on the way out. Template values (",[10,262,263],{},"${OCTAVES}",") are pasted in as text, so a constant can be a loop bound.",[139,266,267,268,271,272,275,276,279],{},"Use the ",[10,269,270],{},"{body, inputs, alpha}"," form to bind extra names (",[10,273,274],{},"inputs: {t: ctx.time, k: 4}",") or to say a gather body already returns straight alpha (",[10,277,278],{},"alpha: 'straight'",").",[281,282,284],"h2",{"id":283},"parameters","Parameters",[286,287,288,304],"table",{},[289,290,291],"thead",{},[292,293,294,298,301],"tr",{},[295,296,297],"th",{},"Name",[295,299,300],{},"Type",[295,302,303],{},"Notes",[305,306,307],"tbody",{},[292,308,309,315,320],{},[310,311,312],"td",{},[10,313,314],{},"spec",[310,316,317],{},[10,318,319],{},"WgslSpec",[310,321],{},[281,323,325],{"id":324},"examples","Examples",[147,327,329],{"className":149,"code":328,"language":151,"meta":152,"style":152},"paint: wgsl`\n  let d = length((uv - center) * vec2f(aspect, 1.0)) \u002F radius;\n  return vec4f(mix(outer.rgb, inner.rgb, 1.0 - smoothstep(0.0, 1.0, d)), 1.0);\n`\n",[10,330,331,345,350,355],{"__ignoreMap":152},[156,332,333,336,339,341],{"class":158,"line":159},[156,334,335],{"class":162},"paint",[156,337,338],{"class":165},": ",[156,340,131],{"class":162},[156,342,344],{"class":343},"sU2Wk","`\n",[156,346,347],{"class":158,"line":169},[156,348,349],{"class":343},"  let d = length((uv - center) * vec2f(aspect, 1.0)) \u002F radius;\n",[156,351,352],{"class":158,"line":177},[156,353,354],{"class":343},"  return vec4f(mix(outer.rgb, inner.rgb, 1.0 - smoothstep(0.0, 1.0, d)), 1.0);\n",[156,356,358],{"class":158,"line":357},4,[156,359,344],{"class":343},[147,361,363],{"className":149,"code":362,"language":151,"meta":152,"style":152},"\u002F\u002F A gather filter: the layer inside, sampled at a rippled coordinate.\neffect: wgsl`\n  let wave = sin(length(uv - center) * frequency - time * 4.0) * amplitude;\n  return textureSample(childTexture, childSampler, uv + wave);\n`\n",[10,364,365,371,382,387,392],{"__ignoreMap":152},[156,366,367],{"class":158,"line":159},[156,368,370],{"class":369},"sAwPA","\u002F\u002F A gather filter: the layer inside, sampled at a rippled coordinate.\n",[156,372,373,376,378,380],{"class":158,"line":169},[156,374,375],{"class":162},"effect",[156,377,338],{"class":165},[156,379,131],{"class":162},[156,381,344],{"class":343},[156,383,384],{"class":158,"line":177},[156,385,386],{"class":343},"  let wave = sin(length(uv - center) * frequency - time * 4.0) * amplitude;\n",[156,388,389],{"class":158,"line":357},[156,390,391],{"class":343},"  return textureSample(childTexture, childSampler, uv + wave);\n",[156,393,395],{"class":158,"line":394},5,[156,396,344],{"class":343},[398,399,400],"blockquote",{},[139,401,402,406,407,409,410,409,412,409,414,409,416,409,418,409,420,422,423,425],{},[403,404,405],"strong",{},"Tip."," The names ",[10,408,224],{},", ",[10,411,228],{},[10,413,236],{},[10,415,240],{},[10,417,244],{},[10,419,251],{},[10,421,255],{}," and ",[10,424,259],{}," belong to the body; a prop spelled the same is not bound, so rename the prop.",[281,427,429],{"id":428},"see-also","See also",[431,432,433,444,471],"ul",{},[434,435,436,443],"li",{},[437,438,440],"a",{"href":439},"\u002Fdocs\u002Fprimitives\u002Fdefine\u002Fdefineshader",[10,441,442],{},"defineShader"," — Define a shader component from a plain object: its props, and one field that says what it draws.",[434,445,446,452,453,409,456,409,459,409,462,409,465,409,468,199],{},[437,447,449],{"href":448},"\u002Fdocs\u002Fprimitives\u002Finvoke\u002Fctx",[10,450,451],{},"ctx"," — The context values as tokens: ",[10,454,455],{},"ctx.uv",[10,457,458],{},"ctx.time",[10,460,461],{},"ctx.aspect",[10,463,464],{},"ctx.pointer",[10,466,467],{},"ctx.viewportSize",[10,469,470],{},"ctx.logicalViewportSize",[434,472,473,478],{},[437,474,476],{"href":475},"\u002Fdocs\u002Fprimitives\u002Fvalues\u002Fp",[10,477,139],{}," — Reference one of the definition's props by name, wherever a word asks for a value.",[480,481,482],"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}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":152,"searchDepth":169,"depth":169,"links":484},[485,486,487],{"id":283,"depth":169,"text":284},{"id":324,"depth":169,"text":325},{"id":428,"depth":169,"text":429},"define","defineShader & wgsl",false,"Write the per-pixel math by hand, as one WGSL function body that returns a `vec4f` color.",null,"md","Defining a shader","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fdefine\u002Fwgsl",{"title":131,"description":491},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fwgsl.ts#L159","docs\u002Fprimitives\u002F1.define\u002F2.wgsl","wBCmtxxE5xdod0Ikgv0msvVmd41ntPwrW6hWB2USFaI"]