示例#1
0
void Shader::Setup::addUniformParameter( const std::string &name, IECore::ConstDataPtr value )
{
    const Parameter *p = m_memberData->shader->uniformParameter( name );
    if( !p )
    {
        return;
    }

    if( p->size > 1 )
    {
        IECore::msg( IECore::Msg::Warning, "Shader::Setup::addUniformParameter", format( "Array parameter \"%s\" is currently unsupported." ) % name );
        return;
    }

    if( p->type == GL_BOOL || p->type == GL_INT || p->type == GL_INT_VEC2 || p->type == GL_INT_VEC3 )
    {
        // integer value

        vector<GLint> integers;
        if( value->isInstanceOf( IECore::BoolDataTypeId ) )
        {
            integers.push_back( static_cast<const IECore::BoolData *>( value.get() )->readable() );
        }
        else
        {
            UniformDataConverter<vector<GLint> > converter( integers );
            IECore::despatchTypedData< UniformDataConverter<vector<GLint> >, IECore::TypeTraits::IsNumericBasedTypedData, DespatchTypedDataIgnoreError>( IECore::constPointerCast<IECore::Data>( value ), converter );
        }
        if( !integers.size() )
        {
            IECore::msg( IECore::Msg::Warning, "Shader::Setup::addUniformParameter", format( "Uniform parameter \"%s\" has unsuitable data type \%s\"" ) % name % value->typeName() );
        }
void IECoreArnold::RendererImplementation::setOption( const std::string &name, IECore::ConstDataPtr value )
{
	if( 0 == name.compare( 0, 3, "ai:" ) )
	{
		AtNode *options = AiUniverseGetOptions();
		const AtParamEntry *parameter = AiNodeEntryLookUpParameter( AiNodeGetNodeEntry( options ), name.c_str() + 3 );
		if( parameter )
		{
			ParameterAlgo::setParameter( options, name.c_str() + 3, value.get() );
			return;
		}
	}
	else if( 0 == name.compare( 0, 5, "user:"******":" )!=string::npos )
	{
		// ignore options prefixed for some other renderer
		return;
	}

	msg( Msg::Warning, "IECoreArnold::RendererImplementation::setOption", format( "Unknown option \"%s\"." ) % name );
}
void IECoreRI::SXRendererImplementation::setOption( const std::string &name, IECore::ConstDataPtr value )
{
	if( name.compare( 0, 3, "ri:" )==0 || name.compare( 0, 3, "sx:" )==0 )
	{
		switch( value->typeId() )
		{
			case IntDataTypeId :
				SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxInt, (void *)&(static_cast<const IntData *>( value.get() )->readable() ) );
				break;
			case FloatDataTypeId :
				SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxFloat, (void *)&(static_cast<const FloatData *>( value.get() )->readable() ) );
				break;
			case StringDataTypeId :
				{
					const char *s = static_cast<const StringData *>( value.get() )->readable().c_str();
					SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxString, &s );
					break;	
				}
			default :
				msg( Msg::Warning, "IECoreRI::SXRendererImplementation::setOption", format( "Unsupport type \"%s\"." ) % value->typeName() );
		}
	}
	else if( name.compare( 0, 5, "user:"******"IECoreRI::SXRendererImplementation::setOption", format( "Unsupport type \"%s\"." ) % value->typeName() );
		}
	}
	else if( name.find_first_of( ":" )!=string::npos )
	{
		// ignore options prefixed for some other renderer
	}
	else
	{
		msg( Msg::Warning, "IECoreRI::SXRendererImplementation::setOption", format( "Unknown option \"%s\"." ) % name );
	}
}
示例#4
0
void OSLRenderer::setOption( const std::string &name, IECore::ConstDataPtr value )
{
    if( boost::starts_with( name, "osl:" ) )
    {
        const void *data = 0;
        TypeDesc typeDesc = typeDescFromData( value.get(), data );
        if( data )
        {
            m_shadingSystem->attribute( name.c_str() + 4, typeDesc, data );
        }
        else
        {
            msg( Msg::Warning, "OSLRenderer::setOption", boost::format( "Option \"%s\" has unsupported type \"%s\"" ) % name % value->typeName() );
        }
    }
    else if( boost::starts_with( name, "user:"******"OSLRenderer::setOption", boost::format( "Unsupported option \"%s\"" ) % name );
    }
    else
    {
        // option is for another renderer and can be ignored.
    }
}
示例#5
0
void ColorTexture::construct( unsigned int width, unsigned int height, IECore::ConstDataPtr r,
	IECore::ConstDataPtr g, IECore::ConstDataPtr b, IECore::ConstDataPtr a )
{
	if( r->typeId() != g->typeId() ||
		r->typeId() != b->typeId() ||
		( a && (r->typeId() != a->typeId()) ) )
	{
		throw Exception( "Channel types do not match." );
	}

	if( r->typeId()==UCharVectorData::staticTypeId() )
	{
		castConstruct<UCharVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==CharVectorData::staticTypeId() )
	{
		castConstruct<CharVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==UIntVectorData::staticTypeId() )
	{
		castConstruct<UIntVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==IntVectorData::staticTypeId() )
	{
		castConstruct<IntVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==HalfVectorData::staticTypeId() )
	{
		castConstruct<HalfVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==FloatVectorData::staticTypeId() )
	{
		castConstruct<FloatVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==DoubleVectorData::staticTypeId() )
	{
		castConstruct<DoubleVectorData>( width, height, r, g, b, a );
	}
	else {
		throw Exception( boost::str( boost::format( "Unsupported channel type \"%s\"." ) % r->typeName() ) );
	}
}
示例#6
0
void Primitive::addVertexAttribute( const std::string &name, IECore::ConstDataPtr data )
{
	m_vertexAttributes[name] = data->copy();
}
示例#7
0
void Primitive::addUniformAttribute( const std::string &name, IECore::ConstDataPtr data )
{
	m_uniformAttributes[name] = data->copy();
}
void IECoreArnold::RendererImplementation::setAttribute( const std::string &name, IECore::ConstDataPtr value )
{
	m_attributeStack.top().attributes->writable()[name] = value->copy();
}