[Bf-extensions-cvs] [3fbcd35f] master: glTF: Fix factors export after Mix Node change in Blender
Julien Duroure
noreply at git.blender.org
Sat Dec 10 00:32:32 CET 2022
Commit: 3fbcd35feb2a2c06ce1200bee648a9f39583d37e
Author: Julien Duroure
Date: Sat Dec 10 00:32:10 2022 +0100
Branches: master
https://developer.blender.org/rBA3fbcd35feb2a2c06ce1200bee648a9f39583d37e
glTF: Fix factors export after Mix Node change in Blender
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
M io_scene_gltf2/blender/exp/gltf2_blender_get.py
M io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
M io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_sheen.py
M io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_specular.py
M io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 8b5b6d34..2da12265 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,8 +4,8 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (3, 5, 5),
- 'blender': (3, 3, 0),
+ "version": (3, 5, 6),
+ 'blender': (3, 4, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
'warning': '',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
index 01d261be..8c7cf80b 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
@@ -123,14 +123,14 @@ def __gather_occlusion_strength(primary_socket, export_settings):
# Look for a MixRGB node that mixes with pure white in front of
# primary_socket. The mix factor gives the occlusion strength.
node = gltf2_blender_get.previous_node(primary_socket)
- if node and node.type == 'MIX_RGB' and node.blend_type == 'MIX':
- fac = gltf2_blender_get.get_const_from_socket(node.inputs['Fac'], kind='VALUE')
- col1 = gltf2_blender_get.get_const_from_socket(node.inputs['Color1'], kind='RGB')
- col2 = gltf2_blender_get.get_const_from_socket(node.inputs['Color2'], kind='RGB')
+ if node and node.type == 'MIX' and node.blend_type == 'MIX':
+ fac = gltf2_blender_get.get_const_from_socket(node.inputs['Factor'], kind='VALUE')
+ col1 = gltf2_blender_get.get_const_from_socket(node.inputs[6], kind='RGB')
+ col2 = gltf2_blender_get.get_const_from_socket(node.inputs[7], kind='RGB')
if fac is not None:
- if col1 == [1, 1, 1] and col2 is None:
+ if col1 == [1.0, 1.0, 1.0] and col2 is None:
return fac
- if col1 is None and col2 == [1, 1, 1]:
+ if col1 is None and col2 == [1.0, 1.0, 1.0]:
return 1.0 - fac # reversed for reversed inputs
return None
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_get.py b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
index dacfbf4a..1a5bb681 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_get.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
@@ -244,14 +244,14 @@ def get_factor_from_socket(socket, kind):
if node is not None:
x1, x2 = None, None
if kind == 'RGB':
- if node.type == 'MIX_RGB' and node.blend_type == 'MULTIPLY':
+ if node.type in 'MIX' and node.data_type == "RGBA" and node.blend_type == 'MULTIPLY':
# TODO: handle factor in inputs[0]?
- x1 = get_const_from_socket(node.inputs[1], kind)
- x2 = get_const_from_socket(node.inputs[2], kind)
+ x1 = get_const_from_socket(node.inputs[6], kind)
+ x2 = get_const_from_socket(node.inputs[7], kind)
if kind == 'VALUE':
if node.type == 'MATH' and node.operation == 'MULTIPLY':
x1 = get_const_from_socket(node.inputs[0], kind)
- x2 = get_const_from_socket(node.inputs[1], kind)
+ x2 = get_const_from_socket(node.inputs[1], kind)
if x1 is not None and x2 is None: return x1
if x2 is not None and x1 is None: return x2
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
index 19a394b9..0af88f04 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
@@ -117,16 +117,17 @@ def specular_glossiness(mh, location, specular_socket, roughness_socket):
# Mix in spec/gloss factor
if spec_factor != [1, 1, 1] or gloss_factor != 1:
if spec_factor != [1, 1, 1]:
- node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
+ node = mh.node_tree.nodes.new('ShaderNodeMix')
+ node.data_type = 'RGBA'
node.label = 'Specular Factor'
node.location = x - 140, y
node.blend_type = 'MULTIPLY'
# Outputs
mh.node_tree.links.new(specular_socket, node.outputs[0])
# Inputs
- node.inputs['Fac'].default_value = 1.0
- specular_socket = node.inputs['Color1']
- node.inputs['Color2'].default_value = spec_factor + [1]
+ node.inputs['Factor'].default_value = 1.0
+ specular_socket = node.inputs[6]
+ node.inputs[7].default_value = spec_factor + [1]
if gloss_factor != 1:
node = mh.node_tree.nodes.new('ShaderNodeMath')
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_sheen.py b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_sheen.py
index aa5cef75..91c202eb 100644
--- a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_sheen.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_sheen.py
@@ -40,16 +40,17 @@ def sheen( mh,
# Mix sheenColor factor
sheenColorFactor = sheenColorFactor + [1.0]
if sheenColorFactor != [1.0, 1.0, 1.0, 1.0]:
- node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
+ node = mh.node_tree.nodes.new('ShaderNodeMix')
node.label = 'sheenColor Factor'
+ node.data_type = 'RGBA'
node.location = x_sheenColor - 140, y_sheenColor
node.blend_type = 'MULTIPLY'
# Outputs
mh.node_tree.links.new(sheenColor_socket, node.outputs[0])
# Inputs
- node.inputs['Fac'].default_value = 1.0
- sheenColor_socket = node.inputs['Color1']
- node.inputs['Color2'].default_value = sheenColorFactor
+ node.inputs['Factor'].default_value = 1.0
+ sheenColor_socket = node.inputs[6]
+ node.inputs[7].default_value = sheenColorFactor
x_sheenColor -= 200
texture(
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_specular.py b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_specular.py
index 3441b5ad..35afcc3e 100644
--- a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_specular.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_specular.py
@@ -335,16 +335,17 @@ def original_specular( mh,
specular_color_factor = list(specular_color_factor) + [1.0]
if specular_color_factor != [1.0, 1.0, 1.0, 1.0]:
# Mix specularColorFactor
- node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
+ node = mh.node_tree.nodes.new('ShaderNodeMix')
node.label = 'SpecularColor Factor'
+ node.data_type = 'RGBA'
node.location = x_specularcolor - 140, y_specularcolor
node.blend_type = 'MULTIPLY'
# Outputs
mh.node_tree.links.new(original_specularcolor_socket, node.outputs[0])
# Inputs
- node.inputs['Fac'].default_value = 1.0
- original_specularcolor_socket = node.inputs['Color1']
- node.inputs['Color2'].default_value = specular_color_factor
+ node.inputs['Factor'].default_value = 1.0
+ original_specularcolor_socket = node.inputs[6]
+ node.inputs[7].default_value = specular_color_factor
x_specularcolor -= 200
texture(
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
index 18cb68ab..519fe221 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
@@ -316,16 +316,17 @@ def emission(mh: MaterialHelper, location, color_socket, strength_socket):
# Otherwise, use a multiply node for it
else:
if emissive_factor != [1, 1, 1]:
- node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
+ node = mh.node_tree.nodes.new('ShaderNodeMix')
node.label = 'Emissive Factor'
+ node.data_type = 'RGBA'
node.location = x - 140, y
node.blend_type = 'MULTIPLY'
# Outputs
mh.node_tree.links.new(color_socket, node.outputs[0])
# Inputs
- node.inputs['Fac'].default_value = 1.0
- color_socket = node.inputs['Color1']
- node.inputs['Color2'].default_value = emissive_factor + [1]
+ node.inputs['Factor'].default_value = 1.0
+ color_socket = node.inputs[6]
+ node.inputs[7].default_value = emissive_factor + [1]
x -= 200
@@ -381,16 +382,17 @@ def base_color(
needs_alpha_factor = base_color_factor[3] != 1.0 and alpha_socket is not None
if needs_color_factor or needs_alpha_factor:
if needs_color_factor:
- node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
+ node = mh.node_tree.nodes.new('ShaderNodeMix')
node.label = 'Color Factor'
+ node.data_type = "RGBA"
node.location = x - 140, y
node.blend_type = 'MULTIPLY'
# Outputs
mh.node_tree.links.new(color_socket, node.outputs[0])
# Inputs
- node.inputs['Fac'].default_value = 1.0
- color_socket = node.inputs['Color1']
- node.inputs['Color2'].default_value = base_color_factor[:3] + [1]
+ node.inputs['Factor'].default_value = 1.0
+ color_socket = node.inputs[6]
+ node.inputs[7].default_value = base_color_factor[:3] + [1]
if needs_alpha_factor:
node = mh.node_tree.nodes.new('ShaderNodeMath')
@@ -413,7 +415,7 @@ def base_color(
# Mix texture and vertex color together
if base_color_texture is not None a
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list