diff options
author | Vilem Duha <vilem.duha@gmail.com> | 2019-06-13 01:21:29 +0300 |
---|---|---|
committer | Vilem Duha <vilem.duha@gmail.com> | 2019-06-13 01:22:31 +0300 |
commit | 9df44aaff67d72f06d4d6e8a66a7f3cb19a85d42 (patch) | |
tree | 32694f380f29bbdad61ae60660727d72a97088ce /blenderkit/overrides.py | |
parent | b35189e003e14301df22c264d6c762d6acaa9e2f (diff) |
BlenderKit: fix transparent materials for eevee on upload time
Diffstat (limited to 'blenderkit/overrides.py')
-rw-r--r-- | blenderkit/overrides.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/blenderkit/overrides.py b/blenderkit/overrides.py index 348a3d21..df9b1729 100644 --- a/blenderkit/overrides.py +++ b/blenderkit/overrides.py @@ -147,6 +147,34 @@ def modelProxy(): return False +eevee_transp_nodes = [ + 'BSDF_GLASS', + 'BSDF_REFRACTION', + 'BSDF_TRANSPARENT', + 'PRINCIPLED_VOLUME', + 'VOLUME_ABSORPTION', + 'VOLUME_SCATTER' +] + + +def ensure_eevee_transparency(m): + ''' ensures alpha for transparent materials when the user didn't set it up correctly''' + # if the blend mode is opaque, it means user probably ddidn't know or forgot to + # set up material properly + if m.blend_method == 'OPAQUE': + alpha = False + for n in m.node_tree.nodes: + if n.type in eevee_transp_nodes: + alpha = True + elif n.type == 'BSDF_PRINCIPLED': + i = n.inputs['Transmission'] + if i.default_value > 0 or len(i.links) > 0: + alpha = True + if alpha: + m.blend_method = 'HASHED' + m.shadow_method = 'HASHED' + + class BringToScene(Operator): """Bring linked object hierarchy to scene and make it editable.""" @@ -215,7 +243,7 @@ class BringToScene(Operator): class ModelProxy(Operator): - """Tooltip""" + """Attempt to create proxy armature from the asset""" bl_idname = "object.blenderkit_make_proxy" bl_label = "BlenderKit Make Proxy" @@ -231,7 +259,7 @@ class ModelProxy(Operator): class ColorCorrector(Operator): - """Tooltip""" + """Add color corector to the asset. """ bl_idname = "object.blenderkit_color_corrector" bl_label = "Add color corrector" |