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-17 12:35:38 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-10-17 12:43:11 +0300
commitd89b65cc91a63544168b5330ba1a288f5c826e15 (patch)
tree176ef875d0b11443a669e94afceadb9ecb8dd404
parentdffe702d782990b2b6fd36767254d35ab47f25eb (diff)
Node shader wrapper: use 'Non-Color' profile for BW textures inputs.
All the single-value texture inputs of Principled BSDF node should use non-color colorspace profile, not sRGB one (issue raised in https://blender.stackexchange.com/questions/155617, thanks). That also revealed another issue - since those color space settings are stored at the image level itself, not the node one, we need to duplicate those image data-blocks when we use same picture for e.g. base color (sRGB) and specular (non-color) inputs... For now using a basic mechanism for that, might generate several extra, uneeded copies of the image ID, but that’s better than breaking custom settings and such. Note that while this will modify the behavior of the impporters using that node wrapper, no change should be needed in IO add-ons themselves.
-rw-r--r--release/scripts/modules/bpy_extras/node_shader_utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/release/scripts/modules/bpy_extras/node_shader_utils.py b/release/scripts/modules/bpy_extras/node_shader_utils.py
index 720d1d8af5a..ce5edde5adf 100644
--- a/release/scripts/modules/bpy_extras/node_shader_utils.py
+++ b/release/scripts/modules/bpy_extras/node_shader_utils.py
@@ -336,6 +336,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["Specular"],
grid_row_diff=0,
+ colorspace_name='Non-Color',
)
specular_texture = property(specular_texture_get)
@@ -367,6 +368,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["Roughness"],
grid_row_diff=0,
+ colorspace_name='Non-Color',
)
roughness_texture = property(roughness_texture_get)
@@ -398,6 +400,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["Metallic"],
grid_row_diff=0,
+ colorspace_name='Non-Color',
)
metallic_texture = property(metallic_texture_get)
@@ -428,6 +431,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["IOR"],
grid_row_diff=-1,
+ colorspace_name='Non-Color',
)
ior_texture = property(ior_texture_get)
@@ -455,6 +459,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["Transmission"],
grid_row_diff=-1,
+ colorspace_name='Non-Color',
)
transmission_texture = property(transmission_texture_get)
@@ -482,6 +487,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
self, self.node_principled_bsdf,
self.node_principled_bsdf.inputs["Alpha"],
grid_row_diff=-1,
+ colorspace_name='Non-Color',
)
alpha_texture = property(alpha_texture_get)
@@ -568,6 +574,7 @@ class ShaderImageTextureWrapper():
"grid_row_diff",
"use_alpha",
"colorspace_is_data",
+ "colorspace_name",
*NODES_LIST,
)
@@ -580,7 +587,7 @@ class ShaderImageTextureWrapper():
return instance
def __init__(self, owner_shader: ShaderWrapper, node_dst, socket_dst, grid_row_diff=0,
- use_alpha=False, colorspace_is_data=...):
+ use_alpha=False, colorspace_is_data=..., colorspace_name=...):
self.owner_shader = owner_shader
self.is_readonly = owner_shader.is_readonly
self.node_dst = node_dst
@@ -588,6 +595,7 @@ class ShaderImageTextureWrapper():
self.grid_row_diff = grid_row_diff
self.use_alpha = use_alpha
self.colorspace_is_data = colorspace_is_data
+ self.colorspace_name = colorspace_name
self._node_image = ...
self._node_mapping = ...
@@ -685,7 +693,13 @@ class ShaderImageTextureWrapper():
@_set_check
def image_set(self, image):
if self.colorspace_is_data is not ...:
+ if image.colorspace_settings.is_data != self.colorspace_is_data and image.users >= 1:
+ image = image.copy()
image.colorspace_settings.is_data = self.colorspace_is_data
+ if self.colorspace_name is not ...:
+ if image.colorspace_settings.is_data != self.colorspace_is_data and image.users >= 1:
+ image = image.copy()
+ image.colorspace_settings.name = self.colorspace_name
self.node_image.image = image
image = property(image_get, image_set)