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
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,
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.
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 :
vec3 computeNoise(){
return vec3(1., 0., 0.);
}
and calling the function the vector.frag works fine.
I’m using Mac OS, with OF.0.11.0 .
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