Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-10-10 18:17:04 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-10-10 18:21:06 +0300
commit826db891abe810d611922130cfd6c29279c11c11 (patch)
tree49b80fef7e1e77a9e2cf0e681867ecd89c3fd9a4 /release
parent8ada6855811b7750fdee829306b908a7472c1315 (diff)
Node Shader wrapper: add access to the Emission color of Principled BSDF node.
This did not exist when that wrapper was created, but is supported by many formats, so worth supporting it now. See also T70666.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy_extras/node_shader_utils.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_extras/node_shader_utils.py b/release/scripts/modules/bpy_extras/node_shader_utils.py
index 45741f911f4..720d1d8af5a 100644
--- a/release/scripts/modules/bpy_extras/node_shader_utils.py
+++ b/release/scripts/modules/bpy_extras/node_shader_utils.py
@@ -487,6 +487,35 @@ class PrincipledBSDFWrapper(ShaderWrapper):
alpha_texture = property(alpha_texture_get)
+ # --------------------------------------------------------------------
+ # Emission color.
+
+ def emission_color_get(self):
+ if not self.use_nodes or self.node_principled_bsdf is None:
+ return Color((0.0, 0.0, 0.0))
+ return rgba_to_rgb(self.node_principled_bsdf.inputs["Emission"].default_value)
+
+ @_set_check
+ def emission_color_set(self, color):
+ if self.use_nodes and self.node_principled_bsdf is not None:
+ color = values_clamp(color, 0.0, 1.0)
+ color = rgb_to_rgba(color)
+ self.node_principled_bsdf.inputs["Emission"].default_value = color
+
+ emission_color = property(emission_color_get, emission_color_set)
+
+
+ def emission_color_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["Emission"],
+ grid_row_diff=1,
+ )
+
+ emission_color_texture = property(emission_color_texture_get)
+
# --------------------------------------------------------------------
# Normal map.