I have a bunch of metallic materials that use the Principled BDSF, and I need to change all of them from a metallic value of 10 to a metallic value of 1. Can this be done using a script?
$\begingroup$
$\endgroup$
3
-
$\begingroup$ Yes, it can, though I’m not sure how. Check out docs.blender.org for the main manual and the Python api docs. $\endgroup$– TheLabCatCommented Feb 21, 2021 at 20:49
-
1$\begingroup$ PS: I did some code on GitHub.com that messes with shader nodes, though it does not do what you want. It might give you an idea of how the API works, though. github.com/thelabcat/SMD-Model-PostImport/blob/main/… $\endgroup$– TheLabCatCommented Feb 21, 2021 at 20:51
-
$\begingroup$ "metallic value of 10 to a metallic value of 1" I don't think this will have a visible effect. I think the metallic factor is just a lerp factor between "metal" and "nonmetal" and gets clamped to [0,1]. $\endgroup$– scurestCommented Feb 21, 2021 at 21:54
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
Shamelessly modified from:
Automatically change the properties of multiple materials
import bpy
for mat in bpy.data.materials:
if not mat.use_nodes:
mat.metallic = 1
continue
for n in mat.node_tree.nodes:
if n.type == 'BSDF_PRINCIPLED':
n.inputs["Metallic"].default_value = 1