// ========================================================================== // http://www.tjgalda.com // // Copyright (C) 2007 TJ Galda. All rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to TJ Galda which is protected by U.S. and // Canadian federal copyright law and by international treaties. // // The Data is provided for use exclusively by You. You have the right // to use, modify, and incorporate this Data into other products for // purposes authorized by TJ Galda, without fee. // // The copyright notices in the Software and this entire statement, // including the above license grant, this restriction and the // following disclaimer, must be included in all copies of the // Software, in whole or in part, and all derivative works of // the Software, unless such copies or derivative works are solely // in the form of machine-executable object code generated by a // source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. // TJ GALDA DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED // WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF // NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR // PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE, OR // TRADE PRACTICE. IN NO EVENT WILL TJ GALDA AND/OR ITS LICENSORS // BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF TJ GALDA // AND/OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY // OR PROBABILITY OF SUCH DAMAGES. // // http://www.tjgalda.com // ========================================================================== // // TJ Galda Script File // MODIFY THIS AT YOUR OWN RISK // // Creation Date: tj, February 6, 2003 // // Procedure Name: // tj_toonShader2.mel // // Description: // v 2.0 revision: updated to handle new versions of Maya // v 1.4 revision: fixed to update shadow link area properly // v 1.3 revision: fixed interface updating bug // set to copy same values when new shader created // // To Install: // 1) extract files into directory of your choice, if you put it in // one of ?:/AW/Maya?.?/scripts directories, you won't have to source it // 2) open the script editor [window -> general editor -> script editor] // 3) source TJ_toonShader.mel in script editor // 4) to execute, type: TJ_toonShader // 5) or if you prefer a button: type TJ_toonShader in the editor and // select it, then middle mouse button drag onto shelf // 6) open shelf editor [window -> settings/preferences -> shelves] // 7) browse to icon file of your choice // 8) change name in shelf editor appropriately // 9) you might want to display titles [options -> icons/text below] // // Good stuff: // // - toon shades objects to best of Maya's ability // - creates a shader network with no hidden options, it's all available to examine // - couple extra features that others don't have to soften more // // Input Arguments: // None // // Return Value: // None. // // http://www.tjgalda.com // ========================================================================== global proc tj_toonShader2() { print "Let's make some toons...\n"; if (`window -exists TJ_toonShader2Window`){ deleteUI -window TJ_toonShader2Window; } { window -widthHeight 250 250 -title "TJ Toon Shader2" -in "TJ Toon Shader2" -mxb false -s true TJ_toonShader2Window; ////////////////// // nag window interface ////////////////// columnLayout -adjustableColumn true; text -label ""; text -label ""; text -label "TJ Toon Shading Interface" -align "center"; text -label ""; text -label "(c) Copyright 2002 - All Rights Reserved." -align "center"; text -label "requires Maya 4.5+"; text -label ""; text -label ""; button -label "LAUNCH INTERFACE" -c "TJ_toonShaderInterface 0"; text -label ""; text -label "Creator: TJ Galda, www.tjgalda.com"; text -label ""; showWindow; } showWindow TJ_toonShader2Window; } global proc TJ_toonShaderInterface(int $network_number) { if (`window -exists TJ_toonShader2Window`){ deleteUI -window TJ_toonShader2Window; } { string $list_of_shaders[] = `ls "tj_toon_network*APPLY"`; string $create_new = "Create a new network"; int $size_of_list = `size($list_of_shaders)`; if ($size_of_list < 1){ string $build_default = "TJ_createToonNetwork 0"; eval $build_default; $list_of_shaders[0] = ("tj_toon_network_0_shader_to_APPLY");; int $i = 1; $list_of_shaders[$i] = " "; $i ++; $list_of_shaders[$i] = $create_new; $i ++; while ($i < 50){ $list_of_shaders[$i] = " "; $i ++; } } else{ int $t = $size_of_list; $list_of_shaders[$t] = " "; $t ++; $list_of_shaders[$t] = $create_new; $t ++; while ($t < 50){ $list_of_shaders[$t] = " "; $t ++; } } window -widthHeight 900 375 -title "TJ Toon Shader2: Working on shader 0" -in "TJ Toon Shader2: Working on shader 0" -mxb false -s true -rtf true TJ_toonShader2Window; //make a window that can scroll as a whole scrollLayout scrollLayout; //make it a columned window rowColumnLayout -nc 3 -cw 1 180 -cw 2 400 -cw 3 400 -co 2 "left" 15 -co 3 "left" 30; //-------------------------------------------------------------------- //////////////// // first frame, for the shader networks //////////////// //frame layout so we can add a title for the area frameLayout -label "Shading Networks" -labelAlign "center" -borderStyle "etchedIn"; //scrolling area for buttons to reside in string $scrollLayout1 = `scrollLayout -horizontalScrollBarThickness 16 -verticalScrollBarThickness 16 -width 150 -height 350`; string $rowLayout1 =`rowColumnLayout -numberOfColumns 1 -columnWidth 1 200`; //initialize variables string $text_entries[]; int $tj_shader_index = 0; string $temp_cmd = ""; string $tj_ann = "Click on a blank button to create a new shader, or select an existing one to work on it."; int $current_network_list_length = 0; //build list of shaders to pick from for ($tj_shader_index = 0; $tj_shader_index < `size($list_of_shaders)`; $tj_shader_index ++){ // attach command to each button with number $tj_shader_index attached and list length if ($tj_shader_index < $size_of_list){ $temp_cmd = ("TJ_updateToonInterface " + $tj_shader_index); } else{ $temp_cmd = ("TJ_createToonNetwork " + $tj_shader_index); } $current_network_list_length ++; string $tj_shader_button = ("tj_shader_button_" + $tj_shader_index); //build each button $text_entries[$tj_shader_index] = `button -label $list_of_shaders[$tj_shader_index] -w 180 -align "left" -ann $tj_ann -command $temp_cmd $tj_shader_button`; } setParent ..; setParent ..; setParent ..; //-------------------------------------------------------------------- //////////////// // second frame, for the colour options //////////////// string $net_pref = ("tj_toon_network_"+$network_number); string $cc_update = ("TJ_updateToonWindow "+$network_number); frameLayout -label "Colour Options" -labelAlign "center" -borderStyle "etchedIn"; rowColumnLayout -numberOfRows 7 -rowHeight 1 50 -rowHeight 2 50 -rowHeight 3 50 -rowHeight 4 50 -rowHeight 5 50 -rowHeight 6 50 -rowHeight 7 50 -co 1 "left" 5 -co 2 "left" 5 -co 3 "left" 15 -co 4 "left" 5 -co 5 "left" 5 -co 6 "left" 5 -co 7 "left" 5 -ro 1 "top" 5; colorSliderGrp -label "Outline Colour" -rgb 0 0 0 -ann "Colour of the outline ink on the outer most edges." -cc $cc_update outline_colour; attrFieldSliderGrp -l "Outline Thickness" -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 150 -cw 2 70 -cw 3 155 -ann "Control the thickness of the outline ink." -at ($net_pref+"_condition1a.secondTerm") outline_thickness; checkBox -label "Link Shadow Colour to Interior Fill" -v true -al left -ann "Indicates whether to or not to have colour update when interior paint is changed" -cc $cc_update current_checkbox_second_line; colorSliderGrp -label "Shadow Area Colour" -rgb 0 0.35 0 -en false -cc $cc_update -ann "Chose a colour that is between your outline ink and your interior for nicer blending." second_line_colour; attrFieldSliderGrp -l "Interior Area Thickness" -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 150 -cw 2 70 -cw 3 155 -ann "Control the thickness of the interior shaded area to control blending." -at ($net_pref+"_condition2.secondTerm") second_line_thickness; colorSliderGrp -label "Interior Paint Colour 1" -rgb 0 0.5 0 -cc $cc_update -ann "Colour in the darker areas of fill paint." interior_fill_colour_1; colorSliderGrp -label "Interior Paint Colour 2" -rgb 0 0.7 0 -cc $cc_update -ann "Colour in the brighter areas of fill paint." interior_fill_colour_2; setParent ..; setParent ..; //////////////// // third frame, for the advanced options //////////////// frameLayout -label "Advanced Options" -labelAlign "center" -borderStyle "etchedIn"; rowColumnLayout -numberOfRows 7 -rowHeight 1 50 -rowHeight 2 50 -rowHeight 3 50 -rowHeight 4 50 -rowHeight 5 50 -rowHeight 6 50 -rowHeight 7 50 -co 1 "left" 5 -co 2 "left" 5 -co 3 "left" 5 -co 4 "left" 5 -co 5 "left" 5 -co 6 "left" 5 -co 7 "left" 5 -ro 1 "top" 5; checkBox -label "Soften Using Glow" -v false -al left -ann "Turns on glow to soften the image, default off" -cc $cc_update current_checkbox_soft_glow; attrFieldSliderGrp -l "Glow Level" -en false -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 100 -cw 2 70 -cw 3 155 -ann "Control the intensity of the glow, a good number is usually around 0.1 -> 0.2" -at ($net_pref+"_shader_to_APPLY.glowIntensity") soft_glow_level; string $go_label = ("Assign Shader "+$network_number+" to selected objects"); string $select_label =("Select Shader "+$network_number+" assignment node"); string $cur_shading_group = ($net_pref+"_shader_to_APPLYSG"); string $go_cmd = ("sets -e -forceElement "+$cur_shading_group); string $select_cmd = ("select -r "+$net_pref+"_shader_to_APPLY"); string $blow_label = ("Delete Shading Network "+$network_number); string $blow_cmd = ("TJ_deleteToonNetwork "+$network_number); button -label $go_label -c $go_cmd -ann "Assign the current shading network to selected geometry" go_button; button -label $select_label -c $select_cmd -ann "Select the current shading network to allow for mapping in hypershade, etcetera." select_button; button -label $blow_label -en false -ann "Delete entire shading network hierarchy to clean up scene." -c $blow_cmd blow_button; text -en 0 -l "By: TJ Galda, (c) 2002"; setParent ..; setParent ..; setParent ..; } showWindow TJ_toonShader2Window; } global proc TJ_updateToonWindow(int $tj_working_num) { string $list_of_shaders[] = `ls "tj_toon_network*APPLY"`; string $create_new = "Create a new network"; int $size_of_list = `size($list_of_shaders)`; if ($size_of_list < 1){ string $build_default = "TJ_createToonNetwork 0"; eval $build_default; $list_of_shaders[0] = ("tj_toon_network_0_shader_to_APPLY");; int $i = 1; $list_of_shaders[$i] = " "; $i ++; $list_of_shaders[$i] = $create_new; $i ++; while ($i < 50){ $list_of_shaders[$i] = " "; $i ++; } } else{ int $t = $size_of_list; $list_of_shaders[$t] = " "; $t ++; $list_of_shaders[$t] = $create_new; $t ++; while ($t < 50){ $list_of_shaders[$t] = " "; $t ++; } } string $net_pref = ("tj_toon_network_"+$tj_working_num); string $cc_update = ("TJ_updateToonWindow "+$tj_working_num); int $network_number = $tj_working_num; if ( `window -exists TJ_toonShader2Window` ){ window -edit -title ("TJ Toon Shader2: Working on shader "+$tj_working_num) -in ("TJ Toon Shader2: Working on shader "+$tj_working_num) -mxb false -s true -rtf true TJ_toonShader2Window; string $text_entries[]; int $tj_shader_index = 0; string $temp_cmd = ""; string $tj_ann = "Click on a blank button to create a new shader, or select an existing one."; int $current_network_list_length = 0; //build list of shaders to pick from for ($tj_shader_index = 0; $tj_shader_index < `size($list_of_shaders)`; $tj_shader_index ++){ // attach command to each button with number $tj_shader_index attached and list length if ($tj_shader_index < $size_of_list){ $temp_cmd = ("TJ_updateToonInterface " + $tj_shader_index); } else{ $temp_cmd = ("TJ_createToonNetwork " + $tj_shader_index); } $current_network_list_length ++; string $tj_shader_button = ("tj_shader_button_" + $tj_shader_index); //build each button $text_entries[$tj_shader_index] = `button -edit -label $list_of_shaders[$tj_shader_index] -w 180 -align "left" -ann $tj_ann -command $temp_cmd $tj_shader_button`; } colorSliderGrp -edit -cc $cc_update outline_colour; attrFieldSliderGrp -edit -l "Outline Thickness" -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 150 -cw 2 70 -cw 3 155 -at ($net_pref+"_condition1a.secondTerm") outline_thickness; checkBox -edit -cc $cc_update current_checkbox_second_line; colorSliderGrp -edit -cc $cc_update second_line_colour; attrFieldSliderGrp -edit -l "Interior Area Thickness" -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 150 -cw 2 70 -cw 3 155 -at ($net_pref+"_condition2.secondTerm") second_line_thickness; colorSliderGrp -edit -cc $cc_update interior_fill_colour_1; colorSliderGrp -edit -cc $cc_update interior_fill_colour_2; checkBox -edit -cc $cc_update current_checkbox_soft_glow; float $outline_colours[] = `colorSliderGrp -q -rgb outline_colour`; setAttr ($net_pref+"_lambert1a.c") $outline_colours[0] $outline_colours[1] $outline_colours[2]; if ($outline_colours[0] > 0.35 || $outline_colours[1] > 0.35 || $outline_colours[2] > 0.35){ setAttr ($net_pref+"_sShader1.ambientColor") $outline_colours[0] $outline_colours[1] $outline_colours[2]; } else{ setAttr ($net_pref+"_sShader1.ambientColor") 0 0 0; } float $interior_paint_colours[] = `colorSliderGrp -q -rgb interior_fill_colour_1`; setAttr ($net_pref+"_ramp2.colorEntryList[1].color") -type double3 $interior_paint_colours[0] $interior_paint_colours[1] $interior_paint_colours[2]; float $interior_paint_colours2[] = `colorSliderGrp -q -rgb interior_fill_colour_2`; setAttr ($net_pref+"_ramp2.colorEntryList[2].color") -type double3 $interior_paint_colours2[0] $interior_paint_colours2[1] $interior_paint_colours2[2]; float $second_line_colours[] = `colorSliderGrp -q -rgb second_line_colour`; setAttr ($net_pref+"_lambert2.c") $second_line_colours[0] $second_line_colours[1] $second_line_colours[2]; string $go_label = ("Assign Shader "+$network_number+" to selected objects"); string $select_label =("Select Shader "+$network_number+" assignment node"); string $cur_shading_group = ($net_pref+"_shader_to_APPLYSG"); string $go_cmd = ("sets -e -forceElement "+$cur_shading_group); string $select_cmd = ("select -r "+$net_pref+"_shader_to_APPLY"); string $blow_label = ("Delete Shading Network "+$network_number); string $blow_cmd = ("TJ_deleteToonNetwork "+$network_number); button -edit -label $go_label -c $go_cmd go_button; button -edit -label $select_label -c $select_cmd select_button; string $list_of_shaders[] = `ls "tj_toon_network*APPLY"`; int $size_of_list = `size($list_of_shaders)`; if ($network_number = 0 || $network_number < ($size_of_list-1)) { button -edit -label "Can only delete highest number network" -en false -c $blow_cmd blow_button; } else{ button -edit -label $blow_label -en true -c $blow_cmd blow_button; } int $second_line_box_state = `checkBox -q -v current_checkbox_second_line`; int $soft_glow_box_state = `checkBox -q -v current_checkbox_soft_glow`; if ($soft_glow_box_state == 1){ attrFieldSliderGrp -edit -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 100 -cw 2 70 -cw 3 155 -en true -at ($net_pref+"_shader_to_APPLY.glowIntensity") soft_glow_level; } else{ attrFieldSliderGrp -edit -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 100 -cw 2 70 -cw 3 155 -en false -at ($net_pref+"_shader_to_APPLY.glowIntensity") soft_glow_level; setAttr ($net_pref+"_shader_to_APPLY.glowIntensity") 0; } float $paint_colours[] = `colorSliderGrp -q -rgb interior_fill_colour_1`; float $inner_slide_colours[]; int $i = 0; float $temp_filler_colour = 0; if ($second_line_box_state == 1){ for ($i = 0; $i < 3; $i ++){ if (($paint_colours[$i] - 0.25) < 0){ $temp_filler_colour = 0; } else{ $temp_filler_colour =($paint_colours[$i] - 0.25); } $inner_slide_colours[$i] = $temp_filler_colour; } colorSliderGrp -edit -en false -rgb $inner_slide_colours[0] $inner_slide_colours[1] $inner_slide_colours[2] second_line_colour; attrFieldSliderGrp -edit -min 0 -max 1 -pre 3 -cal 1 "right" -cw 1 150 -cw 2 70 -cw 3 155 -en true second_line_thickness; } else{ colorSliderGrp -edit -en true second_line_colour; } } } global proc TJ_createToonNetwork(int $tj_existing_number) { string $list_of_shaders[] = `ls "tj_toon_network*APPLY"`; int $size_of_list = `size($list_of_shaders)`; int $network_number = $tj_existing_number; if ($tj_existing_number > $size_of_list){ $network_number = $size_of_list; } string $net_pref = ("tj_toon_network_"+$network_number); shadingNode -n ($net_pref+"_blinn1") -asShader blinn; setAttr ($net_pref+"_blinn1.diffuse") 1; setAttr ($net_pref+"_blinn1.color") 0.584 0.584 0.584; setAttr ($net_pref+"_blinn1.specularColor") 1 1 1; setAttr ($net_pref+"_blinn1.eccentricity") 0.341; setAttr ($net_pref+"_blinn1.specularRollOff") 0.585; shadingNode -n ($net_pref+"_clamp1") -asUtility clamp; setAttr ($net_pref+"_clamp1.maxR") 1; connectAttr ($net_pref+"_blinn1.oc") ($net_pref+"_clamp1.ip"); shadingNode -n ($net_pref+"_ramp1") -asTexture ramp; setAttr ($net_pref+"_ramp1.interpolation") 4; removeMultiInstance -break true ($net_pref+"_ramp1.colorEntryList[1]"); removeMultiInstance -break true ($net_pref+"_ramp1.colorEntryList[2]"); setAttr ($net_pref+"_ramp1.colorEntryList[0].position") 0.275; setAttr ($net_pref+"_ramp1.colorEntryList[0].color") -type double3 1 1 1 ; connectAttr ($net_pref+"_clamp1.outputR") ($net_pref+"_ramp1.vCoord"); shadingNode -n ($net_pref+"_lambert1a") -asShader lambert; setAttr ($net_pref+"_lambert1a.diffuse") 0.8; setAttr ($net_pref+"_lambert1a.color") 0 0.15 0; shadingNode -n ($net_pref+"_lambert1b") -asShader lambert; setAttr ($net_pref+"_lambert1b.diffuse") 0.8; setAttr ($net_pref+"_lambert1b.color") 0 0 0; shadingNode -n ($net_pref+"_samplerInfo1") -asUtility samplerInfo; setAttr ($net_pref+"_samplerInfo1.normalCamera") 0 0 1; setAttr ($net_pref+"_samplerInfo1.uCoord") 0; setAttr ($net_pref+"_samplerInfo1.vCoord") 0; setAttr ($net_pref+"_samplerInfo1.rayDirection") 0 0 1; setAttr ($net_pref+"_samplerInfo1.tangentUx") 1; setAttr ($net_pref+"_samplerInfo1.tangentUy") 0; setAttr ($net_pref+"_samplerInfo1.tangentUz") 0; setAttr ($net_pref+"_samplerInfo1.tangentVx") 0; setAttr ($net_pref+"_samplerInfo1.tangentVy") 1; setAttr ($net_pref+"_samplerInfo1.tangentVz") 0; setAttr ($net_pref+"_samplerInfo1.pixelCenterX") 0; setAttr ($net_pref+"_samplerInfo1.pixelCenterY") 0; setAttr ($net_pref+"_samplerInfo1.facingRatio") 0; setAttr ($net_pref+"_samplerInfo1.flippedNormal") 0; setAttr ($net_pref+"_samplerInfo1.pointWorld") 0 0 0; setAttr ($net_pref+"_samplerInfo1.pointObj") 0 0 0; setAttr ($net_pref+"_samplerInfo1.pointCamera") 0 0 0; setAttr ($net_pref+"_samplerInfo1.tangentUx") 1; shadingNode -n ($net_pref+"_condition1a") -asUtility condition; setAttr ($net_pref+"_condition1a.secondTerm") 0.189; setAttr ($net_pref+"_condition1a.operation") 2; shadingNode -n ($net_pref+"_condition1b") -asUtility condition; connectAttr ($net_pref+"_condition1a.secondTerm")($net_pref+"_condition1b.secondTerm"); setAttr ($net_pref+"_condition1b.operation") 2; connectAttr ($net_pref+"_samplerInfo1.facingRatio") ($net_pref+"_condition1a.firstTerm"); connectAttr ($net_pref+"_samplerInfo1.facingRatio") ($net_pref+"_condition1b.firstTerm"); connectAttr ($net_pref+"_ramp1.oc") ($net_pref+"_condition1a.colorIfTrue"); connectAttr ($net_pref+"_ramp1.oc") ($net_pref+"_condition1b.colorIfTrue"); connectAttr ($net_pref+"_lambert1a.oc") ($net_pref+"_condition1a.colorIfFalse"); connectAttr ($net_pref+"_lambert1b.oc") ($net_pref+"_condition1b.colorIfFalse"); shadingNode -n ($net_pref+"_sShader1") -asShader lambert; connectAttr ($net_pref+"_condition1b.oc") ($net_pref+"_sShader1.transparency"); connectAttr ($net_pref+"_condition1a.oc") ($net_pref+"_sShader1.color"); setAttr ($net_pref+"_sShader1.outMatteOpacity") -type double3 1 1 1; setAttr ($net_pref+"_sShader1.outGlowColor") -type double3 0 0 0 ; shadingNode -n ($net_pref+"_blinn2") -asShader blinn; setAttr ($net_pref+"_blinn2.diffuse") 1; setAttr ($net_pref+"_blinn2.color") 0.584 0.584 0.584; setAttr ($net_pref+"_blinn2.specularColor") 1 1 1; setAttr ($net_pref+"_blinn2.eccentricity") 0.341; setAttr ($net_pref+"_blinn2.specularRollOff") 0.585; shadingNode -n ($net_pref+"_clamp2") -asUtility clamp; setAttr ($net_pref+"_clamp2.maxR") 1; connectAttr ($net_pref+"_blinn2.oc") ($net_pref+"_clamp2.ip"); shadingNode -n ($net_pref+"_ramp2") -asTexture ramp; setAttr ($net_pref+"_ramp2.interpolation") 4; removeMultiInstance -break true ($net_pref+"_ramp2.colorEntryList[0]"); setAttr ($net_pref+"_ramp2.colorEntryList[1].position") 0.075; setAttr ($net_pref+"_ramp2.colorEntryList[2].position") 0.54; setAttr ($net_pref+"_ramp2.colorEntryList[1].color") -type double3 0.1 0.3 0.13 ; setAttr ($net_pref+"_ramp2.colorEntryList[2].color") -type double3 0.1 0.6 0.13; connectAttr ($net_pref+"_clamp2.outputR") ($net_pref+"_ramp2.vCoord"); shadingNode -n ($net_pref+"_lambert2") -asShader lambert; setAttr ($net_pref+"_lambert2.diffuse") 0.8; setAttr ($net_pref+"_lambert2.color") 0.1 0.3 0.2; shadingNode -n ($net_pref+"_samplerInfo2") -asUtility samplerInfo; setAttr ($net_pref+"_samplerInfo2.normalCamera") 0 0 1; setAttr ($net_pref+"_samplerInfo2.uCoord") 0; setAttr ($net_pref+"_samplerInfo2.vCoord") 0; setAttr ($net_pref+"_samplerInfo2.rayDirection") 0 0 1; setAttr ($net_pref+"_samplerInfo2.tangentUx") 1; setAttr ($net_pref+"_samplerInfo2.tangentUy") 0; setAttr ($net_pref+"_samplerInfo2.tangentUz") 0; setAttr ($net_pref+"_samplerInfo2.tangentVx") 0; setAttr ($net_pref+"_samplerInfo2.tangentVy") 1; setAttr ($net_pref+"_samplerInfo2.tangentVz") 0; setAttr ($net_pref+"_samplerInfo2.pixelCenterX") 0; setAttr ($net_pref+"_samplerInfo2.pixelCenterY") 0; setAttr ($net_pref+"_samplerInfo2.facingRatio") 0; setAttr ($net_pref+"_samplerInfo2.flippedNormal") 0; setAttr ($net_pref+"_samplerInfo2.pointWorld") 0 0 0; setAttr ($net_pref+"_samplerInfo2.pointObj") 0 0 0; setAttr ($net_pref+"_samplerInfo2.pointCamera") 0 0 0; setAttr ($net_pref+"_samplerInfo2.tangentUx") 1; shadingNode -n ($net_pref+"_condition2") -asUtility condition; setAttr ($net_pref+"_condition2.secondTerm") 0.269; setAttr ($net_pref+"_condition2.operation") 2; connectAttr ($net_pref+"_samplerInfo2.facingRatio") ($net_pref+"_condition2.firstTerm"); connectAttr ($net_pref+"_ramp2.oc") ($net_pref+"_condition2.colorIfTrue"); connectAttr ($net_pref+"_lambert2.oc") ($net_pref+"_condition2.colorIfFalse"); shadingNode -n ($net_pref+"_sShader2") -asShader surfaceShader; connectAttr ($net_pref+"_condition2.oc") ($net_pref+"_sShader2.oc"); setAttr ($net_pref+"_sShader2.outMatteOpacity") -type double3 1 1 1; setAttr ($net_pref+"_sShader2.outGlowColor") -type double3 0 0 0 ; setAttr ($net_pref+"_sShader2.outTransparency") -type double3 0 0 0 ; shadingNode -n ($net_pref+"_lShader1") -asShader layeredShader; connectAttr -f ($net_pref+"_sShader2.outColor") ($net_pref+"_lShader1.inputs[2].color"); connectAttr -f ($net_pref+"_sShader2.outGlowColor") ($net_pref+"_lShader1.inputs[2].glowColor"); setAttr ($net_pref+"_lShader1.inputs[2].transparency") -type double3 0 0 0 ; connectAttr -f ($net_pref+"_sShader1.outTransparency") ($net_pref+"_lShader1.inputs[1].transparency"); connectAttr -f ($net_pref+"_sShader1.outColor") ($net_pref+"_lShader1.inputs[1].color"); connectAttr -f ($net_pref+"_sShader1.outGlowColor") ($net_pref+"_lShader1.inputs[1].glowColor"); removeMultiInstance -break true ($net_pref+"_lShader1.inputs[0]"); shadingNode -n ($net_pref+"_shader_to_APPLY") -asShader lambert; setAttr ($net_pref+"_shader_to_APPLY.diffuse") 0.8; connectAttr ($net_pref+"_lShader1.oc") ($net_pref+"_shader_to_APPLY.color"); sets -renderable true -noSurfaceShader true -empty -name ($net_pref+"_shader_to_APPLYSG"); connectAttr -f ($net_pref+"_shader_to_APPLY.outColor") ($net_pref+"_shader_to_APPLYSG.surfaceShader"); TJ_updateToonWindow $network_number; } global proc int TJ_deleteToonNetwork(int $network_number) { //establish current existing shaders string $list_of_shaders[] = `ls "tj_toon_network*APPLY"`; int $size_of_list = `size($list_of_shaders)`; string $net_pref = ("tj_toon_network_"+$network_number); string $names[] = {"_condition1a", "_condition1b","_condition2", "_sShader1", "_sShader2", "_lShader1", "_blinn1", "_clamp1", "_ramp1", "_lambert1a", "_lambert1b","_samplerInfo1", "_blinn2", "_clamp2", "_ramp2", "_lambert2", "_samplerInfo2", "_shader_to_APPLY", "_shader_to_APPLYSG"}; string $temp_string; int $warn = 0; for ($item in $names){ $temp_string = ($net_pref+$item); if (`objExists $temp_string`){ delete $temp_string; } else{ print ("\nWARNING: "+$temp_string+" did not exist!\n"); $warn = 1; } } if ($warn != 1){ print ("\nDeleted all items in "+$net_pref+" successfully.\n"); } else{ print ("\nWARNING: some items did not exist!\n"); } //establish current existing shaders string $list_of_shaders[] = `ls "tj_toon_network*APPLY"`; int $size_of_list = `size($list_of_shaders)`; if ($size_of_list < 1){ print "\nDeleted all Shaders, closing interface.\n"; if (`window -exists TJ_toonShader2Window`){ deleteUI -window TJ_toonShader2Window; } return 0; } int $new_net_num = $network_number - 1; if ($new_net_num > 0){ TJ_updateToonWindow $new_net_num; } else{ TJ_updateToonWindow 0; } return 1; } global proc TJ_updateToonInterface (int $network_number) { string $net_pref = ("tj_toon_network_"+$network_number); float $UP_outline_colours[] = `getAttr ($net_pref+"_lambert1a.c")`; float $UP_interior_paint_colours[] = `getAttr ($net_pref+"_ramp2.colorEntryList[1].color")`; float $UP_interior_paint_colours2[] = `getAttr ($net_pref+"_ramp2.colorEntryList[2].color")`; float $UP_second_line_colours[] = `getAttr ($net_pref+"_lambert2.c")`; TJ_updateToonWindow $network_number; colorSliderGrp -edit -rgb $UP_outline_colours[0] $UP_outline_colours[1] $UP_outline_colours[2] outline_colour; if ($UP_outline_colours[0] > 0.35 || $UP_outline_colours[1] > 0.35 || $UP_outline_colours[2] > 0.35){ setAttr ($net_pref+"_sShader1.ambientColor") $UP_outline_colours[0] $UP_outline_colours[1] $UP_outline_colours[2]; } else{ setAttr ($net_pref+"_sShader1.ambientColor") 0 0 0; } colorSliderGrp -edit -rgb $UP_interior_paint_colours[0] $UP_interior_paint_colours[1] $UP_interior_paint_colours[2] interior_fill_colour_1; colorSliderGrp -edit -rgb $UP_interior_paint_colours2[0] $UP_interior_paint_colours2[1] $UP_interior_paint_colours2[2] interior_fill_colour_2; colorSliderGrp -edit -rgb $UP_second_line_colours[0] $UP_second_line_colours[1] $UP_second_line_colours[2] second_line_colour; TJ_updateToonWindow $network_number; }