Thanks Stephane, it's a pitty that this can't be done directly. Would this be of use for anyone but me? I could imagine to introduce some mechnism to set such defines per shader. Might involve pre-parsing the shader-source ... mmh I just asking myself if this would somehow break other things.
cheers Sebastian Stephane Lamoliatte schrieb: > Hi, > > No you can't do that directly. > But you could load your shader file into a string and add your > preprocessor definitions at the begining of it and then send it as > source to the osg::Shader constructor: > > std::string source = loadShaderFile(filename); > source = "#define SIMPLE \n" + source; > osg::Shader* shader = new osg::Shader(osg::Shader::VERTEX, source); > > Sebastian Messerschmidt a écrit : > >> Hello, >> >> I was wondering if the preprocessor language in GLSL is somehow useable >> for osg. >> Imagine I had a shader with >> >> .. >> #ifdef SIMPLE >> vec4 Color = vec4(1.0); >> #else if NOT_SO_SIMPLE >> vec4 Color = unimaginableComplicatedColorFunction(...) >> #endif >> >> Can I pass those defines to osg::Shader? I didn't find anything. >> So the only way to achive this is to modify the shader-code before >> loading, right? >> >> cheers >> Sebastian >> >> >> .. >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or >> > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

