PDA

View Full Version : swap 2 material


authentic
08-11-2004, 10:32 AM
does someone have an idea to make a button to swap between 2 materials for the same object / clusters.
For example, i have a tv with a material when she is off et another when she is on. Is there a way, atips maybe a script to have the 2 materials attached to the model and then the person in charge of the scene will have a button to enable to...enable the tv.

Hope I'm clear

yog
08-11-2004, 10:46 AM
Make two complete illumination shaders (blinn, phong, etc), each with their own diffuse, spec, reflection, etc, then mix them into the final material using the Mix2Colours node. Now it's just a matter of switching between them by keyframing the weight value in the mixxer node, you could even tie it to a custom slider or event if you wanted.

Atyss
08-11-2004, 11:14 AM
Open the material in the render tree. Create a Boolean_switch node (from the Switch sub-menu). Plug the Boolean_switch shader in the surface input of the material node.
Plug the two materials in the inputs of the boolean_switch.

Now you can play with the checkbox in the boolean_switch.

If you want to prevent the artist from digging in the Render Tree each time, attach a cpset on the object, and link the checkbox with a boolean parameter in the cpset.



Cheers
Bernard



CreatePrim("Sphere", "MeshSurface", null, null);
ApplyShader(null, "", null, "", siLetLocalMaterialsOverlap);
CopyPaste(null, "Shaders\\Texture\\Math\\Boolean_Math_Logic.Preset", "TransientObjectContainer", null);
CopyPaste(null, "Shaders\\Texture\\Switch\\Boolean_switch.Preset", "TransientObjectContainer", null);
RemoveShaderFromCnxPoint("sphere.Material.Phong", "sphere.Material.surface", false);
SIConnectShaderToCnxPoint("TransientObjectContainer.Boolean_switch", "sphere.Material.surface", null);
CopyPaste(null, "Shaders\\Material\\Constant.Preset", "TransientObjectContainer", null);
CopyPaste(null, "Shaders\\Material\\Constant.Preset", "TransientObjectContainer", null);
SIConnectShaderToCnxPoint("TransientObjectContainer.Constant", "sphere.Material.Boolean_switch.input1", null);
SIConnectShaderToCnxPoint("TransientObjectContainer.Constant1", "sphere.Material.Boolean_switch.input2", null);
AddProp("Custom_parameter_list", "", "", "CustomPSet");
SelectObj("sphere.CustomPSet", null, null);
SIAddCustomParameter("sphere.CustomPSet", "Switch", siBool, 0, 0, 1, null, 5, 0, 1, null, null);
CopyPaste("sphere.CustomPSet.Switch", null, "sphere.Material.Boolean_switch.switch", 1);
SetValue("sphere.CustomPSet.Switch", true, null);
SetValue("sphere.CustomPSet.Switch", false, null);
SelectObj("sphere.Material", null, null);
SetValue("sphere.Material.Boolean_switch.Constant.color.red", 0.7, null);
SetValue("sphere.Material.Boolean_switch.Constant.color.green", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant.color.blue", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant.color.red", 1, null);
SetValue("sphere.Material.Boolean_switch.Constant.color.green", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant.color.blue", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.red", 0.7, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.green", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.blue", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.red", 0.14, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.green", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.blue", 0.7, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.red", 0.2, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.green", 0, null);
SetValue("sphere.Material.Boolean_switch.Constant1.color.blue", 1, null);
SetValue("sphere.CustomPSet.Switch", true, null);
SetValue("sphere.CustomPSet.Switch", false, null);

CGTalk Moderation
01-18-2006, 10:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.