diff options
author | Peter Kim <pk15950@gmail.com> | 2022-09-08 07:00:43 +0300 |
---|---|---|
committer | Peter Kim <pk15950@gmail.com> | 2022-09-08 07:00:43 +0300 |
commit | e83f88c951e26b01893acee4f24b40a46062a41c (patch) | |
tree | 09f60bf7d4fc2ae1ef50668823e416fc675b252e /io_scene_gltf2/blender/imp/gltf2_blender_texture.py | |
parent | ec84e3294593e2e26475f18c81e847bf00dc201e (diff) | |
parent | 0cd92169d40ae1c7e103ff269e850eaf1b901646 (diff) |
Merge branch 'master' into xr-devxr-dev
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_texture.py')
-rw-r--r-- | io_scene_gltf2/blender/imp/gltf2_blender_texture.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_texture.py b/io_scene_gltf2/blender/imp/gltf2_blender_texture.py index 24c9df7c..12e6d594 100644 --- a/io_scene_gltf2/blender/imp/gltf2_blender_texture.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_texture.py @@ -17,6 +17,7 @@ def texture( color_socket, alpha_socket=None, is_data=False, + forced_image=None ): """Creates nodes for a TextureInfo and hooks up the color/alpha outputs.""" x, y = location @@ -36,12 +37,15 @@ def texture( tex_img.location = x - 240, y tex_img.label = label # Get image - if pytexture.source is not None: - BlenderImage.create(mh.gltf, pytexture.source) - pyimg = mh.gltf.data.images[pytexture.source] - blender_image_name = pyimg.blender_image_name - if blender_image_name: - tex_img.image = bpy.data.images[blender_image_name] + if forced_image is None: + if pytexture.source is not None: + BlenderImage.create(mh.gltf, pytexture.source) + pyimg = mh.gltf.data.images[pytexture.source] + blender_image_name = pyimg.blender_image_name + if blender_image_name: + tex_img.image = bpy.data.images[blender_image_name] + else: + tex_img.image = forced_image # Set colorspace for data images if is_data: if tex_img.image: @@ -49,7 +53,8 @@ def texture( # Set filtering set_filtering(tex_img, pysampler) # Outputs - mh.node_tree.links.new(color_socket, tex_img.outputs['Color']) + if color_socket is not None: + mh.node_tree.links.new(color_socket, tex_img.outputs['Color']) if alpha_socket is not None: mh.node_tree.links.new(alpha_socket, tex_img.outputs['Alpha']) # Inputs |