Okay, I'm seeing some decidedly weird results from mixing osgEarth and osgOcean. I've attached a picture link, but here's the text description...
I've cut the code back to creating an osgEarth globe but I'm not putting any map data into it. (If I do, I get the same results anyway.) This means that without osgOcean attached to the graph, I get a gray sphere as expected, the first image in the picture below. If I turn on osgOcean, the sphere turns black but with a thin ocean-colored band that varies in diameter, from the outer edge of the globe to about 10% smaller (2nd image). The variation occurs only when I move the camera, and is random in appearance. It does not move with the sphere as I rotate the view - it is always centered on the middle of the sphere. If I zoom in and tilt the camera so as to look along the surface of the globe, the ocean-colored band gets bigger (while still hopping about in diameter) and shows some of the expected reflective properties of the osgOcean surface (3rd image). Up very close, it becomes bands of blue and blue-green that I can see increase in complexity, adding more bands (3rd image). And now the picture: http://nonsanity.com/x/osg-earth-ocean-probs.jpg And now some code. First, the code that creates my main scene, including osgEarth, and the class constructor that creates the osgOcean. And portion of the code that made no change to the outcome when it was commented out has been removed in this example. (Such as the addition of map data.) Code: // Init the main Root Groups m_pRoot = new osg::Group; m_pSceneRoot = new osg::Group; m_pRoot->addChild( m_pSceneRoot ); m_pUIRoot = new osg::Group; m_pRoot->addChild( m_pUIRoot ); // osgEarth osgEarth::Map* map = new osgEarth::Map( osgEarth::Map::CSTYPE_GEOCENTRIC ); osgEarth::MapEngineProperties props; m_pMapNode = new osgEarth::MapNode( map, props ); m_pSceneRoot->addChild( m_pMapNode ); // osgOcean osg::Matrixd placerm; osgEarthUtil::ObjectPlacer placer( GetMapNode() ); placer.createPlacerMatrix( 30.17400170, -85.75135240, 0, placerm ); //osg::Drawable* water = CreateQuad( osg::Vec3(0,0,0), 100000, 100000 ); //osg::Geode* ocean = new osg::Geode(); //ocean->addDrawable( water ); m_pOcean = new C3DOcean; osg::MatrixTransform* mat = new osg::MatrixTransform(); mat->addChild( m_pOcean->GetRoot() ); // mat->addChild( ocean ); m_pSceneRoot->addChild( mat ); C3DOcean::C3DOcean() { osg::Vec2f windDirection = osg::Vec2f( 1.0f, 1.0f ); float windx = 1.1f; float windy = 1.1f; float windSpeed = 12.f; float depth = 1000.f; float reflectionDamping = 0.35f; float waveScale = 1e-8; bool isChoppy = true; float choppyFactor = -2.5f; float crestFoamHeight = 2.2f; double oceanSurfaceHeight = 0.0f; osg::Vec3f sunDir = - osg::Vec3f(-1056.89f, -771.886f, 1221.18f ); sunDir.normalize(); // Ocean Root m_pOcean = new osg::Group; // prep paths // .. added pathnames here // Sky Cubemap - used for SkyDome and for relfection/refraction mapping m_pCubemap = C3DSkyDome::loadCubeMapTextures( "sky_fair_cloudy" ); // Ocean Surface m_pOceanSurface = new osgOcean::FFTOceanSurface( 32, 256, 17, windDirection, windSpeed, depth, reflectionDamping, waveScale, isChoppy, choppyFactor, 10.f, 256 ); m_pOceanSurface->setEnvironmentMap( m_pCubemap.get() ); m_pOceanSurface->setFoamBottomHeight( 2.2f ); m_pOceanSurface->setFoamTopHeight( 3.0f ); m_pOceanSurface->enableCrestFoam( false ); m_pOceanSurface->setLightColor( osg::Vec4( 105/255.0, 138/255.0, 174/255.0, 0.0 ) ); m_pOceanSurface->enableEndlessOcean( false ); // Ocean Scene m_pOceanScene = new osgOcean::OceanScene( m_pOceanSurface.get() ); m_pOceanScene->setLightID( 0 ); m_pOceanScene->enableReflections( true); m_pOceanScene->enableRefractions( true ); m_pOceanScene->setCylinderSize( 1900.f, 4000.f ); m_pOceanScene->setAboveWaterFog( 0.0012f, osg::Vec4( 172/255.0, 224/255.0, 251/255.0, 0.0 ) ); m_pOceanScene->setUnderwaterFog( 0.002f, osg::Vec4( 84/255.0, 135/255.0, 172/255.0, 0.0 ) ); m_pOceanScene->setUnderwaterDiffuse( osg::Vec4( 84/255.0, 135/255.0, 172/255.0, 0.0 ) ); m_pOceanScene->setUnderwaterAttenuation( osg::Vec3( 0.008f, 0.003f, 0.002f ) ); m_pOceanScene->setSunDirection( sunDir ); m_pOceanScene->enableGodRays( true ); m_pOceanScene->enableSilt( true ); m_pOceanScene->enableUnderwaterDOF( false ); m_pOceanScene->enableDistortion( true ); m_pOceanScene->enableGlare( true ); m_pOceanScene->setGlareAttenuation( 0.8f ); // Create and add fake texture for use with nodes without any texture // since the OceanScene default scene shader assumes that texture unit // 0 is used as a base texture map. // * I've tried the code with this section both on and off - no difference * osg::Image* image = new osg::Image; image->allocateImage( 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE ); *(osg::Vec4ub*)image->data() = osg::Vec4ub( 0xFF, 0xFF, 0xFF, 0xFF ); osg::Texture2D* fakeTex = new osg::Texture2D( image ); fakeTex->setWrap( osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT ); fakeTex->setWrap( osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT ); fakeTex->setFilter( osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST ); fakeTex->setFilter( osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST ); osg::StateSet* stateset = m_pOceanScene->getOrCreateStateSet(); stateset->setTextureAttribute( 0, fakeTex, osg::StateAttribute::ON ); stateset->setTextureMode( 0, GL_TEXTURE_1D, osg::StateAttribute::OFF ); stateset->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::ON ); stateset->setTextureMode( 0, GL_TEXTURE_3D, osg::StateAttribute::OFF ); // attach to ocean root m_pOcean->addChild( m_pOceanScene ); } Much of the osgOcean code was based on the bundled example app. As the comments mention, the section that creates the "fake texture" can also be turned off with no effect on the visual outcome, but I've left that in there for this example. All that said... Anyone have a clue what's going on here?? Because I'm now at a complete loss after the better part of a day of twddling things... ~ Chris Innanen ~ Nonsanity P.s. Perhaps when I asked if anyone had merged osgEarth and osgOcean together, instead of asking "how?" I should have asked "can?"... ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=24498#24498 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org