Example #1
0
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;
}
Example #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;
}
Example #3
0
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();
}
Example #4
0
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;
}