[Bf-blender-cvs] [826db891abe] master: Node Shader wrapper: add access to the Emission color of Principled BSDF node.

Bastien Montagne noreply at git.blender.org
Thu Oct 10 17:21:18 CEST 2019


Commit: 826db891abe810d611922130cfd6c29279c11c11
Author: Bastien Montagne
Date:   Thu Oct 10 17:17:04 2019 +0200
Branches: master
https://developer.blender.org/rB826db891abe810d611922130cfd6c29279c11c11

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.

===================================================================

M	release/scripts/modules/bpy_extras/node_shader_utils.py

===================================================================

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.



More information about the Bf-blender-cvs mailing list