void Shader::parameterHash( const Gaffer::Plug *parameterPlug, NetworkBuilder &network, IECore::MurmurHash &h ) const { const Plug *inputPlug = parameterPlug->source<Plug>(); if( inputPlug != parameterPlug ) { const Shader *n = IECore::runTimeCast<const Shader>( inputPlug->node() ); if( n && ( inputPlug == n->outPlug() || n->outPlug()->isAncestorOf( inputPlug ) ) ) { h.append( network.shaderHash( n ) ); if( inputPlug != n->outPlug() ) { // shader has multiple outputs - we need to make sure the particular // output in question is taken into account by the hash. h.append( inputPlug->relativeName( n->outPlug() ) ); } return; } // fall through to hash plug value } const ValuePlug *vplug = IECore::runTimeCast<const ValuePlug>( parameterPlug ); if( vplug ) { vplug->hash( h ); } else { h.append( parameterPlug->typeId() ); } }
IECore::DataPtr Shader::parameterValue( const Gaffer::Plug *parameterPlug, NetworkBuilder &network ) const { const Plug *inputPlug = parameterPlug->source<Plug>(); if( inputPlug != parameterPlug ) { const Shader *n = IECore::runTimeCast<const Shader>( inputPlug->node() ); if( n && ( inputPlug == n->outPlug() || n->outPlug()->isAncestorOf( inputPlug ) ) ) { const std::string &shaderHandle = network.shaderHandle( n ); if( !shaderHandle.size() ) { return NULL; } std::string result = "link:" + shaderHandle; if( n->outPlug()->isAncestorOf( inputPlug ) ) { result += "." + inputPlug->relativeName( n->outPlug() ); } return new IECore::StringData( result ); } // fall through to use plug value } if( const Gaffer::ValuePlug *valuePlug = IECore::runTimeCast<const Gaffer::ValuePlug>( parameterPlug ) ) { return Gaffer::CompoundDataPlug::extractDataFromPlug( valuePlug ); } return NULL; }
IECore::DataPtr RenderManShader::parameterValue( const Gaffer::Plug *parameterPlug, NetworkBuilder &network ) const { if( parameterPlug->typeId() == Plug::staticTypeId() ) { // coshader parameter const Plug *inputPlug = parameterPlug->source<Plug>(); if( inputPlug && inputPlug != parameterPlug ) { const RenderManShader *inputShader = inputPlug->parent<RenderManShader>(); if( inputShader ) { const std::string &handle = network.shaderHandle( inputShader ); if( handle.size() ) { return new StringData( handle ); } } } } else if( parameterPlug->isInstanceOf( ArrayPlug::staticTypeId() ) ) { // coshader array parameter StringVectorDataPtr value = new StringVectorData(); for( InputPlugIterator cIt( parameterPlug ); cIt != cIt.end(); ++cIt ) { const Plug *inputPlug = (*cIt)->source<Plug>(); const RenderManShader *inputShader = inputPlug && inputPlug != *cIt ? inputPlug->parent<RenderManShader>() : 0; if( inputShader ) { value->writable().push_back( network.shaderHandle( inputShader ) ); } else { value->writable().push_back( "" ); } } return value; } return Shader::parameterValue( parameterPlug, network ); }
IECore::DataPtr ArnoldShader::parameterValue( const Gaffer::Plug *plug, NetworkBuilder &network ) const { const Plug *inputPlug = plug->getInput<Plug>(); if( inputPlug ) { const ArnoldShader *n = IECore::runTimeCast<const ArnoldShader>( inputPlug->node() ); if( n && inputPlug == n->outPlug() ) { const std::string &shaderHandle = network.shaderHandle( n ); if( shaderHandle.size() ) { return new IECore::StringData( "link:" + shaderHandle ); } return 0; } } return Shader::parameterValue( plug, network ); }