void IECoreRI::SXRendererImplementation::shader( const std::string &type, const std::string &name, const IECore::CompoundDataMap &parameters )
{	
	
	if( type=="displacement" || type=="ri:displacement" )
	{
		m_stateStack.top().displacementShader = createShader( name.c_str(), 0, parameters );
	}
	else if( type=="surface" || type=="ri:surface" )
	{
		m_stateStack.top().surfaceShader = createShader( name.c_str(), 0, parameters );
	}
	else if( type=="atmosphere"	|| type=="ri:atmosphere" )
	{
		m_stateStack.top().atmosphereShader = createShader( name.c_str(), 0, parameters );
	}
	else if( type=="imager"	|| type=="ri:imager" )
	{
		m_stateStack.top().imagerShader = createShader( name.c_str(), 0, parameters );
	}
	else if( type=="shader" || type=="ri:shader" )
	{
		const StringData *handleData = 0;
		CompoundDataMap::const_iterator it = parameters.find( "__handle" );
		if( it!=parameters.end() )
		{
			handleData = runTimeCast<const StringData>( it->second );
		}
		if( !handleData )
		{
			msg( Msg::Error, "IECoreRI::SXRendererImplementation::shader", "Must specify StringData \"__handle\" parameter for coshaders." );
		}
		else
		{
			SxShader s = createShader( name.c_str(), handleData->readable().c_str(), parameters );
			if( s )
			{
				m_stateStack.top().coshaders.push_back( s );
			}
		}
	}
	else
	{
		msg( Msg::Error, "IECoreRI::SXRendererImplementation::shader", boost::format( "Unsupported shader type \"%s\"" ) % type );
	}
}
void IECoreArnold::RendererImplementation::shader( const std::string &type, const std::string &name, const IECore::CompoundDataMap &parameters )
{
	if(
		type=="shader" || type=="ai:shader" ||
		type=="surface" || type=="ai:surface" ||
		type=="displacement" || type=="ai:displacement"
	)
	{
		AtNode *s = 0;
		if( 0 == name.compare( 0, 10, "reference:" ) )
		{
			s = AiNodeLookUpByName( name.c_str() + 10 );
			if( !s )
			{
				msg( Msg::Warning, "IECoreArnold::RendererImplementation::shader", boost::format( "Couldn't find shader \"%s\"" ) % name );
				return;
			}
		}
		else
		{
			s = AiNode( name.c_str() );
			if( !s )
			{
				msg( Msg::Warning, "IECoreArnold::RendererImplementation::shader", boost::format( "Couldn't load shader \"%s\"" ) % name );
				return;
			}
			for( CompoundDataMap::const_iterator parmIt=parameters.begin(); parmIt!=parameters.end(); parmIt++ )
			{
				if( parmIt->second->isInstanceOf( IECore::StringDataTypeId ) )
				{
					const std::string &potentialLink = static_cast<const StringData *>( parmIt->second.get() )->readable();
					if( 0 == potentialLink.compare( 0, 5, "link:" ) )
					{
						std::string linkHandle = potentialLink.c_str() + 5;
						AttributeState::ShaderMap::const_iterator shaderIt = m_attributeStack.top().shaders.find( linkHandle );
						if( shaderIt != m_attributeStack.top().shaders.end() )
						{
							AiNodeLinkOutput( shaderIt->second, "", s, parmIt->first.value().c_str() );
						}
						else
						{
							msg( Msg::Warning, "IECoreArnold::RendererImplementation::shader", boost::format( "Couldn't find shader handle \"%s\" for linking" ) % linkHandle );
						}
						continue;
					}
				}
				ParameterAlgo::setParameter( s, parmIt->first.value().c_str(), parmIt->second.get() );
			}
			addNode( s );
		}

		if( type=="shader" || type == "ai:shader" )
		{
			CompoundDataMap::const_iterator handleIt = parameters.find( "__handle" );
			if( handleIt != parameters.end() && handleIt->second->isInstanceOf( IECore::StringDataTypeId ) )
			{
				const std::string &handle = static_cast<const StringData *>( handleIt->second.get() )->readable();
				m_attributeStack.top().shaders[handle] = s;
			}
			else
			{
				msg( Msg::Warning, "IECoreArnold::RendererImplementation::shader", "No __handle parameter specified." );
			}
		}
		else if( type=="surface" || type == "ai:surface" )
		{
			m_attributeStack.top().surfaceShader = s;
		}
		else
		{
			m_attributeStack.top().displacementShader = s;
		}
	}
	else
	{
		if( type.find( ':' ) == string::npos )
		{
			msg( Msg::Warning, "IECoreArnold::RendererImplementation::shader", boost::format( "Unsupported shader type \"%s\"" ) % type );
		}
	}
}