Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
Hi all, Generalizing my 3 pass logic on a group of models, it seems I don't get the expected result. Let me ask a question. In the following case : am I correct if I assume the rendering order will be A1-A2-...-An-B-A1(with B context)-A2(with B context)-...-An(with B context)-C-A1(with C context)-A2(with C context)-...-An(with C context) , in each {A1-A2-...-An} sequence, precise order being unassumable ? By with B context I mean having stateset attributes inherited from B stateset ones. If not, what would be a correct way to give rise to this render order ?? Thanks for any teaching about this. -- Christophe Médard Société OKTAL (http://www.oktal.fr) 2 impasse Boudeville 31100 Toulouse (France) Tél. : (+33) 5 62 11 50 10 Fax : (+33) 5 62 11 50 29 - Original Message - From: Christophe Medard To: OpenSceneGraph Users Sent: Friday, October 05, 2007 3:55 PM Subject: Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails) Yop, All right, Tim's right. So to conclude : - setRenderingHint is just a shortcut for setRenderBinDetails, it allows not to have to specify the name of bin type, and _renderingHint is useless (for those making inquiries on the OSG source) - indeed, the binNumber is the draw order number against other children in the parent Group, evaluated in a left-first traversall logic. The draw order for this case (3 pass on an geode) is A-B-C. It works well, one just have to beware of z-fighting, through the reuse of the depth buffer of the 1st pass (via setAttributeAndModes(new osg::Depth(osg::Depth::EQUAL,0.0,1.0,false) for example). | osg::Group Root | --- | | | | | | |osg::Group B osg::Group C |[binNumber = 20] [binNumber = 30] | || -- | osg::Geode A [binNumber = 15] Thanks to all. Question_about_bins.jpg___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
Hi Christophe, The definitive answer comes from the source: void StateSet::setRenderingHint(int hint) { _renderingHint = hint; // temporary hack to get new render bins working. switch(_renderingHint) { case(TRANSPARENT_BIN): { _binMode = USE_RENDERBIN_DETAILS; _binNum = 10; _binName = DepthSortedBin; break; } case(OPAQUE_BIN): { _binMode = USE_RENDERBIN_DETAILS; _binNum = 0; _binName = RenderBin; break; } default: // DEFAULT_BIN { setRenderBinToInherit(); break; } } } Which shows that setting rendering bin number *and* bin name is equivalent, but not bin number alone. Robert. On 10/4/07, Christophe Medard [EMAIL PROTECTED] wrote: Hi all, There's something I can't get a clear vision of despite my efforts. To parameterize order of drawing, there are two levers : renderingHint (set on a node or drawable through it's stateset osg::StateSet::setRenderingHint()) and binnumber (set on a node or drawable through it's stateset osg::StateSet::setRenderBinDetails()). I still have two interrogations : - what is the difference (or should i say level of priority) between renderingHint and binnumber ? * - there seems to be no notion of inheritance (like there is on a stateattribute typically) for those renderhint or renderbindetail features : if you set a rendering order (through one or the other feature) on a group node, does that rendering order affect the whole subgraph (understand children and children of children) ? What happens if a renderhint or renderdindetail is set again on one child ? Thanks to anyone capable of clearing that because after different attemps for different purposes, in some cases I succeded to obtain what I wanted, in some cases I didn't, and I'm ending kinda confused on that. Cheers, -- Christophe Médard Société OKTAL (http://www.oktal.fr) 2 impasse Boudeville 31100 Toulouse (France) Tél. : (+33) 5 62 11 50 10 Fax : (+33) 5 62 11 50 29 * There must be a difference between the two since they aren't linked together : setting TRANSPARENT_BIN isn't equivalent to binDetails = 10 because you can do osg::StateSet::setRenderingHint(OPAQUE_BIN) and osg::StateSet::setRenderBinDetails(10), it's valid. Saying that I point out that the order of those two calls is important for if you make osg::StateSet::setRenderBinDetails(10) and osg::StateSet::setRenderingHint(OPAQUE_BIN) your binnumber is 0 !! Is that a bug ? ___ 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
[osg-users] RenderingHint vs binNumber(RenderBinDetails)
Hi all, There's something I can't get a clear vision of despite my efforts. To parameterize order of drawing, there are two levers : renderingHint (set on a node or drawable through it's stateset osg::StateSet::setRenderingHint()) and binnumber (set on a node or drawable through it's stateset osg::StateSet::setRenderBinDetails()). I still have two interrogations : - what is the difference (or should i say level of priority) between renderingHint and binnumber ? * - there seems to be no notion of inheritance (like there is on a stateattribute typically) for those renderhint or renderbindetail features : if you set a rendering order (through one or the other feature) on a group node, does that rendering order affect the whole subgraph (understand children and children of children) ? What happens if a renderhint or renderdindetail is set again on one child ? Thanks to anyone capable of clearing that because after different attemps for different purposes, in some cases I succeded to obtain what I wanted, in some cases I didn't, and I'm ending kinda confused on that. Cheers, -- Christophe Médard Société OKTAL (http://www.oktal.fr) 2 impasse Boudeville 31100 Toulouse (France) Tél. : (+33) 5 62 11 50 10 Fax : (+33) 5 62 11 50 29 * There must be a difference between the two since they aren't linked together : setting TRANSPARENT_BIN isn't equivalent to binDetails = 10 because you can do osg::StateSet::setRenderingHint(OPAQUE_BIN) and osg::StateSet::setRenderBinDetails(10), it's valid. Saying that I point out that the order of those two calls is important for if you make osg::StateSet::setRenderBinDetails(10) and osg::StateSet::setRenderingHint(OPAQUE_BIN) your binnumber is 0 !! Is that a bug ? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert Osfield wrote: Hi Christophe, The definitive answer comes from the source: ... Which shows that setting rendering bin number *and* bin name is equivalent, but not bin number alone. Robert. On 10/4/07, Christophe Medard [EMAIL PROTECTED] wrote: Hi all, There's something I can't get a clear vision of despite my efforts. ... - there seems to be no notion of inheritance (like there is on a stateattribute typically) for those renderhint or renderbindetail features : if you set a rendering order (through one or the other feature) on a group node, does that rendering order affect the whole subgraph (understand children and children of children) ? What happens if a renderhint or renderdindetail is set again on one child ? Robert didn't answer your second question; I'll have a go because I think I understand it. First of all, there aren't a fixed number of render bins. You can assign a StateSet to any integer, positive or negative. This turns out to be quite useful. When you say set a rendering order on a group node, you mean that you've set the render bin in a state set in that node. There is an inheritance effect, but it may not be what you expect. Render bins can contain other render bins! If the children of your group node have state sets that also set the render bin detail, their render bins are stored inside the group state set's render bin, and they will be rendered in order when that render bin is traversed. This can give you unexpected results, when for example you assign a state sets with TRANSPARENT_BIN or OPAQUE_BIN to nodes up and down the scene graph :) On the other hand you can get very precise control of the ordering of drawables with it. In FlightGear I just used this feature to order cloud layers. The layers are too big for normal transparency sorting to work well, and you want to draw the cloud layer tops from low altitude to high and the bottoms from high to low. I used the altitudes of the layers as render bin numbers to get the right order: // Force the cloud layers into recursive bins of bin 4. osg::StateSet *rootSet = layer_root-getOrCreateStateSet(); rootSet-setRenderBinDetails(4, RenderBin); Child 0 has the bottom layers and child 1 has the tops: layer_root-getChild(0)-getStateSet()-setRenderBinDetails(-(int)layer_asl, RenderBin); layer_root-getChild(1)-getStateSet()-setRenderBinDetails((int)layer_asl, RenderBin); I hope someone will correct me if I've gotten this all wrong! Tim -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFHBNXNeDhWHdXrDRURAt9NAJ4kiuDzr0ZFCj7iATsgs+1J0aQHjwCfUzqc 9A/Otv/kDQZCBcdR7VPozqg= =eU+I -END PGP SIGNATURE- ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
There RenderBin name exist in StateSet so you can define your own bins with their own bin names. There are just two default ones RenderBin and DepthSortedBin. See include/osgUtil/RenderBIn for further details. On 10/4/07, Paul Melis [EMAIL PROTECTED] wrote: Robert Osfield wrote: StateSet::setRenderingHint is merly a convenience function for setting the bin number and bin name it has no function beyond this. Just chiming in here: it seems the sort-order of a renderbin is determined by its name. This has always bothered me a bit, as it gives the impression that you can assign any name, while there are only 2 valid ones. Would it be an option to change this to a simple sort_mode variable whose value comes from an enum { SortByState, SortByDepth, ...} ? Paul On 10/4/07, Christophe Medard [EMAIL PROTECTED] wrote: To react to what says Robert, I'm under the impression that renderingHint in fact isn't used internally, is it ? Why is there two informations in fact redundant (an order of draw), renderingHint and binNumber ? So if I'm correct, things must only be thought of in 'binNumber' terms. To react to what says Tim, I'm passing through stateset on group nodes indeed, but I'm not sure to perfecly understand well what you're saying. Let's take a over simple example, if I have the following three, what will be the order of draw ? | | | osg::Group A osg::Group B [binNumber = 8] dft, so binNumber = 0 | | | | osg::Geode C osg::Geode D osg::Geode E [binNumber = 5] [binNumber = 1] | | --- | | osg::Drawable E0 osg::Drawable E1 dft, so binNumber = 0[binNumber = 6] Is it B/E0 - D - C - A - E1 ? Another example, closer to my current purpose test, practical to make multi pass drawings : | osg::Group | -- | | | | osg::Group B osg::Group C | [binNumber = 20][binNumber = 30] | osg::Geode A [binNumber = 15] Is it A - B - C ? I think exploring a concrete example like that clear things. Thanks - Original Message - From: Tim Moore [EMAIL PROTECTED] To: OpenSceneGraph Users osg-users@lists.openscenegraph.org Sent: Thursday, October 04, 2007 2:00 PM Subject: Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails) Robert didn't answer your second question; I'll have a go because I think I understand it. First of all, there aren't a fixed number of render bins. You can assign a StateSet to any integer, positive or negative. This turns out to be quite useful. When you say set a rendering order on a group node, you mean that you've set the render bin in a state set in that node. There is an inheritance effect, but it may not be what you expect. Render bins can contain other render bins! If the children of your group node have state sets that also set the render bin detail, their render bins are stored inside the group state set's render bin, and they will be rendered in order when that render bin is traversed. This can give you unexpected results, when for example you assign a state sets with TRANSPARENT_BIN or OPAQUE_BIN to nodes up and down the scene graph :) On the other hand you can get very precise control of the ordering of drawables with it. In FlightGear I just used this feature to order cloud layers. The layers are too big for normal transparency sorting to work well, and you want to draw the cloud layer tops from low altitude to high and the bottoms from high to low. I used the altitudes of the layers as render bin numbers to get the right order: // Force the cloud layers into recursive bins of bin 4. osg::StateSet *rootSet = layer_root-getOrCreateStateSet(); rootSet-setRenderBinDetails(4, RenderBin); Child 0 has the bottom layers and child 1 has the tops: layer_root-getChild(0)-getStateSet()-setRenderBinDetails(-(int)layer_asl, RenderBin); layer_root-getChild(1)-getStateSet
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
Sorry for the mailer redisposing of things. Here are the examples I wanted to submit : | | | osg::Group Aosg::Group B [binNumber = 8] dft, so binNumber = 0 | - | || osg::Geode Cosg::Geode Dosg::Geode E [binNumber = 5] [binNumber = 1] | | | | osg::Drawable E0 osg::Drawable E1 dft, so binNumber = 0[binNumber=6] Is it B/E0 - D - C - A - E1 ? Another example, closer to my current purpose test, practical to make multi pass drawings : | osg::Group | - | | | | | | | osg::Group B osg::Group C | [binNumber = 20] [binNumber = 30] | osg::Geode A [binNumber = 15] Is it A - B - C ? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
Robert Osfield wrote: StateSet::setRenderingHint is merly a convenience function for setting the bin number and bin name it has no function beyond this. Just chiming in here: it seems the sort-order of a renderbin is determined by its name. This has always bothered me a bit, as it gives the impression that you can assign any name, while there are only 2 valid ones. Would it be an option to change this to a simple sort_mode variable whose value comes from an enum { SortByState, SortByDepth, ...} ? Paul On 10/4/07, Christophe Medard [EMAIL PROTECTED] wrote: To react to what says Robert, I'm under the impression that renderingHint in fact isn't used internally, is it ? Why is there two informations in fact redundant (an order of draw), renderingHint and binNumber ? So if I'm correct, things must only be thought of in 'binNumber' terms. To react to what says Tim, I'm passing through stateset on group nodes indeed, but I'm not sure to perfecly understand well what you're saying. Let's take a over simple example, if I have the following three, what will be the order of draw ? | | | osg::Group A osg::Group B [binNumber = 8] dft, so binNumber = 0 | | | | osg::Geode C osg::Geode D osg::Geode E [binNumber = 5] [binNumber = 1] | | --- | | osg::Drawable E0 osg::Drawable E1 dft, so binNumber = 0[binNumber = 6] Is it B/E0 - D - C - A - E1 ? Another example, closer to my current purpose test, practical to make multi pass drawings : | osg::Group | -- | | | | osg::Group B osg::Group C | [binNumber = 20][binNumber = 30] | osg::Geode A [binNumber = 15] Is it A - B - C ? I think exploring a concrete example like that clear things. Thanks - Original Message - From: Tim Moore [EMAIL PROTECTED] To: OpenSceneGraph Users osg-users@lists.openscenegraph.org Sent: Thursday, October 04, 2007 2:00 PM Subject: Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails) Robert didn't answer your second question; I'll have a go because I think I understand it. First of all, there aren't a fixed number of render bins. You can assign a StateSet to any integer, positive or negative. This turns out to be quite useful. When you say set a rendering order on a group node, you mean that you've set the render bin in a state set in that node. There is an inheritance effect, but it may not be what you expect. Render bins can contain other render bins! If the children of your group node have state sets that also set the render bin detail, their render bins are stored inside the group state set's render bin, and they will be rendered in order when that render bin is traversed. This can give you unexpected results, when for example you assign a state sets with TRANSPARENT_BIN or OPAQUE_BIN to nodes up and down the scene graph :) On the other hand you can get very precise control of the ordering of drawables with it. In FlightGear I just used this feature to order cloud layers. The layers are too big for normal transparency sorting to work well, and you want to draw the cloud layer tops from low altitude to high and the bottoms from high to low. I used the altitudes of the layers as render bin numbers to get the right order: // Force the cloud layers into recursive bins of bin 4. osg::StateSet *rootSet = layer_root-getOrCreateStateSet(); rootSet-setRenderBinDetails(4, RenderBin); Child 0 has the bottom layers and child 1 has the tops: layer_root-getChild(0)-getStateSet()-setRenderBinDetails(-(int)layer_asl, RenderBin); layer_root-getChild(1)-getStateSet()-setRenderBinDetails((int)layer_asl, RenderBin); I hope someone will correct me if I've gotten this all wrong! Tim ___ 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
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
To react to what says Robert, I'm under the impression that renderingHint in fact isn't used internally, is it ? Why is there two informations in fact redundant (an order of draw), renderingHint and binNumber ? So if I'm correct, things must only be thought of in 'binNumber' terms. To react to what says Tim, I'm passing through stateset on group nodes indeed, but I'm not sure to perfecly understand well what you're saying. Let's take a over simple example, if I have the following three, what will be the order of draw ? | | | osg::Group A osg::Group B [binNumber = 8] dft, so binNumber = 0 | | | | osg::Geode C osg::Geode D osg::Geode E [binNumber = 5] [binNumber = 1] | | --- | | osg::Drawable E0 osg::Drawable E1 dft, so binNumber = 0[binNumber = 6] Is it B/E0 - D - C - A - E1 ? Another example, closer to my current purpose test, practical to make multi pass drawings : | osg::Group | -- | | | | osg::Group B osg::Group C | [binNumber = 20][binNumber = 30] | osg::Geode A [binNumber = 15] Is it A - B - C ? I think exploring a concrete example like that clear things. Thanks - Original Message - From: Tim Moore [EMAIL PROTECTED] To: OpenSceneGraph Users osg-users@lists.openscenegraph.org Sent: Thursday, October 04, 2007 2:00 PM Subject: Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails) Robert didn't answer your second question; I'll have a go because I think I understand it. First of all, there aren't a fixed number of render bins. You can assign a StateSet to any integer, positive or negative. This turns out to be quite useful. When you say set a rendering order on a group node, you mean that you've set the render bin in a state set in that node. There is an inheritance effect, but it may not be what you expect. Render bins can contain other render bins! If the children of your group node have state sets that also set the render bin detail, their render bins are stored inside the group state set's render bin, and they will be rendered in order when that render bin is traversed. This can give you unexpected results, when for example you assign a state sets with TRANSPARENT_BIN or OPAQUE_BIN to nodes up and down the scene graph :) On the other hand you can get very precise control of the ordering of drawables with it. In FlightGear I just used this feature to order cloud layers. The layers are too big for normal transparency sorting to work well, and you want to draw the cloud layer tops from low altitude to high and the bottoms from high to low. I used the altitudes of the layers as render bin numbers to get the right order: // Force the cloud layers into recursive bins of bin 4. osg::StateSet *rootSet = layer_root-getOrCreateStateSet(); rootSet-setRenderBinDetails(4, RenderBin); Child 0 has the bottom layers and child 1 has the tops: layer_root-getChild(0)-getStateSet()-setRenderBinDetails(-(int)layer_asl, RenderBin); layer_root-getChild(1)-getStateSet()-setRenderBinDetails((int)layer_asl, RenderBin); I hope someone will correct me if I've gotten this all wrong! Tim ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Christophe Medard wrote: Sorry for the mailer redisposing of things. Here are the examples I wanted to submit : | | | osg::Group Aosg::Group B [binNumber = 8] dft, so binNumber = 0 | - | || osg::Geode Cosg::Geode Dosg::Geode E [binNumber = 5] [binNumber = 1] | | | | osg::Drawable E0 osg::Drawable E1 dft, so binNumber = 0[binNumber=6] Is it B/E0 - D - C - A - E1 ? No. Assuming that E is a child of A, and by the rendering order of a group you mean other drawables that are under that group, the order is B-A-E0-D-C-E1. If E is not a child of A -- I can't tell from the diagram -- then the order is B/E0-E1-A-D-C. It turns out (I didn't know this) that the sign of a render bin number is significant; negative child bins are drawn before a bin's render leaves, postive bins are drawn after. Another example, closer to my current purpose test, practical to make multi pass drawings : | osg::Group | - | | | | | | | osg::Group B osg::Group C | [binNumber = 20] [binNumber = 30] | osg::Geode A [binNumber = 15] Is it A - B - C ? Yes. Tim -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFHBPP4eDhWHdXrDRURArhVAJoC5ENolBRvuwevA4O6oBtSrRWZFACgpl/1 9K7HUvn2NWv1ahs1NlEhXpc= =nulc -END PGP SIGNATURE- ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
Sorry if the drawing isn't clear (do the images pass the mails submitted in the mailing list ? If so, I could quickly make a quick drawing, more clearer that this verbatim presentation...) yes E is child of A in my diagram, so the answer is B-A-E0-D-C-E1. I understand that in fact you're saying than the binNumber is the draw order number against other children in the parent Group, evaluated in a left-first traversall logic. However binNumber inside drawable list of Geode are evaluated at once (otherwise the answer would have be B-A-E0-E1-D-C). If can submit small pictures I may ask a last case where B as children. I'm sorry I missed something in my second diagram (there is no multipass in the one I submitted). In fact I'm wondering about that situation (encountered in a personnal shadowMap implementation) : | osg::Group Root | - | | | | | | |osg::Group B osg::Group C |[binNumber = 20] [binNumber = 30] | || -- | osg::Geode A [binNumber = 15] A is child of Root, B and C simultaneously (therefore A is rendered three times, with stateset context successivley of Root, B, and C). Is the draw order A-B-C ? Thanks for those explanations, -- Christophe Médard Société OKTAL (http://www.oktal.fr) 2 impasse Boudeville 31100 Toulouse (France) Tél. : (+33) 5 62 11 50 10 Fax : (+33) 5 62 11 50 29 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails)
OK, but why introducing a _renderingHint member variable not used and therefore confusing (_binNum is the one taken into account, once again if I'm correct..) ?? It's not really exclusively an implementation matter : those member variables are both clearly saved in the .osg format - readable format highly appreciable to infer problem origins when encountered with a complex scene -. A newcomer examining his scene graph naturally infer they both have a different implication on rendering order... Anyway thanks for clearing that : binNumber is the important data. -- Christophe Médard Société OKTAL (http://www.oktal.fr) 2 impasse Boudeville 31100 Toulouse (France) Tél. : (+33) 5 62 11 50 10 Fax : (+33) 5 62 11 50 29 - Original Message - From: Robert Osfield [EMAIL PROTECTED] To: OpenSceneGraph Users osg-users@lists.openscenegraph.org Sent: Thursday, October 04, 2007 3:13 PM Subject: Re: [osg-users] RenderingHint vs binNumber(RenderBinDetails) StateSet::setRenderingHint is merly a convenience function for setting the bin number and bin name it has no function beyond this. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org