[{"data":1,"prerenderedAt":404,"buildId":405},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fthroughslab":3,"github-stars":312,"guide-nav":314},{"id":4,"title":5,"body":6,"categoryId":99,"categorySlug":99,"categoryTitle":298,"curated":299,"description":16,"editUrl":300,"extension":301,"group":302,"groupTitle":303,"kind":304,"meta":305,"navigation":306,"path":307,"seo":308,"sourceUrl":309,"stem":310,"wordCount":300,"__hash__":311},"primitives\u002Fdocs\u002Fprimitives\u002F14.materials\u002F63.throughslab.md","throughSlab",{"type":7,"value":8,"toc":292},"minimark",[9,13,17,94,109,143,148,183,191,194,198,242,246,278,282,288],[10,11,5],"h1",{"id":12},"throughslab",[14,15,16],"p",{},"Follow one ray through a transparent body: in through the front face, out through the back.",[18,19,24],"pre",{"className":20,"code":21,"language":22,"meta":23,"style":23},"language-ts shiki shiki-themes github-dark","throughSlab(opts: {\n    view: Expr\n    front: Expr\n    back: Expr\n    ior: Expr\n    thickness: Expr\n    behind: Expr\n    hint?: string\n}): SlabPassage\n","ts","",[25,26,27,39,45,51,57,63,69,75,88],"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","(opts: {\n",[28,40,42],{"class":30,"line":41},2,[28,43,44],{"class":37},"    view: Expr\n",[28,46,48],{"class":30,"line":47},3,[28,49,50],{"class":37},"    front: Expr\n",[28,52,54],{"class":30,"line":53},4,[28,55,56],{"class":37},"    back: Expr\n",[28,58,60],{"class":30,"line":59},5,[28,61,62],{"class":37},"    ior: Expr\n",[28,64,66],{"class":30,"line":65},6,[28,67,68],{"class":37},"    thickness: Expr\n",[28,70,72],{"class":30,"line":71},7,[28,73,74],{"class":37},"    behind: Expr\n",[28,76,78,81,85],{"class":30,"line":77},8,[28,79,80],{"class":37},"    hint",[28,82,84],{"class":83},"snl16","?:",[28,86,87],{"class":37}," string\n",[28,89,91],{"class":30,"line":90},9,[28,92,93],{"class":37},"}): SlabPassage\n",[14,95,96,97,100,101,104,105,108],{},"Import ",[25,98,99],{},"materials"," from ",[25,102,103],{},"shaders\u002Fstd"," and use ",[25,106,107],{},"materials.throughSlab",".",[14,110,111,114,115,118,119,122,123,126,127,130,131,134,135,138,139,142],{},[25,112,113],{},"view"," is the incoming direction, ",[25,116,117],{},"front"," the front face's normal (facing the viewer) and ",[25,120,121],{},"back"," the back face's normal turned inward (also facing the viewer). ",[25,124,125],{},"ior"," is the index of refraction, ",[25,128,129],{},"thickness"," the distance between the faces and ",[25,132,133],{},"behind"," how far past the back face the scene sits. Returns where the ray lands on the scene (",[25,136,137],{},"landing","), how much escapes (Fresnel at the back face, zero under total internal reflection), the exit and grazing measures, and the ",[25,140,141],{},"bounce",": light the back face reflects back out through the front, the sparkle inside a gem. Light trapped at the front face too runs out along the surface, so the hand-off is seamless.",[144,145,147],"h2",{"id":146},"parameters","Parameters",[149,150,151,167],"table",{},[152,153,154],"thead",{},[155,156,157,161,164],"tr",{},[158,159,160],"th",{},"Name",[158,162,163],{},"Type",[158,165,166],{},"Notes",[168,169,170],"tbody",{},[155,171,172,178,181],{},[173,174,175],"td",{},[25,176,177],{},"opts",[173,179,180],{},"`{",[173,182],{},[18,184,189],{"className":185,"code":187,"language":188},[186],"language-text","view: Expr\nfront: Expr\nback: Expr\nior: Expr\nthickness: Expr\nbehind: Expr\nhint?: string\n","text",[25,190,187],{"__ignoreMap":23},[14,192,193],{},"}` |  |",[144,195,197],{"id":196},"example","Example",[18,199,201],{"className":20,"code":200,"language":22,"meta":23,"style":23},"const pass = throughSlab({view, front: nF, back: nB, ior, thickness, behind: u.backdrop})\nconst seen = mul(backdropAt(pass.landing), pass.escape)\n",[25,202,203,221],{"__ignoreMap":23},[28,204,205,208,212,215,218],{"class":30,"line":31},[28,206,207],{"class":83},"const",[28,209,211],{"class":210},"sDLfK"," pass",[28,213,214],{"class":83}," =",[28,216,217],{"class":34}," throughSlab",[28,219,220],{"class":37},"({view, front: nF, back: nB, ior, thickness, behind: u.backdrop})\n",[28,222,223,225,228,230,233,236,239],{"class":30,"line":41},[28,224,207],{"class":83},[28,226,227],{"class":210}," seen",[28,229,214],{"class":83},[28,231,232],{"class":34}," mul",[28,234,235],{"class":37},"(",[28,237,238],{"class":34},"backdropAt",[28,240,241],{"class":37},"(pass.landing), pass.escape)\n",[144,243,245],{"id":244},"see-also","See also",[247,248,249,260,269],"ul",{},[250,251,252,259],"li",{},[253,254,256],"a",{"href":255},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fspectralsum",[25,257,258],{},"spectralSum"," — Light seen across the whole visible spectrum, added up slice by slice into one rgb colour.",[250,261,262,268],{},[253,263,265],{"href":264},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Froundedslab",[25,266,267],{},"roundedSlab"," — A flat shape's glass profile: a slab whose edge rounds over in a quarter circle.",[250,270,271,277],{},[253,272,274],{"href":273},"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fbeerlambert",[25,275,276],{},"beerLambert"," — How much light survives a thickness of tinted material, per channel.",[144,279,281],{"id":280},"used-by","Used by",[14,283,284],{},[253,285,287],{"href":286},"\u002Fdocs\u002Fcomponents\u002Fprismaticglass","PrismaticGlass",[289,290,291],"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 .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}",{"title":23,"searchDepth":41,"depth":41,"links":293},[294,295,296,297],{"id":146,"depth":41,"text":147},{"id":196,"depth":41,"text":197},{"id":244,"depth":41,"text":245},{"id":280,"depth":41,"text":281},"Materials & surfaces",false,null,"md","light","Noise, light & materials","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fmaterials\u002Fthroughslab",{"title":5,"description":16},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fpaint\u002Fmaterials.ts#L1453","docs\u002Fprimitives\u002F14.materials\u002F63.throughslab","4CZLHAmFV5C_-Al-iiaEnMGN-6P_31FTTUEv24OOCkM",{"stars":313},6080,[315,319,323,327,331,335,339,343,347,351,355,359,363,367,371,375,379,384,388,392,396,400],{"path":316,"title":317,"description":318,"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":320,"title":321,"description":322,"category":25},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":324,"title":325,"description":326,"category":25},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":328,"title":329,"description":330,"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":332,"title":333,"description":334,"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":336,"title":337,"description":338,"category":25},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":340,"title":341,"description":342,"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":344,"title":345,"description":346,"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":348,"title":349,"description":350,"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":352,"title":353,"description":354,"category":25},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":356,"title":357,"description":358,"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":360,"title":361,"description":362,"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":364,"title":365,"description":366,"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":368,"title":369,"description":370,"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":372,"title":373,"description":374,"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":376,"title":377,"description":378,"category":25},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":380,"title":381,"description":382,"category":383},"\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":385,"title":386,"description":387,"category":383},"\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":389,"title":390,"description":391,"category":383},"\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":393,"title":394,"description":395,"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":397,"title":398,"description":399,"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":401,"title":402,"description":403,"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.",1796051178799,"06e02370-81a6-4d74-9931-661d71414be1"]