[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"guide-nav":3,"doc-\u002Fdocs\u002Fprimitives\u002Fcompose\u002Flayered":145},[4,10,16,20,24,28,32,36,40,44,48,52,56,60,64,69,73,78,82,86,90,94,98,102,106,110,114,117,120,124,127,131,134,138,141],{"path":5,"title":6,"description":7,"category":8,"exclude":9,"forceFramework":9},"\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",null,{"path":11,"title":12,"description":13,"category":8,"exclude":14,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",[15],"js",{"path":17,"title":18,"description":19,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":21,"title":22,"description":23,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":25,"title":26,"description":27,"category":8,"exclude":9,"forceFramework":9},"\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":29,"title":30,"description":31,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":33,"title":34,"description":35,"category":8,"exclude":9,"forceFramework":9},"\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":37,"title":38,"description":39,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in % or px units.",{"path":41,"title":42,"description":43,"category":8,"exclude":9,"forceFramework":9},"\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":45,"title":46,"description":47,"category":8,"exclude":9,"forceFramework":9},"\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":49,"title":50,"description":51,"category":8,"exclude":9,"forceFramework":9},"\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":53,"title":54,"description":55,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":57,"title":58,"description":59,"category":8,"exclude":9,"forceFramework":9},"\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":61,"title":62,"description":63,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":65,"title":66,"description":67,"category":68,"exclude":9,"forceFramework":9},"\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":70,"title":71,"description":72,"category":68,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fcli","Shaders CLI","Install shaders and presets into your codebase as component files, and keep them in sync with the design editor.",{"path":74,"title":75,"description":76,"category":77,"exclude":9,"forceFramework":9},"\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":79,"title":80,"description":81,"category":77,"exclude":9,"forceFramework":9},"\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":83,"title":84,"description":85,"category":77,"exclude":9,"forceFramework":9},"\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":87,"title":88,"description":89,"category":77,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fmasking-and-blending","Masking and blending","How blend modes and masks combine components in the design editor.",{"path":91,"title":92,"description":93,"category":77,"exclude":9,"forceFramework":9},"\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":95,"title":96,"description":97,"category":77,"exclude":9,"forceFramework":9},"\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":99,"title":100,"description":101,"category":77,"exclude":9,"forceFramework":9},"\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":103,"title":104,"description":105,"category":77,"exclude":9,"forceFramework":9},"\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":107,"title":108,"description":109,"category":77,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fglass-component-spotlight","Component spotlight: Glass","A short look at the Glass component and the liquid-glass look it creates.",{"path":111,"title":112,"description":113,"category":77,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fdigital-looks-component-spotlight","Component spotlight: Digital looks","A look at the digital stylization components for glitchy, futuristic, or technical effects.",{"path":115,"title":12,"description":116,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fjs\u002Fquickstart","Install Shaders without a framework, render your first effect on a canvas, and update props at runtime.",{"path":118,"title":12,"description":119,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Freact\u002Fquickstart","Install Shaders in a React app, render your first effect, and drive a prop from state.",{"path":121,"title":122,"description":123,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Freact\u002Fssr","Next.js and SSR","Render Shaders in Next.js and other React SSR apps by keeping each shader on the client.",{"path":125,"title":12,"description":126,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fsolid\u002Fquickstart","Install Shaders in a Solid app, render your first effect, and drive a prop from a signal.",{"path":128,"title":129,"description":130,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fsolid\u002Fssr","SolidStart and SSR","Render Shaders in SolidStart and other Solid SSR apps by keeping each shader on the client.",{"path":132,"title":12,"description":133,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fsvelte\u002Fquickstart","Install Shaders in a Svelte app, render your first effect, and drive a prop from state.",{"path":135,"title":136,"description":137,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fsvelte\u002Fssr","SvelteKit and SSR","Render Shaders in SvelteKit and other Svelte SSR apps, where each shader already waits for the browser.",{"path":139,"title":12,"description":140,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fvue\u002Fquickstart","Install Shaders in a Vue app, render your first effect, and drive a prop from a ref.",{"path":142,"title":143,"description":144,"category":8,"exclude":9,"forceFramework":9},"\u002Fdocs\u002Fguide\u002Fvue\u002Fssr","Nuxt and SSR","Render Shaders in Nuxt and other Vue SSR apps by keeping each shader on the client.",{"id":146,"title":147,"body":148,"categoryId":239,"categorySlug":239,"categoryTitle":452,"curated":453,"description":157,"editUrl":9,"extension":454,"group":455,"groupTitle":456,"kind":457,"meta":458,"navigation":459,"path":460,"seo":461,"sourceUrl":462,"stem":463,"wordCount":9,"__hash__":464},"primitives\u002Fdocs\u002Fprimitives\u002F10.compose\u002F4.layered.md","layered",{"type":149,"value":150,"toc":446},"minimark",[151,154,158,234,249,268,273,324,328,404,414,418,432,436,442],[152,153,147],"h1",{"id":147},[155,156,157],"p",{},"Builds N variations of one thing from a data list and sums them with weights.",[159,160,165],"pre",{"className":161,"code":162,"language":163,"meta":164,"style":164},"language-ts shiki shiki-themes github-dark","layered\u003CT>(\n  layerData: readonly T[],\n  build: (layer: T, index: number) =,\n> {value: Expr; weight: Expr}): {weightedSum: Expr; totalWeight: Expr}\n","ts","",[8,166,167,185,197,228],{"__ignoreMap":164},[168,169,172,175,179,182],"span",{"class":170,"line":171},"line",1,[168,173,147],{"class":174},"svObZ",[168,176,178],{"class":177},"s95oV","\u003C",[168,180,181],{"class":174},"T",[168,183,184],{"class":177},">(\n",[168,186,188,191,194],{"class":170,"line":187},2,[168,189,190],{"class":177},"  layerData: readonly ",[168,192,181],{"class":193},"sDLfK",[168,195,196],{"class":177},"[],\n",[168,198,200,203,207,211,214,217,220,222,225],{"class":170,"line":199},3,[168,201,202],{"class":177},"  build: (",[168,204,206],{"class":205},"s9osk","layer",[168,208,210],{"class":209},"snl16",":",[168,212,213],{"class":174}," T",[168,215,216],{"class":177},", ",[168,218,219],{"class":205},"index",[168,221,210],{"class":209},[168,223,224],{"class":193}," number",[168,226,227],{"class":177},") =,\n",[168,229,231],{"class":170,"line":230},4,[168,232,233],{"class":177},"> {value: Expr; weight: Expr}): {weightedSum: Expr; totalWeight: Expr}\n",[155,235,236,237,240,241,244,245,248],{},"Import ",[8,238,239],{},"compose"," from ",[8,242,243],{},"shaders\u002Fstd"," and use ",[8,246,247],{},"compose.layered",".",[155,250,251,252,255,256,259,260,263,264,267],{},"Give it a list of plain data and a function that turns one entry into ",[8,253,254],{},"{value, weight}",". You get ",[8,257,258],{},"weightedSum"," and ",[8,261,262],{},"totalWeight"," back and choose the blend yourself, usually ",[8,265,266],{},"weightedSum \u002F (totalWeight + 0.001)",". Slice the list to change how many layers are built.",[269,270,272],"h2",{"id":271},"parameters","Parameters",[274,275,276,292],"table",{},[277,278,279],"thead",{},[280,281,282,286,289],"tr",{},[283,284,285],"th",{},"Name",[283,287,288],{},"Type",[283,290,291],{},"Notes",[293,294,295,310],"tbody",{},[280,296,297,303,308],{},[298,299,300],"td",{},[8,301,302],{},"layerData",[298,304,305],{},[8,306,307],{},"readonly T[]",[298,309],{},[280,311,312,317,322],{},[298,313,314],{},[8,315,316],{},"build",[298,318,319],{},[8,320,321],{},"(layer: T, index: number) => {value: Expr; weight: Expr}",[298,323],{},[269,325,327],{"id":326},"example","Example",[159,329,331],{"className":161,"code":330,"language":163,"meta":164,"style":164},"const {weightedSum, totalWeight} = layered(CURTAINS.slice(0, count), ({offset, weight}) => ({value: curtain(offset), weight: math.mul(alpha, weight)}))\n",[8,332,333],{"__ignoreMap":164},[168,334,335,338,341,343,345,347,350,353,356,359,362,364,367,369,372,375,378,380,383,386,389,392,395,398,401],{"class":170,"line":171},[168,336,337],{"class":209},"const",[168,339,340],{"class":177}," {",[168,342,258],{"class":193},[168,344,216],{"class":177},[168,346,262],{"class":193},[168,348,349],{"class":177},"} ",[168,351,352],{"class":209},"=",[168,354,355],{"class":174}," layered",[168,357,358],{"class":177},"(",[168,360,361],{"class":193},"CURTAINS",[168,363,248],{"class":177},[168,365,366],{"class":174},"slice",[168,368,358],{"class":177},[168,370,371],{"class":193},"0",[168,373,374],{"class":177},", count), ({",[168,376,377],{"class":205},"offset",[168,379,216],{"class":177},[168,381,382],{"class":205},"weight",[168,384,385],{"class":177},"}) ",[168,387,388],{"class":209},"=>",[168,390,391],{"class":177}," ({value: ",[168,393,394],{"class":174},"curtain",[168,396,397],{"class":177},"(offset), weight: math.",[168,399,400],{"class":174},"mul",[168,402,403],{"class":177},"(alpha, weight)}))\n",[405,406,407],"blockquote",{},[155,408,409,413],{},[410,411,412],"strong",{},"Tip."," Cheap depth: aurora curtains, cloud banks, echo trails are all a few layers of one recipe.",[269,415,417],{"id":416},"see-also","See also",[419,420,421],"ul",{},[422,423,424,431],"li",{},[425,426,428],"a",{"href":427},"\u002Fdocs\u002Fprimitives\u002Fcompose\u002Flayers",[8,429,430],{},"layers"," — Stacks colors into one, first entry at the back.",[269,433,435],{"id":434},"used-by","Used by",[155,437,438],{},[425,439,441],{"href":440},"\u002Fdocs\u002Fcomponents\u002Faurora","Aurora",[443,444,445],"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 .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}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);}",{"title":164,"searchDepth":187,"depth":187,"links":447},[448,449,450,451],{"id":271,"depth":187,"text":272},{"id":326,"depth":187,"text":327},{"id":416,"depth":187,"text":417},{"id":434,"depth":187,"text":435},"Layering & output",false,"md","paint","Painting","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fcompose\u002Flayered",{"title":147,"description":157},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fpaint\u002Fcompose.ts#L53","docs\u002Fprimitives\u002F10.compose\u002F4.layered","h0Eqjv0LEEtHTFnB-IgbIY1WvBv2nXbTdHtjgKC3_Ko"]