GithubHelp home page GithubHelp logo

Live reloading shaders? about regl HOT 2 CLOSED

jeffawang avatar jeffawang commented on May 25, 2024
Live reloading shaders?

from regl.

Comments (2)

jeffawang avatar jeffawang commented on May 25, 2024 1

Ah, nice. This seems like just what I need. Props to you for the quick answer and proof of concept 😄 !

from regl.

rreusser avatar rreusser commented on May 25, 2024

If you reuse the same regl instance, you can write:

draw = regl({
  vert: regl.prop('vert'),
  frag: regl.prop('frag'),
  ...
})

and then call it with

draw({ vert: myVertSource, frag: myFragSource })

On each call it will do a string comparison of the source and only recompile if the source has changed. Relatively speaking, it should be quite performant (the string comparison is the only downside, but that shouldn't be too significant. If it were, I guess you could always throw a serial counter in a comment near the top of the source just to early-return from the comparison asap).

The main thing is to definitely avoid recreating the entire regl instance from scratch if you can, and also try to avoid recreating the regl command if you can, since that's still moderately expensive.

Just to double-check I wasn't giving bad advice, I made a notebook here to demonstrate: https://observablehq.com/d/79823713d23613cd

from regl.

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.