ReplaceShaderWithPreset

Introduced

v1.0

Categories

shader

Description

Disconnects a shader and connects another shader created from a preset.

Scripting Syntax

ReplaceShaderWithPreset( [Source], PresetObj );

Parameters

Parameter Type Description
Source String Shader to disconnect

Default Value: Current selection

PresetObj String or a preset object (see SIGetPreset) Any of the appropriate Shader Presets

Examples

VBScript Example

'
' This example demonstrates how to replace an existing shader on an object with
' a preset shader.
'
NewScene , false
' Get the default pass
Set oDefPass = GetValue( "Passes.Default_Pass" )
' Create a sphere and apply a default (Phong) shader to it 
Set oSphere = CreatePrim( "Sphere", "MeshSurface" )
ApplyShader , oSphere
' 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 looks magenta
' with a specular highlight)
RenderPasses oDefPass, 1, 1
' Now, replace the Phong shader on the sphere by a Toon preset shader 
ReplaceShaderWithPreset oPhong, "Material\Toon_Paint_Highlight.Preset"
Set oToon = oSphere.Material.Shaders( "Toon_Paint_Highlight" )
oToon.cover.Value = 0.1
oToon.softness.Value = 0.6
' View the results in a rendered frame. (Now the sphere has a gray, soft and
' dull appearance)
RenderPasses oDefPass, 1, 1

See Also

ApplyShader ReplaceShader ReplaceShaderWithProgID