[osg-users] TexGenNode vs Group with TexGen attribute

2008-03-27 Thread Wojciech Lewandowski
Hi,

Whats the difference in coord generation (in practice) between TexGenNode and 
Group with TexGen attribute. Suppose I have the same subgraph attached to 
either such TexGenNode or such Group with TexGen. In both cases TexGens are eye 
linear and use the same texture stage.

I expected them to produce the same tex coords but results different. So I am 
bit puzzled. What did I miss ?

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


Re: [osg-users] TexGenNode vs Group with TexGen attribute

2008-03-27 Thread Robert Osfield
Hi Wojtek,

You've come across the wacky world of position OpenGL state.  Normal
OpenGL state like modes and textures etc are invarient of the current
modelview matrix, not so for positional state these use the current
modelview matrix to position themselves so its become crucial that you
apply a specific modelview matrix before you apply the state otherwise
it's position will vary widely according to what modelview matrices
just so happens to be applied.

Examples of positional state are glLight, glClipPlane and glTexGen
EYE_LINEAR.  glTexGen OBJECT_LINEAR is not positional though so it
doesn't matter when its applied - its just like ordinary OpenGL state.
 So how does the scene graph handle this positional state?  We have to
anchor in space using a special node, osg::LightSource, osg::ClipLane
and osg::TexGenNode all exist for this purpose.

Robert.

On Thu, Mar 27, 2008 at 9:16 AM, Wojciech Lewandowski
[EMAIL PROTECTED] wrote:


 Hi,

 Whats the difference in coord generation (in practice) between TexGenNode
 and Group with TexGen attribute. Suppose I have the same subgraph attached
 to either such TexGenNode or such Group with TexGen. In both cases TexGens
 are eye linear and use the same texture stage.

 I expected them to produce the same tex coords but results different. So I
 am bit puzzled. What did I miss ?

 Cheers,
 Wojtek Lewandowski
 ___
  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] TexGenNode vs Group with TexGen attribute

2008-03-27 Thread Robert Osfield
Hi Wojtek,

I'm afraid I'm too overloaded to go deep into discussion on this
topic.  There has been lots of discussion about it over the years so
I'd recommend checking out the archives.  The upshot there aren't any
easy solutions to positional state.

Robert.

On Thu, Mar 27, 2008 at 11:00 AM, Wojciech Lewandowski
[EMAIL PROTECTED] wrote:
 Hi Robert,

  I think I understand these nuances when it refers to TexGenNode. But what
  bothers me is a question what modelview matrix  is used while applying
  TexGen to OpenGL when I use TexGen as an attribute ? Is this the modelview
  that CullVisitor accumulated when processing the group with texgen state
  attribute ? Or is it a random modelview which is current when render stage
  aplies texgen attribute before rendering renderleafs using this stateset ?

  I wish to use TexGen as attribute because TexGenNode behaviour seems
  globally superfluous. Tex coords are generated for children as well as
  sibling subgraphs of  TexGenNode (I am not sure what about ancestors). I
  would rather want to limit tex coord generation to children subgraphs. But I
  can't sort out how to modify texgen matrix to produce exactly the same
  coords as TexGenNode used to...

  Few more questions: what happens if I set two or more TexGenNodes on the
  same stage somewhere in the graph. Is it allowed ? What will be their scope
  ? And what happens if there is TexGenNode and some other node with TexGen
  attribute on the stateset ?

  We had the occasion to test this last case and observed some TexGen
  coordinate bleeding. We had TexGenNode in the graph root and one node with
  environment mapping texgen attribute positioned somewhere down the graph.
  For simplicity lets name this node a ENV_MAP_NODE.

  I would expect that TexGenNode coords would be used for all the drawables
  except those that inherit TexGen attribute from ENV_MAP_NODE. But we saw
  that ENV_MAP_NODE TexGen attribute was overriding coord generation for nodes
  above in graph hierarchy whenever the ENV_MAP_NODE entered the frustum.
  Should this happen ?

  Wojtek



  - Original Message -
  From: Robert Osfield [EMAIL PROTECTED]
  To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
  Sent: Thursday, March 27, 2008 10:27 AM
  Subject: Re: [osg-users] TexGenNode vs Group with TexGen attribute


   Hi Wojtek,
  
   You've come across the wacky world of position OpenGL state.  Normal
   OpenGL state like modes and textures etc are invarient of the current
   modelview matrix, not so for positional state these use the current
   modelview matrix to position themselves so its become crucial that you
   apply a specific modelview matrix before you apply the state otherwise
   it's position will vary widely according to what modelview matrices
   just so happens to be applied.
  
   Examples of positional state are glLight, glClipPlane and glTexGen
   EYE_LINEAR.  glTexGen OBJECT_LINEAR is not positional though so it
   doesn't matter when its applied - its just like ordinary OpenGL state.
   So how does the scene graph handle this positional state?  We have to
   anchor in space using a special node, osg::LightSource, osg::ClipLane
   and osg::TexGenNode all exist for this purpose.
  
   Robert.
  
   On Thu, Mar 27, 2008 at 9:16 AM, Wojciech Lewandowski
   [EMAIL PROTECTED] wrote:
  
  
   Hi,
  
   Whats the difference in coord generation (in practice) between TexGenNode
   and Group with TexGen attribute. Suppose I have the same subgraph
   attached
   to either such TexGenNode or such Group with TexGen. In both cases
   TexGens
   are eye linear and use the same texture stage.
  
   I expected them to produce the same tex coords but results different. So
   I
   am bit puzzled. What did I miss ?
  
   Cheers,
   Wojtek Lewandowski
   ___
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

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


Re: [osg-users] TexGenNode vs Group with TexGen attribute

2008-03-27 Thread Wojciech Lewandowski
Hi Robert,

I think I understand these nuances when it refers to TexGenNode. But what 
bothers me is a question what modelview matrix  is used while applying 
TexGen to OpenGL when I use TexGen as an attribute ? Is this the modelview 
that CullVisitor accumulated when processing the group with texgen state 
attribute ? Or is it a random modelview which is current when render stage 
aplies texgen attribute before rendering renderleafs using this stateset ?

I wish to use TexGen as attribute because TexGenNode behaviour seems 
globally superfluous. Tex coords are generated for children as well as 
sibling subgraphs of  TexGenNode (I am not sure what about ancestors). I 
would rather want to limit tex coord generation to children subgraphs. But I 
can't sort out how to modify texgen matrix to produce exactly the same 
coords as TexGenNode used to...

Few more questions: what happens if I set two or more TexGenNodes on the 
same stage somewhere in the graph. Is it allowed ? What will be their scope 
? And what happens if there is TexGenNode and some other node with TexGen 
attribute on the stateset ?

We had the occasion to test this last case and observed some TexGen 
coordinate bleeding. We had TexGenNode in the graph root and one node with 
environment mapping texgen attribute positioned somewhere down the graph. 
For simplicity lets name this node a ENV_MAP_NODE.

I would expect that TexGenNode coords would be used for all the drawables 
except those that inherit TexGen attribute from ENV_MAP_NODE. But we saw 
that ENV_MAP_NODE TexGen attribute was overriding coord generation for nodes 
above in graph hierarchy whenever the ENV_MAP_NODE entered the frustum. 
Should this happen ?

Wojtek

- Original Message - 
From: Robert Osfield [EMAIL PROTECTED]
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Sent: Thursday, March 27, 2008 10:27 AM
Subject: Re: [osg-users] TexGenNode vs Group with TexGen attribute


 Hi Wojtek,

 You've come across the wacky world of position OpenGL state.  Normal
 OpenGL state like modes and textures etc are invarient of the current
 modelview matrix, not so for positional state these use the current
 modelview matrix to position themselves so its become crucial that you
 apply a specific modelview matrix before you apply the state otherwise
 it's position will vary widely according to what modelview matrices
 just so happens to be applied.

 Examples of positional state are glLight, glClipPlane and glTexGen
 EYE_LINEAR.  glTexGen OBJECT_LINEAR is not positional though so it
 doesn't matter when its applied - its just like ordinary OpenGL state.
 So how does the scene graph handle this positional state?  We have to
 anchor in space using a special node, osg::LightSource, osg::ClipLane
 and osg::TexGenNode all exist for this purpose.

 Robert.

 On Thu, Mar 27, 2008 at 9:16 AM, Wojciech Lewandowski
 [EMAIL PROTECTED] wrote:


 Hi,

 Whats the difference in coord generation (in practice) between TexGenNode
 and Group with TexGen attribute. Suppose I have the same subgraph 
 attached
 to either such TexGenNode or such Group with TexGen. In both cases 
 TexGens
 are eye linear and use the same texture stage.

 I expected them to produce the same tex coords but results different. So 
 I
 am bit puzzled. What did I miss ?

 Cheers,
 Wojtek Lewandowski
 ___
  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] TexGenNode vs Group with TexGen attribute

2008-03-27 Thread Robert Osfield
On Thu, Mar 27, 2008 at 2:01 PM, Wojciech Lewandowski
[EMAIL PROTECTED] wrote:
 Hi Robert and Mathias,

  Thanks for the anwers. Let me reassume, from my perspective, to make sure I
  understood correctly what the problems are.

  1. There is no use in TexGen as a texture state attribute with EYE_LINEAR,
  because no one knows with what modelview matrix it will be applied.

  2. For EYE_LINEAR one have to use TexGenNode. But its then global for whole
  render stage and may conflict with other TexGenNodes and TexGens as
  attributes if they use the same stage ...

  Is this correct ?

Yep this is correct.

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