Pragmatic shader / shader include files

Skip to first unread message

Werner Modenbach

Feb 18, 2022, 5:41:02 AM2/18/22
Hi all,
I'm using osg in a Qt environment.
All my shader code is not located in the file system and also not as const in the code.
Instead it is in the Qt-Resources. Does anybody know a way how to load include "files" from those resources?

An alternative approach might be using the pragmatic shader composition instead.
Unfortunately I couldn't find a description of how to use it and also no example code.

Any hints for me?
Thanks in advance

Brett Gossage

Aug 25, 2022, 12:19:57 PM8/25/22
I keep the shader code in include files with the code wrapped as C++11 raw strings.  That way, you can edit them in a clean format and still include the code as std::string's.

The code becomes embedded in the application and the build system dependencies monitor the included shader files..

std::string fragment_shader_code = R"shader(

uniform sampler2D source;

void main()
// Sample the source texture...
   vec3 color = texture2D( source, gl_TexCoord[0].st ).rgb;
// Compute output color
   gl_FragColor = vec4( color,  1.0 );
} // end main /////////////////////////////////////////


You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages