当前位置: 首页>>代码示例>>C++>>正文


C++ Shaders::loadAll方法代码示例

本文整理汇总了C++中Shaders::loadAll方法的典型用法代码示例。如果您正苦于以下问题:C++ Shaders::loadAll方法的具体用法?C++ Shaders::loadAll怎么用?C++ Shaders::loadAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shaders的用法示例。


在下文中一共展示了Shaders::loadAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: epo

void
SimpleOceanNode::rebuild()
{
    this->removeChildren( 0, this->getNumChildren() );

    osg::ref_ptr<MapNode> mapNode;
    if (_parentMapNode.lock(mapNode))
    {
        const MapOptions&     parentMapOptions     = mapNode->getMap()->getMapOptions();
        const MapNodeOptions& parentMapNodeOptions = mapNode->getMapNodeOptions();

        // set up the map to "match" the parent map:
        MapOptions mo;
        mo.coordSysType() = parentMapOptions.coordSysType();
        mo.profile()      = mapNode->getMap()->getProfile()->toProfileOptions();

        // new data model for the ocean:
        Map* oceanMap = new Map( mo );

        // ditto with the map node options:
        MapNodeOptions mno;
        if ( mno.enableLighting().isSet() )
            mno.enableLighting() = *mno.enableLighting();

        RexTerrainEngineOptions terrainoptions;

        terrainoptions.enableBlending() = true;        // gotsta blend with the main node

        terrainoptions.color() = baseColor().get();

        terrainoptions.tileSize() = 5;

        mno.setTerrainOptions( terrainoptions );

        // make the ocean's map node:
        MapNode* oceanMapNode = new MapNode( oceanMap, mno );

        // set up the shaders.
        osg::StateSet* ss = this->getOrCreateStateSet();

        // if the caller requested a mask layer, install that now.
        if ( maskLayer().isSet() )
        {
            if ( !maskLayer()->maxLevel().isSet() )
            {
                // set the max subdivision level if it's not already specified in the 
                // mask layer options:
                maskLayer()->maxLevel() = maxLOD().get();
            }

            // make sure the mask is shared (so we can access it from our shader)
            // and invisible (so we can't see it)
            maskLayer()->shared() = true;
            maskLayer()->visible() = false;

            ImageLayer* layer = new ImageLayer("ocean-mask", maskLayer().get());
            oceanMap->addLayer( layer );

            ss->setDefine("OE_SIMPLE_OCEAN_USE_MASK");
            OE_INFO << LC << "Using mask layer \"" << layer->getName() << "\"\n";
        }

        // otherwise, install a "proxy layer" that will use the elevation data in the map
        // to determine where the ocean is. This approach is limited in that it cannot
        // detect the difference between ocean and inland areas that are below sea level.
        else
        {
            // install an "elevation proxy" layer that reads elevation tiles from the
            // parent map and turns them into encoded images for our shader to use.
            ImageLayerOptions epo( "ocean-proxy" );
            epo.cachePolicy() = CachePolicy::NO_CACHE;
            epo.shared() = true;
            epo.visible() = false;
            epo.shareTexUniformName() = "oe_ocean_proxyTex";
            epo.shareTexMatUniformName() = "oe_ocean_proxyMat";
            oceanMap->addLayer( new ElevationProxyImageLayer(mapNode->getMap(), epo) );
            OE_INFO << LC << "Using elevation proxy layer\n";
        }

        this->addChild( oceanMapNode );

        // install the shaders on the ocean map node.
        VirtualProgram* vp = VirtualProgram::getOrCreate( ss );
        vp->setName( "osgEarth SimpleOcean" );        
        Shaders shaders;
        shaders.loadAll(vp, 0L);

        // set up the options uniforms.

        _seaLevel = new osg::Uniform(osg::Uniform::FLOAT, "ocean_seaLevel");
        ss->addUniform( _seaLevel.get() );

        _lowFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_lowFeather");
        ss->addUniform( _lowFeather.get() );

        _highFeather = new osg::Uniform(osg::Uniform::FLOAT, "ocean_highFeather");
        ss->addUniform( _highFeather.get() );

        _baseColor = new osg::Uniform(osg::Uniform::FLOAT_VEC4, "ocean_baseColor");
        ss->addUniform( _baseColor.get() );
//.........这里部分代码省略.........
开发者ID:JD31,项目名称:osgearth,代码行数:101,代码来源:SimpleOceanNode.cpp


注:本文中的Shaders::loadAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。