Pragmatic shader / shader include files

35 views
Skip to first unread message

Werner Modenbach

unread,
Feb 18, 2022, 5:41:02 AM2/18/22
to osg-...@googlegroups.com
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
Werner

Brett Gossage

unread,
Aug 25, 2022, 12:19:57 PM8/25/22
to osg-...@googlegroups.com
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 /////////////////////////////////////////

)shader";

--
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 osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/4dfba532-bcae-197f-44e6-7779abaa35e9%40modenbach-ac.de.
Reply all
Reply to author
Forward
0 new messages