本文整理汇总了C++中ImageLayer::shareTexUniformName方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLayer::shareTexUniformName方法的具体用法?C++ ImageLayer::shareTexUniformName怎么用?C++ ImageLayer::shareTexUniformName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageLayer
的用法示例。
在下文中一共展示了ImageLayer::shareTexUniformName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
RexTerrainEngineNode::addTileLayer(Layer* tileLayer)
{
if ( tileLayer && tileLayer->getEnabled() )
{
// Install the image layer stateset on this layer.
// Later we will refactor this into an ImageLayerRenderer or something similar.
//osg::StateSet* stateSet = tileLayer->getOrCreateStateSet();
//stateSet->merge(*getSurfaceStateSet());
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(tileLayer);
if (imageLayer)
{
// for a shared layer, allocate a shared image unit if necessary.
if ( imageLayer->isShared() )
{
optional<int>& unit = imageLayer->shareImageUnit();
if ( !unit.isSet() )
{
int temp;
if ( getResources()->reserveTextureImageUnit(temp) )
{
imageLayer->shareImageUnit() = temp;
OE_INFO << LC << "Image unit " << temp << " assigned to shared layer " << imageLayer->getName() << std::endl;
}
else
{
OE_WARN << LC << "Insufficient GPU image units to share layer " << imageLayer->getName() << std::endl;
}
}
// Build a sampler binding for the shared layer.
if ( unit.isSet() )
{
// Find the next empty SHARED slot:
unsigned newIndex = SamplerBinding::SHARED;
while (_renderBindings[newIndex].isActive())
++newIndex;
// Put the new binding there:
SamplerBinding& newBinding = _renderBindings[newIndex];
newBinding.usage() = SamplerBinding::SHARED;
newBinding.sourceUID() = imageLayer->getUID();
newBinding.unit() = unit.get();
newBinding.samplerName() = imageLayer->shareTexUniformName().get();
newBinding.matrixName() = imageLayer->shareTexMatUniformName().get();
OE_INFO << LC
<< " .. Sampler=\"" << newBinding.samplerName() << "\", "
<< "Matrix=\"" << newBinding.matrixName() << ", "
<< "unit=" << newBinding.unit() << "\n";
}
}
}
else
{
// non-image tile layer. Keep track of these..
}
refresh();
}
}
示例2: Depth
//.........这里部分代码省略.........
cf_body << I << "}\n";
ifStarted = true;
}
}
}
if ( haveColorFilters )
{
std::string cf_head_str, cf_body_str;
cf_head_str = cf_head.str();
cf_body_str = cf_body.str();
replaceIn( fs_colorfilters, "$COLOR_FILTER_HEAD", cf_head_str );
replaceIn( fs_colorfilters, "$COLOR_FILTER_BODY", cf_body_str );
vp->setFunction(
"oe_mp_apply_filters",
fs_colorfilters,
ShaderComp::LOCATION_FRAGMENT_COLORING,
0.5f );
}
}
}
// binding for the terrain texture
terrainStateSet->getOrCreateUniform(
"oe_layer_tex", osg::Uniform::SAMPLER_2D )->set( _primaryUnit );
// binding for the secondary texture (for LOD blending)
if ( parentTexturesRequired() )
{
terrainStateSet->getOrCreateUniform(
"oe_layer_tex_parent", osg::Uniform::SAMPLER_2D )->set( _secondaryUnit );
// binding for the default secondary texture matrix
osg::Matrixf parent_mat;
parent_mat(0,0) = 0.0f;
terrainStateSet->getOrCreateUniform(
"oe_layer_parent_matrix", osg::Uniform::FLOAT_MAT4 )->set( parent_mat );
}
// uniform for accessing the elevation texture sampler.
if ( elevationTexturesRequired() )
{
terrainStateSet->getOrCreateUniform(
"oe_terrain_tex", osg::Uniform::SAMPLER_2D)->set( _elevationTextureUnit );
}
// uniform that controls per-layer opacity
terrainStateSet->getOrCreateUniform(
"oe_layer_opacity", osg::Uniform::FLOAT )->set( 1.0f );
// uniform that conveys the layer UID to the shaders; necessary
// for per-layer branching (like color filters)
// UID -1 => no image layer (no texture)
terrainStateSet->getOrCreateUniform(
"oe_layer_uid", osg::Uniform::INT )->set( -1 );
// uniform that conveys the render order, since the shaders
// need to know which is the first layer in order to blend properly
terrainStateSet->getOrCreateUniform(
"oe_layer_order", osg::Uniform::INT )->set( 0 );
// default min/max range uniforms. (max < min means ranges are disabled)
terrainStateSet->addUniform( new osg::Uniform("oe_layer_minRange", 0.0f) );
terrainStateSet->addUniform( new osg::Uniform("oe_layer_maxRange", FLT_MAX) );
terrainStateSet->addUniform( new osg::Uniform("oe_layer_attenuationRange", _terrainOptions.attentuationDistance().get()) );
terrainStateSet->getOrCreateUniform(
"oe_min_tile_range_factor",
osg::Uniform::FLOAT)->set( *_terrainOptions.minTileRangeFactor() );
// special object ID that denotes the terrain surface.
terrainStateSet->addUniform( new osg::Uniform(
Registry::objectIndex()->getObjectIDUniformName().c_str(), OSGEARTH_OBJECTID_TERRAIN) );
// assign the uniforms for each shared layer.
if ( _update_mapf )
{
ImageLayerVector imageLayers;
_update_mapf->getLayers(imageLayers);
int numImageLayers = imageLayers.size();
for( int i=0; i<numImageLayers; ++i )
{
ImageLayer* layer = imageLayers[i].get();
if ( layer->getEnabled() && layer->isShared() )
{
terrainStateSet->addUniform( new osg::Uniform(
layer->shareTexUniformName()->c_str(),
layer->shareImageUnit().get() ) );
}
}
}
}
_stateUpdateRequired = false;
}
}
示例3: updateModels
void
RexTerrainEngineNode::addTileLayer(Layer* tileLayer)
{
if ( tileLayer && tileLayer->getEnabled() )
{
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(tileLayer);
if (imageLayer)
{
// for a shared layer, allocate a shared image unit if necessary.
if ( imageLayer->isShared() )
{
if (!imageLayer->shareImageUnit().isSet())
{
int temp;
if ( getResources()->reserveTextureImageUnit(temp, imageLayer->getName().c_str()) )
{
imageLayer->shareImageUnit() = temp;
//OE_INFO << LC << "Image unit " << temp << " assigned to shared layer " << imageLayer->getName() << std::endl;
}
else
{
OE_WARN << LC << "Insufficient GPU image units to share layer " << imageLayer->getName() << std::endl;
}
}
// Build a sampler binding for the shared layer.
if ( imageLayer->shareImageUnit().isSet() )
{
// Find the next empty SHARED slot:
unsigned newIndex = SamplerBinding::SHARED;
while (_renderBindings[newIndex].isActive())
++newIndex;
// Put the new binding there:
SamplerBinding& newBinding = _renderBindings[newIndex];
newBinding.usage() = SamplerBinding::SHARED;
newBinding.sourceUID() = imageLayer->getUID();
newBinding.unit() = imageLayer->shareImageUnit().get();
newBinding.samplerName() = imageLayer->shareTexUniformName().get();
newBinding.matrixName() = imageLayer->shareTexMatUniformName().get();
OE_INFO << LC
<< "Shared Layer \"" << imageLayer->getName() << "\" : sampler=\"" << newBinding.samplerName() << "\", "
<< "matrix=\"" << newBinding.matrixName() << "\", "
<< "unit=" << newBinding.unit() << "\n";
}
}
}
else
{
// non-image tile layer. Keep track of these..
}
if (_terrain)
{
// Update the existing render models, and trigger a data reload.
// Later we can limit the reload to an update of only the new data.
UpdateRenderModels updateModels(_mapFrame);
#if 0
// This uses the loaddata filter approach which will only request
// data for one layer. It mostly works but not 100%; see hires-insets
// as an example. Removing the world layer and re-adding it while
// zoomed in doesn't result in all tiles reloading. Possibly a
// synchronization issue.
ImageLayerVector imageLayers;
_mapFrame.getLayers(imageLayers);
if (imageLayers.size() == 1)
updateModels.setReloadData(true);
else
updateModels.layersToLoad().insert(tileLayer->getUID());
#else
updateModels.setReloadData(true);
#endif
_terrain->accept(updateModels);
}
}
}