Announcement

Collapse
No announcement yet.

Override material; exclude material instead of object.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Done... and a small bug fixed too.
    Maxscript made easy....
    davewortley.wordpress.com
    Follow me here:
    facebook.com/MaxMadeEasy

    If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

    Comment


    • #17
      Just closed the script and then realised it'd be really cool if you could tell it which objects to exclude in this interface, then I thought hang on you've probably already got them set up in the Vray Material Override Include/Exclude list, so I've put the ability to borrow them from there too. So that's in as well now!
      Maxscript made easy....
      davewortley.wordpress.com
      Follow me here:
      facebook.com/MaxMadeEasy

      If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

      Comment


      • #18
        Originally posted by Dave_Wortley View Post
        Just closed the script and then realised it'd be really cool if you could tell it which objects to exclude in this interface, then I thought hang on you've probably already got them set up in the Vray Material Override Include/Exclude list, so I've put the ability to borrow them from there too. So that's in as well now!
        Amazing, but something broke, I get an error now:

        Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	16.4 KB
ID:	856252

        edit: Nevermind; all the " " needed to be replaced.

        Here ya go.

        Code:
        --Written by Dave Wortley
        --http://davewortley.wordpress.com
        --MaxScript Made Easy
        --2015
        --
        --This Script Converts your materials on all your objects to be in a Shell Material which allows you to store a chalk setup, and switch from your normal render setup to chalk rendering excluding Vray Light Materials and any Vray material which is refractive.
        try(destroyDialog RL_ChalkMatSwitcher)catch()
        
        rollout RL_ChalkMatSwitcher "Chalk Mat Switcher" width:200
        (
        label lbl_a "Get Chalk Material from" align:#left
        spinner spn_ID “Material Editor Slot:” type:#integer range:[1,24,1] tooltip:”Pick Material Slot to get Chalk Material from, this is the CME, or the Sample Slots palette in the Slate Editor”
        label lbl_b “Options:” align:#left
        checkbox chk_VrayLightMtl “Exclude VRayLightMtl” checked:true tooltip:”Exclude VrayLightMtl”
        checkbox chk_RefractiveMaterials “Keep Refractive VrayMtls” checked:true tooltip:”Exclude any material who’s refraction colour is not black”
        checkbox chk_monoChromeRefractions “Monochrome Refractions” tooltip:”Desaturates any colour in refraction” checked:true
        checkbox chk_preserveBump “Preserve Bump/Displace Maps” tooltip:”Preserves Bump/Displace Maps on VRayMtls” checked:true
        checkbox chk_preserveOpacities “Preserve Opacities” tooltip:”Preserves Opacity Maps in Materials” checked:true
        checkbox chk_getExcludefromVray “Get Object Excludes from VRay” tooltip:”If you have objects in the include/exclude dialog for material override exclusion this will pick them up as well.”
        checkbox chk_ignoreName “Ignore with Material Name:” align:#left tooltip:”Allows you to ignore materials based on name, using wildcards as well, so ‘*Glass*’ will exclude all the materials with the word glass in them. (not Case Sensitive)”
        edittext edt_ignoreName “” text:”*glass*”
        
        button btn_createChalkSetup “Create Chalk Setup” width:170 tooltip:”Create Chalk Setup”
        button btn_goChalk “Go Chalk” across:2 width:80 tooltip:”Change Materials to Chalk, Hold SHIFT to only affect selected objects”
        button btn_goMaterial “Go Material” width:80 tooltip:”Change Materials to original, Hold SHIFT to only affect selected objects”
        button btn_removeChalkSetup “Remove Chalk Setup” width:170 tooltip:”Remove Chalk Setup”
        
        local ChalkMap
        
        fn preserveBump matA matB =
        (
        if chk_preserveBump.checked or chk_preserveOpacities.checked then
        (
        theMat = copy matB
        
        if chk_preserveBump.checked do
        (
        theMat.texmap_bump = matA.texmap_bump
        theMat.texmap_bump_on = matA.texmap_bump_on
        theMat.texmap_bump_multiplier = matA.texmap_bump_multiplier
        
        theMat.texmap_displacement = matA.texmap_displacement
        theMat.texmap_displacement_on = matA.texmap_displacement_on
        theMat.texmap_displacement_multiplier = matA.texmap_displacement_multiplier
        )
        if chk_preserveOpacities.checked do
        (
        theMat.texmap_opacity = matA.texmap_opacity
        theMat.texmap_opacity_on = matA.texmap_opacity_on
        theMat.texmap_opacity_multiplier = matA.texmap_opacity_multiplier
        )
        
        theMat
        )
        else
        (
        matB
        )
        )
        
        fn chalkTheMat subMat =
        (
        If subMat != undefined and chk_ignoreName.checked and matchpattern submat.name pattern:edt_ignoreName.text then
        (
        subMat
        )
        else
        (
        Case (classof submat) of
        (
        VrayLightMtl: (
        if chk_VraylightMtl.checked then
        submat
        else
        ChalkMat
        )
        VrayMtl: (
        if chk_RefractiveMaterials.checked then
        (
        if submat.refraction != (color 0 0 0) then
        (
        if chk_monoChromeRefractions.checked do
        (
        local c = subMat.refraction
        c.saturation = 0
        submat.refraction = c
        
        c = subMat.refraction_fogColor
        c.saturation = 0
        submat.refraction_fogColor = c
        
        c = subMat.refraction_exitColor
        c.saturation = 0
        submat.refraction_exitColor = c
        
        c = subMat.diffuse
        c.saturation = 0
        submat.diffuse = c
        
        c = subMat.reflection
        c.saturation = 0
        submat.reflection = c
        
        if submat.texmap_diffuse_on and submat.texmap_diffuse != undefined do
        (
        local cc = color_Correction saturation:-100 map:submat.texmap_diffuse
        submat.texmap_diffuse = cc
        )
        
        if submat.texmap_reflection_on and submat.texmap_reflection != undefined do
        (
        local cc = color_Correction saturation:-100 map:submat.texmap_reflection
        submat.texmap_reflection = cc
        )
        
        if submat.texmap_refraction_on and submat.texmap_refraction != undefined do
        (
        local cc = color_Correction saturation:-100 map:submat.texmap_refraction
        submat.texmap_refraction = cc
        )
        if submat.texmap_refraction_fog_on and submat.texmap_refraction_fog != undefined do
        (
        local cc = color_Correction saturation:-100 map:submat.texmap_refraction_fog
        submat.texmap_refraction_fog = cc
        )
        )
        preserveBump Submat Submat
        )
        else
        preserveBump subMat ChalkMat
        )
        else
        preserveBump subtMat ChalkMat
        )
        VRayBumpMtl: (
        if not chk_preserveBump.checked then
        (
        submat.bump_amount = 0
        )
        submat.base_mtl = ChalkTheMat subMat.base_Mtl
        submat
        )
        UndefinedClass: (
        undefined
        )
        Default: (
        if (getNumSubMtls submat) != 0 then
        (
        for i = 1 to (getNumSubMtls submat) do
        (
        setSubMtl subMat i (ChalkTheMat (getSubMtl subMat i))
        )
        subMat
        )
        else
        ChalkMat
        )
        
        )
        )
        )
        
        on btn_createChalkSetup pressed do
        (
        for o in objects where o.material != undefined and classof o.material == Shell_Material do
        (
        o.material = o.material.originalMaterial
        )
        
        ChalkMat = meditmaterials[spn_ID.value]
        
        theObjs = #()
        
        if chk_getExcludefromVRay.checked then
        (
        if renderers.current.includeListOverrideMtl != undefined and renderers.current.includeListOverrideMtl.count != 0 do
        (
        theobjs = renderers.current.includeListOverrideMtl
        )
        if renderers.current.excludeListOverrideMtl != undefined and renderers.current.excludeListOverrideMtl.count != 0 do
        (
        theobjs = for o in objects where (finditem renderers.current.excludeListOverrideMtl o) == 0 collect o
        )
        )
        else
        (
        for o in objects do append theObjs o
        )
        
        for o in theObjs do
        (
        if o.material != undefined and classof o.material != Shell_Material do
        (
        theMat = Shell_Material name:(o.material.name + “_Wrapper”)
        theMat.originalMaterial = o.material
        
        tempMat = copy o.material
        
        tempMat = chalkTheMat tempMat
        
        themat.bakedMaterial = tempMat
        themat.viewportMtlIndex = 1
        themat.rendermtlIndex = 1
        
        o.material = theMat
        
        )
        )
        )
        
        on btn_goChalk pressed do
        (
        if keyboard.shiftPressed then
        (
        for o in selection where o.material != undefined and classof o.material == Shell_material do
        (
        o.material.viewportMtlIndex = 1
        o.material.renderMtlIndex = 1
        )
        )
        else
        (
        for o in getclassinstances Shell_material do
        (
        o.viewportMtlIndex = 1
        o.renderMtlIndex = 1
        )
        )
        )
        
        on btn_goMaterial pressed do
        (
        if keyboard.shiftPressed then
        (
        for o in selection where o.material != undefined and classof o.material == Shell_material do
        (
        o.material.viewportMtlIndex = 0
        o.material.renderMtlIndex = 0
        )
        )
        else
        (
        for o in getclassinstances Shell_material do
        (
        o.viewportMtlIndex = 0
        o.renderMtlIndex = 0
        )
        )
        )
        
        on btn_removeChalkSetup pressed do
        (
        for o in objects where o.material != undefined and classof o.material == Shell_Material do
        (
        o.material = o.material.originalMaterial
        )
        )
        )
        
        CreateDialog RL_ChalkMatSwitcher
        Last edited by Vizioen; 05-06-2015, 01:22 PM.
        A.

        ---------------------
        www.digitaltwins.be

        Comment


        • #19
          edit 2 (can't seem to edit without losing my entire post weird):

          there's still something wrong with the script (or with me); I can't seem to able to get it to work. If opacity or bump are switched on I get this error (or the opacity version of this):

          Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	14.7 KB
ID:	856253

          Even if there's a map in the scene with for instance a vrayhdri map in the opacity slot. So it's not like I'm getting the error because those sort of mats don't exist.

          Even with these 2 disabled if I try to render the chalk setup, everything is black except the lights, I can succesfully remove it though, but doesn't want to render the chalk setup.
          A.

          ---------------------
          www.digitaltwins.be

          Comment


          • #20
            Click image for larger version

Name:	chalk_switcher_error.JPG
Views:	1
Size:	17.3 KB
ID:	856256thanks, seems to me more difficult than it sounds!
            Originally posted by Vizioen View Post
            edit 2 (can't seem to edit without losing my entire post weird):

            there's still something wrong with the script (or with me); I can't seem to able to get it to work. If opacity or bump are switched on I get this error (or the opacity version of this):

            [ATTACH=CONFIG]24559[/ATTACH]

            Even if there's a map in the scene with for instance a vrayhdri map in the opacity slot. So it's not like I'm getting the error because those sort of mats don't exist.

            Even with these 2 disabled if I try to render the chalk setup, everything is black except the lights, I can succesfully remove it though, but doesn't want to render the chalk setup.

            Comment


            • #21
              Hi Guys, sorry there seems to have been strange on my blog where the characters for quotation marks have been swapped for different ones, and the other issue was because I didn't scope-checked the script (where you restart max to make sure you didn't have any variables defined in global space that shouldn't have been).

              I've fixed it now, just a small typo annoyingly, but working now!

              Here's the code, this forum doesn't seem to mess it up.

              Code:
              --Dave Wortley - 2015
              --http://davewortley.wordpress.com
              --Maxscript Made Easy
              --Switch your scene to render chalks keeping your refractive materials and Light Materials, and you can preserve opacity, displace and bump maps.
              --(that clever bit doesn't currently work on VRayBlendMtls)
              --It shouldn't break your scene but if it does, then usual damage limitations apply.--(save incrementally if in doubt)
              
              try(destroyDialog RL_ChalkMatSwitcher)catch()
              
              rollout RL_ChalkMatSwitcher "Chalk Mat Switcher" width:200
              (
              	label lbl_a "Get Chalk Material from" align:#left
              	spinner spn_ID "Material Editor Slot:" type:#integer range:[1,24,1] tooltip:"Pick Material Slot to get Chalk Material from, this is the CME, or the Sample Slots palette in the Slate Editor"
              	label lbl_b "Options:" align:#left
              	checkbox chk_VrayLightMtl "Exclude VRayLightMtl" checked:true tooltip:"Exclude VrayLightMtl"
              	checkbox chk_RefractiveMaterials "Keep Refractive VrayMtls" checked:true tooltip:"Exclude any material who's refraction colour is not black"
              	checkbox chk_monoChromeRefractions "Monochrome Refractions" tooltip:"Desaturates any colour in refraction" checked:true
              	checkbox chk_preserveBump "Preserve Bump/Displace Maps" tooltip:"Preserves Bump/Displace Maps on VRayMtls" checked:true
              	checkbox chk_preserveOpacities "Preserve Opacities" tooltip:"Preserves Opacity Maps in Materials" checked:true
              	checkbox chk_getExcludefromVray "Get Object Excludes from VRay" tooltip:"If you have objects in the include/exclude dialog for material override exclusion this will pick them up as well."
              	checkbox chk_ignoreName "Ignore with Material Name:" align:#left tooltip:"Allows you to ignore materials based on name, using wildcards as well, so '*Glass*' will exclude all the materials with the word glass in them. (not Case Sensitive)"
              	edittext edt_ignoreName "" text:"*glass*"
              	
              	button btn_createChalkSetup "Create Chalk Setup" width:170 tooltip:"Create Chalk Setup"
              	button btn_goChalk "Go Chalk" across:2 width:80 tooltip:"Change Materials to Chalk, Hold SHIFT to only affect selected objects"
              	button btn_goMaterial "Go Material" width:80 tooltip:"Change Materials to original, Hold SHIFT to only affect selected objects"
              	button btn_removeChalkSetup "Remove Chalk Setup" width:170 tooltip:"Remove Chalk Setup"
              
              	local ChalkMat
              	
              	fn preserveBump matA matB =
              	(
              		if chk_preserveBump.checked or chk_preserveOpacities.checked then
              		(
              			theMat = copy matB
              			
              			if chk_preserveBump.checked do
              			(
              				theMat.texmap_bump = matA.texmap_bump
              				theMat.texmap_bump_on = matA.texmap_bump_on
              				theMat.texmap_bump_multiplier = matA.texmap_bump_multiplier
              				
              				theMat.texmap_displacement = matA.texmap_displacement
              				theMat.texmap_displacement_on = matA.texmap_displacement_on
              				theMat.texmap_displacement_multiplier = matA.texmap_displacement_multiplier
              			)
              			if chk_preserveOpacities.checked do
              			(
              				theMat.texmap_opacity = matA.texmap_opacity
              				theMat.texmap_opacity_on = matA.texmap_opacity_on
              				theMat.texmap_opacity_multiplier = matA.texmap_opacity_multiplier
              			)
              			
              			theMat
              		)
              		else
              		(
              			matB
              		)
              	)
              	
              	fn chalkTheMat subMat =
              	(
              		If subMat != undefined and chk_ignoreName.checked and matchpattern submat.name pattern:edt_ignoreName.text then
              		(
              			subMat
              		)
              		else
              		(
              			Case (classof submat) of
              			(
              				VrayLightMtl: (
              					if chk_VraylightMtl.checked then
              						submat
              					else
              						ChalkMat
              				)
              				VrayMtl: (
              					if chk_RefractiveMaterials.checked then
              					(
              						if submat.refraction != (color 0 0 0) then
              						(
              							if chk_monoChromeRefractions.checked do 
              							(
              								local c = subMat.refraction
              								c.saturation = 0
              								submat.refraction = c
              								
              								c = subMat.refraction_fogColor
              								c.saturation = 0
              								submat.refraction_fogColor = c
              								
              								c = subMat.refraction_exitColor
              								c.saturation = 0 
              								submat.refraction_exitColor = c
              								
              								c = subMat.diffuse
              								c.saturation = 0
              								submat.diffuse = c
              								
              								c = subMat.reflection
              								c.saturation = 0
              								submat.reflection = c
              								
              								if submat.texmap_diffuse_on and submat.texmap_diffuse != undefined do
              								(
              									local cc = color_Correction saturation:-100 map:submat.texmap_diffuse
              									submat.texmap_diffuse = cc
              								)
              								
              								if submat.texmap_reflection_on and submat.texmap_reflection != undefined do
              								(
              									local cc = color_Correction saturation:-100 map:submat.texmap_reflection
              									submat.texmap_reflection = cc
              								)
              								
              								if submat.texmap_refraction_on and submat.texmap_refraction != undefined do
              								(
              									local cc = color_Correction saturation:-100 map:submat.texmap_refraction
              									submat.texmap_refraction = cc
              								)
              								if submat.texmap_refraction_fog_on and submat.texmap_refraction_fog != undefined do
              								(
              									local cc = color_Correction saturation:-100 map:submat.texmap_refraction_fog
              									submat.texmap_refraction_fog = cc
              								)
              							)
              							preserveBump Submat Submat
              						)
              						 else
              							preserveBump subMat ChalkMat
              					)
              					else
              						preserveBump subMat ChalkMat
              				)
              				VRayBumpMtl: (
              					if not chk_preserveBump.checked then
              					(
              						submat.bump_amount = 0
              					)
              					submat.base_mtl = ChalkTheMat subMat.base_Mtl
              					submat
              				)
              				UndefinedClass: (
              					undefined
              				)
              				Default: (
              					if (getNumSubMtls submat) != 0  then
              					(
              						for i = 1 to (getNumSubMtls submat) do
              						(
              							setSubMtl subMat i (ChalkTheMat (getSubMtl subMat i))
              						)
              						subMat
              					)
              					else
              						ChalkMat
              				)
              			 
              			)
              		)
              	)
               
              	on btn_createChalkSetup pressed do
              	(
              		for o in objects where o.material != undefined and classof o.material == Shell_Material do
              		(
              			o.material = o.material.originalMaterial
              		)
              		
              		
              		ChalkMat = meditmaterials[spn_ID.value]
              		
              		theObjs = #()
              		
              		if chk_getExcludefromVRay.checked then
              		(
              			if renderers.current.includeListOverrideMtl != undefined and renderers.current.includeListOverrideMtl.count != 0 do
              			(
              				theobjs = renderers.current.includeListOverrideMtl
              			)
              			if renderers.current.excludeListOverrideMtl != undefined and renderers.current.excludeListOverrideMtl.count != 0 do
              			(
              				theobjs = for o in objects where (finditem renderers.current.excludeListOverrideMtl o) == 0 collect o
              			)
              		)
              		else
              		(
              			for o in objects do append theObjs o
              		)
              		
              		for o in theObjs do
              		(
              			if o.material != undefined and classof o.material != Shell_Material do
              			(
              				theMat = Shell_Material name:(o.material.name + "_Wrapper")
              				theMat.originalMaterial = o.material
              				
              				tempMat = copy o.material
              				
              				tempMat = chalkTheMat tempMat
              				
              				
              				themat.bakedMaterial = tempMat
              				themat.viewportMtlIndex = 1
              				themat.rendermtlIndex = 1
              				
              				
              				o.material = theMat
              			 
              			)
              		)
              	)
               
              	on btn_goChalk pressed do
              	(
              		if keyboard.shiftPressed then
              		(
              			for o in selection where o.material != undefined and classof o.material == Shell_material do
              			(
              				o.material.viewportMtlIndex = 1
              				o.material.renderMtlIndex = 1
              			)
              		)
              		else
              		(
              			for o in getclassinstances Shell_material do 
              			(
              				o.viewportMtlIndex = 1
              				o.renderMtlIndex = 1
              			)
              		)
              	)
              
              	on btn_goMaterial pressed do
              	(
              		if keyboard.shiftPressed then
              		(
              			for o in selection where o.material != undefined and classof o.material == Shell_material do
              			(
              				o.material.viewportMtlIndex = 0
              				o.material.renderMtlIndex = 0
              			)
              		)
              		else
              		(
              			for o in getclassinstances Shell_material do 
              			(
              				o.viewportMtlIndex = 0
              				o.renderMtlIndex = 0
              			)
              		)
              	)
              
              	on btn_removeChalkSetup pressed do
              	(
              		for o in objects where o.material != undefined and classof o.material == Shell_Material do
              		(
              			o.material = o.material.originalMaterial
              		)
              	)
              )
              
              CreateDialog RL_ChalkMatSwitcher
              Maxscript made easy....
              davewortley.wordpress.com
              Follow me here:
              facebook.com/MaxMadeEasy

              If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

              Comment


              • #22
                Originally posted by Dave_Wortley View Post
                Hi Guys, sorry there seems to have been strange on my blog where the characters for quotation marks have been swapped for different ones, and the other issue was because I didn't scope-checked the script (where you restart max to make sure you didn't have any variables defined in global space that shouldn't have been).

                I've fixed it now, just a small typo annoyingly, but working now!

                Here's the code, this forum doesn't seem to mess it up.

                Code:
                --Dave Wortley - 2015
                --http://davewortley.wordpress.com
                --Maxscript Made Easy
                --Switch your scene to render chalks keeping your refractive materials and Light Materials, and you can preserve opacity, displace and bump maps.
                --(that clever bit doesn't currently work on VRayBlendMtls)
                --It shouldn't break your scene but if it does, then usual damage limitations apply.--(save incrementally if in doubt)
                
                try(destroyDialog RL_ChalkMatSwitcher)catch()
                
                rollout RL_ChalkMatSwitcher "Chalk Mat Switcher" width:200
                (
                	label lbl_a "Get Chalk Material from" align:#left
                	spinner spn_ID "Material Editor Slot:" type:#integer range:[1,24,1] tooltip:"Pick Material Slot to get Chalk Material from, this is the CME, or the Sample Slots palette in the Slate Editor"
                	label lbl_b "Options:" align:#left
                	checkbox chk_VrayLightMtl "Exclude VRayLightMtl" checked:true tooltip:"Exclude VrayLightMtl"
                	checkbox chk_RefractiveMaterials "Keep Refractive VrayMtls" checked:true tooltip:"Exclude any material who's refraction colour is not black"
                	checkbox chk_monoChromeRefractions "Monochrome Refractions" tooltip:"Desaturates any colour in refraction" checked:true
                	checkbox chk_preserveBump "Preserve Bump/Displace Maps" tooltip:"Preserves Bump/Displace Maps on VRayMtls" checked:true
                	checkbox chk_preserveOpacities "Preserve Opacities" tooltip:"Preserves Opacity Maps in Materials" checked:true
                	checkbox chk_getExcludefromVray "Get Object Excludes from VRay" tooltip:"If you have objects in the include/exclude dialog for material override exclusion this will pick them up as well."
                	checkbox chk_ignoreName "Ignore with Material Name:" align:#left tooltip:"Allows you to ignore materials based on name, using wildcards as well, so '*Glass*' will exclude all the materials with the word glass in them. (not Case Sensitive)"
                	edittext edt_ignoreName "" text:"*glass*"
                	
                	button btn_createChalkSetup "Create Chalk Setup" width:170 tooltip:"Create Chalk Setup"
                	button btn_goChalk "Go Chalk" across:2 width:80 tooltip:"Change Materials to Chalk, Hold SHIFT to only affect selected objects"
                	button btn_goMaterial "Go Material" width:80 tooltip:"Change Materials to original, Hold SHIFT to only affect selected objects"
                	button btn_removeChalkSetup "Remove Chalk Setup" width:170 tooltip:"Remove Chalk Setup"
                
                	local ChalkMat
                	
                	fn preserveBump matA matB =
                	(
                		if chk_preserveBump.checked or chk_preserveOpacities.checked then
                		(
                			theMat = copy matB
                			
                			if chk_preserveBump.checked do
                			(
                				theMat.texmap_bump = matA.texmap_bump
                				theMat.texmap_bump_on = matA.texmap_bump_on
                				theMat.texmap_bump_multiplier = matA.texmap_bump_multiplier
                				
                				theMat.texmap_displacement = matA.texmap_displacement
                				theMat.texmap_displacement_on = matA.texmap_displacement_on
                				theMat.texmap_displacement_multiplier = matA.texmap_displacement_multiplier
                			)
                			if chk_preserveOpacities.checked do
                			(
                				theMat.texmap_opacity = matA.texmap_opacity
                				theMat.texmap_opacity_on = matA.texmap_opacity_on
                				theMat.texmap_opacity_multiplier = matA.texmap_opacity_multiplier
                			)
                			
                			theMat
                		)
                		else
                		(
                			matB
                		)
                	)
                	
                	fn chalkTheMat subMat =
                	(
                		If subMat != undefined and chk_ignoreName.checked and matchpattern submat.name pattern:edt_ignoreName.text then
                		(
                			subMat
                		)
                		else
                		(
                			Case (classof submat) of
                			(
                				VrayLightMtl: (
                					if chk_VraylightMtl.checked then
                						submat
                					else
                						ChalkMat
                				)
                				VrayMtl: (
                					if chk_RefractiveMaterials.checked then
                					(
                						if submat.refraction != (color 0 0 0) then
                						(
                							if chk_monoChromeRefractions.checked do 
                							(
                								local c = subMat.refraction
                								c.saturation = 0
                								submat.refraction = c
                								
                								c = subMat.refraction_fogColor
                								c.saturation = 0
                								submat.refraction_fogColor = c
                								
                								c = subMat.refraction_exitColor
                								c.saturation = 0 
                								submat.refraction_exitColor = c
                								
                								c = subMat.diffuse
                								c.saturation = 0
                								submat.diffuse = c
                								
                								c = subMat.reflection
                								c.saturation = 0
                								submat.reflection = c
                								
                								if submat.texmap_diffuse_on and submat.texmap_diffuse != undefined do
                								(
                									local cc = color_Correction saturation:-100 map:submat.texmap_diffuse
                									submat.texmap_diffuse = cc
                								)
                								
                								if submat.texmap_reflection_on and submat.texmap_reflection != undefined do
                								(
                									local cc = color_Correction saturation:-100 map:submat.texmap_reflection
                									submat.texmap_reflection = cc
                								)
                								
                								if submat.texmap_refraction_on and submat.texmap_refraction != undefined do
                								(
                									local cc = color_Correction saturation:-100 map:submat.texmap_refraction
                									submat.texmap_refraction = cc
                								)
                								if submat.texmap_refraction_fog_on and submat.texmap_refraction_fog != undefined do
                								(
                									local cc = color_Correction saturation:-100 map:submat.texmap_refraction_fog
                									submat.texmap_refraction_fog = cc
                								)
                							)
                							preserveBump Submat Submat
                						)
                						 else
                							preserveBump subMat ChalkMat
                					)
                					else
                						preserveBump subMat ChalkMat
                				)
                				VRayBumpMtl: (
                					if not chk_preserveBump.checked then
                					(
                						submat.bump_amount = 0
                					)
                					submat.base_mtl = ChalkTheMat subMat.base_Mtl
                					submat
                				)
                				UndefinedClass: (
                					undefined
                				)
                				Default: (
                					if (getNumSubMtls submat) != 0  then
                					(
                						for i = 1 to (getNumSubMtls submat) do
                						(
                							setSubMtl subMat i (ChalkTheMat (getSubMtl subMat i))
                						)
                						subMat
                					)
                					else
                						ChalkMat
                				)
                			 
                			)
                		)
                	)
                 
                	on btn_createChalkSetup pressed do
                	(
                		for o in objects where o.material != undefined and classof o.material == Shell_Material do
                		(
                			o.material = o.material.originalMaterial
                		)
                		
                		
                		ChalkMat = meditmaterials[spn_ID.value]
                		
                		theObjs = #()
                		
                		if chk_getExcludefromVRay.checked then
                		(
                			if renderers.current.includeListOverrideMtl != undefined and renderers.current.includeListOverrideMtl.count != 0 do
                			(
                				theobjs = renderers.current.includeListOverrideMtl
                			)
                			if renderers.current.excludeListOverrideMtl != undefined and renderers.current.excludeListOverrideMtl.count != 0 do
                			(
                				theobjs = for o in objects where (finditem renderers.current.excludeListOverrideMtl o) == 0 collect o
                			)
                		)
                		else
                		(
                			for o in objects do append theObjs o
                		)
                		
                		for o in theObjs do
                		(
                			if o.material != undefined and classof o.material != Shell_Material do
                			(
                				theMat = Shell_Material name:(o.material.name + "_Wrapper")
                				theMat.originalMaterial = o.material
                				
                				tempMat = copy o.material
                				
                				tempMat = chalkTheMat tempMat
                				
                				
                				themat.bakedMaterial = tempMat
                				themat.viewportMtlIndex = 1
                				themat.rendermtlIndex = 1
                				
                				
                				o.material = theMat
                			 
                			)
                		)
                	)
                 
                	on btn_goChalk pressed do
                	(
                		if keyboard.shiftPressed then
                		(
                			for o in selection where o.material != undefined and classof o.material == Shell_material do
                			(
                				o.material.viewportMtlIndex = 1
                				o.material.renderMtlIndex = 1
                			)
                		)
                		else
                		(
                			for o in getclassinstances Shell_material do 
                			(
                				o.viewportMtlIndex = 1
                				o.renderMtlIndex = 1
                			)
                		)
                	)
                
                	on btn_goMaterial pressed do
                	(
                		if keyboard.shiftPressed then
                		(
                			for o in selection where o.material != undefined and classof o.material == Shell_material do
                			(
                				o.material.viewportMtlIndex = 0
                				o.material.renderMtlIndex = 0
                			)
                		)
                		else
                		(
                			for o in getclassinstances Shell_material do 
                			(
                				o.viewportMtlIndex = 0
                				o.renderMtlIndex = 0
                			)
                		)
                	)
                
                	on btn_removeChalkSetup pressed do
                	(
                		for o in objects where o.material != undefined and classof o.material == Shell_Material do
                		(
                			o.material = o.material.originalMaterial
                		)
                	)
                )
                
                CreateDialog RL_ChalkMatSwitcher
                Works like a charm Dave; thank you. I've only tested it on a simple test scene now, will give feedback when using a complex scene.
                A.

                ---------------------
                www.digitaltwins.be

                Comment


                • #23
                  I can probably add some performance improvements to the script so let me know how it works on a complex scene at the expense of an undo record.

                  I'll add an option to get the material from the VRay Material Override slot too, and an option to just replace VRayBlendMtls with chalk materials as that'll help performance.
                  Maxscript made easy....
                  davewortley.wordpress.com
                  Follow me here:
                  facebook.com/MaxMadeEasy

                  If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                  Comment


                  • #24
                    Look forward to trying this out Dave. Thanks!
                    Alex York
                    Founder of Atelier York - Bespoke Architectural Visualisation
                    www.atelieryork.co.uk

                    Comment


                    • #25
                      Available on ScriptSpot!

                      http://www.scriptspot.com/3ds-max/sc...rride-excluder
                      Maxscript made easy....
                      davewortley.wordpress.com
                      Follow me here:
                      facebook.com/MaxMadeEasy

                      If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                      Comment


                      • #26
                        Great; new problem. With get material override from render checked; I get this:

                        Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	151.4 KB
ID:	856274
                        A.

                        ---------------------
                        www.digitaltwins.be

                        Comment


                        • #27
                          Originally posted by Vizioen View Post
                          Great; new problem. With get material override from render checked; I get this:

                          [ATTACH=CONFIG]24600[/ATTACH]
                          This should be "options_overrideMtl_on" instead of "options_overrideMtl" AFAIK.
                          Nicolas Caplat
                          www.intangibles.fr

                          Comment


                          • #28
                            Sorry guys, I fixed that error and didn't save before I pressed upload!

                            Fixed now and just put another level of bug checking in as well.
                            Maxscript made easy....
                            davewortley.wordpress.com
                            Follow me here:
                            facebook.com/MaxMadeEasy

                            If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                            Comment


                            • #29
                              Thanks a lot, Dave
                              Nicolas Caplat
                              www.intangibles.fr

                              Comment


                              • #30
                                Updated this script with a few new features.

                                http://www.scriptspot.com/3ds-max/sc...rride-excluder
                                Maxscript made easy....
                                davewortley.wordpress.com
                                Follow me here:
                                facebook.com/MaxMadeEasy

                                If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                                Comment

                                Working...
                                X