Example #1
0
void RenderManShader::loadShader( const std::string &shaderName, bool keepExistingValues )
{
	IECore::ConstShaderPtr shader = runTimeCast<const IECore::Shader>( shaderLoader()->read( shaderName + ".sdl" ) );
	loadShaderParameters( shader, parametersPlug(), keepExistingValues );
	namePlug()->setValue( shaderName );
	typePlug()->setValue( "ri:" + shader->getType() );
}
Example #2
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 );
	}
}