示例#1
0
void RenderManShader::loadShader( const std::string &shaderName, bool keepExistingValues )
{
	IECore::ConstShaderPtr shader = runTimeCast<const IECore::Shader>( shaderLoader()->read( shaderName + ".sdl" ) );
	loadShaderParameters( shader.get(), parametersPlug(), keepExistingValues );
	namePlug()->setValue( shaderName );

	string type = "ri:" + shader->getType();
	bool oldAndNewTypesCompatible = false;
	if( type == "ri:volume" )
	{
		// "ri:volume" is the type of the shader, but it's not a valid assignment
		// type. Valid assignment types are "ri:atmosphere", "ri:interior" and "ri:exterior".
		type = "ri:atmosphere";
		const string oldType = typePlug()->getValue();
		oldAndNewTypesCompatible = oldType == "ri:atmosphere" || oldType == "ri:interior" || oldType == "ri:exterior";
	}

	if( !keepExistingValues || !oldAndNewTypesCompatible )
	{
		typePlug()->setValue( type );
	}
}
示例#2
0
void RenderManLight::loadShader( const std::string &shaderName )
{
	IECore::ConstShaderPtr shader = IECore::runTimeCast<const IECore::Shader>( RenderManShader::shaderLoader()->read( shaderName + ".sdl" ) );
	RenderManShader::loadShaderParameters( shader.get(), parametersPlug() );
	getChild<StringPlug>( "__shaderName" )->setValue( shaderName );
}