moderngl-window icon indicating copy to clipboard operation
moderngl-window copied to clipboard

Look into supporting #include for shaders

Open einarf opened this issue 4 years ago • 4 comments

We should look into supporting #include for shaders.

#version 330
#include utils/functions.glsl
...

Need to figure out how to handle line numbers.

einarf avatar Mar 22 '20 17:03 einarf

Done. Need to document this. We can include up to 100 levels of sources as max sanity check.

utils.glsl

// A bunch of functions

library.glsl

#include path/to/utils.glsl
#incluide path/to/utils_2.glsl
#incluide path/to/utils_3.glsl
...

test.glsl

#version 330
#include path/to/library.glsl
#include path/to/something_else.glsl

einarf avatar Mar 23 '20 20:03 einarf

Example : https://github.com/moderngl/moderngl-window/blob/master/examples/advanced/shader_includes.py

einarf avatar Mar 24 '20 16:03 einarf

Seriously considering revamping this one a bit.

einarf avatar Jun 25 '21 18:06 einarf

For some reason this seems to run into problems with includes of the form #include "somepath/somefile". In particularly when trying to include the lygia shader library and the cnoise function for example.

loreno-heer avatar Oct 27 '23 10:10 loreno-heer