Git Product home page Git Product logo

Comments (1)

patriciogonzalezvivo avatar patriciogonzalezvivo commented on May 11, 2024 1

Shouldn't be a problem. You just need to resolve the #include dependencies. For that you can do it locally, so before you bundle you regl app. For that depends on what you are using, there is a vite plugin, webpack and esbuild that support's it.

The other way to do it is dynamically when loading the shaders (it's slower and depends on https://lygia.xyz server) for it add this to your HTML (note this is the way P5.js examples for LYGIA are working):

    <!-- as a JavaScript source -->
    <script src="https://lygia.xyz/resolve.js"></script>

    <!-- Or as a ES6 module -->
    <script type="module">
        import resolveLygia from "https://lygia.xyz/resolve.esm.js"
    </script>

And then in JS when loading a shader as a string call resolveLygia() functions which return a string resolved:

    // 1. FIRST

    // Sync resolver, one include at a time
    vertSource = resolveLygia(vertSource);
    fragSource = resolveLygia(fragSource);

    // OR.

    // ASync resolver, all includes in parallel calls
    vertSource = resolveLygiaAsync(vertSource);
    fragSource = resolveLygiaAsync(fragSource);

    // 2. SECOND

    // Use the resolved source code 
    shdr = createShader(vertSource, fragSource);

If all this fail, you can drag&drop a shader file (.glsl, .frag, .vert) with dependencies to #include "lygia/something/something.glsl" and will return it (will automatically download on your computer) with all dependencies resolved.

from lygia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.