Re: [osg-users] Shadow mapping, multiple lights

2013-11-07 Thread Robert Osfield
Hi Mustafa,

The ViewDepedentShadowMap implementation has the beginnings of multiple
light support but it isn't yet complete. The basic infrastructure for
generating multiple shadow map texture is there, but the final bits that
tie together like shaders and management aren't there yet.

Robert.


On 6 November 2013 20:11, Mustafa Kabak mustafa_ka...@gmx.com wrote:

 Hi,

 Does any shadow mapping technique in osgShadow support multiple lights?  I
 have seen some commit logs and list messages hinting at this functionality,
 but no solid information.

 http://osdir.com/ml/osg-users/2011-08/msg00413.html

 http://trac.openscenegraph.org/projects/osg//changeset/12782/OpenSceneGraph/trunk/include/osgShadow/ViewDependentShadowMap

 Simply putting two LightSources in the scene with ViewDependentShadowMap
 didn't help.

 Thanks,

 --
 Mustafa Kabak
 ___
 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] OSG Qt integration and thread safety

2013-11-07 Thread Trajce Nikolov NICK
Hi Jan,

 Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
not threadsafe from arbitrary modifications. If you want to be safe,
the only time when modifications to the scene graph may happen is
before or after the frame() is invoked, not while frame() is running.



On Wed, Nov 6, 2013 at 9:19 PM, Jan Ciger jan.ci...@gmail.com wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hello Deniz,

 On 11/06/2013 07:07 PM, Deniz Koçak wrote:
  This is already a long mail, still I have more to say, many code to
  post, but I am not sure where should I begin. I can provide as
  much as possible. However, before ending my e-mail, I would like to
  ask if this approach is safe or not? I mean, I call frame() method
  within a Qt slot and again update related datas within another Qt
  slot. Qt has a main loop (GUI thread) of course, and is it possible
  to cause a race-condition with OSG, because it has its own
  threading model? Please ask if you need more information and of
  course you will, I would be glad to tell more.

 Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
 not threadsafe from arbitrary modifications. If you want to be safe,
 the only time when modifications to the scene graph may happen is
 before or after the frame() is invoked, not while frame() is running.

 If your GUI is modifying the vertex array from the Qt slot, that is,
 by definition, asynchronous - you have no idea when the user presses
 that button. Which may well be during the rendering when OSG is using
 that data structure. If you are clearing the vertex array while the
 size of the array is still set, it will go boom.

 One way to solve this is to use the slot to only modify a buffer/set a
 flag and then use e.g. an update callback on the affected OSG node to
 pick up the changes and implement them in the scene graph when it is
 safe (during update traversal).

 Regards,

 J.
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.14 (GNU/Linux)
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

 iD8DBQFSeqRWn11XseNj94gRAuBdAKDuE2rxjaXltXEWg4g2Mka1ZBqVIgCfbKju
 vGG9MllrwxlDZjkUd1HHg+8=
 =S3At
 -END PGP SIGNATURE-
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG Qt integration and thread safety

2013-11-07 Thread Trajce Nikolov NICK
Hi Jan,

You can modify the scenegraph in the update traversal as well. Like I did
in the TerraPage (txp) loader. In the Cull traversall I collect info for
what is to be modified and then in the update traversal I update the
scenegraph safely.

Just a note

Nick


On Thu, Nov 7, 2013 at 9:33 AM, Trajce Nikolov NICK 
trajce.nikolov.n...@gmail.com wrote:

 Hi Jan,

  Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
 not threadsafe from arbitrary modifications. If you want to be safe,
 the only time when modifications to the scene graph may happen is
 before or after the frame() is invoked, not while frame() is running.



 On Wed, Nov 6, 2013 at 9:19 PM, Jan Ciger jan.ci...@gmail.com wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hello Deniz,

 On 11/06/2013 07:07 PM, Deniz Koçak wrote:
  This is already a long mail, still I have more to say, many code to
  post, but I am not sure where should I begin. I can provide as
  much as possible. However, before ending my e-mail, I would like to
  ask if this approach is safe or not? I mean, I call frame() method
  within a Qt slot and again update related datas within another Qt
  slot. Qt has a main loop (GUI thread) of course, and is it possible
  to cause a race-condition with OSG, because it has its own
  threading model? Please ask if you need more information and of
  course you will, I would be glad to tell more.

 Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
 not threadsafe from arbitrary modifications. If you want to be safe,
 the only time when modifications to the scene graph may happen is
 before or after the frame() is invoked, not while frame() is running.

 If your GUI is modifying the vertex array from the Qt slot, that is,
 by definition, asynchronous - you have no idea when the user presses
 that button. Which may well be during the rendering when OSG is using
 that data structure. If you are clearing the vertex array while the
 size of the array is still set, it will go boom.

 One way to solve this is to use the slot to only modify a buffer/set a
 flag and then use e.g. an update callback on the affected OSG node to
 pick up the changes and implement them in the scene graph when it is
 safe (during update traversal).

 Regards,

 J.
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.14 (GNU/Linux)
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

 iD8DBQFSeqRWn11XseNj94gRAuBdAKDuE2rxjaXltXEWg4g2Mka1ZBqVIgCfbKju
 vGG9MllrwxlDZjkUd1HHg+8=
 =S3At
 -END PGP SIGNATURE-
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




 --
 trajce nikolov nick




-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG Qt integration and thread safety

2013-11-07 Thread Deniz Koçak
Hi Trajce,

I think Jan's answer [1] in the first mail mentions a similar
solution. Setting a flag (by using userdata of the drawable may be)
and updating the drawable in the osg::Drawable::UpdateCallback (of
course by checking the flag) MAY solve the problem. It seems that,
thrusting the Qt's Signal/Slot mechanism is not a good option as Jan
pointed.

Cheers,
Deniz



[1] One way to solve this is to use the slot to only modify a buffer/set a
flag and then use e.g. an update callback on the affected OSG node to
pick up the changes and implement them in the scene graph when it is
safe (during update traversal).

On Thu, Nov 7, 2013 at 10:35 AM, Trajce Nikolov NICK
trajce.nikolov.n...@gmail.com wrote:
 Hi Jan,

 You can modify the scenegraph in the update traversal as well. Like I did in
 the TerraPage (txp) loader. In the Cull traversall I collect info for what
 is to be modified and then in the update traversal I update the scenegraph
 safely.

 Just a note

 Nick


 On Thu, Nov 7, 2013 at 9:33 AM, Trajce Nikolov NICK
 trajce.nikolov.n...@gmail.com wrote:

 Hi Jan,

  Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
 not threadsafe from arbitrary modifications. If you want to be safe,
 the only time when modifications to the scene graph may happen is
 before or after the frame() is invoked, not while frame() is running.



 On Wed, Nov 6, 2013 at 9:19 PM, Jan Ciger jan.ci...@gmail.com wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hello Deniz,

 On 11/06/2013 07:07 PM, Deniz Koçak wrote:
  This is already a long mail, still I have more to say, many code to
  post, but I am not sure where should I begin. I can provide as
  much as possible. However, before ending my e-mail, I would like to
  ask if this approach is safe or not? I mean, I call frame() method
  within a Qt slot and again update related datas within another Qt
  slot. Qt has a main loop (GUI thread) of course, and is it possible
  to cause a race-condition with OSG, because it has its own
  threading model? Please ask if you need more information and of
  course you will, I would be glad to tell more.

 Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
 not threadsafe from arbitrary modifications. If you want to be safe,
 the only time when modifications to the scene graph may happen is
 before or after the frame() is invoked, not while frame() is running.

 If your GUI is modifying the vertex array from the Qt slot, that is,
 by definition, asynchronous - you have no idea when the user presses
 that button. Which may well be during the rendering when OSG is using
 that data structure. If you are clearing the vertex array while the
 size of the array is still set, it will go boom.

 One way to solve this is to use the slot to only modify a buffer/set a
 flag and then use e.g. an update callback on the affected OSG node to
 pick up the changes and implement them in the scene graph when it is
 safe (during update traversal).

 Regards,

 J.
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.14 (GNU/Linux)
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

 iD8DBQFSeqRWn11XseNj94gRAuBdAKDuE2rxjaXltXEWg4g2Mka1ZBqVIgCfbKju
 vGG9MllrwxlDZjkUd1HHg+8=
 =S3At
 -END PGP SIGNATURE-
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




 --
 trajce nikolov nick




 --
 trajce nikolov nick

 ___
 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] OSG Qt integration and thread safety

2013-11-07 Thread Trajce Nikolov NICK
Hi Deniz,

yes I read Jan has mentioned this. Have a look in the osgdb_txp loader in
TXPNode::traverse() for inspiration if helps a bit

Nick


On Thu, Nov 7, 2013 at 9:40 AM, Deniz Koçak lend...@gmail.com wrote:

 Hi Trajce,

 I think Jan's answer [1] in the first mail mentions a similar
 solution. Setting a flag (by using userdata of the drawable may be)
 and updating the drawable in the osg::Drawable::UpdateCallback (of
 course by checking the flag) MAY solve the problem. It seems that,
 thrusting the Qt's Signal/Slot mechanism is not a good option as Jan
 pointed.

 Cheers,
 Deniz



 [1] One way to solve this is to use the slot to only modify a buffer/set a
 flag and then use e.g. an update callback on the affected OSG node to
 pick up the changes and implement them in the scene graph when it is
 safe (during update traversal).

 On Thu, Nov 7, 2013 at 10:35 AM, Trajce Nikolov NICK
 trajce.nikolov.n...@gmail.com wrote:
  Hi Jan,
 
  You can modify the scenegraph in the update traversal as well. Like I
 did in
  the TerraPage (txp) loader. In the Cull traversall I collect info for
 what
  is to be modified and then in the update traversal I update the
 scenegraph
  safely.
 
  Just a note
 
  Nick
 
 
  On Thu, Nov 7, 2013 at 9:33 AM, Trajce Nikolov NICK
  trajce.nikolov.n...@gmail.com wrote:
 
  Hi Jan,
 
   Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
  not threadsafe from arbitrary modifications. If you want to be safe,
  the only time when modifications to the scene graph may happen is
  before or after the frame() is invoked, not while frame() is running.
 
 
 
  On Wed, Nov 6, 2013 at 9:19 PM, Jan Ciger jan.ci...@gmail.com wrote:
 
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  Hello Deniz,
 
  On 11/06/2013 07:07 PM, Deniz Koçak wrote:
   This is already a long mail, still I have more to say, many code to
   post, but I am not sure where should I begin. I can provide as
   much as possible. However, before ending my e-mail, I would like to
   ask if this approach is safe or not? I mean, I call frame() method
   within a Qt slot and again update related datas within another Qt
   slot. Qt has a main loop (GUI thread) of course, and is it possible
   to cause a race-condition with OSG, because it has its own
   threading model? Please ask if you need more information and of
   course you will, I would be glad to tell more.
 
  Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
  not threadsafe from arbitrary modifications. If you want to be safe,
  the only time when modifications to the scene graph may happen is
  before or after the frame() is invoked, not while frame() is running.
 
  If your GUI is modifying the vertex array from the Qt slot, that is,
  by definition, asynchronous - you have no idea when the user presses
  that button. Which may well be during the rendering when OSG is using
  that data structure. If you are clearing the vertex array while the
  size of the array is still set, it will go boom.
 
  One way to solve this is to use the slot to only modify a buffer/set a
  flag and then use e.g. an update callback on the affected OSG node to
  pick up the changes and implement them in the scene graph when it is
  safe (during update traversal).
 
  Regards,
 
  J.
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.14 (GNU/Linux)
  Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
 
  iD8DBQFSeqRWn11XseNj94gRAuBdAKDuE2rxjaXltXEWg4g2Mka1ZBqVIgCfbKju
  vGG9MllrwxlDZjkUd1HHg+8=
  =S3At
  -END PGP SIGNATURE-
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 
 
  --
  trajce nikolov nick
 
 
 
 
  --
  trajce nikolov nick
 
  ___
  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




-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG Qt integration and thread safety

2013-11-07 Thread Deniz Koçak
Thank you Trajce.

On Thu, Nov 7, 2013 at 10:59 AM, Trajce Nikolov NICK
trajce.nikolov.n...@gmail.com wrote:
 Hi Deniz,

 yes I read Jan has mentioned this. Have a look in the osgdb_txp loader in
 TXPNode::traverse() for inspiration if helps a bit

 Nick


 On Thu, Nov 7, 2013 at 9:40 AM, Deniz Koçak lend...@gmail.com wrote:

 Hi Trajce,

 I think Jan's answer [1] in the first mail mentions a similar
 solution. Setting a flag (by using userdata of the drawable may be)
 and updating the drawable in the osg::Drawable::UpdateCallback (of
 course by checking the flag) MAY solve the problem. It seems that,
 thrusting the Qt's Signal/Slot mechanism is not a good option as Jan
 pointed.

 Cheers,
 Deniz



 [1] One way to solve this is to use the slot to only modify a buffer/set a
 flag and then use e.g. an update callback on the affected OSG node to
 pick up the changes and implement them in the scene graph when it is
 safe (during update traversal).

 On Thu, Nov 7, 2013 at 10:35 AM, Trajce Nikolov NICK
 trajce.nikolov.n...@gmail.com wrote:
  Hi Jan,
 
  You can modify the scenegraph in the update traversal as well. Like I
  did in
  the TerraPage (txp) loader. In the Cull traversall I collect info for
  what
  is to be modified and then in the update traversal I update the
  scenegraph
  safely.
 
  Just a note
 
  Nick
 
 
  On Thu, Nov 7, 2013 at 9:33 AM, Trajce Nikolov NICK
  trajce.nikolov.n...@gmail.com wrote:
 
  Hi Jan,
 
   Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
  not threadsafe from arbitrary modifications. If you want to be safe,
  the only time when modifications to the scene graph may happen is
  before or after the frame() is invoked, not while frame() is running.
 
 
 
  On Wed, Nov 6, 2013 at 9:19 PM, Jan Ciger jan.ci...@gmail.com wrote:
 
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  Hello Deniz,
 
  On 11/06/2013 07:07 PM, Deniz Koçak wrote:
   This is already a long mail, still I have more to say, many code to
   post, but I am not sure where should I begin. I can provide as
   much as possible. However, before ending my e-mail, I would like to
   ask if this approach is safe or not? I mean, I call frame() method
   within a Qt slot and again update related datas within another Qt
   slot. Qt has a main loop (GUI thread) of course, and is it possible
   to cause a race-condition with OSG, because it has its own
   threading model? Please ask if you need more information and of
   course you will, I would be glad to tell more.
 
  Your approach isn't safe. OSG is *not threadsafe*. Or, rather, it is
  not threadsafe from arbitrary modifications. If you want to be safe,
  the only time when modifications to the scene graph may happen is
  before or after the frame() is invoked, not while frame() is running.
 
  If your GUI is modifying the vertex array from the Qt slot, that is,
  by definition, asynchronous - you have no idea when the user presses
  that button. Which may well be during the rendering when OSG is using
  that data structure. If you are clearing the vertex array while the
  size of the array is still set, it will go boom.
 
  One way to solve this is to use the slot to only modify a buffer/set a
  flag and then use e.g. an update callback on the affected OSG node to
  pick up the changes and implement them in the scene graph when it is
  safe (during update traversal).
 
  Regards,
 
  J.
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.14 (GNU/Linux)
  Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
 
  iD8DBQFSeqRWn11XseNj94gRAuBdAKDuE2rxjaXltXEWg4g2Mka1ZBqVIgCfbKju
  vGG9MllrwxlDZjkUd1HHg+8=
  =S3At
  -END PGP SIGNATURE-
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 
 
  --
  trajce nikolov nick
 
 
 
 
  --
  trajce nikolov nick
 
  ___
  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




 --
 trajce nikolov nick

 ___
 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] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread michael kapelko
Hi.

I decided to go with single pipeline that provides big shaders and objects
using own uniforms and textures to change the pipeline behaviour.
I started to design a simple material format so that it resembles the one
of EffectCompositor.

Thanks.


2013/10/31 michael kapelko korn...@gmail.com

 Hi, Wang.

 I've just checked if I can use some uber shader and control its behaviour
 per object by setting the object's uniforms. And it works.
 I wonder if that's ok to do that to make different objects rendered
 differently in the same scene.
 Thanks.


 2013/10/31 Wang Rui wangra...@gmail.com

 Hi Michael,

 Effect compositor in fact adds the child scene graph to a camera binding
 to a FBO, and then uses RTT cameras to perform the post processing work.
 The last step is always to show the final image on an HUD quad so all other
 scene nodes will be occluded. The only way to make the effect compositor
 work with other fixed pipeline nodes is to write to the depth values in the
 shader code of the last step, which cannot be automated.

 The dof.xml does such work so you may try ./osgeffectcompositor
 --normal-scene cessna.osg --effect dof.xml to see how normal and deferred
 shaded objects are merged. At present I haven't had a better idea about
 this problem. :-)

 Wang Rui



 2013/10/30 michael kapelko korn...@gmail.com

 Hi.
 I've recently implemented deferred shading with normal mapping and
 shadow mapping using EffectCompositor, but it has effect on the whole
 scene, not a single object.
 Is it possible to use EffectCompositor to apply effects per object?
 Thanks.

 ___
 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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG Qt integration and thread safety

2013-11-07 Thread Jan Ciger
Hi,

On Thu, Nov 7, 2013 at 9:35 AM, Trajce Nikolov NICK 
trajce.nikolov.n...@gmail.com wrote:

 You can modify the scenegraph in the update traversal as well. Like I did
 in the TerraPage (txp) loader. In the Cull traversall I collect info for
 what is to be modified and then in the update traversal I update the
 scenegraph safely.


Thanks for the correction, you are right, of course  - I was actually
suggesting the same in my earlier mails.

J.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG Qt integration and thread safety

2013-11-07 Thread Jan Ciger
On Thu, Nov 7, 2013 at 9:40 AM, Deniz Koçak lend...@gmail.com wrote:

 It seems that,
 thrusting the Qt's Signal/Slot mechanism is not a good option as Jan
 pointed.


I think the trouble is that you are expecting it to do something that it
isn't meant to do. Perhaps you have confused the synchronous call with
the idea of synchronized call from Java. In Java it does actually mean
mutual exclusion on the object and with that semantics your code would have
worked. In C++ you could implement something similar with an object-level
lock shared between all synchronized slots, but I think the performance
would be better if you use the buffer and the callback instead - the buffer
would be locked for a much shorter time (callback invocation vs. the entire
rendering time), decoupling the rendering and GUI.

J.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Drawing lines using OpenGL ES 2.0

2013-11-07 Thread deniz diktas
Hi,

you are outputting the position as color, that's why you see black (because 
these have negative coordinate values) and the three values. Just set an 
arbitrary fixed color value in the frag-shader to see anything. But if you need 
to see colors, then you need to define your own vertex attribute for passing in 
colors.

But my advice is that you should first get used to writing very basic shaders 
in opengl 3.0 core profile mode. OpenGL ES 2.0 is similar in the sense they do 
not support fixed function pipeline. You need to learn the basics first.

-deniz

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread Sebastian Messerschmidt

Hi Michael,

I solved a similar problem by overriding osg::Program which composes a 
shader from an Ubershader. This is not done via uniforms but defines.
It seems to work somehow and improved the performance over branching 
based on uniforms.




Hi.

I decided to go with single pipeline that provides big shaders and 
objects using own uniforms and textures to change the pipeline behaviour.
I started to design a simple material format so that it resembles the 
one of EffectCompositor.


Thanks.


2013/10/31 michael kapelko korn...@gmail.com mailto:korn...@gmail.com

Hi, Wang.

I've just checked if I can use some uber shader and control its
behaviour per object by setting the object's uniforms. And it works.
I wonder if that's ok to do that to make different objects
rendered differently in the same scene.
Thanks.


2013/10/31 Wang Rui wangra...@gmail.com mailto:wangra...@gmail.com

Hi Michael,

Effect compositor in fact adds the child scene graph to a
camera binding to a FBO, and then uses RTT cameras to perform
the post processing work. The last step is always to show the
final image on an HUD quad so all other scene nodes will be
occluded. The only way to make the effect compositor work with
other fixed pipeline nodes is to write to the depth values in
the shader code of the last step, which cannot be automated.

The dof.xml does such work so you may try
./osgeffectcompositor --normal-scene cessna.osg --effect
dof.xml to see how normal and deferred shaded objects are
merged. At present I haven't had a better idea about this
problem. :-)

Wang Rui



2013/10/30 michael kapelko korn...@gmail.com
mailto:korn...@gmail.com

Hi.
I've recently implemented deferred shading with normal
mapping and shadow mapping using EffectCompositor, but it
has effect on the whole scene, not a single object.
Is it possible to use EffectCompositor to apply effects
per object?
Thanks.

___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto:osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto: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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread michael kapelko
Hi, Sebastian.

So you compose one shader per object?

Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de

  Hi Michael,

 I solved a similar problem by overriding osg::Program which composes a
 shader from an Ubershader. This is not done via uniforms but defines.
 It seems to work somehow and improved the performance over branching based
 on uniforms.


   Hi.

  I decided to go with single pipeline that provides big shaders and
 objects using own uniforms and textures to change the pipeline behaviour.
 I started to design a simple material format so that it resembles the one
 of EffectCompositor.

  Thanks.


 2013/10/31 michael kapelko korn...@gmail.com

  Hi, Wang.

  I've just checked if I can use some uber shader and control its
 behaviour per object by setting the object's uniforms. And it works.
 I wonder if that's ok to do that to make different objects rendered
 differently in the same scene.
 Thanks.


 2013/10/31 Wang Rui wangra...@gmail.com

 Hi Michael,

  Effect compositor in fact adds the child scene graph to a camera
 binding to a FBO, and then uses RTT cameras to perform the post processing
 work. The last step is always to show the final image on an HUD quad so all
 other scene nodes will be occluded. The only way to make the effect
 compositor work with other fixed pipeline nodes is to write to the depth
 values in the shader code of the last step, which cannot be automated.

  The dof.xml does such work so you may try ./osgeffectcompositor
 --normal-scene cessna.osg --effect dof.xml to see how normal and deferred
 shaded objects are merged. At present I haven't had a better idea about
 this problem. :-)

  Wang Rui



 2013/10/30 michael kapelko korn...@gmail.com

   Hi.
  I've recently implemented deferred shading with normal mapping and
 shadow mapping using EffectCompositor, but it has effect on the whole
 scene, not a single object.
 Is it possible to use EffectCompositor to apply effects per object?
 Thanks.

  ___
 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 mailing 
 listosg-users@lists.openscenegraph.orghttp://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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread Sebastian Messerschmidt

Am 07.11.2013 12:55, schrieb michael kapelko:

Hi, Sebastian.

So you compose one shader per object?
No, one program per define-set (e.g. #define NORMAL_MAPPING,#define 
PARALLAX_MAPPING, ...)
The idea is not to compose the shader from functional blocks, but to 
write one shader containing all paths which are activated based upon the 
defines.
It is still complicated to get all the paths correctly in the 
ubershader, but i found it a good transition from uniform based 
de/activation.


So you will end up with N different programs with N being the number of 
define-combinations used.




Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de 
mailto:sebastian.messerschm...@gmx.de


Hi Michael,

I solved a similar problem by overriding osg::Program which
composes a shader from an Ubershader. This is not done via
uniforms but defines.
It seems to work somehow and improved the performance over
branching based on uniforms.



Hi.

I decided to go with single pipeline that provides big shaders
and objects using own uniforms and textures to change the
pipeline behaviour.
I started to design a simple material format so that it resembles
the one of EffectCompositor.

Thanks.


2013/10/31 michael kapelko korn...@gmail.com
mailto:korn...@gmail.com

Hi, Wang.

I've just checked if I can use some uber shader and control
its behaviour per object by setting the object's uniforms.
And it works.
I wonder if that's ok to do that to make different objects
rendered differently in the same scene.
Thanks.


2013/10/31 Wang Rui wangra...@gmail.com
mailto:wangra...@gmail.com

Hi Michael,

Effect compositor in fact adds the child scene graph to a
camera binding to a FBO, and then uses RTT cameras to
perform the post processing work. The last step is always
to show the final image on an HUD quad so all other scene
nodes will be occluded. The only way to make the effect
compositor work with other fixed pipeline nodes is to
write to the depth values in the shader code of the last
step, which cannot be automated.

The dof.xml does such work so you may try
./osgeffectcompositor --normal-scene cessna.osg --effect
dof.xml to see how normal and deferred shaded objects are
merged. At present I haven't had a better idea about this
problem. :-)

Wang Rui



2013/10/30 michael kapelko korn...@gmail.com
mailto:korn...@gmail.com

Hi.
I've recently implemented deferred shading with
normal mapping and shadow mapping using
EffectCompositor, but it has effect on the whole
scene, not a single object.
Is it possible to use EffectCompositor to apply
effects per object?
Thanks.

___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto:osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto:osg-users@lists.openscenegraph.org

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





___
osg-users mailing list
osg-users@lists.openscenegraph.org  
mailto:osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto: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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread michael kapelko
Can you please provide an example of how an object manages its define-set?
In my case, I simply get the object's StateSet and setup uniforms. But I
don't get how to setup defines.
Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de

  Am 07.11.2013 12:55, schrieb michael kapelko:

  Hi, Sebastian.

  So you compose one shader per object?

 No, one program per define-set (e.g. #define NORMAL_MAPPING,#define
 PARALLAX_MAPPING, ...)
 The idea is not to compose the shader from functional blocks, but to write
 one shader containing all paths which are activated based upon the defines.
 It is still complicated to get all the paths correctly in the ubershader,
 but i found it a good transition from uniform based de/activation.

 So you will end up with N different programs with N being the number of
 define-combinations used.



  Thanks.


 2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de

  Hi Michael,

 I solved a similar problem by overriding osg::Program which composes a
 shader from an Ubershader. This is not done via uniforms but defines.
 It seems to work somehow and improved the performance over branching
 based on uniforms.


Hi.

  I decided to go with single pipeline that provides big shaders and
 objects using own uniforms and textures to change the pipeline behaviour.
 I started to design a simple material format so that it resembles the one
 of EffectCompositor.

  Thanks.


 2013/10/31 michael kapelko korn...@gmail.com

  Hi, Wang.

  I've just checked if I can use some uber shader and control its
 behaviour per object by setting the object's uniforms. And it works.
 I wonder if that's ok to do that to make different objects rendered
 differently in the same scene.
 Thanks.


 2013/10/31 Wang Rui wangra...@gmail.com

 Hi Michael,

  Effect compositor in fact adds the child scene graph to a camera
 binding to a FBO, and then uses RTT cameras to perform the post processing
 work. The last step is always to show the final image on an HUD quad so all
 other scene nodes will be occluded. The only way to make the effect
 compositor work with other fixed pipeline nodes is to write to the depth
 values in the shader code of the last step, which cannot be automated.

  The dof.xml does such work so you may try ./osgeffectcompositor
 --normal-scene cessna.osg --effect dof.xml to see how normal and deferred
 shaded objects are merged. At present I haven't had a better idea about
 this problem. :-)

  Wang Rui



 2013/10/30 michael kapelko korn...@gmail.com

   Hi.
  I've recently implemented deferred shading with normal mapping and
 shadow mapping using EffectCompositor, but it has effect on the whole
 scene, not a single object.
 Is it possible to use EffectCompositor to apply effects per object?
 Thanks.

  ___
 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 mailing 
 listosg-users@lists.openscenegraph.orghttp://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 mailing 
 listosg-users@lists.openscenegraph.orghttp://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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread Sebastian Messerschmidt
As this is company code and part of a bigger framework I can only give 
you some hints.


I have a custom shader loader which parses the shader source in order to 
later add the defines and creates a osg::Program derived class

e.g. CustomProgram.

In GLSL you can use preprocessor macros like in C.
So you can say:

#define PATH_1

and later

vec4  color = vec4();
#ifdef PATH_1
color = vec4(1,0,0,0);
#else
color = vec4(0,0,1,0);
#endif

So  the shader loader will create the CustomProgram which holds a list 
of defines which should be applied later.
The CustomProgram itself will do this in the ::apply function, by 
injecting the #define %DEFINE_NAME% in to the shadersource before 
compiling it.


For setting the defines at the statesets you want, you can simply check 
the stateset for a program-attribute, cast it to CustomShader and add a 
define.
You will have to do some management inside the CustomProgram to make it 
aware of changed define-sets etc. But it the end you are simply adding 
some custom attributes to control the compiled shader program at the 
state set, instead of setting uniforms directly.

While this seems complicated it allows for two things:
1. Fast less-branching shader code
2. Different sets of shaders realizing rendering based upon defines. In 
my case I can do deferred and forward shading with the same framework 
without having to know which one is running under the hood, when 
assigning materials/material effects.


cheers
Sebastian


Can you please provide an example of how an object manages its define-set?
In my case, I simply get the object's StateSet and setup uniforms. But 
I don't get how to setup defines.

Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de 
mailto:sebastian.messerschm...@gmx.de


Am 07.11.2013 12:55, schrieb michael kapelko:

Hi, Sebastian.

So you compose one shader per object?

No, one program per define-set (e.g. #define
NORMAL_MAPPING,#define PARALLAX_MAPPING, ...)
The idea is not to compose the shader from functional blocks, but
to write one shader containing all paths which are activated based
upon the defines.
It is still complicated to get all the paths correctly in the
ubershader, but i found it a good transition from uniform based
de/activation.

So you will end up with N different programs with N being the
number of define-combinations used.




Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de
mailto:sebastian.messerschm...@gmx.de

Hi Michael,

I solved a similar problem by overriding osg::Program which
composes a shader from an Ubershader. This is not done via
uniforms but defines.
It seems to work somehow and improved the performance over
branching based on uniforms.



Hi.

I decided to go with single pipeline that provides big
shaders and objects using own uniforms and textures to
change the pipeline behaviour.
I started to design a simple material format so that it
resembles the one of EffectCompositor.

Thanks.


2013/10/31 michael kapelko korn...@gmail.com
mailto:korn...@gmail.com

Hi, Wang.

I've just checked if I can use some uber shader and
control its behaviour per object by setting the object's
uniforms. And it works.
I wonder if that's ok to do that to make different
objects rendered differently in the same scene.
Thanks.


2013/10/31 Wang Rui wangra...@gmail.com
mailto:wangra...@gmail.com

Hi Michael,

Effect compositor in fact adds the child scene graph
to a camera binding to a FBO, and then uses RTT
cameras to perform the post processing work. The
last step is always to show the final image on an
HUD quad so all other scene nodes will be occluded.
The only way to make the effect compositor work with
other fixed pipeline nodes is to write to the depth
values in the shader code of the last step, which
cannot be automated.

The dof.xml does such work so you may try
./osgeffectcompositor --normal-scene cessna.osg
--effect dof.xml to see how normal and deferred
shaded objects are merged. At present I haven't had
a better idea about this problem. :-)

Wang Rui



2013/10/30 michael kapelko korn...@gmail.com
mailto:korn...@gmail.com

Hi.
I've recently implemented deferred shading with
normal mapping and shadow mapping using
EffectCompositor, but it has effect on the whole
scene, not a single object.
 

Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread michael kapelko
I was thinking of creating some sort of material.xml and assign it to each
object (or a group of objects).
As far as I understand, the define approach creates one shader per object
eventually. And that turns out to be faster than one shader per pipeline
with different StateSets and uniforms per object.
Am I correct?
Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de

  As this is company code and part of a bigger framework I can only give
 you some hints.

 I have a custom shader loader which parses the shader source in order to
 later add the defines and creates a osg::Program derived class
 e.g. CustomProgram.

 In GLSL you can use preprocessor macros like in C.
 So you can say:

 #define PATH_1

 and later

 vec4  color = vec4();
 #ifdef PATH_1
 color = vec4(1,0,0,0);
 #else
 color = vec4(0,0,1,0);
 #endif

 So  the shader loader will create the CustomProgram which holds a list of
 defines which should be applied later.
 The CustomProgram itself will do this in the ::apply function, by
 injecting the #define %DEFINE_NAME% in to the shadersource before compiling
 it.

 For setting the defines at the statesets you want, you can simply check
 the stateset for a program-attribute, cast it to CustomShader and add a
 define.
 You will have to do some management inside the CustomProgram to make it
 aware of changed define-sets etc. But it the end you are simply adding some
 custom attributes to control the compiled shader program at the state set,
 instead of setting uniforms directly.
 While this seems complicated it allows for two things:
 1. Fast less-branching shader code
 2. Different sets of shaders realizing rendering based upon defines. In my
 case I can do deferred and forward shading with the same framework without
 having to know which one is running under the hood, when assigning
 materials/material effects.

 cheers
 Sebastian

   Can you please provide an example of how an object manages its
 define-set?
 In my case, I simply get the object's StateSet and setup uniforms. But I
 don't get how to setup defines.
 Thanks.


 2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de

  Am 07.11.2013 12:55, schrieb michael kapelko:

  Hi, Sebastian.

  So you compose one shader per object?

  No, one program per define-set (e.g. #define NORMAL_MAPPING,#define
 PARALLAX_MAPPING, ...)
 The idea is not to compose the shader from functional blocks, but to
 write one shader containing all paths which are activated based upon the
 defines.
 It is still complicated to get all the paths correctly in the ubershader,
 but i found it a good transition from uniform based de/activation.

 So you will end up with N different programs with N being the number of
 define-combinations used.



  Thanks.


 2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de

  Hi Michael,

 I solved a similar problem by overriding osg::Program which composes a
 shader from an Ubershader. This is not done via uniforms but defines.
 It seems to work somehow and improved the performance over branching
 based on uniforms.


Hi.

  I decided to go with single pipeline that provides big shaders and
 objects using own uniforms and textures to change the pipeline behaviour.
 I started to design a simple material format so that it resembles the
 one of EffectCompositor.

  Thanks.


 2013/10/31 michael kapelko korn...@gmail.com

  Hi, Wang.

  I've just checked if I can use some uber shader and control its
 behaviour per object by setting the object's uniforms. And it works.
 I wonder if that's ok to do that to make different objects rendered
 differently in the same scene.
 Thanks.


 2013/10/31 Wang Rui wangra...@gmail.com

 Hi Michael,

  Effect compositor in fact adds the child scene graph to a camera
 binding to a FBO, and then uses RTT cameras to perform the post processing
 work. The last step is always to show the final image on an HUD quad so 
 all
 other scene nodes will be occluded. The only way to make the effect
 compositor work with other fixed pipeline nodes is to write to the depth
 values in the shader code of the last step, which cannot be automated.

  The dof.xml does such work so you may try ./osgeffectcompositor
 --normal-scene cessna.osg --effect dof.xml to see how normal and deferred
 shaded objects are merged. At present I haven't had a better idea about
 this problem. :-)

  Wang Rui



 2013/10/30 michael kapelko korn...@gmail.com

   Hi.
  I've recently implemented deferred shading with normal mapping and
 shadow mapping using EffectCompositor, but it has effect on the whole
 scene, not a single object.
 Is it possible to use EffectCompositor to apply effects per object?
 Thanks.

  ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



 ___
 osg-users mailing list
 

Re: [osg-users] Is it possible to use EffectCompositor to describe effects per object?

2013-11-07 Thread Sebastian Messerschmidt

Am 07.11.2013 14:04, schrieb michael kapelko:
I was thinking of creating some sort of material.xml and assign it to 
each object (or a group of objects).

You could totally do this. So material.xml could contain the defines.
As far as I understand, the define approach creates one shader per 
object eventually. And that turns out to be faster than one shader per 
pipeline with different StateSets and uniforms per object.

Am I correct?
Partially. It eventually creates one shader program per node. There 
might be different statesets after all. As the shader-program is part of 
the StateSet.
The thing saved here are the uniforms (in my case there where around 50 
non-material/camera related uniforms just for controlling which 
rendering-paths are taken)




Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de 
mailto:sebastian.messerschm...@gmx.de


As this is company code and part of a bigger framework I can only
give you some hints.

I have a custom shader loader which parses the shader source in
order to later add the defines and creates a osg::Program derived
class
e.g. CustomProgram.

In GLSL you can use preprocessor macros like in C.
So you can say:

#define PATH_1

and later

vec4  color = vec4();
#ifdef PATH_1
color = vec4(1,0,0,0);
#else
color = vec4(0,0,1,0);
#endif

So  the shader loader will create the CustomProgram which holds a
list of defines which should be applied later.
The CustomProgram itself will do this in the ::apply function, by
injecting the #define %DEFINE_NAME% in to the shadersource before
compiling it.

For setting the defines at the statesets you want, you can simply
check the stateset for a program-attribute, cast it to
CustomShader and add a define.
You will have to do some management inside the CustomProgram to
make it aware of changed define-sets etc. But it the end you are
simply adding some custom attributes to control the compiled
shader program at the state set, instead of setting uniforms directly.
While this seems complicated it allows for two things:
1. Fast less-branching shader code
2. Different sets of shaders realizing rendering based upon
defines. In my case I can do deferred and forward shading with the
same framework without having to know which one is running under
the hood, when assigning materials/material effects.

cheers
Sebastian


Can you please provide an example of how an object manages its
define-set?
In my case, I simply get the object's StateSet and setup
uniforms. But I don't get how to setup defines.
Thanks.


2013/11/7 Sebastian Messerschmidt sebastian.messerschm...@gmx.de
mailto:sebastian.messerschm...@gmx.de

Am 07.11.2013 12:55, schrieb michael kapelko:

Hi, Sebastian.

So you compose one shader per object?

No, one program per define-set (e.g. #define
NORMAL_MAPPING,#define PARALLAX_MAPPING, ...)
The idea is not to compose the shader from functional blocks,
but to write one shader containing all paths which are
activated based upon the defines.
It is still complicated to get all the paths correctly in the
ubershader, but i found it a good transition from uniform
based de/activation.

So you will end up with N different programs with N being the
number of define-combinations used.




Thanks.


2013/11/7 Sebastian Messerschmidt
sebastian.messerschm...@gmx.de
mailto:sebastian.messerschm...@gmx.de

Hi Michael,

I solved a similar problem by overriding osg::Program
which composes a shader from an Ubershader. This is not
done via uniforms but defines.
It seems to work somehow and improved the performance
over branching based on uniforms.



Hi.

I decided to go with single pipeline that provides big
shaders and objects using own uniforms and textures to
change the pipeline behaviour.
I started to design a simple material format so that it
resembles the one of EffectCompositor.

Thanks.


2013/10/31 michael kapelko korn...@gmail.com
mailto:korn...@gmail.com

Hi, Wang.

I've just checked if I can use some uber shader and
control its behaviour per object by setting the
object's uniforms. And it works.
I wonder if that's ok to do that to make different
objects rendered differently in the same scene.
Thanks.


2013/10/31 Wang Rui wangra...@gmail.com
mailto:wangra...@gmail.com

Hi Michael,

Effect compositor in fact adds the child scene
graph 

Re: [osg-users] Drawing lines using OpenGL ES 2.0

2013-11-07 Thread John Moore
Actually I solved it... one of the problems was that the number I was using for 
the attribute was too big (or reserved).



I am forced to use OpenGL ES 2.0 because I develop on iOS platform! 

Thank you anyway for your advice.

Cheers,

John

This is the working code

Code:


#define BARYCENTRIC_ATTR_UNIT 11

void OSGGraphicsUtils::setBarycentricCoordinates(osg::Node * object, 
osg::Program *shaderProgram)
{
GeodeFinder myGeodeFinder;
std::vector osg::Geode * listOfGeodes;

object-accept(myGeodeFinder);

listOfGeodes = myGeodeFinder.getNodeList();


std::cout  there are   listOfGeodes.size()   geodes  std::endl;

for (int j = 0; j  listOfGeodes.size() ; j++)
{
//play with the Geode here
std::cout  Geode number   j  std::endl;

//get the current geode
osg::Geode* currentGeode = listOfGeodes.at(j);

if (currentGeode != NULL)
{

std::cout  number of drawables in geode is   
currentGeode-getNumDrawables()  std::endl;

for (int i = 0; i  currentGeode-getNumDrawables(); i++)
{
std::cout  current geode class is  
currentGeode-getDrawable(i)-className()  std::endl;

std::cout  inside cycle   i  std::endl;
osg::Geometry *cubeGeometry = 
currentGeode-getDrawable(i)-asGeometry();

if (!cubeGeometry) continue;

int numAttribs = 
cubeGeometry-getVertexArray()-getNumElements();
std::cout number of vertices is numAttribsstd::endl;

osg::ref_ptr osg::Vec3Array cubeVertexVector;
if (! strcmp (cubeGeometry-getVertexArray()-className(), 
Vec3Array))
{
cubeVertexVector = (osg::Vec3Array *) 
cubeGeometry-getVertexArray();
} else {
//handle the error however you want -- here all I do is 
print a warning and bail out.
std::cerr  Unexpected VertexArray className.\n  
std::endl;
return;
}

osg::ref_ptrosg::Vec3Array array = new osg::Vec3Array;

//add this to declaration section:
std::map int, int vertexMap;

osg::ref_ptr osg::PrimitiveSet nextPrimitiveSet;

// ... //

int k = 0;
for (i = 0; i  cubeGeometry-getNumPrimitiveSets(); i++) {
nextPrimitiveSet = cubeGeometry-getPrimitiveSet(i);

//cout  PrimitiveSet #  i   has Mode:   
nextPrimitiveSet-getMode()  endl;
//cout  \tVertex Indices:   endl;

for (j = 0; j  nextPrimitiveSet-getNumIndices(); j++)
{

if(vertexMap.find(nextPrimitiveSet-index(j)) == 
vertexMap.end())
{
if (k==3) k = 0;

//cout  \t  nextPrimitiveSet-index(j)  
endl;

vertexMap[nextPrimitiveSet-index(j)] = k;

k++;
}
else
{
k = vertexMap[nextPrimitiveSet-index(j)] + 1;
}
}
}

for (int i = 0; i  numAttribs; i++) {

int j = vertexMap[i];

if (j==0)
{
array-push_back(osg::Vec3f(1.0f,0.0f,0.0f));
}
else if (j==1)
{
array-push_back(osg::Vec3f(0.0f,1.0f,0.0f));

}
else if (j==2)
{
array-push_back(osg::Vec3f(0.0f,0.0f,1.0f));
}

//std::cout  Vertex #  i  : ( 
cubeVertexVector-getName()): (  nextVertex[0]  ,   nextVertex[1] 
 ,   nextVertex[2]  )\n;
}

std::cout  Array size is  array-getNumElements()  
std::endl;

if( !cubeGeometry-getVertexAttribArray( BARYCENTRIC_ATTR_UNIT 
) )
{
//cubeGeometry-setVertexAttribData(31, 
osg::Geometry::ArrayData(array,osg::Geometry::BIND_PER_VERTEX, GL_FALSE ) );
std::cout  setting barycentric attr unit array of size  
 array-getNumElements()  std::endl;
cubeGeometry-setVertexAttribArray(BARYCENTRIC_ATTR_UNIT, 
array.get());

Re: [osg-users] Drawing lines using OpenGL ES 2.0

2013-11-07 Thread John Moore
I want to add that this is the fragment shader I used for drawing the wireframe 
model


Code:

precision highp float;
varying vec3 vBC;

#extension GL_OES_standard_derivatives : enable
float edgeFactor(){
vec3 d = fwidth(vBC);
vec3 a3 = smoothstep(vec3(0.0), d*1.0, vBC);
return min(min(a3.x, a3.y), a3.z);
}

void main (void)
{
gl_FragColor = vec4(0.0, 0.0, 0.0, (1.0-edgeFactor())*1.0);
}




Special thanks to this blog for the fragment shader and the idea of using 
barycentric coordinates!
http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Drawing lines using OpenGL ES 2.0

2013-11-07 Thread deniz diktas
Hi,

for learning basic shader programming you do not have to  constrain yourself to 
opengl es 2.0. It is sufficient to do the same basic stuff with OGL 3.0 in 
order at least to understand the difference between assigning a coordinate 
value and a color value as the final fragment value. I wanted to help you with 
that. This was my point. For your app you have to work wherever you need to 
work in, of course, there you are right.

But I am glad you have been able to solve your problem on your own.

best,
-deniz

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] [linux] OSG + X11 and question about osgViewer

2013-11-07 Thread First Last
              
                                « Hi people
 of OSG mailing list I'm Nicoo, and I come in peace! »
 
 well,
 I try to write a minimal application  using X11 and OSG, I
 would like to know first if the library osgViewer is
 something written only to help newcomer.
 I borrowed a book where all examples I saw use osgViewer.
 
 I'm interested to have a full control of my camera
 (position, gaze...) like I do in Opengl.
 
 Same for inputs, I'm using X11  key/mouse event. So I'm
 looking for a tutorial who  starts from scratch, using only
 OSG
 and X11.
 
 I didn't found any tutorial so far.  Moreover, I'm bit
 confused,  when I go there : 
 
 http://trac.openscenegraph.org/projects/osg//wiki/Support/Tutorials
 
 and  see many tutorials with some note like  : Code needs
 conversion to osgViewer I don't  know if it's not wothless
 to take time to study these tutorials...
 
 So I try to write my own application from scratch using X11
 and osg. I uploaded a  tarball :
 
 http://ge.tt/4g9ZzLx/v/0?c
 
 so there is the commands to do :
 $ tar -xvf OSGX11.tar
 $ cd FlammingCessna
 $ cmake .
 $ make
 $ ./FlammingCessna
 
 then you'll see : scrot.png
 (in the tarball too)
 
 as you can see, there is some  black parts, I don't know
 why... (p.s. I don't think they are some burnt triangles...
 cessnafire... like my invisible roomate says )
 
 
 -nicoo
 
 p.s. : there is a reason why http://trac.openscenegraph.org is so slow ?
 
 
 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] blending on multiple targets

2013-11-07 Thread Bram Vaessen
Hi,

I ran into something weird, or something that I don't know how it works exactly.

What I want to do when rendering to multiple targets is that I selectively 
write to certain color buffers in my shader, but leave others alone. 
for example 


Code:
gl_FragData[3] = vec4(0,1,0,1);



without setting the fragment data for the first 3 buffers...

This doesn't seem to go well. for example, if I don't explicity set a value in 
the color buffer 4, it seems to copy the color value from the first color 
buffer for some reason instead of leaving it alone.

So I though: ok I HAVE to explicitly set all a value on all used color buffers, 
so then if I don't want to touch one of the buffers, I just use blending and I 
write a value with an alpha of 0, so it doesn't effect the buffer. This doesn't 
work as expected.

It seems that the blending only looks at the color buffer 0 ? if I write a some 
color-value with an alpha of 0 to the color buffer 0, it doesn't seem to matter 
what I write to the other buffers, it doesn't write anything.

So not sure if you can follow what I'm explaining, but bottom line is: I would 
like to selectively write to certain color buffers in my shaders, and leave the 
other alone. Any ideas on how to do that properly? Or am I trying something 
impossible and do I need another solution?


Thank you!

Cheers,
Bram

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] blending on multiple targets

2013-11-07 Thread Sebastian Messerschmidt

Hi Bram,

There is nothing weird about what you are seeing given what you're doing.
Blending with MRT ist always applied to all bound render targets of the 
framebuffer object.
If you want to blend only a single buffer, then do a separate pass, 
where you blend it.
In case you want to apply different blend functions to different FBO 
attachments you cat take a look at:

http://www.opengl.org/registry/specs/EXT/draw_buffers2.txt
This extension would actually allow to blend only a single attachment.
I've asked for support on the mailing list how to use it/integrate into  
OSG. Unfortunately without any response.


But it is undefined behaviour not writing all attached buffers, as you 
do in your description.

So If there is something like

gl_FragData[3] = vec4(0,1,0,1);

without any

gl_FragData[0] .. gl_FragData[2]

then you shader is invalid (yet syntactically correct)


cheers
Sebastian

Hi,

I ran into something weird, or something that I don't know how it works exactly.

What I want to do when rendering to multiple targets is that I selectively 
write to certain color buffers in my shader, but leave others alone.
for example


Code:
gl_FragData[3] = vec4(0,1,0,1);



without setting the fragment data for the first 3 buffers...

This doesn't seem to go well. for example, if I don't explicity set a value in 
the color buffer 4, it seems to copy the color value from the first color 
buffer for some reason instead of leaving it alone.

So I though: ok I HAVE to explicitly set all a value on all used color buffers, 
so then if I don't want to touch one of the buffers, I just use blending and I 
write a value with an alpha of 0, so it doesn't effect the buffer. This doesn't 
work as expected.

It seems that the blending only looks at the color buffer 0 ? if I write a some 
color-value with an alpha of 0 to the color buffer 0, it doesn't seem to matter 
what I write to the other buffers, it doesn't write anything.

So not sure if you can follow what I'm explaining, but bottom line is: I would 
like to selectively write to certain color buffers in my shaders, and leave the 
other alone. Any ideas on how to do that properly? Or am I trying something 
impossible and do I need another solution?


Thank you!

Cheers,
Bram

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





___
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