Introduced
1.0
Description
Disconnects a shader and connects another shader in its place.
Note: Both parameters are required, and you cannot use a preset path for the Target parameter ("Shaders/Material/Lambert.Preset" does not work), so if you need to specify a shader that has not been introduced to the scene yet, you get it with the CopyPaste command and then use the resulting TransientObjectContainer for the Target parameter (see the example for details) or use the ReplaceShaderWithPreset command.
Scripting Syntax
ReplaceShader( Source, Target )
Parameters
|
Parameter |
Type |
Description |
|
Source |
Shaders to disconnect (eg., "sphere.Material.Phong"). |
|
|
Target |
Shader to connect. Only a shader that is already in the scene is accepted, so if you are using a shader from disk, you need to add it with the CopyPaste command first. |
Examples
VBScript Example
' ' This example demonstrates how to replace one shader with another one ' on scene objects. It also shows how you can use the scripting ' equivalent of Drag & Drop (CopyPaste) which is required by the ' ReplaceShader command. ' NewScene , false ' Get the default pass Set oDefPass = GetValue( "Passes.Default_Pass" ) ' Create a sphere and apply a default shader to it (since the ' sphere is already selected we don't need to specify it as ' an input object) Set oSphere = CreatePrim( "Sphere", "MeshSurface" ) ApplyShader ' Tweak the color values on the sphere's material using the Shader ' parameter shortcuts "diffuse" and "ambient" Set oPhong = oSphere.Material.Shaders( "Phong" ) oPhong.diffuse.Parameters( "red" ).Value = 0.9 oPhong.diffuse.Parameters( "green" ).Value = 0.5 oPhong.ambient.Parameters( "green" ).Value = 0.7 ' View the results in a rendered frame. (You can see the sphere now has the ' default image wrapped around it with a specular highlight) RenderPasses oDefPass, 1, 1 ' Now, replace the Phong shader on the sphere by a Lambert preset shader which ' we access through the CopyPaste command (the scripting equivalent of Drag & Drop) CopyPaste , InstallationPath( siFactoryPath ) & _ "\Data\DSPresets\Shaders\Material\Lambert.Preset", _ "TransientObjectContainer", vbLinkSource ReplaceShader "sphere.Material.Phong", "TransientObjectContainer.Lambert" ' View the results in a rendered frame. (Now the image is still on the sphere, ' but it appears with a matte surface and no specular highlight) RenderPasses oDefPass, 1, 1
See Also
|
|
|
|
SOFTIMAGE|XSI v6.01