[Bf-extensions-cvs] [54f2341b] master: glTF importer: set alpha mode in viewport

Julien Duroure noreply at git.blender.org
Wed Jan 23 18:52:00 CET 2019


Commit: 54f2341bdee0e6e5dfacd65a38740f99996efa52
Author: Julien Duroure
Date:   Wed Jan 23 18:51:31 2019 +0100
Branches: master
https://developer.blender.org/rBA54f2341bdee0e6e5dfacd65a38740f99996efa52

glTF importer: set alpha mode in viewport

===================================================================

M	io_scene_gltf2/blender/imp/gltf2_blender_material.py

===================================================================

diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_material.py b/io_scene_gltf2/blender/imp/gltf2_blender_material.py
index c910b7f8..8abfc217 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_material.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_material.py
@@ -80,7 +80,7 @@ class BlenderMaterial():
             BlenderOcclusionMap.create(gltf, material_idx, vertex_color)
 
         if pymaterial.alpha_mode is not None and pymaterial.alpha_mode != 'OPAQUE':
-            BlenderMaterial.blender_alpha(gltf, material_idx, vertex_color)
+            BlenderMaterial.blender_alpha(gltf, material_idx, vertex_color, pymaterial.alpha_mode)
 
     @staticmethod
     def set_uvmap(gltf, material_idx, prim, obj, vertex_color):
@@ -94,11 +94,19 @@ class BlenderMaterial():
                 uvmap_node.uv_map = prim.blender_texcoord[uvmap_node["gltf2_texcoord"]]
 
     @staticmethod
-    def blender_alpha(gltf, material_idx, vertex_color):
+    def blender_alpha(gltf, material_idx, vertex_color, alpha_mode):
         """Set alpha."""
         pymaterial = gltf.data.materials[material_idx]
         material = bpy.data.materials[pymaterial.blender_material[vertex_color]]
 
+        # Set alpha value in material
+        if alpha_mode == 'BLEND':
+            material.blend_method = 'BLEND'
+        elif alpha_mode == "MASK":
+            material.blend_method = 'CLIP'
+            alpha_cutoff = 1.0 - pymaterial.alpha_cutoff if pymaterial.alpha_cutoff is not None else 0.5
+            material.alpha_threshold = alpha_cutoff
+
         node_tree = material.node_tree
         # Add nodes for basic transparency
         # Add mix shader between output and Principled BSDF



More information about the Bf-extensions-cvs mailing list