[{"data":1,"prerenderedAt":285,"buildId":286},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fspectralweight":3,"github-stars":193,"guide-nav":195},{"id":4,"title":5,"body":6,"categoryId":44,"categorySlug":44,"categoryTitle":179,"curated":180,"description":16,"editUrl":181,"extension":182,"group":183,"groupTitle":184,"kind":185,"meta":186,"navigation":187,"path":188,"seo":189,"sourceUrl":190,"stem":191,"wordCount":181,"__hash__":192},"primitives\u002Fdocs\u002Fprimitives\u002F14.materials\u002F61.spectralweight.md","spectralWeight",{"type":7,"value":8,"toc":173},"minimark",[9,13,17,39,54,64,69,105,109,143,147,169],[10,11,5],"h1",{"id":12},"spectralweight",[14,15,16],"p",{},"The colour one slice of the visible spectrum adds to white light, as linear rgb weights.",[18,19,24],"pre",{"className":20,"code":21,"language":22,"meta":23,"style":23},"language-ts shiki shiki-themes github-dark","spectralWeight(t: Expr): Expr\n","ts","",[25,26,27],"code",{"__ignoreMap":23},[28,29,32,35],"span",{"class":30,"line":31},"line",1,[28,33,5],{"class":34},"svObZ",[28,36,38],{"class":37},"s95oV","(t: Expr): Expr\n",[14,40,41,42,45,46,49,50,53],{},"Import ",[25,43,44],{},"materials"," from ",[25,47,48],{},"shaders\u002Fstd"," and use ",[25,51,52],{},"materials.spectralWeight",".",[14,55,56,59,60,63],{},[25,57,58],{},"t"," runs from 0 (deep red) to 1 (violet). Evenly spaced slices sum to white once divided by their summed weights, which is what ",[25,61,62],{},"spectralSum"," does. The weights never go negative.",[65,66,68],"h2",{"id":67},"parameters","Parameters",[70,71,72,88],"table",{},[73,74,75],"thead",{},[76,77,78,82,85],"tr",{},[79,80,81],"th",{},"Name",[79,83,84],{},"Type",[79,86,87],{},"Notes",[89,90,91],"tbody",{},[76,92,93,98,103],{},[94,95,96],"td",{},[25,97,58],{},[94,99,100],{},[25,101,102],{},"Expr",[94,104],{},[65,106,108],{"id":107},"example","Example",[18,110,112],{"className":20,"code":111,"language":22,"meta":23,"style":23},"const tint = spectralWeight(0.5) \u002F\u002F a green slice\n",[25,113,114],{"__ignoreMap":23},[28,115,116,120,124,127,130,133,136,139],{"class":30,"line":31},[28,117,119],{"class":118},"snl16","const",[28,121,123],{"class":122},"sDLfK"," tint",[28,125,126],{"class":118}," =",[28,128,129],{"class":34}," spectralWeight",[28,131,132],{"class":37},"(",[28,134,135],{"class":122},"0.5",[28,137,138],{"class":37},") ",[28,140,142],{"class":141},"sAwPA","\u002F\u002F a green slice\n",[65,144,146],{"id":145},"see-also","See also",[148,149,150,160],"ul",{},[151,152,153,159],"li",{},[154,155,157],"a",{"href":156},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fspectralsum",[25,158,62],{}," — Light seen across the whole visible spectrum, added up slice by slice into one rgb colour.",[151,161,162,168],{},[154,163,165],{"href":164},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fcosinerainbow",[25,166,167],{},"cosineRainbow"," — A smooth rainbow color from a value that wraps every 1.",[170,171,172],"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 .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 .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":23,"searchDepth":174,"depth":174,"links":175},2,[176,177,178],{"id":67,"depth":174,"text":68},{"id":107,"depth":174,"text":108},{"id":145,"depth":174,"text":146},"Materials & surfaces",false,null,"md","light","Noise, light & materials","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fspectralweight",{"title":5,"description":16},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fpaint\u002Fmaterials.ts#L1337","docs\u002Fprimitives\u002F14.materials\u002F61.spectralweight","xviIY-sgq3jkLAIUh86P95-heP4MJsQEW36PO0Rk3zE",{"stars":194},6080,[196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,256,260,265,269,273,277,281],{"path":197,"title":198,"description":199,"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":201,"title":202,"description":203,"category":25},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":205,"title":206,"description":207,"category":25},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":209,"title":210,"description":211,"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":213,"title":214,"description":215,"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":217,"title":218,"description":219,"category":25},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":221,"title":222,"description":223,"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":225,"title":226,"description":227,"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":229,"title":230,"description":231,"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":233,"title":234,"description":235,"category":25},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":237,"title":238,"description":239,"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":241,"title":242,"description":243,"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":245,"title":246,"description":247,"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":249,"title":250,"description":251,"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":253,"title":254,"description":255,"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":257,"title":258,"description":259,"category":25},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":261,"title":262,"description":263,"category":264},"\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":266,"title":267,"description":268,"category":264},"\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":270,"title":271,"description":272,"category":264},"\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":274,"title":275,"description":276,"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":278,"title":279,"description":280,"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":282,"title":283,"description":284,"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.",1796051178787,"06e02370-81a6-4d74-9931-661d71414be1"]