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 

Greetings, and a few bug.


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean]
View previous topic :: View next topic  
Author Message
benang
User


Joined: 31 Jan 2011
Posts: 21

PostPosted: Mon Jan 31, 2011 12:56 pm    Post subject:
Greetings, and a few bug.
Reply with quote

Hi, I actually have been using osgOcean for a year now. Well, I actually use Delta 3D which uses OSG and in turn osgOcean. It's a pretty good library for rendering ocean, would be better if you can add atmospheric scattering using Mie and Rayleigh approximation for real time day-night situation. But beggars can't be chosers, right? Very Happy

Anyway I've found 2 bugs on osgOcean. One I still haven't been able to solve, that is the glare functionality. It seems like the glare would also affect the skybox and not only the ocean. I believe it's a shader issue when you are downsampling the rendered texture with glare.

The other one is the "FFTOceanSurface::getSurfaceHeightAt()" method. It would crash from time to time due to negative tile_x and/or tile_y value whereas they are used to determine an index for vectors in "OceanTile::normalBiLinearInterp()" and "OceanTile::biLinearInterp()" function. I know that because I used the method quite a lot for determining a ship's transformation when there's a wave. Below is the fix for the said problem:


Code:

      ...
      if (_oldFrame < _mipmapData.size())
      {
         const OceanTile& data = _mipmapData[_oldFrame][0];

         float tile_x = oceanX - ix * _tileResolution;
         float tile_y = oceanY - iy * _tileResolution;

         //++ BAWE-20101119: BUG FIX
         // Absolute value of dx & dy
         tile_x = tile_x > 0 ? tile_x : -tile_x;

         tile_y = tile_y > 0 ? tile_y : -tile_y;
         //-- BAWE-20101119: BUG FIX

         if (normal != 0)
         {
            *normal = data.normalBiLinearInterp(tile_x, tile_y);
         }

         return data.biLinearInterp(tile_x, tile_y);
      }



Thank you!

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


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Mon Jan 31, 2011 2:43 pm    Post subject:
Greetings, and a few bug.
Reply with quote

Hi Bawenang,

Quote:
Hi, I actually have been using osgOcean for a year now. Well, I actually use Delta 3D which uses OSG and in turn osgOcean.

Excellent, we appreciate you using it! Progress has been slow in the
past few months but we hope to be able to put a bit more time on it in
the near future.

Quote:
It's a pretty good library for rendering ocean, would be better if you can add atmospheric scattering using Mie and Rayleigh approximation for real time day-night situation. But beggars can't be chosers, right? Very Happy

I think the skydome that osgOcean does is useful just for the demo app,
its focus is really the ocean so adding effects in the sky would be an
over-extension of the library's goal IMHO. Another library should do
this. We use osgEphemeris for our skydome, it doesn't do scattering but
gives a beautiful day and night sky (with accurate stars, moon and
planets placement relative to the
longitude/latitude/year/month/day/hour/minute/second you set). It would
be possible to add scattering effects to that nodekit and in that case I
think it would be appropriate.

Quote:
Anyway I've found 2 bugs on osgOcean. One I still haven't been able to solve, that is the glare functionality. It seems like the glare would also affect the skybox and not only the ocean. I believe it's a shader issue when you are downsampling the rendered texture with glare.

I'll have to let Kim field any questions on the shaders as I didn't work
on them (apart from fixing a few issues that prevented them from
compiling on GeForce 7 GPUs).

Quote:
The other one is the "FFTOceanSurface::getSurfaceHeightAt()" method.

Thanks for investigating the bug. Actually, the code I have for this
function is different from what you have (the condition at the top is
different):

if(ix < _numTiles && iy < _numTiles)
{
const OceanTile& data = _mipmapData[_oldFrame][0];

float tile_x = oceanX - ix * _tileResolution;
float tile_y = oceanY - iy * _tileResolution;

if (normal != 0)
{
*normal = data.normalBiLinearInterp(tile_x, tile_y);
}

return data.biLinearInterp(tile_x, tile_y);
}

It seems to have been that way forever in the SVN repo (that function
was added in revision 146 and it hasn't changed since) so I don't know
why your code is different... We have also used that function
extensively here at CM-Labs, and have never had a crash there, so I
wonder if it could be that check that makes it work for us (it indeed
seems like it could influence the values of tile_x and tile_y which
could then be valid all the time in our version).

Could you try out our version, and also perhaps investigate why your
code is different? Are you using a version of osgOcean that was
integrated into Delta3D? Could the Delta3D people have made changes when
integrating it?

In general, when submitting fixes to an open source library, it's always
best to try out the most up-to-date version first (SVN trunk) and see if
your problem is still reproducible. It may have been fixed already,
which saves you some time coding up and submitting a fix. That being
said, if the modified code doesn't fix your problem, then by all means
you should try to find a fix and submit it. The other thing is that in
OSG's case (and I think the same for osgOcean) it's preferable to submit
whole modified files when submitting a change, that way we can clearly
see what you changed, and would have quickly spotted that different if()
I noted above.

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
benang
User


Joined: 31 Jan 2011
Posts: 21

PostPosted: Tue Feb 01, 2011 3:35 am    Post subject:
Reply with quote

Hi,

Oops sorry, the if condition was my first attempt to check and fix the bug. It turns out that it was not working and the bug was somewhere else. The whole method is this:

Code:

float FFTOceanSurface::getSurfaceHeightAt(float x, float y, osg::Vec3f* normal)
{
    if(_isDirty)
        build();

    // ocean surface coordinates
    float oceanX, oceanY;

    // translate x, y to oceanSurface origin coordinates
    oceanX = -_startPos.x() + x;
    oceanY =  _startPos.y() - y;

    // calculate the corresponding tile on the ocean surface
    unsigned int ix = oceanX/_tileResolution;
    unsigned int iy = oceanY/_tileResolution;

    unsigned int frame = _oldFrame;

    // Test if the tile is valid
    if(ix < _numTiles && iy < _numTiles)
    {
      //++ BAWE-20101109: BUG FIX.
      //NOTE: 20101112 - Not working but what the heck...
      if (_oldFrame < _mipmapData.size())
      {
         const OceanTile& data = _mipmapData[_oldFrame][0];

         float tile_x = oceanX - ix * _tileResolution;
         float tile_y = oceanY - iy * _tileResolution;

         //++ BAWE-20101119: BUG FIX
         // Absolute value of dx & dy
         tile_x = tile_x > 0 ? tile_x : -tile_x;

         tile_y = tile_y > 0 ? tile_y : -tile_y;
         //-- BAWE-20101119: BUG FIX

         if (normal != 0)
         {
            *normal = data.normalBiLinearInterp(tile_x, tile_y);
         }

         return data.biLinearInterp(tile_x, tile_y);
      }
      //-- BAWE-20101109: BUG FIX
    }

    return 0.0f;
}


If you want to try to replicate the bug, you can try attaching a camera to a Node, make the Node transform along with the ocean's surface just like the collision test on osgOcean example, and also make the Node move with around along the xy plane with a certain velocity for a while. I usually crashed after about 30 minutes to 1 hour.

Thank you!

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


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Tue Feb 01, 2011 2:35 pm    Post subject:
Greetings, and a few bug.
Reply with quote

Hello Bawenang,

Quote:
//++ BAWE-20101109: BUG FIX.
//NOTE: 20101112 - Not working but what the heck...
if (_oldFrame< _mipmapData.size())
{

I don't think I'll check in this change, if it doesn't fix anything then
it has more chances of changing functionality or breaking something else
than just leaving it out.

Quote:
//++ BAWE-20101119: BUG FIX
// Absolute value of dx& dy
tile_x = tile_x> 0 ? tile_x : -tile_x;

tile_y = tile_y> 0 ? tile_y : -tile_y;
//-- BAWE-20101119: BUG FIX

I don't see the harm of this, however I do wonder why we never had this
problem, we call this method often... I'll check it out in our own projects.

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
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean] All times are GMT
Page 1 of 1

 
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



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