Skip to content

Instantly share code, notes, and snippets.

@caiwan
Last active September 4, 2017 09:13
Show Gist options
  • Save caiwan/c7b21bce94106b400b6cb0250222afe8 to your computer and use it in GitHub Desktop.
Save caiwan/c7b21bce94106b400b6cb0250222afe8 to your computer and use it in GitHub Desktop.
Handy blender scripts
# quick add pbr texture names to properties
# used in grafkit2
for material in bpy.data.materials:
for key in ["metalness", "normal", "roughness"]:
material["mat_{0}".format(key)] = "pbr_{0}_{1}.jpg".format(material.name, key)
# a bit refined version, which add emissive map if emission was set
for material in bpy.data.materials:
for key in ["metalness", "normal", "roughness", "emission"]:
if key == "emission" and material.emit < 0.0001:
continue
material["mat_{0}".format(key)] = "pbr_{0}_{1}.jpg".format(material.name, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment