[osg-users] ClipNode Opposite Behavior

Erik Hensens ehensens at hunter.com
Fri Jul 24 06:22:37 PDT 2015


Thanks Christian. It's funny you mention that because since I'm not setting the color, the quad looks like an old television tuned to a frequency not in service, i.e. "static" or "snow". I think every time the quad is rendered each fragment's color is set to whatever value is in some uninitialized portion of memory, and each fragment changes color each time it is rendered. Quite a funny effect!

I added the following line to set the color, and now it is always blue, but it's still not putting a hole in my quad, it's all there or all gone depending on whether I say if (fDist < rad) or if (fDist > rad):


Code:

// The fragment shader program source code
std::string szFragSource(
"uniform vec3 center;\n"
"uniform float rad;\n"
"void main()\n"
"{\n"
"float fDistX = gl_FragCoord.x - center.x;\n"
"float fDistY = gl_FragCoord.y - center.y;\n"
"float fDistZ = gl_FragCoord.z - center.z;\n"
"float fDist = sqrt(fDistX * fDistX + fDistY * fDistY + fDistZ * fDistZ);\n"
"gl_FragColor = vec4(0.0,0.0,1.0,1.0);\n"
"if (fDist < rad) discard;\n"
"}\n"
);




Any other ideas about why my code doesn't achieve what I want? For example, am I using gl_FragCoord correctly? Are there other errors in my frag source?

Thanks again!


cbuchner1 wrote:
> I believe your fragment shader is not setting the output fragment color at all, which is a minimum requirement for a fragment shader to work.
> 
> 
> Christian
> 
> 
> 
> 2015-07-23 23:59 GMT+02:00 Erik Hensens < ()>:
> 
> > Sorry for the triplicate post, I received an error message on trying to post until I removed the quotes...
> > 
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=64458#64458 (http://forum.openscenegraph.org/viewtopic.php?p=64458#64458)
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> > 
> > 
> 
> 
>  ------------------
> Post generated by Mail2Forum


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64467#64467








More information about the osg-users mailing list