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; }
IECore::ObjectVectorPtr AppleseedLight::computeLight( const Gaffer::Context *context ) const { IECoreScene::ShaderPtr result = new IECoreScene::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; }
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; }
void ObjectVectorParameterHandler::setParameterValue( IECore::Parameter *parameter, InputIterator first, InputIterator last ) { assert( last == first + 1 ); IECore::ObjectVectorPtr value = new IECore::ObjectVector; for( InputIterator it=first; it!=last; it++ ) { OpHolder *opHolder = static_cast<OpHolder *>( *it ); if( opHolder ) { IECore::ObjectPtr o = opHolder->engine(); value->members().push_back( o ); } } parameter->setValue( value ); }
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; }
IECore::ObjectVectorPtr ArnoldLight::computeLight( const Gaffer::Context *context ) const { IECore::ObjectVectorPtr result = new IECore::ObjectVector; IECoreScene::ShaderPtr lightShader = new IECoreScene::Shader( shaderNamePlug()->getValue(), "ai:light" ); for( InputPlugIterator it( parametersPlug() ); !it.done(); ++it ) { if( const Shader *shader = (*it)->source<Plug>()->ancestor<Shader>() ) { /// \todo We should generalise Shader::NetworkBuilder so we can /// use it directly to do the whole of the light generation, instead /// of dealing with input networks manually one by one here. Alternatively /// we could take the approach that OSLLight takes, and use an internal /// ArnoldShader to do all the shader loading and network generation. /// This would avoid exposing any Shader internals, and would generalise /// nicely to the other Light subclasses too. IECore::ConstCompoundObjectPtr inputAttributes = shader->attributes(); const IECore::ObjectVector *inputNetwork = inputAttributes->member<const IECore::ObjectVector>( "ai:surface" ); if( !inputNetwork || inputNetwork->members().empty() ) { continue; } // Add input network into our result. result->members().insert( result->members().end(), inputNetwork->members().begin(), inputNetwork->members().end() ); // Update endpoint of network with a handle we can refer to it with. result->members().back() = result->members().back()->copy(); IECoreScene::Shader *endpoint = static_cast<IECoreScene::Shader *>( result->members().back().get() ); endpoint->parameters()["__handle"] = new IECore::StringData( (*it)->getName() ); // Add a parameter value linking to the input network. lightShader->parameters()[(*it)->getName()] = new IECore::StringData( "link:" + (*it)->getName().string() ); } else if( ValuePlug *valuePlug = IECore::runTimeCast<ValuePlug>( it->get() ) ) { lightShader->parameters()[valuePlug->getName()] = CompoundDataPlug::extractDataFromPlug( valuePlug ); } } result->members().push_back( lightShader ); return result; }