Checking the availability of needed input geometry channels

A material method allows to query about the mesh channels it uses: RED::IMaterial::GetUsedChannels.

This function returns a list of RED::MESH_CHANNEL needed by the material shaders. The list data are grouped by RED::LayerSet.

typedef RED::Vector< RED::MESH_CHANNEL > ChannelVector;
RED::Map< RED::LayerSet, ChannelVector > channels;

// Retrieve the mesh channel list from the material:
RC_TEST( imat->GetUsedChannels( channels ) );

// Get the channels for the 'all layer' layerset:
ChannelVector* chan = channels.find( RED::LayerSet::ALL_LAYERS );

bool usetex0 = false;
if( chan != NULL )
  // Loop through the needed mesh channels and search for the RED::MCL_TEX0 channel:
  for( int i = 0; i < chan->size(); ++i )
    usetex0 = usetex0 || ( (*chan)[i] == RED::MCL_TEX0 );

if( usetex0 )
  // Be sure this channel is filled in your geometry...

In this sample, the channel list was retrieved from the material. Then we looped through it to find if the material needs the RED::MCL_TEX0 channel.