Re: [osg-users] Changing the value of a uniform during at scene graph traversal
Hi Matthew, Now, you can't change a uniform during a single OpenGL traversal, of course (i.e., between glBegin() and glEnd()), but there is nothing stopping you from changing a uniform at any other time. If a single object is broken into several glBegin()/glEnd() sections for a given rendering pass, it is perfectly acceptable to change the value of a uniform in between each individual section. Sure, but at a higher level, if your object is broken up in such a way, then you might as well think if it as two distinct drawables, in which case they can both have the uniform with different values. I guess I'm just used to building a graph at startup as much as possible, and only modifying things at run time if necessary. If part of an object will need a certain uniform value and another part needs another value, I'd probably just break it up into two drawables, each with the right value, from the start. Anyways, I don't think the OP was thinking of something quite so detailed... I think they actually had distinct objects and thought they could only have a given named uniform once in the scene graph, and thus they wanted to modify it when the rendering got to a given object. I pointed out that in each stateset (if you want), and in particular in that object's stateset, you can have a uniform with the same name but a different value, which is not obvious but follows how other state attributes work too. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Changing the value of a uniform during at scene graph traversal
I want to change the value of a uniform for the traversal of a subgraph. A the moment I am not sure how to do this. Does anyone have any suggestions on the easiest way to do this? Thanks, Roger ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Changing the value of a uniform during at scene graph traversal
Hi Roger, Do you mean you want a uniform to hold multiple values, one for each subgraph it's associated with? If so this isn't possible, if you want different values then you'll need to use multiple Uniforms, perhaps dynamically deciding which StateSet to use for each subgraph to be able to pass in the uniforms you want. If you just want to update a uniform say in the update traversal then you an just use an update callback on the uniform or the Node/StateSet it's associated with. Robert. On Wed, Jan 21, 2009 at 5:04 PM, Roger James ro...@beardandsandals.co.uk wrote: I want to change the value of a uniform for the traversal of a subgraph. A the moment I am not sure how to do this. Does anyone have any suggestions on the easiest way to do this? Thanks, Roger ___ 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] Changing the value of a uniform during at scene graph traversal
Robert Osfield wrote: Hi Roger, Do you mean you want a uniform to hold multiple values, one for each subgraph it's associated with? If so this isn't possible, if you want different values then you'll need to use multiple Uniforms, perhaps dynamically deciding which StateSet to use for each subgraph to be able to pass in the uniforms you want. If you just want to update a uniform say in the update traversal then you an just use an update callback on the uniform or the Node/StateSet it's associated with. Robert. On Wed, Jan 21, 2009 at 5:04 PM, Roger James ro...@beardandsandals.co.uk wrote: I want to change the value of a uniform for the traversal of a subgraph. A the moment I am not sure how to do this. Does anyone have any suggestions on the easiest way to do this? Thanks, Roger Thanks for the quick reply Robert. I was hoping that I could change the value the uniform of a whilst a particular geode was rendered and use it to tell a shader to do something different for that geometry. I was wondered if I could do something like attaching a uniform of the same name to the stateset of that node. I must admit I could not think of an easy way of doing it! I am trying to override some of the shader functionality in osgShadow to make it work with geometry that is unlit and uses a texgen for its main texture coords. osgShadow::StandardShadowMap uses a vertex shader which defeats any built in texgen functinality (and also does not work with unlit geometry). Unfortunaterly there does not appear to be a way of finding out if fixed function loightinh is off or a fixed function texgen has been requested when you are in a shader. Roger ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Changing the value of a uniform during at scene graph traversal
Hi Roger, I was wondered if I could do something like attaching a uniform of the same name to the stateset of that node. I must admit I could not think of an easy way of doing it! Well, you can do that! Different statesets can have uniforms of the same name, same type but different values and the values will be as you expect when it comes time for the shader to render a vertex or fragment of the given object. I (and probably Robert too) thought you wanted to change the value of a Uniform in mid-traversal... I am trying to override some of the shader functionality in osgShadow to make it work with geometry that is unlit and uses a texgen for its main texture coords. osgShadow::StandardShadowMap uses a vertex shader which defeats any built in texgen functinality (and also does not work with unlit geometry). Unfortunaterly there does not appear to be a way of finding out if fixed function loightinh is off or a fixed function texgen has been requested when you are in a shader. You could just write your own shader (you can start by copying the ones in osgShadow's code) which does lighting only when a uniform (say named EnableLighting) is true, and generates texcoords as osgShadow expects, and when it isn't then it wouldn't calculate any lighting and would calculate texcoords differently. You can also have a uniform (say named TexcoordType) which would be an int which would select different types of texcoord generation, and you would set it to be what osgShadow expects in the root node, but then change it to what you want in your own node's stateset. There's lots of possibilities. We do this for texcoord generation, lighting, texturing, fog coordinates and application, shadows, etc. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Changing the value of a uniform during at scene graph traversal
Jean-Sbastien Guay wrote: Hi Roger, I was wondered if I could do something like attaching a uniform of the same name to the stateset of that node. I must admit I could not think of an easy way of doing it! Well, you can do that! Different statesets can have uniforms of the same name, same type but different values and the values will be as you expect when it comes time for the shader to render a vertex or fragment of the given object. I (and probably Robert too) thought you wanted to change the value of a Uniform in mid-traversal... I am trying to override some of the shader functionality in osgShadow to make it work with geometry that is unlit and uses a texgen for its main texture coords. osgShadow::StandardShadowMap uses a vertex shader which defeats any built in texgen functinality (and also does not work with unlit geometry). Unfortunaterly there does not appear to be a way of finding out if fixed function loightinh is off or a fixed function texgen has been requested when you are in a shader. You could just write your own shader (you can start by copying the ones in osgShadow's code) which does lighting only when a uniform (say named EnableLighting) is true, and generates texcoords as osgShadow expects, and when it isn't then it wouldn't calculate any lighting and would calculate texcoords differently. You can also have a uniform (say named TexcoordType) which would be an int which would select different types of texcoord generation, and you would set it to be what osgShadow expects in the root node, but then change it to what you want in your own node's stateset. There's lots of possibilities. We do this for texcoord generation, lighting, texturing, fog coordinates and application, shadows, etc. Hope this helps, J-S Thanks J-S, Thats good news. I keep forgetting that cull just puts things into render bins for a later draw stage. I tend to visualise the rendering as occuring in the cull pass which I know is wrong. Sorry. Yes, I am planning to do exactly what you suggest. I have been hacking the code in osgShadow, but for production I want to avoid that! I just need to workj out how to override the ViewData::init code now, I cannot seem to get the method signature right. I have mailed Wojciech asking for help! Roger ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org