Last active
May 28, 2021 19:21
-
-
Save lampysprites/91191246b2953fb35fb6b2af4182f9fd to your computer and use it in GitHub Desktop.
Convert blender materials to pixel shadeless
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
## For materials that have an image and a principled bsdf (like .obj imports fo instance) | |
## it will re-connect and set up everything to pixely emission with binary alpha | |
## IMPORTANT | |
## it will fuck up everything else that has an image texture and bsdf | |
## add some if's that make sence in your case | |
for mat in bpy.data.materials: | |
try: | |
mat.blend_method = 'CLIP' | |
mat.use_backface_culling = True | |
nt = mat.node_tree | |
img = nt.nodes['Image Texture'] | |
bsdf = nt.nodes['Principled BSDF'] | |
img.interpolation = 'Closest' | |
nt.links.remove(img.outputs['Color'].links[0]) | |
nt.links.new(img.outputs['Color'], bsdf.inputs['Emission']) | |
nt.links.new(img.outputs['Alpha'], bsdf.inputs['Alpha']) | |
bsdf.inputs['Base Color'].default_value = (0, 0, 0, 0) | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment