OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

OSGOcean reflection is not mirrored

Goto page 1, 2  Next
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean]
View previous topic :: View next topic  
Author Message
Martin Scheffler (Martin Scheffler)
Appreciator


Joined: 29 Mar 2009
Posts: 138

PostPosted: Thu Jul 23, 2009 2:41 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi,

seems like the reflection in osgOcean is not mirrored correctly.
When I have letters reflecting in the water, they are from right to left (mirrored vertically) but they should be from bottom to top (mirrored horizontally)!

Cheers,
Martin
Back to top
View user's profile Send private message
Kim Bale
Guest





PostPosted: Thu Jul 23, 2009 2:55 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Martin,

I've not come across this problem before. Could you post a screenshot? 


Also how is the camera position being set, are you using a manipulator?


Regards,


Kim.

2009/7/23 Martin Scheffler <>
Quote:
Hi,

seems like the reflection in osgOcean is not mirrored correctly.
When I have letters reflecting in the water, they are from right to left (mirrored vertically) but they should be from bottom to top (mirrored horizontally)!

Cheers,
Martin

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Martin Scheffler (Martin Scheffler)
Appreciator


Joined: 29 Mar 2009
Posts: 138

PostPosted: Thu Jul 23, 2009 3:44 pm    Post subject:
Reply with quote

OK, never mind, everything is fine. The ship model I am working with is open on the bottom side, so I could peek under the hull and the inner side of the hull was reflected.

That reminds me, is there a way to set the height of the ocean? By default it seems to be at z = 0, is there a way for me to change that?

Cheers,
Martin
Back to top
View user's profile Send private message
Skylark (Jean-Sébastien Guay)
Professional


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Thu Jul 23, 2009 3:57 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Martin,

Quote:
That reminds me, is there a way to set the height of the ocean?

Not yet, but I'll be needing that soon too, it was on my ToDo list. You
can always implement it and submit it here, if you get to it before I
do... :-)

Theoretically it should just amount to inserting a transform between the
OceanScene and the OceanTechnique, and making a setHeight() and
getHeight() that set/get the transform's matrix's Z coordinate. Perhaps
the OceanTechnique should even subclass MatrixTransform instead of
Geode? Kim, what do you think?

J-S
--
______________________________________________________
Jean-Sebastien Guay
http://www.cm-labs.com/
http://whitestar02.webhop.org/


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Kim Bale
Guest





PostPosted: Thu Jul 23, 2009 6:32 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Martin, J-S,

I haven't tried applying any transformations to the ocean surface yet,
but I foresee some problems there.

The mipmapping detail tests in FFTOceanSurface are pretty hard coded
and don't take into account any transformations from it's parents.
This I realise is a flaw in the design.

Adding in a transform between OceanScene and OceanTechnique would be
ok, aslong as it's just a translation on the z axis. Any other
transformations (scaling x/y trans, rotations) would cause problems
with the mipmap level calculations and the tracking of the sea
relative to the camera position.

The only thing I think I would be wary of is this line in UpdateMipMaps():

osg::Vec3f newbound = getTile(x,y)->getBound().center();

That getBound would have to be updated manually as I don't think a
transform from a parent would change it's size/position and so would
still be using zero for z. Not a big task but something to consider.

Subclassing from MatrixTransform might be a good way to do this type
of thing cleanly. I was in fact thinking of changing the base class
for OceanTechnique to a group style class anyway as it lends itself
nicely to some ideas I've had about improving the efficiency of the
mipmapping and vertex updates and also gives more flexibility if
people wish to add their own OceanTechnique.

Alternatively a quick hack would be add an offset to the _startPos
variable in FFTOceanSurface, or even make it a member variable of the
base class. That way you could position the ocean surface at any point
on the x,y,z and *i think* it would all still work. However, I think
perhaps adding in support for matrix transforms is a more desirable
solution.

I apologise for the vague answer but I don't have time at the moment
to dig around and test out how it would be done best.


Regards,

Kim.



2009/7/23 Jean-Sébastien Guay <>
Quote:

Hi Martin,

Quote:
That reminds me, is there a way to set the height of the ocean?

Not yet, but I'll be needing that soon too, it was on my ToDo list. You can always implement it and submit it here, if you get to it before I do... :-)

Theoretically it should just amount to inserting a transform between the OceanScene and the OceanTechnique, and making a setHeight() and getHeight() that set/get the transform's matrix's Z coordinate. Perhaps the OceanTechnique should even subclass MatrixTransform instead of Geode? Kim, what do you think?

J-S
--
______________________________________________________
Jean-Sebastien Guay    
                              http://www.cm-labs.com/
                       http://whitestar02.webhop.org/



------------------
Post generated by Mail2Forum
Back to top
Skylark (Jean-Sébastien Guay)
Professional


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Thu Jul 23, 2009 7:57 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Kim,

Quote:
Adding in a transform between OceanScene and OceanTechnique would be
ok, aslong as it's just a translation on the z axis. Any other
transformations (scaling x/y trans, rotations) would cause problems
with the mipmap level calculations and the tracking of the sea
relative to the camera position.

Yes, so perhaps as a first step hiding the transform and just giving
access to s/getHeight() would be safer. If OceanTechnique subclasses
from MatrixTransform, then people will think they can position it by
calling oceanTechnique->setMatrix(), which might lead to problems as you
say.


Quote:
Alternatively a quick hack would be add an offset to the _startPos
variable in FFTOceanSurface, or even make it a member variable of the
base class. That way you could position the ocean surface at any point
on the x,y,z and *i think* it would all still work. However, I think
perhaps adding in support for matrix transforms is a more desirable
solution.

The problem with the offset to _startPos is that for it to take effect,
you'll have to regenerate the geometry, am I right? Whereas with a
transform (perhaps limiting it to z offset as discussed above) the
change would be instantaneous and not change anything in the geometry.

Quote:
I apologise for the vague answer but I don't have time at the moment
to dig around and test out how it would be done best.

You call that vague? I thought it was pretty darn detailed! :-)

Thanks,

J-S
--
______________________________________________________
Jean-Sebastien Guay
http://www.cm-labs.com/
http://whitestar02.webhop.org/


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Kim Bale
Guest





PostPosted: Tue Jul 28, 2009 1:10 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hello hello I'm back!

Quote:
Yes, so perhaps as a first step hiding the transform and just giving access to s/getHeight() would be safer. If >OceanTechnique subclasses from MatrixTransform, then people will think they can position it by calling >oceanTechnique->setMatrix(), which might lead to problems as you say.

Yes that sounds perfectly reasonable, although you'll still have to
update the bounds calculation in updateMipmaps. Just one variable
though.

Quote:
The problem with the offset to _startPos is that for it to take effect,
you'll have to regenerate the geometry, am I right? Whereas with a transform
(perhaps limiting it to z offset as discussed above) the change would be
instantaneous and not change anything in the geometry.

Yes that's right, like I say I didn't think it was the best way to
proceed rather one for a quick solution.

Will hopefully be back on dev soon.

Regards,

Kim.

2009/7/23 Jean-Sébastien Guay <>:
Quote:
Hi Kim,

Quote:
Adding in a transform between OceanScene and OceanTechnique would be
ok, aslong as it's just a translation on the z axis. Any other
transformations (scaling x/y trans, rotations) would cause problems
with the mipmap level calculations and the tracking of the sea
relative to the camera position.

Yes, so perhaps as a first step hiding the transform and just giving access
to s/getHeight() would be safer. If OceanTechnique subclasses from
MatrixTransform, then people will think they can position it by calling
oceanTechnique->setMatrix(), which might lead to problems as you say.


Quote:
Alternatively a quick hack would be add an offset to the _startPos
variable in FFTOceanSurface, or even make it a member variable of the
base class. That way you could position the ocean surface at any point
on the x,y,z and *i think* it would all still work. However, I think
perhaps adding in support for matrix transforms is a more desirable
solution.

The problem with the offset to _startPos is that for it to take effect,
you'll have to regenerate the geometry, am I right? Whereas with a transform
(perhaps limiting it to z offset as discussed above) the change would be
instantaneous and not change anything in the geometry.

Quote:
I apologise for the vague answer but I don't have time at the moment
to dig around and test out how it would be done best.

You call that vague? I thought it was pretty darn detailed! :-)

Thanks,

J-S
--
______________________________________________________
Jean-Sebastien Guay    
                              http://www.cm-labs.com/
                       http://whitestar02.webhop.org/




------------------
Post generated by Mail2Forum
Back to top
Matthew Lehner
Guest





PostPosted: Wed Aug 12, 2009 5:10 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

I was attempting to transform the ocean surface along the z-axis as
described Kim using a MatrixTransform in the constructor of OceanScene
where OceanSurface is added to the Scene as a child node. The surface
is indeed transformed properly, but the reflection it completely
wrong. First off it gives the illusion the surface is still at the
original z-axis position, but it also seems to be reflecting the top
of my landscape onto the water which doesn't seem correct to me.
Though I believe the problem with the reflection is because the bottom
of my landscape scene is transparent. I am more interested in fixing
the z-offset reflection problem. I have attached a screen shot of the
reflection I am seeing.

This is the code I am using to transform the ocean surface along the z-axis.

Quote:
osg::MatrixTransform* mt = new osg::MatrixTransform( osg::Matrixd::transform(osg::Vec3d(0.0, 0.0, 1.0)) );
mt->addChild(_oceanSurface.get());
addChild(mt);

Screenshots of the reflection can be seen here: http://www.xavia.org/osgocean/

Regards,

Matt Lehner


------------------
Post generated by Mail2Forum
Back to top
Kim Bale
Guest





PostPosted: Wed Aug 12, 2009 6:34 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Matthew,

Yes that is, unfortunately, expected behaviour.

The clipnode that is used for the reflections is set in OceanScene.cpp

osg::ClipPlane* reflClipPlane = new osg::ClipPlane(0);
reflClipPlane->setClipPlane( 0.0, 0.0, 1.0, _oceanSurface->getSurfaceHeight() );
_reflectionClipNode = new osg::ClipNode;
_reflectionClipNode->addClipPlane( reflClipPlane );

The problem as you can see is the _oceanSurface->getSurfaceHeight().
In FFTOceanSurface this value is computed when the mipmap geometry is
initially computed so that it takes the average height of all the
tiles. Unfortunately I forgot to add a setter for this function to
override the computed value. getSurfaceHeight() is also used for a
variety of other effects like silt and switching on the underwater
effects.

I'm afraid I don't have time to fix this at the moment. But it should
be quite easy to add a setSurfaceHeight( float height ) function to
FFTOceanSurface which overrides the _averageHeight variable within it.
However it will need to be set in the following order:

FFTOceanSurface* ocean = new FFTOceanSruface( ... );
ocean->build() <- height is set to average wave height.
ocean->setSurfaceHeight(1.f) <- override computed value.

Quote:
Though I believe the problem with the reflection is because the bottom
of my landscape scene is transparent.

Yes I believe you're seeing the underside of your terrain in the water
there, a result of the clip plane being set too low.

Sorry I can't be of more help.

Kim.

2009/8/12 Matthew Lehner <>:
Quote:
I was attempting to transform the ocean surface along the z-axis as
described Kim using a MatrixTransform in the constructor of OceanScene
where OceanSurface is added to the Scene as a child node. The surface
is indeed transformed properly, but the reflection it completely
wrong. First off it gives the illusion the surface is still at the
original z-axis position, but it also seems to be reflecting the top
of my landscape onto the water which doesn't seem correct to me.
Though I believe the problem with the reflection is because the bottom
of my landscape scene is transparent. I am more interested in fixing
the z-offset reflection problem. I have attached a screen shot of the
reflection I am seeing.

This is the code I am using to transform the ocean surface along the z-axis.

Quote:
osg::MatrixTransform* mt = new osg::MatrixTransform( osg::Matrixd::transform(osg::Vec3d(0.0, 0.0, 1.0)) );
mt->addChild(_oceanSurface.get());
addChild(mt);

Screenshots of the reflection can be seen here: http://www.xavia.org/osgocean/

Regards,

Matt Lehner




------------------
Post generated by Mail2Forum
Back to top
Matthew Lehner
Guest





PostPosted: Wed Aug 12, 2009 6:50 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Kim,

Thank you for your help. I had played with getSurfaceHeight() before
and did not see any affect on the reflection. What did help though was
modifying _reflectionMatrix inside OceanScene. I removed the const and
just did a makeTranslate() inside the contructor where I transformed
the OceanSurface. That *appears* to have corrected the reflection.
Integrating all these changes into an easily modified variable
shouldn't be too bad, but I am not sure if I have all the proper
matrixes being modified yet. I only am concerned with the ocean
surface, and not so much underwater effects.

Regards,

Matt

On Wed, Aug 12, 2009 at 2:33 PM, Kim Bale<> wrote:
Quote:
Hi Matthew,

Yes that is, unfortunately, expected behaviour.

The clipnode that is used for the reflections is set in OceanScene.cpp

osg::ClipPlane* reflClipPlane = new osg::ClipPlane(0);
reflClipPlane->setClipPlane( 0.0, 0.0, 1.0, _oceanSurface->getSurfaceHeight() );
_reflectionClipNode = new osg::ClipNode;
_reflectionClipNode->addClipPlane( reflClipPlane );

The problem as you can see is the _oceanSurface->getSurfaceHeight().
In FFTOceanSurface this value is computed when the mipmap geometry is
initially computed so that it takes the average height of all the
tiles. Unfortunately I forgot to add a setter for this function to
override the computed value. getSurfaceHeight() is also used for a
variety of other effects like silt and switching on the underwater
effects.

I'm afraid I don't have time to fix this at the moment. But it should
be quite easy to add a setSurfaceHeight( float height ) function to
FFTOceanSurface which overrides the _averageHeight variable within it.
However it will need to be set in the following order:

FFTOceanSurface* ocean = new FFTOceanSruface( ... );
ocean->build() <- height is set to average wave height.
ocean->setSurfaceHeight(1.f) <- override computed value.

Quote:
Though I believe the problem with the reflection is because the bottom
of my landscape scene is transparent.

Yes I believe you're seeing the underside of your terrain in the water
there, a result of the clip plane being set too low.

Sorry I can't be of more help.

Kim.

2009/8/12 Matthew Lehner <>:
Quote:
I was attempting to transform the ocean surface along the z-axis as
described Kim using a MatrixTransform in the constructor of OceanScene
where OceanSurface is added to the Scene as a child node. The surface
is indeed transformed properly, but the reflection it completely
wrong. First off it gives the illusion the surface is still at the
original z-axis position, but it also seems to be reflecting the top
of my landscape onto the water which doesn't seem correct to me.
Though I believe the problem with the reflection is because the bottom
of my landscape scene is transparent. I am more interested in fixing
the z-offset reflection problem. I have attached a screen shot of the
reflection I am seeing.

This is the code I am using to transform the ocean surface along the z-axis.

Quote:
osg::MatrixTransform* mt = new osg::MatrixTransform( osg::Matrixd::transform(osg::Vec3d(0.0, 0.0, 1.0)) );
mt->addChild(_oceanSurface.get());
addChild(mt);

Screenshots of the reflection can be seen here: http://www.xavia.org/osgocean/

Regards,

Matt Lehner






------------------
Post generated by Mail2Forum
Back to top
Nonsanity
User


Joined: 28 Jan 2010
Posts: 32

PostPosted: Mon May 24, 2010 5:34 pm    Post subject:
Re: OSGOcean reflection is not mirrored
Reply with quote

Kim Bale wrote:
Yes I believe you're seeing the underside of your terrain in the water
there, a result of the clip plane being set too low.


I think this is exactly what I'm seeing at the moment. I'm using osgEarth to create the terrain, and if the camera is over the water at a height less than the depth of the water at that point, it all looks fine. If the camera's height above the water is greater than the depth, then I see the underside of the terrain, including the seams.

It's a strange and disconcerting effect when flying over the water. Smile But it's something I need to get rid of.

Clip plane being set too low... I thought at first I knew what that meant I had to do to fix this, but I appear to be wrong. Any other hints?

~ Chris Innanen
~ Nonsanity
Back to top
View user's profile Send private message
Kim Bale
Guest





PostPosted: Mon May 24, 2010 7:13 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Chris,

How old is this post?!

The height of the reflection clip plane is set in OceanScene.cpp
around line 412.

osg::ClipPlane* reflClipPlane = new osg::ClipPlane();
reflClipPlane->setClipPlaneNum(0);
reflClipPlane->setClipPlane( 0.0, 0.0, 1.0, -getOceanSurfaceHeight() );
_reflectionClipNode = new osg::ClipNode;

It should be pretty easy to add a mutator to offset it, if you do send
it in and I'll merge it.

Also have you tried the version in the trunk? I fixed a strange
reflection issue a while back where it seemed that you were seeing the
interior but in fact it was due me forgetting to disable back face
culling on the reflection pass.

Details here: http://code.google.com/p/osgocean/issues/detail?id=19&can=1&q=reflection

K.


On 24 May 2010 18:34, Chris Innanen <> wrote:
Quote:

Kim Bale wrote:
Quote:
Yes I believe you're seeing the underside of your terrain in the water
there, a result of the clip plane being set too low.


I think this is exactly what I'm seeing at the moment. I'm using osgEarth to create the terrain, and if the camera is over the water at a height less than the depth of the water at that point, it all looks fine. If the camera's height above the water is greater than the depth, then I see the underside of the terrain, including the seams.

It's a strange and disconcerting effect when flying over the water. Smile But it's something I need to get rid of.

Clip plane being set too low... I thought at first I knew what that meant I had to do to fix this, but I appear to be wrong. Any other hints?

 ~ Chris Innanen
 ~ Nonsanity

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








------------------
Post generated by Mail2Forum
Back to top
Nonsanity
User


Joined: 28 Jan 2010
Posts: 32

PostPosted: Mon May 24, 2010 8:10 pm    Post subject:
Reply with quote

I'm stuck with the last "stable" release of OSG, v2.8.2, and if I recall correctly, the most recent osgOcean requires something later, yes? Maybe I can mix and match a bit...

But yes, it IS a reflection of the back face of the terrain.

~ Chris Innanen
~ Nonsanity
Back to top
View user's profile Send private message
Kim Bale
Guest





PostPosted: Mon May 24, 2010 8:25 pm    Post subject:
OSGOcean reflection is not mirrored
Reply with quote

Hi Chris,

Not at all I've been using 2.8.2 for ages with osgOcean and it's been
working fine here :)

I think you're getting mixed up with the VBO branch which has problems
getting along with 2.9.7

K.


On 24 May 2010 21:10, Chris Innanen <> wrote:
Quote:
I'm stuck with the last "stable" release of OSG, v2.8.2, and if I recall correctly, the most recent osgOcean requires something later, yes? Maybe I can mix and match a bit...

But yes, it IS a reflection of the back face of the terrain.

 ~ Chris Innanen
 ~ Nonsanity

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









------------------
Post generated by Mail2Forum
Back to top
Nonsanity
User


Joined: 28 Jan 2010
Posts: 32

PostPosted: Mon May 24, 2010 8:56 pm    Post subject:
Re: OSGOcean reflection is not mirrored
Reply with quote

Maybe I was thinking of the latest osgEarth then...

Anyway, I made that change to add the override to the cull face setting, but I still see the reflection of the underside of my landscape once I'm higher than the water is deep.

If we weren't in the process of locking down code for a demo, I'd upgrade to the latest osgOcean. For now, I'll just move the land out of the ocean's branch so it isn't included in the reflections. I'll come back to this problem later.

Thanks for the help, Kim. Smile

~ Chris Innanen
~ Nonsanity


Kim Bale wrote:
Hi Chris,

Not at all I've been using 2.8.2 for ages with osgOcean and it's been
working fine here Smile

I think you're getting mixed up with the VBO branch which has problems
getting along with 2.9.7

K.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean] All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osgOcean and OpenSceneGraph issue sta... Paradox osgOcean [osgOcean] 0 Tue Jun 20, 2017 10:21 am View latest post
No new posts osgOcean and OpenSceneGraph issue sta... Paradox osgOcean [osgOcean] 0 Tue Jun 20, 2017 10:16 am View latest post
No new posts osgOcean and OpenSceneGraph issue sta... Paradox osgOcean [osgOcean] 0 Tue Jun 20, 2017 10:13 am View latest post
No new posts osgOcean and OpenSceneGraph issue sta... Paradox osgOcean [osgOcean] 0 Tue Jun 20, 2017 10:04 am View latest post
No new posts osgOcean and OpenSceneGraph issue sta... Paradox osgOcean [osgOcean] 0 Tue Jun 20, 2017 10:03 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP