Re: [osg-users] Issue adding transparency to a simple model
Hi, If you can get by with rendering only first layer of transparency, or rendering all layers without respect to ordering (f.e. when all layers have low alpha values and/or close color values): for 1st case - you can draw your model first only to depth buffer, then 2nd time only to color buffer with depth test set to EQUAL for 2nd - you draw you model first only to color buffer, then only to depth buffer Cheers, Sergey. 04.07.2012, 00:06, Preet prismatic.proj...@gmail.com: Hi. I have a simple model I wanted to apply transparency to. I load the model data into a geometry node, and set my scene up. To get a transparent effect, I apply an alpha value to gl_FragColor in my fragment shader. The shaders are trivial: Vertex: void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } Fragment: void main() { gl_FragColor = vec4(1,0,0,0.5); } I get a strange output that sort of works, but renders a different result based on the camera position. It's hard to describe so I attached a short youtube clip. It seems like certain triangles are only rendered at certain camera angles. http://youtu.be/fQUFSff-uuU I played around with some of the settings I thought might be relevant but I still get the effect that the video shows. osg::StateSet *ss = geodeMesh-getOrCreateStateSet(); ss-setAttributeAndModes(shProgram,osg::StateAttribute::ON); ss-setMode(GL_BLEND,osg::StateAttribute::ON); // options i tried changing around // ss-setMode(GL_DEPTH_TEST,osg::StateAttribute::ON); // ss-setMode(GL_DEPTH_WRITEMASK,osg::StateAttribute::OFF); // ss-setMode(GL_CULL_FACE,osg::StateAttribute::OFF); // ss-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); Any advice would be appreciated. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Issue adding transparency to a simple model
Thanks Paul and Sergey I'll try both methods. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Issue adding transparency to a simple model
Hi. I have a simple model I wanted to apply transparency to. I load the model data into a geometry node, and set my scene up. To get a transparent effect, I apply an alpha value to gl_FragColor in my fragment shader. The shaders are trivial: Vertex: void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } Fragment: void main() { gl_FragColor = vec4(1,0,0,0.5); } I get a strange output that sort of works, but renders a different result based on the camera position. It's hard to describe so I attached a short youtube clip. It seems like certain triangles are only rendered at certain camera angles. http://youtu.be/fQUFSff-uuU I played around with some of the settings I thought might be relevant but I still get the effect that the video shows. osg::StateSet *ss = geodeMesh-getOrCreateStateSet(); ss-setAttributeAndModes(shProgram,osg::StateAttribute::ON); ss-setMode(GL_BLEND,osg::StateAttribute::ON); // options i tried changing around //ss-setMode(GL_DEPTH_TEST,osg::StateAttribute::ON); //ss-setMode(GL_DEPTH_WRITEMASK,osg::StateAttribute::OFF); //ss-setMode(GL_CULL_FACE,osg::StateAttribute::OFF); //ss-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); Any advice would be appreciated. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Issue adding transparency to a simple model
What are you doing to ensure that the triangles are rendered in back-to-front order? -Paul On 7/3/2012 2:06 PM, Preet wrote: Hi. I have a simple model I wanted to apply transparency to. I load the model data into a geometry node, and set my scene up. To get a transparent effect, I apply an alpha value to gl_FragColor in my fragment shader. The shaders are trivial: Vertex: void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } Fragment: void main() { gl_FragColor = vec4(1,0,0,0.5); } I get a strange output that sort of works, but renders a different result based on the camera position. It's hard to describe so I attached a short youtube clip. It seems like certain triangles are only rendered at certain camera angles. http://youtu.be/fQUFSff-uuU I played around with some of the settings I thought might be relevant but I still get the effect that the video shows. osg::StateSet *ss = geodeMesh-getOrCreateStateSet(); ss-setAttributeAndModes(shProgram,osg::StateAttribute::ON); ss-setMode(GL_BLEND,osg::StateAttribute::ON); // options i tried changing around //ss-setMode(GL_DEPTH_TEST,osg::StateAttribute::ON); //ss-setMode(GL_DEPTH_WRITEMASK,osg::StateAttribute::OFF); //ss-setMode(GL_CULL_FACE,osg::StateAttribute::OFF); //ss-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); Any advice would be appreciated. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Issue adding transparency to a simple model
On Tue, Jul 3, 2012 at 4:45 PM, Paul Martz pma...@skew-matrix.com wrote: What are you doing to ensure that the triangles are rendered in back-to-front order? -Paul Nothing! How can I preprocess the data to achieve that? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Issue adding transparency to a simple model
If you're unable to decompose your con-convex model into convex components, then you'll need an order-independent solution such as depth peeling. One possible implementation of depth peeling in OSG is demonstrated with the osgoit example. -Paul On 7/3/2012 3:10 PM, Preet wrote: On Tue, Jul 3, 2012 at 4:45 PM, Paul Martz pma...@skew-matrix.com wrote: What are you doing to ensure that the triangles are rendered in back-to-front order? -Paul Nothing! How can I preprocess the data to achieve that? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org