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-12-01 22:52:55 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-12-01 22:52:55 +0300
commitd5c0d4b77c15002a7e15fbe3ee146def8d11cd27 (patch)
treedaa80929484bb1eaf8d92a6c53ab4cc6820ec438 /io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
parent008bcf44ef35726f4c1373e46b4dd6e3a5a069e2 (diff)
glTF: implement occlusion strength (importer & exporter)
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
index 4bc584b0..21400bc0 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
@@ -433,13 +433,30 @@ def normal(mh: MaterialHelper, location, normal_socket):
)
-# [Texture] => [Separate R] =>
+# [Texture] => [Separate R] => [Mix Strength] =>
def occlusion(mh: MaterialHelper, location, occlusion_socket):
x, y = location
if mh.pymat.occlusion_texture is None:
return
+ strength = mh.pymat.occlusion_texture.strength
+ if strength is None: strength = 1.0
+ if strength != 1.0:
+ # Mix with white
+ node = mh.node_tree.nodes.new('ShaderNodeMixRGB')
+ node.label = 'Occlusion Strength'
+ node.location = x - 140, y
+ node.blend_type = 'MIX'
+ # Outputs
+ mh.node_tree.links.new(occlusion_socket, node.outputs[0])
+ # Inputs
+ node.inputs['Fac'].default_value = strength
+ node.inputs['Color1'].default_value = [1, 1, 1, 1]
+ occlusion_socket = node.inputs['Color2']
+
+ x -= 200
+
# Separate RGB
node = mh.node_tree.nodes.new('ShaderNodeSeparateRGB')
node.location = x - 150, y - 75