Script request- Vray material options rollout/ glossy rays
Hey guys,
first of all thanks for the great content on this site and thanks to the people contributing. I am new here, and have zero scripting experience... but would it be ok to ask for a (hopefully simple) script?
When dealing with reflective/glossy materials or when I use the Vray lens effect, I get weird artefacts on my renders (I use 3dsMax 2017 and Vray 3.4). The only solution that solved this issue completely was to change for each vray material the option 'treat glossy rays as GI rays' to 'Always', in the 'options' rollout of Vray materials (the default is always set to 'only for GI rays'). In a scene with many materials, this can become quite a time-consuming job.
This is why I would like to ask for a script that can do this automatically (for all Vray materials in the scene, to automatically change the 'treat glossy rays as GI rays' option from 'only for GI rays' to 'Always'). Since I have no programming/scripting knowledge, I have no idea if that is even possible; but I thought to give it a try. Any help would be much appreciated :)
Thanks!
Comments
Why such a long code for
Why such a long code for this?
You can actually have a much shorter writing and it will work fine:
Real Code Working
This should work
Amazing job
Amazing job mate, thank you :) I def owe you a beer. Haven't tested it for the VrayBlend, but it works like a charm for multimaterials and vray materials. Thanks sooo much!!!
Thank you
Thank you sooo much mate, it works like a charm. For each Vray material that is applied to an object in the scene, the 'treat glossy rays as GI rays' option is now automatically set to 'Always' after running the script- exactly what I wanted. You really helped me out a lot with this, I am truly grateful :)
New Version
I'm glad it did !
If you have heavy scene and script is low when executing you can use the code in the other comments. Thanks to vusta the operatiosn are conducted on scene materials directly instead of browsing trough objects.
Don't hesitate to contact me if you need something else.
More testing
Hey mate, thanks again for the great work; it helped me a lot. About the second version of the script, I can't get it to work :( Here's the error:
Error occurred in anonymous codeblock; filename: C:\Users\Hory\Desktop\New Archi\Setari Vray\alternative_glossyraysmodifier.ms; position: 64; line: 4
-- Type error: Material library index must be number or name, got: Default:Standard
-- MAXScript callstack:
-- thread data: threadID:4012
-- ------------------------------------------------------
-- [stack level: 0]
-- In i loop; filename: C:\Users\Hory\Desktop\New Archi\Setari Vray\alternative_glossyraysmodifier.ms; position: 65; line: 4
-- Parameters:
-- i: Default:Standard
-- Locals:
-- i: Default:Standard
-- Externals:
-- sceneMaterials: SystemGlobal:sceneMaterials : #materialLibrary()
-- owner: undefined
-- ------------------------------------------------------
-- [stack level: 1]
-- called from top-level
The first version you posted in this thread is great; eased my work quite a bit. However, I noticed that it does have some issues regarding multi/sub object materials (or blend material, I just noticed): for some materials in the stack, the 'treat glossy rays as GI rays' parameter gets set to 'Always' (as intended); whereas for others it just stays at the default settings ('only for GI rays'). Any ideea if it would be possible to fix this as well?
Many thanks again, mate!
2nd version
I haven't tested the second version but i might know where it stucks.
For the blendMtl it is normal that no changes appears because the actual script is not looking inside blendMtl. But we could do something about it for sure !
I do not have access to any computer with 3ds max but I'll reach you on Monday.
For now this code should Work and you should look into the maxscript documentation in order to treat blendMtl.
i'm actually writing it on m'y phone so There Will probably be some typing issues and i didn't tested it
testing
Thank you again for doing this, mate!
I tested this script; unfortunately it gives the following error:
Error occurred in anonymous codeblock; filename: ; position: 199; line: 10
-- Syntax error: at .., expected
-- In line: i.mat2...
Any help would be much appreciated :)
Vray material options rollout/ glossy rays
Hello, Here is a piece of code that should do what you need. Feel free to test it and make me some feedback about it.
question...
in non programmer speak...
why are we counting objects when we should be counting vray materials ? so say we have 1 million objects, all assigned with the same vray material...why should we then do the same thing 1 million times ?