[{"data":1,"prerenderedAt":458,"buildId":459},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fcausticcast":3,"github-stars":366,"guide-nav":368},{"id":4,"title":5,"body":6,"categoryId":111,"categorySlug":111,"categoryTitle":353,"curated":354,"description":16,"editUrl":355,"extension":356,"group":153,"groupTitle":357,"kind":358,"meta":359,"navigation":360,"path":361,"seo":362,"sourceUrl":363,"stem":364,"wordCount":355,"__hash__":365},"primitives\u002Fdocs\u002Fprimitives\u002F14.materials\u002F56.causticcast.md","causticCast",{"type":7,"value":8,"toc":347},"minimark",[9,13,17,106,121,155,160,209,217,220,224,296,306,310,333,337,343],[10,11,5],"h1",{"id":12},"causticcast",[14,15,16],"p",{},"The shadow and the focused light a transparent object throws on the surface behind it.",[18,19,24],"pre",{"className":20,"code":21,"language":22,"meta":23,"style":23},"language-ts shiki shiki-themes github-dark","causticCast(sampleAt: (p: Expr) => Expr, opts: {\n    at: Expr\n    offset: Expr\n    slant: Expr\n    focus: Expr\n    spread: Expr\n    hint?: string\n}): {shadow: Expr; light: Expr}\n","ts","",[25,26,27,58,64,70,76,82,88,100],"code",{"__ignoreMap":23},[28,29,32,35,39,42,46,49,52,55],"span",{"class":30,"line":31},"line",1,[28,33,5],{"class":34},"svObZ",[28,36,38],{"class":37},"s95oV","(sampleAt: (",[28,40,14],{"class":41},"s9osk",[28,43,45],{"class":44},"snl16",":",[28,47,48],{"class":34}," Expr",[28,50,51],{"class":37},") ",[28,53,54],{"class":44},"=>",[28,56,57],{"class":37}," Expr, opts: {\n",[28,59,61],{"class":30,"line":60},2,[28,62,63],{"class":37},"    at: Expr\n",[28,65,67],{"class":30,"line":66},3,[28,68,69],{"class":37},"    offset: Expr\n",[28,71,73],{"class":30,"line":72},4,[28,74,75],{"class":37},"    slant: Expr\n",[28,77,79],{"class":30,"line":78},5,[28,80,81],{"class":37},"    focus: Expr\n",[28,83,85],{"class":30,"line":84},6,[28,86,87],{"class":37},"    spread: Expr\n",[28,89,91,94,97],{"class":30,"line":90},7,[28,92,93],{"class":37},"    hint",[28,95,96],{"class":44},"?:",[28,98,99],{"class":37}," string\n",[28,101,103],{"class":30,"line":102},8,[28,104,105],{"class":37},"}): {shadow: Expr; light: Expr}\n",[14,107,108,109,112,113,116,117,120],{},"Import ",[25,110,111],{},"materials"," from ",[25,114,115],{},"shaders\u002Fstd"," and use ",[25,118,119],{},"materials.causticCast",".",[14,122,123,126,127,130,131,134,135,138,139,142,143,146,147,150,151,154],{},[25,124,125],{},"sampleAt(p)"," returns the object's signed distance (negative inside) at a placement point; the object's centre is at (0.5, 0.5). ",[25,128,129],{},"at"," is this pixel's placement point, ",[25,132,133],{},"offset"," how far the light pushes the object's image across the surface (placement units), and ",[25,136,137],{},"slant"," the cosine of how steeply the light arrives (1 head-on; lower stretches everything along the offset). ",[25,140,141],{},"focus"," (0–1) is how tightly the object gathers the light into a bright spot, ",[25,144,145],{},"spread"," (0–1) how far its colours focus apart, fanning the spot's edge into a spectrum. Returns ",[25,148,149],{},"shadow"," (0–1: how much to darken the surface, open in the middle like a real glass shadow) and ",[25,152,153],{},"light"," (rgb multiplier on the light's colour for the caustic). Four taps of the field.",[156,157,159],"h2",{"id":158},"parameters","Parameters",[161,162,163,179],"table",{},[164,165,166],"thead",{},[167,168,169,173,176],"tr",{},[170,171,172],"th",{},"Name",[170,174,175],{},"Type",[170,177,178],{},"Notes",[180,181,182,197],"tbody",{},[167,183,184,190,195],{},[185,186,187],"td",{},[25,188,189],{},"sampleAt",[185,191,192],{},[25,193,194],{},"(p: Expr) => Expr",[185,196],{},[167,198,199,204,207],{},[185,200,201],{},[25,202,203],{},"opts",[185,205,206],{},"`{",[185,208],{},[18,210,215],{"className":211,"code":213,"language":214},[212],"language-text","at: Expr\noffset: Expr\nslant: Expr\nfocus: Expr\nspread: Expr\nhint?: string\n","text",[25,216,213],{"__ignoreMap":23},[14,218,219],{},"}` |  |",[156,221,223],{"id":222},"example","Example",[18,225,227],{"className":20,"code":226,"language":22,"meta":23,"style":23},"const cast = causticCast((p) => frame.sampler(p).member('x'), {at: frame.sdfUV!, offset, slant: K.member('z'), focus, spread: u.dispersion})\n",[25,228,229],{"__ignoreMap":23},[28,230,231,234,238,241,244,247,249,251,253,256,259,262,265,268,272,275,278,281,284,286,288,290,293],{"class":30,"line":31},[28,232,233],{"class":44},"const",[28,235,237],{"class":236},"sDLfK"," cast",[28,239,240],{"class":44}," =",[28,242,243],{"class":34}," causticCast",[28,245,246],{"class":37},"((",[28,248,14],{"class":41},[28,250,51],{"class":37},[28,252,54],{"class":44},[28,254,255],{"class":37}," frame.",[28,257,258],{"class":34},"sampler",[28,260,261],{"class":37},"(p).",[28,263,264],{"class":34},"member",[28,266,267],{"class":37},"(",[28,269,271],{"class":270},"sU2Wk","'x'",[28,273,274],{"class":37},"), {at: frame.sdfUV",[28,276,277],{"class":44},"!",[28,279,280],{"class":37},", offset, slant: ",[28,282,283],{"class":236},"K",[28,285,120],{"class":37},[28,287,264],{"class":34},[28,289,267],{"class":37},[28,291,292],{"class":270},"'z'",[28,294,295],{"class":37},"), focus, spread: u.dispersion})\n",[297,298,299],"blockquote",{},[14,300,301,305],{},[302,303,304],"strong",{},"Tip."," Only reads right when the layers beneath look like a lit surface (a wall, paper, a studio sweep).",[156,307,309],{"id":308},"see-also","See also",[311,312,313,324],"ul",{},[314,315,316,323],"li",{},[317,318,320],"a",{"href":319},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fthroughslab",[25,321,322],{},"throughSlab"," — Follow one ray through a transparent body: in through the front face, out through the back.",[314,325,326,332],{},[317,327,329],{"href":328},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fbeerlambert",[25,330,331],{},"beerLambert"," — How much light survives a thickness of tinted material, per channel.",[156,334,336],{"id":335},"used-by","Used by",[14,338,339],{},[317,340,342],{"href":341},"\u002Fdocs\u002Fcomponents\u002Fprismaticglass","PrismaticGlass",[344,345,346],"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 .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);}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":23,"searchDepth":60,"depth":60,"links":348},[349,350,351,352],{"id":158,"depth":60,"text":159},{"id":222,"depth":60,"text":223},{"id":308,"depth":60,"text":309},{"id":335,"depth":60,"text":336},"Materials & surfaces",false,null,"md","Noise, light & materials","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fcausticcast",{"title":5,"description":16},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fpaint\u002Fmaterials.ts#L1625","docs\u002Fprimitives\u002F14.materials\u002F56.causticcast","yC3ORhBbCwzZF2kG7w7Y2_9VEZEOxJgxwBfhoJ9AESo",{"stars":367},6080,[369,373,377,381,385,389,393,397,401,405,409,413,417,421,425,429,433,438,442,446,450,454],{"path":370,"title":371,"description":372,"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":374,"title":375,"description":376,"category":25},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":378,"title":379,"description":380,"category":25},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":382,"title":383,"description":384,"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":386,"title":387,"description":388,"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":390,"title":391,"description":392,"category":25},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":394,"title":395,"description":396,"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":398,"title":399,"description":400,"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":402,"title":403,"description":404,"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":406,"title":407,"description":408,"category":25},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":410,"title":411,"description":412,"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":414,"title":415,"description":416,"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":418,"title":419,"description":420,"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":422,"title":423,"description":424,"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":426,"title":427,"description":428,"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":430,"title":431,"description":432,"category":25},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":434,"title":435,"description":436,"category":437},"\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":439,"title":440,"description":441,"category":437},"\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":443,"title":444,"description":445,"category":437},"\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":447,"title":448,"description":449,"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":451,"title":452,"description":453,"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":455,"title":456,"description":457,"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.",1796051178743,"06e02370-81a6-4d74-9931-661d71414be1"]