Skip to content
Snippets Groups Projects
Commit 7ea523d8 authored by Campbell Barton's avatar Campbell Barton
Browse files

use the alpha of an image for the alpha channel when using FBX/Cycles

parent 6e62352c
Branches
Tags
No related merge requests found
...@@ -269,7 +269,7 @@ class CyclesShaderWrapper(): ...@@ -269,7 +269,7 @@ class CyclesShaderWrapper():
self.node_out.inputs["Displacement"]) self.node_out.inputs["Displacement"])
@staticmethod @staticmethod
def _image_create_helper(image, node_dst, sockets_dst): def _image_create_helper(image, node_dst, sockets_dst, use_alpha=False):
tree = node_dst.id_data tree = node_dst.id_data
nodes = tree.nodes nodes = tree.nodes
links = tree.links links = tree.links
...@@ -279,7 +279,7 @@ class CyclesShaderWrapper(): ...@@ -279,7 +279,7 @@ class CyclesShaderWrapper():
node.location = node_dst.location node.location = node_dst.location
node.location.x -= CyclesShaderWrapper._col_size node.location.x -= CyclesShaderWrapper._col_size
for socket in sockets_dst: for socket in sockets_dst:
links.new(node.outputs["Color"], links.new(node.outputs["Alpha" if use_alpha else "Color"],
socket) socket)
return node return node
...@@ -334,7 +334,10 @@ class CyclesShaderWrapper(): ...@@ -334,7 +334,10 @@ class CyclesShaderWrapper():
def alpha_image_set(self, image): def alpha_image_set(self, image):
self.node_bsdf_alpha.mute = False self.node_bsdf_alpha.mute = False
node = self.node_mix_color_alpha node = self.node_mix_color_alpha
self._image_create_helper(image, node, (node.inputs["Color2"],)) # note: use_alpha may need to be configurable
# its not always the case that alpha channels use the image alpha
# a greyscale image may also be used.
self._image_create_helper(image, node, (node.inputs["Color2"],), use_alpha=True)
def alpha_image_set_from_diffuse(self): def alpha_image_set_from_diffuse(self):
tree = self.node_mix_color_diff.id_data tree = self.node_mix_color_diff.id_data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment