You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// getOrCreate ensures we don't overwrite an existing VP.
VirtualProgram* vp = VirtualProgram::getOrCreate( geom->getOrCreateStateSet() );
// install the vertex function
vp->setFunction( "my_filter_vertex", vs, ShaderComp::LOCATION_VERTEX_MODEL );
// install the color filter entry point. This is just a regular shader function,
// not a pipeline injection, so just use setShader.
vp->setShader( "my_color_filter", new osg::Shader(osg::Shader::FRAGMENT, fs) );
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
MPGeometry* geom= dynamic_cast<MPGeometry*>( geode->getDrawable(0) );
std::string vs = Stringify()
<< "varying vec4 oe_layer_texc; \n"
<< "void my_filter_vertex(inout vec4 VertexMODEL) \n"
<< "{ \n"
<< " oe_layer_texc = gl_MultiTexCoord0; \n"
<<"} \n";
std::string fs =
"uniform sampler2D oe_layer_tex; \n"
"varying vec4 oe_layer_texc; \n"
"void my_color_filter(inout vec4 color) \n"
"{ \n"
" vec4 res = texture2D(oe_layer_tex, oe_layer_texc.st); \n"
" if ( res.a >= 0.0 ) \n"
" { \n"
" color.r=res.g+0.2;\n"
" } \n"
"} \n";
geom->getOrCreateStateSet()->getOrCreateUniform("oe_layer_tex", osg::Uniform::SAMPLER_2D)->set(0 );
Beta Was this translation helpful? Give feedback.
All reactions