shader-web-background icon indicating copy to clipboard operation
shader-web-background copied to clipboard

How to source the shader code from a separate file?

Open nonrice opened this issue 3 years ago • 1 comments

It does not document it on the README. When I try my intuition,

<script type="x-shader/x-fragment" id="image" src="shader.frag">

The shader does not compile.

nonrice avatar Oct 27 '22 00:10 nonrice

If script is of other type than text/javascript, it will not be loaded automatically by the browser. I was thinking about that, but I haven't decided on how to implement it, because I believe it would also make sense to observe changes in such a file, to recompile the shader live.

In general the principle behind this library was to be as minimal as possible, allowing to embed shaders in the single HTML file before any other resources are loaded.

morisil avatar Oct 27 '22 09:10 morisil