glTF importer/exporter: Various fix for node tree (shader)
This commit is contained in:
parent
23661bdd40
commit
5a774a6dad
Notes:
blender-bot
2023-02-13 13:52:54 +01:00
Referenced by issue blender/blender#102967: 3.4: Potential candidates for corrective releases Referenced by issue blender/blender#102967, 3.4: Potential candidates for corrective releases
|
@ -4,7 +4,7 @@
|
|||
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, 12),
|
||||
"version": (3, 5, 13),
|
||||
'blender': (3, 4, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -68,7 +68,7 @@ def gather_material(blender_material, active_uvmap_index, export_settings):
|
|||
base_material = gltf2_io.Material(
|
||||
alpha_cutoff=__gather_alpha_cutoff(blender_material, export_settings),
|
||||
alpha_mode=__gather_alpha_mode(blender_material, export_settings),
|
||||
double_sided=__gather_double_sided(blender_material, export_settings),
|
||||
double_sided=__gather_double_sided(blender_material, extensions, export_settings),
|
||||
emissive_factor=emissive_factor,
|
||||
emissive_texture=emissive_texture,
|
||||
extensions=extensions,
|
||||
|
@ -196,7 +196,12 @@ def __gather_alpha_mode(blender_material, export_settings):
|
|||
return None
|
||||
|
||||
|
||||
def __gather_double_sided(blender_material, export_settings):
|
||||
def __gather_double_sided(blender_material, extensions, export_settings):
|
||||
|
||||
# If user create a volume extension, we force double sided to False
|
||||
if 'KHR_materials_volume' in extensions:
|
||||
return False
|
||||
|
||||
if not blender_material.use_backface_culling:
|
||||
return True
|
||||
|
||||
|
@ -358,7 +363,7 @@ def __export_unlit(blender_material, active_uvmap_index, export_settings):
|
|||
base_material = gltf2_io.Material(
|
||||
alpha_cutoff=__gather_alpha_cutoff(blender_material, export_settings),
|
||||
alpha_mode=__gather_alpha_mode(blender_material, export_settings),
|
||||
double_sided=__gather_double_sided(blender_material, export_settings),
|
||||
double_sided=__gather_double_sided(blender_material, {}, export_settings),
|
||||
extensions={"KHR_materials_unlit": Extension("KHR_materials_unlit", {}, required=False)},
|
||||
extras=__gather_extras(blender_material, export_settings),
|
||||
name=__gather_name(blender_material, export_settings),
|
||||
|
|
|
@ -73,12 +73,13 @@ def pbr_specular_glossiness(mh):
|
|||
)
|
||||
|
||||
if mh.pymat.occlusion_texture is not None:
|
||||
node = make_settings_node(mh)
|
||||
node.location = (610, -1060)
|
||||
if mh.settings_node is None:
|
||||
mh.settings_node = make_settings_node(mh)
|
||||
mh.settings_node.location = (610, -1060)
|
||||
occlusion(
|
||||
mh,
|
||||
location=(510, -970),
|
||||
occlusion_socket=node.inputs['Occlusion'],
|
||||
occlusion_socket=mh.settings_node.inputs['Occlusion'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -123,7 +124,7 @@ def specular_glossiness(mh, location, specular_socket, roughness_socket):
|
|||
node.location = x - 140, y
|
||||
node.blend_type = 'MULTIPLY'
|
||||
# Outputs
|
||||
mh.node_tree.links.new(specular_socket, node.outputs[0])
|
||||
mh.node_tree.links.new(specular_socket, node.outputs[2])
|
||||
# Inputs
|
||||
node.inputs['Factor'].default_value = 1.0
|
||||
specular_socket = node.inputs[6]
|
||||
|
|
|
@ -46,7 +46,7 @@ def sheen( mh,
|
|||
node.location = x_sheenColor - 140, y_sheenColor
|
||||
node.blend_type = 'MULTIPLY'
|
||||
# Outputs
|
||||
mh.node_tree.links.new(sheenColor_socket, node.outputs[0])
|
||||
mh.node_tree.links.new(sheenColor_socket, node.outputs[2])
|
||||
# Inputs
|
||||
node.inputs['Factor'].default_value = 1.0
|
||||
sheenColor_socket = node.inputs[6]
|
||||
|
|
|
@ -341,7 +341,7 @@ def original_specular( mh,
|
|||
node.location = x_specularcolor - 140, y_specularcolor
|
||||
node.blend_type = 'MULTIPLY'
|
||||
# Outputs
|
||||
mh.node_tree.links.new(original_specularcolor_socket, node.outputs[0])
|
||||
mh.node_tree.links.new(original_specularcolor_socket, node.outputs[2])
|
||||
# Inputs
|
||||
node.inputs['Factor'].default_value = 1.0
|
||||
original_specularcolor_socket = node.inputs[6]
|
||||
|
|
|
@ -64,11 +64,12 @@ def pbr_metallic_roughness(mh: MaterialHelper):
|
|||
need_volume_node = True
|
||||
|
||||
# We also need glTF Material Output Node, to set thicknessFactor and thicknessTexture
|
||||
mh.settings_node = make_settings_node(mh)
|
||||
mh.settings_node.location = additional_location
|
||||
mh.settings_node.width = 180
|
||||
volume_location = additional_location
|
||||
additional_location = additional_location[0], additional_location[1] - 150
|
||||
if mh.settings_node is None:
|
||||
mh.settings_node = make_settings_node(mh)
|
||||
mh.settings_node.location = additional_location
|
||||
mh.settings_node.width = 180
|
||||
volume_location = additional_location
|
||||
additional_location = additional_location[0], additional_location[1] - 150
|
||||
|
||||
need_velvet_node = False
|
||||
if mh.pymat.extensions and 'KHR_materials_sheen' in mh.pymat.extensions:
|
||||
|
@ -322,7 +323,7 @@ def emission(mh: MaterialHelper, location, color_socket, strength_socket):
|
|||
node.location = x - 140, y
|
||||
node.blend_type = 'MULTIPLY'
|
||||
# Outputs
|
||||
mh.node_tree.links.new(color_socket, node.outputs[0])
|
||||
mh.node_tree.links.new(color_socket, node.outputs[2])
|
||||
# Inputs
|
||||
node.inputs['Factor'].default_value = 1.0
|
||||
color_socket = node.inputs[6]
|
||||
|
|
Loading…
Reference in New Issue