Home Technical Talk

Max Script - Self Illumination + Display texture in viewport

Hi guys,

Any help would be greatly appreciated. Currently I have to do a really repetitive process at work for hundreds of models and I was wondering if any of you guys had a max script to reduce the process time.

My process involves:
Increasing the self illumination to 100% then pressing the' display texture in viewport' button for every individual material within a multi/sub object material.

If anyone can help please post!

Thanks :)

Replies

  • SyncViewS
    Options
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi, I need a little bit of information: do you want to increase Self-Illumination to 100% only, or you want to set Diffuse as White too? Because if the Diffuse isn't white, the "illuminated" part gets the Diffuse tint. Otherwise you can set Self-Illumination to colour white, but you'll loose the "preview" in the editor, because it will be displayed as uniform white. The script is ready, please tell me how to finish it.
  • fr0gg1e
    Options
    Offline / Send Message
    fr0gg1e polycounter lvl 17
    Right click on the view label (in the 3D viewport at top, displaying the name of the view you're currently in) and in the drop down menue go to other - Flat.
    Then go to View menu very top, to the left,and choose Activate all maps to display all maps in one go.
    Now it doesn't turn on self illum to 100%, it's just a viewport "style" si if you need to export your model at 100% self illum for some obscure reasons, you're out of luck for this one.
    Scriptspot.com might help in that case.
  • NuggetOG
    Options
    Offline / Send Message
    Sorry maybe I should have expanded on what I'm trying to achieve.

    I'm baking over 500 models which have been generated by another program. The models are simple boxes of different dimensions and ratios. Each model has a multisub material with 6 materials which need changing to 100% self illumination for baking. I also need to view the materials in the viewport so I can check they are mapped correctly. Once this is done the model is then baked.

    I have to bake it manually because the automatic packing doesn't work very well.


    I've managed to get a script working which displays all the textures in the viewport and I'm trying to adapt it so that it changes the illumination to 100%. Here is the script so far:
    (
        on execute do
        (
                    for object in selection do
                    
                        if (classOf object.material == Standard) then
                            (
                            object.material.showInViewport = on                            
                            object.material.selfIllumAmount = 100
                            )
                        else if (classOf object.material == Multimaterial) then
                            (
                                for b = 1 to b = object.material.numsubs do
                                (
                                    if (classOf object.material.materialList[b] == Standard) then
                                    ( 
                                        object.material.showInViewport = on
                                        object.material.selfIllumAmount = 100
                                    )
                                )
                            )
        )
    )
    
    
    

    The code breaks when trying to set the illumination to 100% in a multi/sub material but works for a standard material. If you take out the self illumination lines the display all in viewport works with both a standard and a multi/sub material.
  • SyncViewS
    Options
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi, I got the code, a patch of mine and yours, still don't know if you want to set the diffuse colour to white too. Not super tested, let me know if you got any issue, or want to extend it.
    MacroScript SelfIllumination
    category:"EdNWoodysScripts"
    tooltip:"Change Materials to Self Illuminated"
    ButtonText:"SelfIlluminated"
    (
        on execute do
        (
            for theNode in (Selection as Array) where ((superClassOf theNode) == GeometryClass) do
            (
                local theMaterial = theNode.material
        
                if ((classOf theMaterial) == Standard) then
                (    
                    theMaterial.selfIllumAmount = 100
        
                    if ((classOf theMaterial.diffuseMap) == BitmapTexture) then
                    (
                        theMaterial.opacityMap = theMaterial.diffuseMap
                        theMaterial.opacityMap.monoOutput = 1
                    )
        
                    showTextureMap theMaterial true
                )
                else if ((classOf theMaterial) == MultiMaterial) then
                (
                    for theSubMat in theMaterial.materialList where ((classOf theSubMat) == Standard) do
                    (
                        theSubMat.selfIllumAmount = 100
        
                        if ((classOf theSubMat.diffuseMap) == BitmapTexture) then
                        (
                            theSubMat.opacityMap = theSubMat.diffuseMap
                            theSubMat.opacityMap.monoOutput = 1
                        )
        
                        showTextureMap theSubMat true
                    )
                )
            )
        
            updateToolbarButtons()
        )
    )
    
  • NuggetOG
    Options
    Offline / Send Message
    Hey

    Thank you so much for you help,

    I have managed to achive what i wanted to achive with the help of your code.

    So the final script is:
    (
        on execute do
        (
            for theNode in (Selection as Array) where ((superClassOf theNode) == GeometryClass) do
            (
                local theMaterial = theNode.material
        
                if ((classOf theMaterial) == Standard) then
                (    
                    theMaterial.selfIllumAmount = 100
                    showTextureMap theMaterial true
                )
                else if ((classOf theMaterial) == MultiMaterial) then
                (
                    for theSubMat in theMaterial.materialList where ((classOf theSubMat) == Standard) do
                    (
                        theSubMat.selfIllumAmount = 100
                        showTextureMap theSubMat true
                    )
                )
            )
            updateToolbarButtons()
        )
    )
    

    This will increase the self illumination to 100% and 'display texture in viewport' for a multi/sub object matierial.

    Thnak so much this will save me alot of time :thumbup: :)
Sign In or Register to comment.