Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2020-09-23 09:02:46 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-09-23 09:02:46 +0300
commitfeca8c5289794a70bdd375be76fc4bc59d83c96b (patch)
treed24fbbf334d30e7fe58f00ce77cdd1c4ef492822 /io_scene_gltf2
parentf510c21650961d579f82352ee40b64bd4ddb7edd (diff)
glTF importer: import grayscale emissiveFactor as Emission Strength (new principled socket)
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-xio_scene_gltf2/__init__.py4
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py35
2 files changed, 23 insertions, 16 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index ab73a475..d6d44f11 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,8 +15,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": (1, 4, 31),
- 'blender': (2, 90, 0),
+ "version": (1, 4, 32),
+ 'blender': (2, 91, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
'warning': '',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
index deb9e301..4bc584b0 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
@@ -62,6 +62,7 @@ def pbr_metallic_roughness(mh: MaterialHelper):
mh,
location=locs['emission'],
color_socket=pbr_node.inputs['Emission'],
+ strength_socket=pbr_node.inputs['Emission Strength'],
)
base_color(
@@ -167,7 +168,7 @@ def calc_locations(mh):
# [Texture] => [Emissive Factor] =>
-def emission(mh: MaterialHelper, location, color_socket):
+def emission(mh: MaterialHelper, location, color_socket, strength_socket=None):
x, y = location
emissive_factor = mh.pymat.emissive_factor or [0, 0, 0]
@@ -178,20 +179,26 @@ def emission(mh: MaterialHelper, location, color_socket):
color_socket.default_value = emissive_factor + [1]
return
- # Mix emissive factor
- 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]
+ # Put grayscale emissive factors into the Emission Strength
+ e0, e1, e2 = emissive_factor
+ if strength_socket and e0 == e1 == e2:
+ strength_socket.default_value = e0
- 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(
mh,