[{"data":1,"prerenderedAt":305,"buildId":306},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fmath\u002Fdpdx":3,"github-stars":213,"guide-nav":215},{"id":4,"title":5,"body":6,"categoryId":43,"categorySlug":43,"categoryTitle":199,"curated":200,"description":15,"editUrl":201,"extension":202,"group":203,"groupTitle":204,"kind":205,"meta":206,"navigation":207,"path":208,"seo":209,"sourceUrl":210,"stem":211,"wordCount":201,"__hash__":212},"primitives\u002Fdocs\u002Fprimitives\u002F22.math\u002F48.dpdx.md","dpdx",{"type":7,"value":8,"toc":193},"minimark",[9,12,16,38,53,60,65,102,106,142,159,163,189],[10,11,5],"h1",{"id":5},[13,14,15],"p",{},"How much a value changes from this pixel to the next one to the right.",[17,18,23],"pre",{"className":19,"code":20,"language":21,"meta":22,"style":22},"language-ts shiki shiki-themes github-dark","dpdx(x: Val): Expr\n","ts","",[24,25,26],"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","(x: Val): Expr\n",[13,39,40,41,44,45,48,49,52],{},"Import ",[24,42,43],{},"math"," from ",[24,46,47],{},"shaders\u002Fstd"," and use ",[24,50,51],{},"math.dpdx",".",[13,54,55,56,59],{},"Works on numbers and vectors. Use it to measure how fast something moves across the screen: a refracted lookup, a reflected direction, a field. Read it before any ",[24,57,58],{},"guarded"," branch. Derivatives exist only in a pixel body (paint, effect, surface): a compute input cannot use them.",[61,62,64],"h2",{"id":63},"parameters","Parameters",[66,67,68,84],"table",{},[69,70,71],"thead",{},[72,73,74,78,81],"tr",{},[75,76,77],"th",{},"Name",[75,79,80],{},"Type",[75,82,83],{},"Notes",[85,86,87],"tbody",{},[72,88,89,95,100],{},[90,91,92],"td",{},[24,93,94],{},"x",[90,96,97],{},[24,98,99],{},"Val",[90,101],{},[61,103,105],{"id":104},"example","Example",[17,107,109],{"className":19,"code":108,"language":21,"meta":22,"style":22},"const stepX = local(dpdx(lookupUV), 'stepX')\n",[24,110,111],{"__ignoreMap":22},[27,112,113,117,121,124,127,130,132,135,139],{"class":29,"line":30},[27,114,116],{"class":115},"snl16","const",[27,118,120],{"class":119},"sDLfK"," stepX",[27,122,123],{"class":115}," =",[27,125,126],{"class":33}," local",[27,128,129],{"class":36},"(",[27,131,5],{"class":33},[27,133,134],{"class":36},"(lookupUV), ",[27,136,138],{"class":137},"sU2Wk","'stepX'",[27,140,141],{"class":36},")\n",[143,144,145],"blockquote",{},[13,146,147,151,152,155,156,158],{},[148,149,150],"strong",{},"Tip."," Derivatives are only legal outside per-pixel branches: wrap the result in ",[24,153,154],{},"local()"," before the guard and pass that local to ",[24,157,58],{}," as a dep.",[61,160,162],{"id":161},"see-also","See also",[164,165,166,177],"ul",{},[167,168,169,176],"li",{},[170,171,173],"a",{"href":172},"\u002Fdocs\u002Fprimitives\u002Fmath\u002Fdpdy",[24,174,175],{},"dpdy"," — How much a value changes from this pixel to the next one down.",[167,178,179,185,186,52],{},[170,180,182],{"href":181},"\u002Fdocs\u002Fprimitives\u002Fmath\u002Ffwidth",[24,183,184],{},"fwidth"," — How much a value changes across one pixel, in any direction: ",[24,187,188],{},"|dpdx| + |dpdy|",[190,191,192],"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 .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}",{"title":22,"searchDepth":194,"depth":194,"links":195},2,[196,197,198],{"id":63,"depth":194,"text":64},{"id":104,"depth":194,"text":105},{"id":161,"depth":194,"text":162},"Math",false,null,"md","space","Shapes, frames & warps","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fmath\u002Fdpdx",{"title":5,"description":15},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fmath.ts#L431","docs\u002Fprimitives\u002F22.math\u002F48.dpdx","Wy6Z0jTA18hv88bnh8CIhJcWdw0bW2KXxm1iI1QjiCg",{"stars":214},6080,[216,220,224,228,232,236,240,244,248,252,256,260,264,268,272,276,280,285,289,293,297,301],{"path":217,"title":218,"description":219,"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":221,"title":222,"description":223,"category":24},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":225,"title":226,"description":227,"category":24},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":229,"title":230,"description":231,"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":233,"title":234,"description":235,"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":237,"title":238,"description":239,"category":24},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":241,"title":242,"description":243,"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":245,"title":246,"description":247,"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":249,"title":250,"description":251,"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":253,"title":254,"description":255,"category":24},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":257,"title":258,"description":259,"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":261,"title":262,"description":263,"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":265,"title":266,"description":267,"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":269,"title":270,"description":271,"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":273,"title":274,"description":275,"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":277,"title":278,"description":279,"category":24},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":281,"title":282,"description":283,"category":284},"\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":286,"title":287,"description":288,"category":284},"\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":290,"title":291,"description":292,"category":284},"\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":294,"title":295,"description":296,"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":298,"title":299,"description":300,"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":302,"title":303,"description":304,"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.",1796051181806,"06e02370-81a6-4d74-9931-661d71414be1"]