patriciogonzalezvivo / glslCanvas

Simple tool to load GLSL shaders on HTML Canvas using WebGL
http://patriciogonzalezvivo.github.io/glslCanvas/
MIT License
1.97k stars 183 forks source link

Load shader as a external file #86

Open joaodafonseca opened 1 year ago

joaodafonseca commented 1 year ago

Hello,

is it possible to load a shader in a external file? any example on how to do that?

thanks, J

raaaahman commented 1 year ago

Hello, would the following code fit your use case?

        const sandbox = new GlslCanvas(document.querySelector('#app'))

        fetch('/path/to/shader.frag')
        .then(response => {
          return response.text()
        })
        .then(fragment => {
          sandbox.load(fragment)
        })