Announcement

Collapse
No announcement yet.

Script or global settings for a scene roll back

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

  • Script or global settings for a scene roll back

    Is there a script or global setting that allows to set the Vray Dirt Ambient Occ mode to "Ambient Occlusion" for all shaders in Vray Next?

    I had to roll back a few scenes from Max 2022+Vray 5 to Max 2020+Vray Next for a client, and realized my shaders lost the "Invert Normal" effect (to get the worn-out corners on the model) when I opened the scene in Max 2020.

    When I checked the shaders, the Vray Dirt Ambient Occ model I use as the Blend Mask between two shaders (Invert Normals enabled and -1.0 for Distribution) was all blank, since it does not carry back the "Inner Occlusion" method from Vray 5.


    I hope this makes sense.


    Thanks!


    -Fausto.






    Attached Files

  • #2
    Sure, here:

    Code:
    (
        theDirts = getclassinstances vraydirt
        for d in theDirts do --act on all collected dirts, without any condition.
        (
           d.mode = 0 --this is ambient occlusion. Set to 4 to use "Inner Occlusion"
           d.subdivs = 3 --This is the new default for subdivs, it will spare you eccessive rendertimes for no visual degradation.
        )
    )
    Copy the text in a new script (open the script editor for that) and then press ctrl+e to execute it all.

    Two things worth noticing:
    the script will change *all* the dirts in a given scene to ambient occlusion.
    This may not be desirable, but to ensure we only act on the offending maps, i'd need a copy of one such map, so to figure out what the error is (f.e. the .mode property set to 6, when we now only have 5.).
    I also added a change to the subdivs, as otherwise you'll incur in much longer rendertimes for no visual improvement.
    Lele
    Trouble Stirrer in RnD @ Chaos
    ----------------------
    emanuele.lecchi@chaos.com

    Disclaimer:
    The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

    Comment


    • #3
      Awesome! I really appreciate the help Lele, I will give this a run!

      Cheers,


      -Fausto.

      Comment


      • #4
        Lele, it worked like magic!!! It turned all the Modes to Ambient Occlusion and the distribution is enabled which is what I needed!


        The only thing that is still turned off is the "Invert Normal" parameter (image attached). Is this something that can be enabled with the script?


        Much appreciated and thanks so much for your time!


        -Fausto.
        Attached Files

        Comment


        • #5
          Originally posted by FaustoDeMartini View Post
          The only thing that is still turned off is the "Invert Normal" parameter (image attached). Is this something that can be enabled with the script?
          I don't have the parameter in either the UI or in the node properties i can query with maxscript.
          What exact version are you on, so i can see if it's still available there?
          Lele
          Trouble Stirrer in RnD @ Chaos
          ----------------------
          emanuele.lecchi@chaos.com

          Disclaimer:
          The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

          Comment


          • #6
            I'm using your script in Max 2020 (update 1) and Vray Next, update 3.2 (4.30.02 build 00001)







            Comment


            • #7
              Eheh, this is the second time in *three minutes* i assume the V-Ray version wrong.
              Please give me a minute to get this sorted.
              Lele
              Trouble Stirrer in RnD @ Chaos
              ----------------------
              emanuele.lecchi@chaos.com

              Disclaimer:
              The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

              Comment


              • #8
                hahaha, no worries Lele! I feel bad for asking so much already, but I REALLY appreciate the help!



                Comment


                • #9
                  Here's the modified script.
                  It's safe to run it time and again.
                  Code:
                  (
                      theDirts = getclassinstances vraydirt
                      for d in theDirts do --act on all collected dirts, without any condition.
                      (
                         d.mode = 0 --this is ambient occlusion. Set to 4 to use "Inner Occlusion"
                         d.subdivs = 3 --This is the new default for subdivs, it will spare you eccessive rendertimes for no visual degradation.
                         try (d.invert_normal = false) catch () --the try/catch is needed as the option doesn't exist in v. 5.x and later, so the script would error out.
                      )
                  )
                  Note that the "invert normals" option is going away entirely in V5.x and later.
                  The script won't error, but the option will be considered off.

                  p.s.: you're very welcome.
                  Last edited by ^Lele^; 03-03-2022, 11:52 AM.
                  Lele
                  Trouble Stirrer in RnD @ Chaos
                  ----------------------
                  emanuele.lecchi@chaos.com

                  Disclaimer:
                  The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                  Comment


                  • #10
                    Lele, it doesn't catch the Invert Normal. I can understand since it was removed altogether in 5

                    I have to resort to enable manually haha. I wish Max/Vray had more ways to make global changes like that. Set global parameters in shaders, modifiers, etc

                    Thanks so much for all the help, your script saved me thousands of clicks already!




                    Comment


                    • #11
                      Duh me, there is a glaring mistake in the code.
                      Try again, i edited the post.

                      Do you know "Zorb's Modifier Modifier" script?
                      Lele
                      Trouble Stirrer in RnD @ Chaos
                      ----------------------
                      emanuele.lecchi@chaos.com

                      Disclaimer:
                      The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                      Comment


                      • #12
                        It worked!!

                        I had to make one change:


                        (
                        theDirts = getclassinstances vraydirt
                        for d in theDirts do --act on all collected dirts, without any condition.
                        (
                        d.mode = 0 --this is ambient occlusion. Set to 4 to use "Inner Occlusion"
                        d.subdivs = 3 --This is the new default for subdivs, it will spare you eccessive rendertimes for no visual degradation.
                        try (d.invert_normal = true) catch () --the try/catch is needed as the option doesn't exist in v. 5.x and later, so the script would error out.
                        )
                        )


                        I had to change this line: try (d.invert_normal = true) since I want the Invert Normal to be ENABLED.

                        The only issue is, I use Vray Dirt to mask between Blend shaders on edges and then a Vray Dirt for crevices in the base shader (which needs the Invert normal to be OFF), and there is no way to selectively say: Add invert normal here, but not here haha

                        Btw, I'm learning quite a bit about scripts one this process, thanks so much for your time!


                        I did not know about Zorb's Mod. Script! Have you tested in Max 2020 up?











                        Last edited by FaustoDeMartini; 03-03-2022, 12:45 PM.

                        Comment


                        • #13
                          You made my day: i wrote the little script as explicatively as i could hoping you'd feel comfy and make some change if needed.

                          You can most definitely do all you mentioned.
                          If you find the time, pack me a simple scene (email will do) where there's an old material in the material editor, and the same material manually converted to be as you want it in the next slot, and i'll prepare and send you the script.

                          Should you get more curious about scripting your way out of millions of clicks, there are a few places you may want to look into.
                          This is the full maxscript 101 course from the very creator, John Wainwright, now made free. Little trivia, he's also Amazon's customer #1.
                          Any of Bobo's courseware are exceptional, and all of them are now out of sale, so you'll have to get creative (Bobo doesn't mind at all, i know this from him, so go torrent them if you can find them!).
                          Dave's material is also top notch, so head here to peruse any of it (watch out that the tutorials are varied in nature and complexity.).
                          Much more modestly, and without any pretense of cohesion or completeness, there's a post i made here (call it rush-scripting, if you wish, for when you're in desperate need.).

                          In any case, you should absolutely install dark scintilla, and get away from the nigh-unusable default editor colors.

                          Zorb's MM has been tied to my ctrl+shift+alt+z key combo since time immemorial, and it still works in max 2022 without updates (that is the mark of someone knowing what they are doing...).
                          Lele
                          Trouble Stirrer in RnD @ Chaos
                          ----------------------
                          emanuele.lecchi@chaos.com

                          Disclaimer:
                          The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                          Comment


                          • #14
                            Lele, you are too kind my friend <3

                            I'm not sure how much I can thank you for all you help!! I will package the scene you mentioned with a jpg file explaining how I setup the shaders


                            Thanks so much for all the links and suggestions! I will definitely look into it!!




                            Comment


                            • #15
                              Email sent! Please let me know if you haven't received it

                              Comment

                              Working...
                              X