
<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      
        <link rel="prev" href="functions.html">
      
      
        <link rel="next" href="json.html">
      
      
      <link rel="icon" href="../src/images/logo_square.png">
      <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.19">
    
    
      
        <title>External Libraries - Synesthesia Docs</title>
      
    
    
      <link rel="stylesheet" href="../assets/stylesheets/main.7e37652d.min.css">
      
      


    
    
      
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
      <link rel="stylesheet" href="../stylesheets/sass_output.css">
    
    <script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
    
  </head>
  
  
    <body dir="ltr">
  
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#external-libraries" class="md-skip">
          Skip to content
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

  

<header class="md-header md-header--shadow" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="Header">
    <a href="../index.html" title="Synesthesia Docs" class="md-header__button md-logo" aria-label="Synesthesia Docs" data-md-component="logo">
      
  <img src="../src/images/logo_square.png" alt="logo">

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            Synesthesia Docs
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              External Libraries
            
          </span>
        </div>
      </div>
    </div>
    
    
      <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
    
    
    
      
      
        <label class="md-header__button md-icon" for="__search">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        </label>
        <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="Search">
        
        <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
        </button>
      </nav>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            Initializing search
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
      
    
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    



<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../index.html" title="Synesthesia Docs" class="md-nav__button md-logo" aria-label="Synesthesia Docs" data-md-component="logo">
      
  <img src="../src/images/logo_square.png" alt="logo">

    </a>
    Synesthesia Docs
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../index.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Introduction
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
        
          
          <label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    Quick Links
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_2">
            <span class="md-nav__icon md-icon"></span>
            Quick Links
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="audio_uniforms.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    SSF Audio Uniforms
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="standard_uniforms.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    SSF Standard Uniforms
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="functions.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    SSF Functions
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="json.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    JSON Configuration
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" >
        
          
          <label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    FAQ
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_3">
            <span class="md-nav__icon md-icon"></span>
            FAQ
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/index.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    General
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/troubleshooting.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Troubleshooting
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/license.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    License
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/audio.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Audio
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/video.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Video
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/settings.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Settings
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../faq/midi_osc.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    MIDI & OSC
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
    
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--active md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4" checked>
        
          
          <label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    SSF Documentation
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="true">
          <label class="md-nav__title" for="__nav_4">
            <span class="md-nav__icon md-icon"></span>
            SSF Documentation
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="ssf.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Synesthesia Shader Format (SSF)
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="audio_uniforms.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    SSF Audio Uniforms
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="standard_uniforms.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    SSF Standard Uniforms
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="functions.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    SSF Functions
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
    
  
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
        
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          
  
  
  <span class="md-ellipsis">
    External Libraries
    
  </span>
  

          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="libraries.html" class="md-nav__link md-nav__link--active">
        
  
  
  <span class="md-ellipsis">
    External Libraries
    
  </span>
  

      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#overview" class="md-nav__link">
    <span class="md-ellipsis">
      Overview
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#custom-library" class="md-nav__link">
    <span class="md-ellipsis">
      Custom Library
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#lygia" class="md-nav__link">
    <span class="md-ellipsis">
      lygia
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#hg_sdf" class="md-nav__link">
    <span class="md-ellipsis">
      hg_sdf
    </span>
  </a>
  
    <nav class="md-nav" aria-label="hg_sdf">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#helper-functions-and-macros" class="md-nav__link">
    <span class="md-ellipsis">
      Helper Functions and Macros
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Helper Functions and Macros">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#sgn" class="md-nav__link">
    <span class="md-ellipsis">
      sgn()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#square" class="md-nav__link">
    <span class="md-ellipsis">
      square()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#lengthsqr" class="md-nav__link">
    <span class="md-ellipsis">
      lengthSqr()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#vmax" class="md-nav__link">
    <span class="md-ellipsis">
      vmax()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#vmin" class="md-nav__link">
    <span class="md-ellipsis">
      vmin()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#primitive-objects" class="md-nav__link">
    <span class="md-ellipsis">
      Primitive Objects
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Primitive Objects">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#fsphere" class="md-nav__link">
    <span class="md-ellipsis">
      fSphere()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fplane" class="md-nav__link">
    <span class="md-ellipsis">
      fPlane()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fboxcheap" class="md-nav__link">
    <span class="md-ellipsis">
      fBoxCheap()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fbox" class="md-nav__link">
    <span class="md-ellipsis">
      fBox()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fbox2cheap" class="md-nav__link">
    <span class="md-ellipsis">
      fBox2Cheap()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fbox2" class="md-nav__link">
    <span class="md-ellipsis">
      fBox2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcorner" class="md-nav__link">
    <span class="md-ellipsis">
      fCorner()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fblob" class="md-nav__link">
    <span class="md-ellipsis">
      fBlob()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcylinder" class="md-nav__link">
    <span class="md-ellipsis">
      fCylinder()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcapsule" class="md-nav__link">
    <span class="md-ellipsis">
      fCapsule()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#flinesegment" class="md-nav__link">
    <span class="md-ellipsis">
      fLineSegment()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcapsule_1" class="md-nav__link">
    <span class="md-ellipsis">
      fCapsule()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcapsule_2" class="md-nav__link">
    <span class="md-ellipsis">
      fCapsule()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftorus" class="md-nav__link">
    <span class="md-ellipsis">
      fTorus()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcircle" class="md-nav__link">
    <span class="md-ellipsis">
      fCircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcircle_1" class="md-nav__link">
    <span class="md-ellipsis">
      fCircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fdisc" class="md-nav__link">
    <span class="md-ellipsis">
      fDisc()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fhexagoncircumcircle" class="md-nav__link">
    <span class="md-ellipsis">
      fHexagonCircumcircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fhexagonincircle" class="md-nav__link">
    <span class="md-ellipsis">
      fHexagonIncircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcone" class="md-nav__link">
    <span class="md-ellipsis">
      fCone()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foctahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fdodecahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fDodecahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ficosahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fIcosahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedoctahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedicosahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedIcosahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foctahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fdodecahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fDodecahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ficosahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fIcosahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedoctahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedicosahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedIcosahedron()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#domain-manipulation-operators" class="md-nav__link">
    <span class="md-ellipsis">
      Domain Manipulation Operators
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Domain Manipulation Operators">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#pr" class="md-nav__link">
    <span class="md-ellipsis">
      pR()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pr45" class="md-nav__link">
    <span class="md-ellipsis">
      pR45()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmod1" class="md-nav__link">
    <span class="md-ellipsis">
      pMod1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodmirror1" class="md-nav__link">
    <span class="md-ellipsis">
      pModMirror1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodsingle1" class="md-nav__link">
    <span class="md-ellipsis">
      pModSingle1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodinterval1" class="md-nav__link">
    <span class="md-ellipsis">
      pModInterval1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodpolar" class="md-nav__link">
    <span class="md-ellipsis">
      pModPolar()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmod2" class="md-nav__link">
    <span class="md-ellipsis">
      pMod2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodmirror2" class="md-nav__link">
    <span class="md-ellipsis">
      pModMirror2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodgrid2" class="md-nav__link">
    <span class="md-ellipsis">
      pModGrid2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmod3" class="md-nav__link">
    <span class="md-ellipsis">
      pMod3()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmirror" class="md-nav__link">
    <span class="md-ellipsis">
      pMirror()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmirroroctant" class="md-nav__link">
    <span class="md-ellipsis">
      pMirrorOctant()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#preflect" class="md-nav__link">
    <span class="md-ellipsis">
      pReflect()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#object-combination-operators" class="md-nav__link">
    <span class="md-ellipsis">
      Object Combination Operators
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Object Combination Operators">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#fopunionchamfer" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionChamfer()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectionchamfer" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionChamfer()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferencechamfer" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceChamfer()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunionround" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionRound()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectionround" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionRound()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferenceround" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceRound()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunioncolumns" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionColumns()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferencecolumns" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceColumns()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectioncolumns" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionColumns()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunionstairs" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionStairs()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectionstairs" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionStairs()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferencestairs" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceStairs()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunionsoft" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionSoft()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foppipe" class="md-nav__link">
    <span class="md-ellipsis">
      fOpPipe()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopengrave" class="md-nav__link">
    <span class="md-ellipsis">
      fOpEngrave()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopgroove" class="md-nav__link">
    <span class="md-ellipsis">
      fOpGroove()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foptongue" class="md-nav__link">
    <span class="md-ellipsis">
      fOpTongue()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="json.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    JSON Configuration
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="script.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    JavaScript Scripting
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="best_practices.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Best Practices
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" >
        
          
          <label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    Synesthesia Manual
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_5">
            <span class="md-nav__icon md-icon"></span>
            Synesthesia Manual
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../manual/control_hotkeys.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Control Hotkeys
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../manual/osc.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    OSC
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" >
        
          
          <label class="md-nav__link" for="__nav_6" id="__nav_6_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    Tutorials
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_6">
            <span class="md-nav__icon md-icon"></span>
            Tutorials
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/links.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    External Links
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/quickstart_guide.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Quickstart Guide
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/first_scene.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Creating Your First Scene
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/presets_favslots_playlists.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    How to Use Presets, Favslots, and Playlists
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/control_hotkeys.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    How to Use Control Hotkeys
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/livestream.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    How to Add Audio Reactive Visuals to a Livestream with OBS
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/shadertoy_conversion.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    How to Manually Convert from Shadertoy.com to SSF
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/1.19_javascript.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    How to Update Controls and Use Event Handlers with JavaScript
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../tutorials/1.16_walkthrough.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    v1.16 Feature Walkthrough
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7" >
        
          
          <label class="md-nav__link" for="__nav_7" id="__nav_7_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    Resources
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_7_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_7">
            <span class="md-nav__icon md-icon"></span>
            Resources
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../resources/syn_installers.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Synesthesia Installers
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../resources/changelogs.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Synesthesia Changelogs
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../resources/syn_resources.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Synesthesia Resources
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../resources/glsl_resources.html" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    GLSL Resources
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#overview" class="md-nav__link">
    <span class="md-ellipsis">
      Overview
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#custom-library" class="md-nav__link">
    <span class="md-ellipsis">
      Custom Library
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#lygia" class="md-nav__link">
    <span class="md-ellipsis">
      lygia
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#hg_sdf" class="md-nav__link">
    <span class="md-ellipsis">
      hg_sdf
    </span>
  </a>
  
    <nav class="md-nav" aria-label="hg_sdf">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#helper-functions-and-macros" class="md-nav__link">
    <span class="md-ellipsis">
      Helper Functions and Macros
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Helper Functions and Macros">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#sgn" class="md-nav__link">
    <span class="md-ellipsis">
      sgn()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#square" class="md-nav__link">
    <span class="md-ellipsis">
      square()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#lengthsqr" class="md-nav__link">
    <span class="md-ellipsis">
      lengthSqr()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#vmax" class="md-nav__link">
    <span class="md-ellipsis">
      vmax()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#vmin" class="md-nav__link">
    <span class="md-ellipsis">
      vmin()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#primitive-objects" class="md-nav__link">
    <span class="md-ellipsis">
      Primitive Objects
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Primitive Objects">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#fsphere" class="md-nav__link">
    <span class="md-ellipsis">
      fSphere()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fplane" class="md-nav__link">
    <span class="md-ellipsis">
      fPlane()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fboxcheap" class="md-nav__link">
    <span class="md-ellipsis">
      fBoxCheap()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fbox" class="md-nav__link">
    <span class="md-ellipsis">
      fBox()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fbox2cheap" class="md-nav__link">
    <span class="md-ellipsis">
      fBox2Cheap()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fbox2" class="md-nav__link">
    <span class="md-ellipsis">
      fBox2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcorner" class="md-nav__link">
    <span class="md-ellipsis">
      fCorner()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fblob" class="md-nav__link">
    <span class="md-ellipsis">
      fBlob()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcylinder" class="md-nav__link">
    <span class="md-ellipsis">
      fCylinder()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcapsule" class="md-nav__link">
    <span class="md-ellipsis">
      fCapsule()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#flinesegment" class="md-nav__link">
    <span class="md-ellipsis">
      fLineSegment()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcapsule_1" class="md-nav__link">
    <span class="md-ellipsis">
      fCapsule()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcapsule_2" class="md-nav__link">
    <span class="md-ellipsis">
      fCapsule()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftorus" class="md-nav__link">
    <span class="md-ellipsis">
      fTorus()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcircle" class="md-nav__link">
    <span class="md-ellipsis">
      fCircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcircle_1" class="md-nav__link">
    <span class="md-ellipsis">
      fCircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fdisc" class="md-nav__link">
    <span class="md-ellipsis">
      fDisc()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fhexagoncircumcircle" class="md-nav__link">
    <span class="md-ellipsis">
      fHexagonCircumcircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fhexagonincircle" class="md-nav__link">
    <span class="md-ellipsis">
      fHexagonIncircle()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fcone" class="md-nav__link">
    <span class="md-ellipsis">
      fCone()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foctahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fdodecahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fDodecahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ficosahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fIcosahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedoctahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedicosahedron" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedIcosahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foctahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fdodecahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fDodecahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ficosahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fIcosahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedoctahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedOctahedron()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#ftruncatedicosahedron_1" class="md-nav__link">
    <span class="md-ellipsis">
      fTruncatedIcosahedron()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#domain-manipulation-operators" class="md-nav__link">
    <span class="md-ellipsis">
      Domain Manipulation Operators
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Domain Manipulation Operators">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#pr" class="md-nav__link">
    <span class="md-ellipsis">
      pR()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pr45" class="md-nav__link">
    <span class="md-ellipsis">
      pR45()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmod1" class="md-nav__link">
    <span class="md-ellipsis">
      pMod1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodmirror1" class="md-nav__link">
    <span class="md-ellipsis">
      pModMirror1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodsingle1" class="md-nav__link">
    <span class="md-ellipsis">
      pModSingle1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodinterval1" class="md-nav__link">
    <span class="md-ellipsis">
      pModInterval1()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodpolar" class="md-nav__link">
    <span class="md-ellipsis">
      pModPolar()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmod2" class="md-nav__link">
    <span class="md-ellipsis">
      pMod2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodmirror2" class="md-nav__link">
    <span class="md-ellipsis">
      pModMirror2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmodgrid2" class="md-nav__link">
    <span class="md-ellipsis">
      pModGrid2()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmod3" class="md-nav__link">
    <span class="md-ellipsis">
      pMod3()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmirror" class="md-nav__link">
    <span class="md-ellipsis">
      pMirror()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#pmirroroctant" class="md-nav__link">
    <span class="md-ellipsis">
      pMirrorOctant()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#preflect" class="md-nav__link">
    <span class="md-ellipsis">
      pReflect()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
          <li class="md-nav__item">
  <a href="#object-combination-operators" class="md-nav__link">
    <span class="md-ellipsis">
      Object Combination Operators
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Object Combination Operators">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#fopunionchamfer" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionChamfer()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectionchamfer" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionChamfer()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferencechamfer" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceChamfer()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunionround" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionRound()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectionround" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionRound()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferenceround" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceRound()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunioncolumns" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionColumns()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferencecolumns" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceColumns()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectioncolumns" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionColumns()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunionstairs" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionStairs()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopintersectionstairs" class="md-nav__link">
    <span class="md-ellipsis">
      fOpIntersectionStairs()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopdifferencestairs" class="md-nav__link">
    <span class="md-ellipsis">
      fOpDifferenceStairs()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopunionsoft" class="md-nav__link">
    <span class="md-ellipsis">
      fOpUnionSoft()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foppipe" class="md-nav__link">
    <span class="md-ellipsis">
      fOpPipe()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopengrave" class="md-nav__link">
    <span class="md-ellipsis">
      fOpEngrave()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#fopgroove" class="md-nav__link">
    <span class="md-ellipsis">
      fOpGroove()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#foptongue" class="md-nav__link">
    <span class="md-ellipsis">
      fOpTongue()
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  



<div><h1 id="external-libraries">External Libraries</h1>
<h2 id="overview">Overview</h2>
<p>In addition to the built in SSF library, Synesthesia includes some external libraries to help create your scenes. These libraries are not compiled by default -- you need to include the files in your <code>main.glsl</code> file to use them. </p>
<p>So far, there are two external libraries available in Synesthesia: <a href="#lygia">lygia</a> and <a href="#hg_sdf">hg_sdf</a>.</p>
<h2 id="custom-library">Custom Library</h2>
<p>You can create your own GLSL library by adding a folder called <code>glsl</code> in your user data folder. Any <code>.glsl</code> files in this folder can be included in your shader. Here is the location of your user data folder:</p>
<ul>
<li>Windows: <code>C:\Users\{username}\AppData\Local\Synesthesia\Data</code></li>
<li>Mac: <code>~/Library/Application Support/com.gravitycurrent.synesthesia/Data</code></li>
</ul>
<p>For example, if you create the file <code>glsl/lib.glsl</code> within this Data folder, you could add <code>#include "lib.glsl"</code> at the top of your shader and use any functions from the file.</p>
<p><strong>NOTE:</strong> if you plan to share a scene that uses custom library code, you'll need to copy paste the library code into your shader, since other users won't have these library files.</p>
<h2 id="lygia">lygia</h2>
<p><a href="link:github.com/patriciogonzalezvivo/lygia">Lygia</a> is an open-source library by Patricio Gonzalez Vivo, creator of many incredible shader resources including <a href="link:thebookofshaders.com/">The Book of Shaders</a>. </p>
<p>The library includes a wide array of functions that touch nearly every aspect of shader programming. It is very granular -- each function has its own file. There are also some files that group multiple functions. For example:</p>
<div class="codehilite"><pre><span></span><code><span class="c1">// include a single function</span>
<span class="n">#include</span><span class="w"> </span><span class="s2">"lygia/math/rotate3d.glsl"</span>
<span class="n">#include</span><span class="w"> </span><span class="s2">"lygia/space/displace.glsl"</span>
<span class="n">#include</span><span class="w"> </span><span class="s2">"lygia/color/tonemap.glsl"</span>

<span class="n">#include</span><span class="w"> </span><span class="s2">"lygia/math.glsl"</span><span class="w">                  </span><span class="c1">// all math functions</span>
<span class="n">#include</span><span class="w"> </span><span class="s2">"lygia/sdf.glsl"</span><span class="w">                   </span><span class="c1">// all sdf functions</span>
<span class="n">#include</span><span class="w"> </span><span class="s2">"lygia/color/blend.glsl"</span><span class="w">       </span><span class="c1">// all blend functions</span>
</code></pre></div>

<p>To learn more about the library and all its functions/files, check out the <a href="link:github.com/patriciogonzalezvivo/lygia">github</a> or <a href="link:lygia.xyz/">website</a>. </p>
<p>Here are links to documentation for each section of the library (copied from the website). <strong>NOTE:</strong> Synesthesia includes Lygia version <strong>1.1.4</strong>.</p>
<ul>
    <li><a href="link:lygia.xyz/v1.1.4/math"><code>math/</code></a>: general math functions and constants: <code>PI</code>, <code>SqrtLength()</code>, etc. </li>
    <li><a href="link:lygia.xyz/v1.1.4/space"><code>space/</code></a>: general spatial operations: <code>scale()</code>, <code>rotate()</code>, etc. </li>
    <li><a href="link:lygia.xyz/v1.1.4/color"><code>color/</code></a>: general color operations: <code>luma()</code>, <code>saturation()</code>, blend modes, palettes, color space conversion, and tonemaps.</li>
    <li><a href="link:lygia.xyz/v1.1.4/animation"><code>animation/</code></a>: animation operations: easing</li>
    <li><a href="link:lygia.xyz/v1.1.4/generative"><code>generative/</code></a>: generative functions: <code>random()</code>, <code>noise()</code>, etc. </li>
    <li><a href="link:lygia.xyz/v1.1.4/sdf"><code>sdf/</code></a>: signed distance field functions.</li>
    <li><a href="link:lygia.xyz/v1.1.4/draw"><code>draw/</code></a>: drawing functions like <code>digits()</code>, <code>stroke()</code>, <code>fill</code>, etc/.</li>
    <li><a href="link:lygia.xyz/v1.1.4/sample"><code>sample/</code></a>: sample operations</li>
    <li><a href="link:lygia.xyz/v1.1.4/filter"><code>filter/</code></a>: typical filter operations: different kind of blurs, mean and median filters.</li>
    <li><a href="link:lygia.xyz/v1.1.4/distort"><code>distort/</code></a>: distort sampling operations</li>
    <li><a href="link:lygia.xyz/v1.1.4/simulate"><code>simulate/</code></a>: simulate sampling operations</li>
    <li><a href="link:lygia.xyz/v1.1.4/lighting"><code>lighting/</code></a>: different lighting models and functions for foward/deferred/raymarching rendering</li>
    <li><a href="link:lygia.xyz/v1.1.4/geometry"><code>geometry/</code></a>: operation related to geometries: intersections and AABB accelerating structures.</li>
    <li><a href="link:lygia.xyz/v1.1.4/morphological"><code>morphological/</code></a>: morphological filters: dilation, erosion, alpha and poisson fill.</li>
</ul>

<h2 id="hg_sdf">hg_sdf</h2>
<p><a href="link:mercury.sexy/hg_sdf/">hg_sdf</a> is an open-source library that provides a powerful toolset for creating raymarched scenes with signed distance functions (sdf). The following documentation is provided by the Mercury team. For more information, check out <a href="link:mercury.sexy/hg_sdf/">their website</a>.</p>
<p><strong>NOTE</strong>: to use hg_sdf, add this include line to the top of your <code>main.glsl</code> file:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#include "hg_sdf.glsl"</span>
</code></pre></div>

<h3 id="helper-functions-and-macros">Helper Functions and Macros</h3>
<h4 id="sgn"><code>sgn()</code></h4>
<p>Sign function that doesn't return 0</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">signedValue</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">sgn</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
<span class="kt">vec2</span><span class="w"> </span><span class="n">signedValue</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">sgn</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>x <code>float</code> | <code>vec2</code> - the value to be signed</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - <code>1</code> or <code>-1</code> </p>
<h4 id="square"><code>square()</code></h4>
<p>square the value</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">squared</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">square</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
<span class="kt">vec2</span><span class="w"> </span><span class="n">squared</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">square</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
<span class="kt">vec3</span><span class="w"> </span><span class="n">squared</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">square</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
<span class="kt">vec4</span><span class="w"> </span><span class="n">squared</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">square</span><span class="p">(</span><span class="kt">vec4</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>x <code>float</code> | <code>vec2</code> | <code>vec3</code> | <code>vec4</code>- the value to be squared</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - squared value</p>
<h4 id="lengthsqr"><code>lengthSqr()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">squared</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">lengthSqr</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
<span class="kt">float</span><span class="w"> </span><span class="n">squared</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">lengthSqr</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">x</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>x <code>vec2</code> | <code>vec3</code> - a vector to find the square of its length</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - squared length value</p>
<h4 id="vmax"><code>vmax()</code></h4>
<p>Maximum components of a vector</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">vectorMax</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vmax</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
<span class="kt">float</span><span class="w"> </span><span class="n">vectorMax</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vmax</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
<span class="kt">float</span><span class="w"> </span><span class="n">vectorMax</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vmax</span><span class="p">(</span><span class="kt">vec4</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>v <code>vec2</code> | <code>vec3</code> | <code>vec4</code> - the vector to be evaluated</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the largest component of the vector</p>
<h4 id="vmin"><code>vmin()</code></h4>
<p>Minimum components of a vector</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">vectorMin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vmin</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
<span class="kt">float</span><span class="w"> </span><span class="n">vectorMin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vmin</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
<span class="kt">float</span><span class="w"> </span><span class="n">vectorMin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vmin</span><span class="p">(</span><span class="kt">vec4</span><span class="w"> </span><span class="n">v</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>v <code>vec2</code> | <code>vec3</code> | <code>vec4</code>- the vector to be evaluated</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the smallest component of the vector</p>
<h3 id="primitive-objects">Primitive Objects</h3>
<p>Conventions:
Everything that is a distance function is called fSomething.
The first argument is always a point in 2 or 3-space called <code>p</code>.
Unless otherwise noted, (if the object has an intrinsic "up"
side or direction) the y axis is "up" and the object is
centered at the origin.</p>
<h4 id="fsphere"><code>fSphere()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">sphere</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fSphere</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code> - the radius of the sphere</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fplane"><code>fPlane()</code></h4>
<p>Plane with normal n (n is normalized) at some distance from the origin</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">plane</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fPlane</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">n</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">distanceFromOrigin</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>n <code>vec3</code> - the plane normal</li>
<li>distanceFromOrigin <code>float</code> - the distance from the center</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fboxcheap"><code>fBoxCheap()</code></h4>
<p>Cheap Box: distance to corners is overestimated</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cheapBox</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBoxCheap</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">b</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>b <code>vec3</code> - the box dimensions</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fbox"><code>fBox()</code></h4>
<p>Box: correct distance to corners</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">box</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBox</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">b</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>b <code>vec3</code> - the box dimensions</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fbox2cheap"><code>fBox2Cheap()</code></h4>
<p>Same as above, but in two dimensions (an endless box)</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">box</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBox2Cheap</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">b</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - a point in space</li>
<li>b <code>vec2</code> - the box dimensions</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fbox2"><code>fBox2()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">box</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBox2</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">b</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - a point in space</li>
<li>b <code>vec2</code> - the box dimensions</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcorner"><code>fCorner()</code></h4>
<p>Endless "corner"</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">corner</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCorner</span><span class="p">(</span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - a point in space</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fblob"><code>fBlob()</code></h4>
<p>Blobby ball object. You've probably seen it somewhere. This is not a correct distance bound, beware.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">blob</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBlob</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcylinder"><code>fCylinder()</code></h4>
<p>Cylinder standing upright on the xz plane</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cylinder</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCylinder</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">height</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code> - the radius of the cylinder</li>
<li>height <code>float</code> - the height of the cylinder along the y axis</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcapsule"><code>fCapsule()</code></h4>
<p>Capsule: A Cylinder with round caps on both sides</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">capsule</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCapsule</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">c</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code> - the radius of the capsule</li>
<li>c <code>float</code> - the height of the capsule along the y axis</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="flinesegment"><code>fLineSegment()</code></h4>
<p>Distance to line segment between <code>a</code> and <code>b</code>, used for fCapsule() version 2 below</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">dist</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fLineSegment</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">b</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>a <code>vec3</code> - line segment A</li>
<li>b <code>vec3</code> - linge segment B</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcapsule_1"><code>fCapsule()</code></h4>
<p>Capsule version 2: between two end points <a> and <b> with radius r</b></a></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">capsule</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCapsule</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>a <code>vec3</code> - line segment A</li>
<li>b <code>vec3</code> - linge segment B</li>
<li>r <code>float</code> - the radius of the capsule</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcapsule_2"><code>fCapsule()</code></h4>
<p>Capsule version 2: between two end points <a> and <b> with radius r</b></a></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">capsule</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCapsule</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>a <code>vec3</code> - line segment A</li>
<li>b <code>vec3</code> - linge segment B</li>
<li>r <code>float</code> - the radius of the capsule</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ftorus"><code>fTorus()</code></h4>
<p>Torus in the XZ-plane</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">donut</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fTorus</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">smallRadius</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">largeRadius</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>smallRadius <code>float</code> - the 'inside' radius</li>
<li>largeRadius <code>float</code> - the 'outside' radius</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcircle"><code>fCircle()</code></h4>
<p>A circle line. Can also be used to make a torus by subtracting the smaller radius of the torus.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">circle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCircle</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code> - the radius</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcircle_1"><code>fCircle()</code></h4>
<p>A circle line. Can also be used to make a torus by subtracting the smaller radius of the torus.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">circle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCircle</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code> - the radius</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fdisc"><code>fDisc()</code></h4>
<p>A circular disc with no thickness (i.e. a cylinder with no height). Subtract some value to make a flat disc with rounded edge.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">disc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fDisc</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code> - the radius</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fhexagoncircumcircle"><code>fHexagonCircumcircle()</code></h4>
<p>Hexagonal prism, circumcircle variant</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">prism</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fHexagonCircumcircle</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">h</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>h <code>vec2</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fhexagonincircle"><code>fHexagonIncircle()</code></h4>
<p>Hexagonal prism, circumcircle variant</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">prism</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fHexagonIncircle</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">h</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>h <code>vec2</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fcone"><code>fCone()</code></h4>
<p>Cone with correct distances to tip and base circle. Y is up, 0 is in the middle of the base.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cone</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fCone</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">radius</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">height</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>radius <code>float</code> - the radius of the cone at the base</li>
<li>height <code>float</code> - the height of the cone</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="foctahedron"><code>fOctahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOctahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">e</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
<li>e <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fdodecahedron"><code>fDodecahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fDodecahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">e</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
<li>e <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ficosahedron"><code>fIcosahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fIcosahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">e</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
<li>e <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ftruncatedoctahedron"><code>fTruncatedOctahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fTruncatedOctahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">e</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
<li>e <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ftruncatedicosahedron"><code>fTruncatedIcosahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fTruncatedIcosahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">e</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
<li>e <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="foctahedron_1"><code>fOctahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOctahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="fdodecahedron_1"><code>fDodecahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fDodecahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ficosahedron_1"><code>fIcosahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fIcosahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ftruncatedoctahedron_1"><code>fTruncatedOctahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fIcosahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h4 id="ftruncatedicosahedron_1"><code>fTruncatedIcosahedron()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">polyhedron</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fTruncatedIcosahedron</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - a point in space</li>
<li>r <code>float</code></li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance from the object at the given point</p>
<h3 id="domain-manipulation-operators">Domain Manipulation Operators</h3>
<p>Conventions:
Everything that modifies the domain is named pSomething.
Many operate only on a subset of the three dimensions. For those,
you must choose the dimensions that you want manipulated
by supplying e.g. <code>p.x</code> or <code>p.zx</code>
<code>inout p</code> is always the first argument and modified in place.
Many of the operators partition space into cells. An identifier
or cell index is returned, if possible. This return value is
intended to be optionally used e.g. as a random seed to change
parameters of the distance functions inside the cells.
Unless stated otherwise, for cell index 0, </p><p> is unchanged and cells
are centered on the origin so objects don't have to be moved to fit.</p>
<h4 id="pr"><code>pR()</code></h4>
<p>Rotate around a coordinate axis (i.e. in a plane perpendicular to that axis) by angle <code>a</code>. Read like this: <code>R(p.xz, a)</code> rotates "x towards z".
This is fast if <code>a</code> is a compile-time constant and slower (but still practical) if not.</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="n">pR</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - a point in space</li>
<li>r <code>float</code> - the rotation amount</li>
</ul>
<h4 id="pr45"><code>pR45()</code></h4>
<p>Shortcut for 45-degrees rotation</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="n">pR45</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">);</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - a point in space</li>
</ul>
<h4 id="pmod1"><code>pMod1()</code></h4>
<p>Repeat space along one axis. .</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="c1">//Use like this to repeat along the x axis:</span>
<span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pMod1</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span><span class="c1">// using the return value is optional</span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>float</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmodmirror1"><code>pModMirror1()</code></h4>
<p>Same, but mirror every second cell so they match at the boundaries</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pModMirror1</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>float</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmodsingle1"><code>pModSingle1()</code></h4>
<p>Repeat the domain only in positive direction. Everything in the negative half-space is unchanged.</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pModSingle1</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>float</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmodinterval1"><code>pModInterval1()</code></h4>
<p>Repeat only a few times: from indices <code>start</code> to <code>stop</code> (similar to above, but more flexible)</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pModInterval1</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">size</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">start</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">stop</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>float</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
<li>start <code>float</code> - which cell to start the repeat</li>
<li>stop <code>float</code> - which cell to stop the repeat</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmodpolar"><code>pModPolar()</code></h4>
<p>Repeat around the origin by a fixed angle. For easier use, num of repetitions is used to specify the angle.</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pModPolar</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">repetitions</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - the axis to repeat along</li>
<li>repetitions <code>float</code> - the angle to repeat</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmod2"><code>pMod2()</code></h4>
<p>Repeat in two dimensions</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pMod2</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmodmirror2"><code>pModMirror2()</code></h4>
<p>Same, but mirror every second cell so all boundaries match</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pModMirror2</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmodgrid2"><code>pModGrid2()</code></h4>
<p>Same, but mirror every second cell at the diagonal as well</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pModMirror2</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmod3"><code>pMod3()</code></h4>
<p>Repeat in three dimensions</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pMod3</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">size</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - the axis to repeat along</li>
<li>size <code>float</code> - the size of the "cells" or repeated spaces</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the current cell</p>
<h4 id="pmirror"><code>pMirror()</code></h4>
<p>Mirror at an axis-aligned plane which is at a specified distance <code>dist</code> from the origin.</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mirror</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pMirror</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">dist</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - the axis to repeat along</li>
<li>dist <code>float</code> - the distance for the mirror</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the sign of the mirror</p>
<h4 id="pmirroroctant"><code>pMirrorOctant()</code></h4>
<p>Mirror in both dimensions and at the diagonal, yielding one eighth of the space.translate by dist before mirroring.</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">cell</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pMirrorOctant</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec2</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">dist</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec2</code> - the axis to repeat along</li>
<li>dist <code>float</code> - the distance for the mirror</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the sign of the mirror</p>
<h4 id="preflect"><code>pReflect()</code></h4>
<p>Reflect space at a plane</p>
<p><strong>Directly modifies the input vector as an <code>inout</code> parameter</strong></p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">reflection</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pReflect</span><span class="p">(</span><span class="k">inout</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="w"> </span><span class="n">planeNormal</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">offset</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>p <code>vec3</code> - the axis to repeat along</li>
<li>planeNormal <code>vec3</code> - the normal for the reflection axis</li>
<li>offset <code>float</code> - offset from the plane</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the sign of the mirror</p>
<h3 id="object-combination-operators">Object Combination Operators</h3>
<p>We usually need the following boolean operators to combine two objects:
Union: OR(a,b)
Intersection: AND(a,b)
Difference: AND(a,!b)
(a and b being the distances to the objects).</p>
<p>The trivial implementations are min(a,b) for union, max(a,b) for intersection
and max(a,-b) for difference. To combine objects in more interesting ways to
produce rounded edges, chamfers, stairs, etc. instead of plain sharp edges we
can use combination operators. It is common to use some kind of "smooth minimum"
instead of min(), but we don't like that because it does not preserve Lipschitz
continuity in many cases.</p>
<p>Naming convention: since they return a distance, they are called fOpSomething.
The different flavours usually implement all the boolean operators above
and are called fOpUnionRound, fOpIntersectionRound, etc.</p>
<p>The basic idea: Assume the object surfaces intersect at a right angle. The two
distances <code>a</code> and <code>b</code> constitute a new local two-dimensional coordinate system
with the actual intersection as the origin. In this coordinate system, we can
evaluate any 2D distance function we want in order to shape the edge.</p>
<p>The operators below are just those that we found useful or interesting and should
be seen as examples. There are infinitely more possible operators.</p>
<p>They are designed to actually produce correct distances or distance bounds, unlike
popular "smooth minimum" operators, on the condition that the gradients of the two
SDFs are at right angles. When they are off by more than 30 degrees or so, the
Lipschitz condition will no longer hold (i.e. you might get artifacts). The worst
case is parallel surfaces that are close to each other.</p>
<p>Most have a float argument <code>r</code> to specify the radius of the feature they represent.
This should be much smaller than the object size.</p>
<p>Some of them have checks like "if ((-a &lt; r) &amp;&amp; (-b &lt; r))" that restrict
their influence (and computation cost) to a certain area. You might
want to lift that restriction or enforce it. We have left it as comments
in some cases.</p>
<p>usage example:</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">fTwoBoxes</span><span class="p">(</span><span class="kt">vec3</span><span class="w"> </span><span class="n">p</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">   </span><span class="kt">float</span><span class="w"> </span><span class="n">box0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBox</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="kt">vec3</span><span class="p">(</span><span class="mi">1</span><span class="p">));</span>
<span class="w">   </span><span class="kt">float</span><span class="w"> </span><span class="n">box1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fBox</span><span class="p">(</span><span class="n">p</span><span class="o">-</span><span class="kt">vec3</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span><span class="w"> </span><span class="kt">vec3</span><span class="p">(</span><span class="mi">1</span><span class="p">));</span>
<span class="w">   </span><span class="k">return</span><span class="w"> </span><span class="n">fOpUnionChamfer</span><span class="p">(</span><span class="n">box0</span><span class="p">,</span><span class="w"> </span><span class="n">box1</span><span class="p">,</span><span class="w"> </span><span class="mf">0.2</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div>

<h4 id="fopunionchamfer"><code>fOpUnionChamfer()</code></h4>
<p>The "Chamfer" flavour makes a 45-degree chamfered edge (the diagonal of a square of size <code>r</code>)</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpUnionChamfer</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopintersectionchamfer"><code>fOpIntersectionChamfer()</code></h4>
<p>Intersection has to deal with what is normally the inside of the resulting object when using union, which we normally don't care about too much. Thus, intersection implementations sometimes differ from union implementations.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpIntersectionChamfer</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopdifferencechamfer"><code>fOpDifferenceChamfer()</code></h4>
<p>Difference can be built from Intersection or Union</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpDifferenceChamfer</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopunionround"><code>fOpUnionRound()</code></h4>
<p>The "Round" variant uses a quarter-circle to join the two objects smoothly:</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpUnionRound</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopintersectionround"><code>fOpIntersectionRound()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpIntersectionRound</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopdifferenceround"><code>fOpDifferenceRound()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpDifferenceRound</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopunioncolumns"><code>fOpUnionColumns()</code></h4>
<p>The "Columns" flavour makes n-1 circular columns at a 45 degree angle</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpDifferenceRound</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">n</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
<li>n <code>float</code> - the number of columns to draw</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopdifferencecolumns"><code>fOpDifferenceColumns()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpDifferenceColumns</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">n</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
<li>n <code>float</code> - the number of columns to draw</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopintersectioncolumns"><code>fOpIntersectionColumns()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpIntersectionColumns</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">n</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
<li>n <code>float</code> - the number of columns to draw</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopunionstairs"><code>fOpUnionStairs()</code></h4>
<p>The "Stairs" flavour produces n-1 steps of a staircase</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpUnionStairs</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">n</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
<li>n <code>float</code> - the number of stairs to draw</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopintersectionstairs"><code>fOpIntersectionStairs()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpIntersectionStairs</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">n</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
<li>n <code>float</code> - the number of stairs to draw</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopdifferencestairs"><code>fOpDifferenceStairs()</code></h4>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpDifferenceStairs</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">n</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
<li>n <code>float</code> - the number of stairs to draw</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopunionsoft"><code>fOpUnionSoft()</code></h4>
<p>Similar to fOpUnionRound, but more lipschitz-y at acute angles (and less so at 90 degrees). Useful when fudging around too much</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpUnionSoft</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="foppipe"><code>fOpPipe()</code></h4>
<p>Produces a cylindical pipe that runs along the intersection. No objects remain, only the pipe. This is not a boolean operator.</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpPipe</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distanced to the object</p>
<h4 id="fopengrave"><code>fOpEngrave()</code></h4>
<p>First object gets a v-shaped engraving where it intersect the second</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpEngrave</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">r</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>r <code>float</code> - the radius of the intersection</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="fopgroove"><code>fOpGroove()</code></h4>
<p>First object gets a capenter-style groove cut out</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpGroove</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">ra</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">rb</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>ra <code>float</code> - the first radius</li>
<li>rb <code>float</code> - the second radius</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p>
<h4 id="foptongue"><code>fOpTongue()</code></h4>
<p>First object gets a capenter-style tongue attached</p>
<div class="codehilite"><pre><span></span><code><span class="kt">float</span><span class="w"> </span><span class="n">mergedGeom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fOpTongue</span><span class="p">(</span><span class="kt">float</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">ra</span><span class="p">,</span><span class="w"> </span><span class="kt">float</span><span class="w"> </span><span class="n">rb</span><span class="p">);</span><span class="w"> </span>
</code></pre></div>

<p><strong>Params</strong></p>
<ul>
<li>a <code>float</code> - the distance from the first geometry you want to unionize</li>
<li>b <code>float</code> - the distance from the second geometry you want to unionize</li>
<li>ra <code>float</code> - the first radius</li>
<li>rb <code>float</code> - the second radius</li>
</ul>
<p><strong>Returns</strong>: <code>float</code> - the distance of the merged geometry</p></div>












                
              </article>
            </div>
          
          
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
        </div>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
  
    Made with
    <a href="link:squidfunk.github.io/mkdocs-material" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    
    
      
      <script id="__config" type="application/json">{"base": "..", "features": [], "search": "../assets/javascripts/workers/search.973d3a69.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
    
    
      <script src="../assets/javascripts/bundle.92b07e13.min.js"></script>
      
    
  </body>
</html>