I have a noise shader function that I’d like to include in my main vertex and fragment shader. I learnt that glsl doesnt have a file system comprehension, meaning i have to handle the includes externally and load all the shaders. In my main.h I have declared
and in my main.cpp I have loaded them as such
shouldnt that be enough to include the noise functions in my shader ?
I have tried adding the GLB_ARB directive this way in my main shader, but couldn’t any explicit examples online,
#extension GL_ARB_shading_language_include : require
my noise shader and main shaders both start with #version 150
If you have any examples I could understand with, thanks a lot !
I use :
#pragma include "../../../pathToMyGlslFileFromDataFolder/nameFile.glsl"
you can see it here in action - work in progress though -.
and it works fine, no separate inclusion from the ofApp.h.
shit, I’ve unsuccesfully tried every combination of this
do you know of any way to include it in the buffer from the of load function ?
that may be easier since of seems to be able to load the base one.
thanks anyhow !
I have not seen it done through an import in the instance of an ofApp.cpp, but maybe it’s possible. In any cases, you are trying to load a shader, but passing a .glsl file as an argument, and that’s not what the shader is expecting - need a .vert + .frag -.
judging by your app structure, you could try this in your shader.frag :
#pragma include "./shaders/noise/noise.glsl"
I have just tested it on my machine, with a noise.glsl file looking like this :
return vec3(1., 0., 0.);
and calling the function the vector.frag works fine.
I’m using Mac OS, with OF.0.11.0 .
Hope you find a way,
Are you getting any errors? @pierre_tardif00’s solution should work fine.
Do make sure your GLSL version preprocessor corresponds to the version of OpenGL you’re running (you can set this in main.cpp). These can be verified here: http://en.wikipedia.org/wiki/OpenGL_Shading_Language
It works ! the problem was that I had redeclared the version inside of noise.glsl
thanks a lot !