KeyShot Forum

Technical discussions => Extending KeyShot => Scripting => Topic started by: Crocq on January 24, 2017, 07:14:55 AM

Title: Script to replace difuse
Post by: Crocq on January 24, 2017, 07:14:55 AM
Hello guys,

I'm am a new user of Keyshot and i am looking a way to make a script to get a proper relfection map
I would replace all diffuses maps of my scene by a black map.
I there a command line to Get/Set the diffuse map in a material or any workaround?

Thank you
Title: Re: Script to replace difuse
Post by: LayC42 on January 24, 2017, 09:03:17 AM
you can add a new scene set to switch between original material and "black" material. Then apply the new black material from your library to the top group in your scene tree to change any material to the black one.
That's all - no script needed!

hope that helps
Title: Re: Script to replace difuse
Post by: Crocq on January 24, 2017, 10:33:01 AM
 Thank LayC42,

I would like to keep roughness, specular and bump informations of each materials.
I could make multiple render with different materials overdrive and using the clown pass to use them, but it's not really an elegant solution.

Thank you for your input anyway.
Title: Re: Script to replace difuse
Post by: DMerz III on January 24, 2017, 12:50:45 PM
I think LayC42 was on the right track. If you would like to not change the specular channel, but just the diffuse color, you could make a separate scene-set. And go to your Library menu > colors > Black and drag that over your scene tree to your high level parts. In theory, it should change JUST the diffuse color of everything within. No script needed.

In fact, this is how we make all "white diffuse" renders on our team, although with the added step of right clicking the high level part folder and selecting change material type to diffuse. Drag white on the folder, and viola, everything is white diffuse but all the bumps are still in tact.

hope this helps?

Title: Re: Script to replace difuse
Post by: DMerz III on January 24, 2017, 12:58:44 PM
To backup my theory, I just did a quick test.
Simply dragged over the "black" color swatch from the library onto the top level folder in the scene tree.

There is one caveat, if you're using an image texture map in the diffuse channel, it will not override that unless you toggled down the diffuse channel and check the box that says BLEND WITH COLOR. This color will be black, and if the box is checked, the object will turn black.

Changed this entire scene in 10 seconds with this method.
Title: Re: Script to replace difuse
Post by: Crocq on January 24, 2017, 05:06:19 PM
Thats cool thank you!
But is it removing textures if there is already a diffuse map (jpg/png) ?
Title: Re: Script to replace difuse
Post by: LayC42 on January 24, 2017, 11:01:43 PM
The textures will not be removed if you hold the alt key (and/or shift for labels) while applying the material from the lib.
(sorry, short in time!)