コード例 #1
0
ファイル: ArnoldLight.cpp プロジェクト: 7on7on/gaffer
IECore::LightPtr ArnoldLight::computeLight( const Gaffer::Context *context ) const
{
	IECore::LightPtr result = new IECore::Light( getChild<StringPlug>( "__shaderName" )->getValue() );
	for( InputValuePlugIterator it( parametersPlug() ); it!=it.end(); it++ )
	{
		result->parameters()[(*it)->getName()] = CompoundDataPlug::extractDataFromPlug( *it );
	}
	return result;
}
コード例 #2
0
IECore::ObjectVectorPtr RenderManLight::computeLight( const Gaffer::Context *context ) const
{
	IECore::LightPtr result = new IECore::Light( "ri:" + shaderNamePlug()->getValue() );
	for( InputValuePlugIterator it( parametersPlug() ); it!=it.end(); it++ )
	{
		result->parameters()[(*it)->getName()] = CompoundDataPlug::extractDataFromPlug( it->get() );
	}

	IECore::ObjectVectorPtr resultVector = new IECore::ObjectVector();
	resultVector->members().push_back( result );
	return resultVector;
}
コード例 #3
0
ファイル: Light.cpp プロジェクト: cnpinto/gaffer
IECore::ConstCompoundObjectPtr Light::computeAttributes( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	IECore::CompoundObjectPtr result = new IECore::CompoundObject;

	std::string lightAttribute = "light";

	IECore::ObjectVectorPtr lightShaders = computeLight( context );
	if( lightShaders->members().size() > 0 )
	{
		IECore::LightPtr light = IECore::runTimeCast< IECore::Light >(
			lightShaders->members()[ lightShaders->members().size() - 1 ] );
		std::string lightName = light->getName();
		size_t colon = lightName.find( ":" );
		if( colon != std::string::npos )
		{
			lightAttribute = lightName.substr( 0, colon ) + ":light";
		}
	}

	result->members()[lightAttribute] = lightShaders;

	return result;
}
コード例 #4
0
ファイル: Shader.cpp プロジェクト: espennordahl/gaffer
IECore::StateRenderable *Shader::NetworkBuilder::shader( const Shader *shaderNode )
{
	shaderNode = effectiveNode( shaderNode );
	if( !shaderNode )
	{
		return NULL;
	}

	if( !m_downstreamShaders.insert( shaderNode ).second )
	{
		throwCycleError( shaderNode );
	}

	ShaderAndHash &shaderAndHash = m_shaders[shaderNode];
	if( shaderAndHash.shader )
	{
		return shaderAndHash.shader.get();
	}

	const std::string &shaderType = shaderNode->typePlug()->getValue();
	if( boost::ends_with( shaderType, "light" ) )
	{
		std::string prefix = "";
		size_t colon = shaderType.find_first_of( ":" );
		if( colon != std::string::npos )
		{
			prefix = shaderType.substr( 0, colon + 1 );
		}

		IECore::LightPtr lightShader = new IECore::Light( prefix + shaderNode->namePlug()->getValue(), "LIGHT_HANDLE_UNUSED" );
		parameterValueWalk( shaderNode, shaderNode->parametersPlug(), IECore::InternedString(), lightShader->parameters() );
		shaderAndHash.shader = lightShader;
	}
	else
	{
		IECore::ShaderPtr shaderShader = new IECore::Shader( shaderNode->namePlug()->getValue(), shaderType );
		parameterValueWalk( shaderNode, shaderNode->parametersPlug(), IECore::InternedString(), shaderShader->parameters() );
		shaderAndHash.shader = shaderShader;
	}

	shaderAndHash.shader->blindData()->writable()["gaffer:nodeName"] = new IECore::StringData( shaderNode->nodeNamePlug()->getValue() );
	shaderAndHash.shader->blindData()->writable()["gaffer:nodeColor"] = new IECore::Color3fData( shaderNode->nodeColorPlug()->getValue() );

	m_state->members().push_back( shaderAndHash.shader );

	m_downstreamShaders.erase( shaderNode );

	return shaderAndHash.shader.get();
}
コード例 #5
0
ファイル: TestLight.cpp プロジェクト: nicoduce/gaffer
IECore::LightPtr TestLight::computeLight( const Gaffer::Context *context ) const
{
    IECore::LightPtr result = new IECore::Light( "testLight" );
    result->parameters()["intensity"] = new IECore::Color3fData( parametersPlug()->getChild<Color3fPlug>( "intensity" )->getValue() );
    return result;
}