Describe the bug
There is a check for more than one shader node from the shader sockets in the __gather_sampler function in gltf2_blender_gather_texture.py
Since this warning gives no indication of the offending socket, shader node I added print statements to show the shader nodes and sockets involvement.
Code
def __gather_sampler(blender_shader_sockets, export_settings):
shader_nodes = [get_texture_node_from_socket(socket, export_settings) for socket in blender_shader_sockets]
if len(shader_nodes) > 1:
export_settings['log'].warning(
"More than one shader node tex image used for a texture. "
"The resulting glTF sampler will behave like the first shader node tex image."
)
for sn in shader_nodes:
print("shader node", sn.shader_node)
for sc in blender_shader_sockets:
print("socket", sc.socket, sc.group_path)
first_valid_shader_node = next(filter(lambda x: x is not None, shader_nodes))
This produces
Info: Saved "bad_texture nodes.blend"
16:33:35 | WARNING: More than one shader node tex image used for a texture. The resulting glTF sampler will behave like the first shader node tex image.
shader node <bpy_struct, ShaderNodeTexImage("Image Texture 1") at 0x0000020477BB8888>
shader node <bpy_struct, ShaderNodeTexImage("Image Texture 1") at 0x0000020477BB8888>
socket <bpy_struct, NodeSocketColor("Base Color") at 0x0000020477B07D88> [bpy.data.materials['Material'].node_tree]
socket <bpy_struct, NodeSocketFloatFactor("Alpha") at 0x0000020477B07388> [bpy.data.materials['Material'].node_tree]
Notice that the shader node is the same one numerous times, based on the color and alpha sockets, or its the same one based on the Metallic roughness sockets.
I feel this is a false warning?
What are the implications
To Reproduce
Steps to reproduce the behavior:
export the blender file with a cube and one texture node and color alpha sockets connected to BSDF
Expected behavior
No false warning to chase down
Screenshots
If applicable, add screenshots to help explain your problem.
def __gather_sampler(blender_shader_sockets, export_settings):
shader_nodes = [get_texture_node_from_socket(socket, export_settings) for socket in blender_shader_sockets]
current_shader_node = shader_nodes[0].shader_node
is_single_shader_node = True
for sn in shader_nodes:
if sn.shader_node != current_shader_node:
print("found", sn.shader_node, current_shader_node)
is_single_shader_node = False
continue
if len(shader_nodes) > 1 and not is_single_shader_node:
export_settings['log'].warning(
"More than one shader node tex image used for a texture. "
"The resulting glTF sampler will behave like the first shader node tex image."
)
for sn in shader_nodes:
print("shader node", sn.shader_node)
for sc in blender_shader_sockets:
print("socket", sc.socket, sc.group_path)
first_valid_shader_node = next(filter(lambda x: x is not None, shader_nodes))
Describe the bug There is a check for more than one shader node from the shader sockets in the __gather_sampler function in gltf2_blender_gather_texture.py
Since this warning gives no indication of the offending socket, shader node I added print statements to show the shader nodes and sockets involvement.
Code
This produces
Notice that the shader node is the same one numerous times, based on the color and alpha sockets, or its the same one based on the Metallic roughness sockets.
I feel this is a false warning? What are the implications
To Reproduce Steps to reproduce the behavior:
Expected behavior No false warning to chase down
Screenshots If applicable, add screenshots to help explain your problem.
.blend file/ .gltf (mandatory)
bad_texture nodes.zip
Version
Additional context a check needed??
results in no warnings