From ee3717cf5d0681896c585659990d21e039d2abd4 Mon Sep 17 00:00:00 2001 From: 1k8 Date: Tue, 3 Dec 2024 13:10:01 +0100 Subject: [PATCH] Update nodes_shader.py --- .../arm/material/cycles_nodes/nodes_shader.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/armory/blender/arm/material/cycles_nodes/nodes_shader.py b/armory/blender/arm/material/cycles_nodes/nodes_shader.py index 087d06c17..0a4620e65 100644 --- a/armory/blender/arm/material/cycles_nodes/nodes_shader.py +++ b/armory/blender/arm/material/cycles_nodes/nodes_shader.py @@ -135,20 +135,36 @@ def parse_bsdfprincipled(node: bpy.types.ShaderNodeBsdfPrincipled, out_socket: N if state.parse_surface: c.write_normal(node.inputs[5]) state.out_basecol = c.parse_vector_input(node.inputs[0]) - subsurface = c.parse_value_input(node.inputs[8]) + subsurface = c.parse_value_input(node.inputs[7]) subsurface_radius = c.parse_vector_input(node.inputs[9]) - subsurface_color = c.parse_vector_input(node.inputs[0]) + subsurface_color = c.parse_vector_input(node.inputs[8]) state.out_metallic = c.parse_value_input(node.inputs[1]) - state.out_specular = c.parse_value_input(node.inputs[7]) + state.out_specular = c.parse_value_input(node.inputs[12]) state.out_roughness = c.parse_value_input(node.inputs[2]) + # Prevent black material when metal = 1.0 and roughness = 0.0 + try: + if float(state.out_roughness) < 0.00101: + state.out_roughness = '0.001' + except ValueError: + pass if (node.inputs['Emission Strength'].is_linked or node.inputs['Emission Strength'].default_value != 0.0)\ and (node.inputs['Emission Color'].is_linked or not mat_utils.equals_color_socket(node.inputs['Emission Color'], (0.0, 0.0, 0.0), comp_alpha=False)): - emission_col = c.parse_vector_input(node.inputs[27]) - emission_strength = c.parse_value_input(node.inputs[28]) + emission_col = c.parse_vector_input(node.inputs[26]) + emission_strength = c.parse_value_input(node.inputs[27]) state.out_emission_col = '({0} * {1})'.format(emission_col, emission_strength) mat_state.emission_type = mat_state.EmissionType.SHADED else: - mat_state.emission_type = mat_state.EmissionType.NO_EMISSION + mat_state.emission_type = mat_state.EmissionType.NO_EMISSION + #state.out_occlusion = state.out_roughness + #state.out_aniso = c.parse_vector_input(node.inputs[14]) + #state.out_aniso_rot = c.parse_vector_input(node.inputs[15]) + #state.out_sheen = c.parse_vector_input(node.inputs[23]) + #state.out_sheen_tint = c.parse_vector_input(node.inputs[25]) + #state.out_clearcoat = c.parse_vector_input(node.inputs[18]) + #state.out_clearcoat_rough = c.parse_vector_input(node.inputs[19]) + #state.out_ior = c.parse_value_input(node.inputs[3]) + #state.out_transmission = c.parse_vector_input(node.inputs[17]) + #state.out_transmission_roughness = state.out_roughness if state.parse_opacity: state.out_ior = c.parse_value_input(node.inputs[3]) state.out_opacity = c.parse_value_input(node.inputs[4])