[osg-users] Shaders for textures with OpenGL ES 2.0
Hello, I'm playing around with OpenSceneGraph with OpenGL ES 2.0. I managed to show some primitives, and later a model that I loaded with osgDB. However at the moment I'm assigning a random color to the gl_FragColor in the fragment shader. When doing this I'm getting the following warning: > Warning: Material::apply(State&) - not supported. I'm confused about how I should write the shaders if I load a model with osgDB in order to show it together with it's texture. So far I couldn't find any OpenSceneGraph related example for this. I would appreciate any help and tips. Thanks ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Light/Material flickering
Hi, On Mon, May 11, 2015 at 4:03 PM, João joao.henrique.pi...@hotmail.com wrote: I'm currently loading .osg models to a scene, and I'm experiencing some inconsistencies when it comes to texturing and lighting in those models. I'm not sure, but did you try enabling the GL_RESCALE_NORMAL attribute for the state sets of the objects? It's also mentioned in the FAQ. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Avoid cleaning drawing buffer
Hello, On Fri May 8 07:49:38 2015 Leandro Linardos leandro.linar...@gmail.com wrote: Is there any way to avoid cleaning the drawing buffer? You can use the setClearMask() function of the camera class. Normally you would provide the buffers which you want to be cleared. In your case you can just pass it a null or only clear the depth buffer. For example: viewer.getCamera()-setClearMask(GL_DEPTH_BUFFER_BIT); ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trouble with a simple shader program.
Hello Alexander, On 11/04/2015 20:21, Alexander Wieser wrote: Vertex Shader Code: #version 430 uniform mat4 osg_ModelViewProjectionMatrix; in vec4 osg_Vertex; void main() { gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; } I don't remember using anything that starts with osg_* in the vertex shader code that I have used with OSG. You can try using the built-in uniforms of the OpenGL, like gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; or simply gl_Position = ftransform(); If you have the OpenSceneGraph 3 Cookbook, you can refer to the point cloud example there. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with clearing the stencil buffer
This issue is solved. To anyone who is wondering, it was because the quad one was rendered before the quad two(duh). This means the stencil test of quad one was made before quad two managed to set the stencil buffer. The solution was to set the quad two to be rendered before anything else in the scene ss_two-setRenderBinDetails(-1, RenderBin); ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with clearing the stencil buffer
Hello everyone, I'm trying to use stencils and I'm not sure what I'm missing. Basically I have two quads in my scene. I want the quad two to set the stencil buffer to 1, and I want the quad one to be visible only where the stencil buffer is not 1. So far I am getting the result which I want if I don't clear the stencil buffer. Of course in that case when I rotate the scene using the viewer, the stencil buffer gets painted to 1's(because of the quad two) and I don't see the quad one even on places where quad two is not positioned anymore. However when I clean the stencil buffer(see below), I don't get the result that I want. viewer-getCamera()-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); In this case both of the quads are visible. I'm suspecting that the stencil buffer gets cleared before the stencil check is done. Here is a part of my code where I set the stencils. osg::ref_ptrosg::PositionAttitudeTransform transform_one = new osg::PositionAttitudeTransform(); osg::ref_ptrosg::PositionAttitudeTransform transform_two = new osg::PositionAttitudeTransform(); transform_one-addChild(createQuad()); transform_two-addChild(createQuad()); transform_two-setScale(osg::Vec3(0.5, 0.5, 0.5)); transform_two-setPosition(osg::Vec3(0.25, 0.2, 0.25)); // --- Begin stencil related stuff osg::ref_ptrosg::StateSet ss_one = transform_one-getOrCreateStateSet(); osg::ref_ptrosg::StateSet ss_two = transform_two-getOrCreateStateSet(); osg::ref_ptrosg::Stencil stencil_one = new osg::Stencil(); osg::ref_ptrosg::Stencil stencil_two = new osg::Stencil(); stencil_two-setFunction(osg::Stencil::ALWAYS, 1, ~0u); stencil_two-setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::REPLACE); stencil_one-setFunction(osg::Stencil::NOTEQUAL, 1, ~0u); stencil_one-setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP); ss_one-setMode(GL_LIGHTING, osg::StateAttribute::OFF); ss_two-setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::ref_ptrosg::ColorMask cm_one = new osg::ColorMask(); // I play with the parameters below to see the position of the quad two cm_one-setMask(false, false, false, false); ss_two-setAttribute(cm_one); ss_two-setAttributeAndModes(stencil_two, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); ss_one-setAttributeAndModes(stencil_one, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); Any help would be appreciated, I am sure I'm missing something really basic :) Thanks ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with clearing the stencil buffer
Hello everyone, I'm trying to use stencils and I'm not sure what I'm missing. Basically I have two quads in my scene. I want the quad two to set the stencil buffer to 1, and I want the quad one to be visible only where the stencil buffer is not 1. So far I am getting the result which I want if I don't clear the stencil buffer. Of course in that case when I rotate the scene using the viewer, the stencil buffer gets painted to 1's(because of the quad two) and I don't see the quad one even on places where quad two is not positioned anymore. However when I clean the stencil buffer(see below), I don't get the result that I want. viewer-getCamera()-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); In this case both of the quads are visible. I'm suspecting that the stencil buffer gets cleared before the stencil check is done. Here is a part of my code where I set the stencils. osg::ref_ptrosg::PositionAttitudeTransform transform_one = new osg::PositionAttitudeTransform(); osg::ref_ptrosg::PositionAttitudeTransform transform_two = new osg::PositionAttitudeTransform(); transform_one-addChild(createQuad()); transform_two-addChild(createQuad()); transform_two-setScale(osg::Vec3(0.5, 0.5, 0.5)); transform_two-setPosition(osg::Vec3(0.25, 0.2, 0.25)); // --- Begin stencil related stuff osg::ref_ptrosg::StateSet ss_one = transform_one-getOrCreateStateSet(); osg::ref_ptrosg::StateSet ss_two = transform_two-getOrCreateStateSet(); osg::ref_ptrosg::Stencil stencil_one = new osg::Stencil(); osg::ref_ptrosg::Stencil stencil_two = new osg::Stencil(); stencil_two-setFunction(osg::Stencil::ALWAYS, 1, ~0u); stencil_two-setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::REPLACE); stencil_one-setFunction(osg::Stencil::NOTEQUAL, 1, ~0u); stencil_one-setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP); ss_one-setMode(GL_LIGHTING, osg::StateAttribute::OFF); ss_two-setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::ref_ptrosg::ColorMask cm_one = new osg::ColorMask(); // I play with the parameters below to see the position of the quad two cm_one-setMask(false, false, false, false); ss_two-setAttribute(cm_one); ss_two-setAttributeAndModes(stencil_two, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); ss_one-setAttributeAndModes(stencil_one, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); Any help would be appreciated, I am sure I'm missing something really basic :) Thanks ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org