Example #1
0
IECore::ObjectVectorPtr TestLight::computeLight( const Gaffer::Context *context ) const
{
	IECore::ShaderPtr result = new IECore::Shader( "testLight", "light" );
	result->parameters()["intensity"] = new IECore::Color3fData( parametersPlug()->getChild<Color3fPlug>( "intensity" )->getValue() );
	result->parameters()["__areaLight"] = new IECore::BoolData( parametersPlug()->getChild<BoolPlug>( "areaLight" )->getValue() );

	IECore::ObjectVectorPtr resultVector = new IECore::ObjectVector();
	resultVector->members().push_back( result );
	return resultVector;
}
Example #2
0
IECore::ObjectVectorPtr AppleseedLight::computeLight( const Gaffer::Context *context ) const
{
	IECore::ShaderPtr result = new IECore::Shader( modelPlug()->getValue(), "as:light" );
	for( InputValuePlugIterator it( parametersPlug() ); !it.done(); ++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();
}