Skip to content
Snippets Groups Projects
Commit feca8c52 authored by Julien Duroure's avatar Julien Duroure
Browse files

glTF importer: import grayscale emissiveFactor as Emission Strength (new principled socket)

parent f510c216
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
bl_info = { bl_info = {
'name': 'glTF 2.0 format', 'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 4, 31), "version": (1, 4, 32),
'blender': (2, 90, 0), 'blender': (2, 91, 0),
'location': 'File > Import-Export', 'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0', 'description': 'Import-Export as glTF 2.0',
'warning': '', 'warning': '',
......
...@@ -62,6 +62,7 @@ def pbr_metallic_roughness(mh: MaterialHelper): ...@@ -62,6 +62,7 @@ def pbr_metallic_roughness(mh: MaterialHelper):
mh, mh,
location=locs['emission'], location=locs['emission'],
color_socket=pbr_node.inputs['Emission'], color_socket=pbr_node.inputs['Emission'],
strength_socket=pbr_node.inputs['Emission Strength'],
) )
base_color( base_color(
...@@ -167,7 +168,7 @@ def calc_locations(mh): ...@@ -167,7 +168,7 @@ def calc_locations(mh):
# [Texture] => [Emissive Factor] => # [Texture] => [Emissive Factor] =>
def emission(mh: MaterialHelper, location, color_socket): def emission(mh: MaterialHelper, location, color_socket, strength_socket=None):
x, y = location x, y = location
emissive_factor = mh.pymat.emissive_factor or [0, 0, 0] emissive_factor = mh.pymat.emissive_factor or [0, 0, 0]
...@@ -178,20 +179,26 @@ def emission(mh: MaterialHelper, location, color_socket): ...@@ -178,20 +179,26 @@ def emission(mh: MaterialHelper, location, color_socket):
color_socket.default_value = emissive_factor + [1] color_socket.default_value = emissive_factor + [1]
return return
# Mix emissive factor # Put grayscale emissive factors into the Emission Strength
if emissive_factor != [1, 1, 1]: e0, e1, e2 = emissive_factor
node = mh.node_tree.nodes.new('ShaderNodeMixRGB') if strength_socket and e0 == e1 == e2:
node.label = 'Emissive Factor' strength_socket.default_value = e0
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]
x -= 200 # Otherwise, use a multiply node for it
else:
if emissive_factor != [1, 1, 1]:
node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
node.label = 'Emissive Factor'
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]
x -= 200
texture( texture(
mh, mh,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment