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:
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_material.py12
1 files changed, 10 insertions, 2 deletions
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