Py NodeShader wrapper helper: add support for new Alpha setting of Principled BSDF.

Now that we have real alpha in BSDF, it's much better option for
transparency, than previously used Transmission value.

Related to T64609.
This commit is contained in:
Bastien Montagne 2019-05-15 20:58:18 +02:00
parent 9baf669493
commit f9784ea6af
1 changed files with 26 additions and 2 deletions

View File

@ -446,8 +446,32 @@ class PrincipledBSDFWrapper(ShaderWrapper):
transmission_texture = property(transmission_texture_get)
# TODO: Do we need more complex handling for alpha (allowing masking and such)?
# Would need extra mixing nodes onto Base Color maybe, or even its own shading chain...
def alpha_get(self):
if not self.use_nodes or self.node_principled_bsdf is None:
return 1.0
return self.node_principled_bsdf.inputs["Alpha"].default_value
@_set_check
def alpha_set(self, value):
if self.use_nodes and self.node_principled_bsdf is not None:
self.node_principled_bsdf.inputs["Alpha"].default_value = value
alpha = property(alpha_get, alpha_set)
# Will only be used as gray-scale one...
def alpha_texture_get(self):
if not self.use_nodes or self.node_principled_bsdf is None:
return None
return ShaderImageTextureWrapper(
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["Alpha"],
grid_row_diff=-1,
)
alpha_texture = property(alpha_texture_get)
# --------------------------------------------------------------------
# Normal map.