Home Technical Talk

3DS Max (Change X-Ray Opacity)

polycounter lvl 10
Offline / Send Message
cromadbomber polycounter lvl 10
I can't seem to find an answer to this question. I looked up to other forums and people are just saying that the best way to do that is to assign a material with transparency but that is kinda annoying since you have to switch between materials constantly.

Is it possible to write a script or something similar to alter this? Any advice would be appreciated. I am using Max 2015.

Also I switched to Max like a week ago so I am still a noob when it comes to finding all this stuff.

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    I don't think you can change the opacity value of See Through mode. You can change the color in Customize > Customize User Interface > Colors > Elements: Geometry > See Through.

    Also, instead of using See Through mode, you can select the object, right click > Object Properties... and change the Visibility value.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hi monster, I'm wondering is there any benefit of using obj property>visibility value instead of see through mode? also I notice that the obj property>visibility didn't work with DirectX shader, but see through work.
  • Joost
    Options
    Offline / Send Message
    Joost polycount sponsor
    I'm a noob at maxscript but you could use this very basic script.
    Just assign it to 2 different hotkeys. It would be nice to make a toggle button that stores the old material, switches to 1 material and then goes back to the old material. But I have no idea how to do that.
    macroScript MaterialCycler1
    category:" Mytools"
    toolTip:"MaterialCycler1"
    ButtonText:"MaterialCycler1"
    
    (
    	if $ != undefined then 
    		(
    			$.material = meditMaterials[1]
    		)
    	else
    		(
    		)
    )
    
    
    
    macroScript MaterialCycler2
    category:" Mytools"
    toolTip:"MaterialCycler2"
    ButtonText:"MaterialCycle2r"
    
    (
    	if $ != undefined then 
    		(
    			$.material = meditMaterials[2]
    		)
    	else
    		(
    		)
    )
    

    Also I usually just create an animated material where frame 0 is 100% opacity and on frame 5 it's 0%. Can't remember where I found that but I got it from some tutorial.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Joost >
    (
        -- $ is the current selection, and could contain several objects
        -- so we put the selection in an array, and parse it. Now it works on several objects !
    
        sel = selection as array 
        for s in sel do --for each object in the selection
            (
                if s.material == meditMaterials[1] then s.material = meditMaterials[2]
                else s.material = meditMaterials[1]
            )
    )
    
    I'll try to cook something based on material name on lunchbreak.

    Downside of visibility is it keeps the texture displayed.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    (
        --opacity in %
        opacityAmount = 20
    
        sel = selection as array 
        try 
        (
        for obj in sel do --for each object in the selection
        (
            mat = obj.mat
            matName = mat.name
    
            if (matchpattern matName pattern:"XRAYMAT_*" ignoreCase:false == true) then
            (    
                matName = substituteString matName "XRAYMAT_" ""    
                
                for m in scenematerials do
                (
                    if m.name == matName do mat = m
                )
                obj.mat = mat
            )
    
            else 
            (
                XrayMat = standardMaterial () 
                XrayMat.name = "XRAYMAT_"+matName
                XrayMat.opacity = opacityAmount
                obj.mat = XrayMat
            )
        )
        )--try
        catch()
    )
    
    
    Didn't have time to go further. It won't work on an object with no material (yet).
    I put a try/catch so atleast it wont crash.

    It works with material name so if you have several materials with the same name (but you shouldn't uh), it might not apply the good material.

    Also I have to put the old material on a new node, because it mays be lost if it isn't present anywhere else.

    You can set the opacity percentage you want in opacityAmount
  • monster
    Options
    Offline / Send Message
    monster polycounter
    Revel wrote: »
    Hi monster, I'm wondering is there any benefit of using obj property>visibility value instead of see through mode? also I notice that the obj property>visibility didn't work with DirectX shader, but see through work.

    There are a couple of benefits. 3ds Max will render the visibility using Scanline and Mental Ray renderers. And you can set the opacity value unlike See Through mode. And you don't need a material assigned. I guess it doesn't work with DX Shaders, but neither would a material.

    Here's a visibility toggle script I had floating around.
    macroScript monsterToggleVis
    	category:"monsterBlues"
    	buttonText:"Toggle Vis"
    	toolTip:"Toggle Visibility"
    (
    	sel = getCurrentSelection()
    
    	visValue = 0.2
    
    	for obj in sel do
    	(
    		if getVisController obj != undefined do
    		(
    			if obj.visibility.controller.value != 1.0 then
    			(
    				visValue = 1.0
    			)
    
    			exit
    		)
    	)
    
    	for obj in sel do
    	(
    		if getVisController obj == undefined do obj.visibility = bezier_float()
    		--obj.visibility.controller.value = if obj.visibility.controller.value != 1.0 then 1.0 else 0.2
    		obj.visibility.controller.value = visValue
    	)
    
    	select sel
    )
    
Sign In or Register to comment.