Skip to content

Commit e8b0980

Browse files
author
Sightskeye
committed
Fix: Support Emission Strength link input blender 4
1 parent 1d8b894 commit e8b0980

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

OmniscientImporter/cameraProjection/cameraProjectionMaterial.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,24 @@ def ensure_bsdf_connection(material, latest_mix_rgb_visibility_node):
202202
except Exception as e:
203203
print(f"Failed to create link: {latest_mix_rgb_visibility_node.name} [0] -> {principled_bsdf_node.name} [{emission_input_name}]. Error: {e}")
204204

205-
# Create a new link from the mix_rgb_emission_node to the Emission input of the BSDF node
205+
# Create a new link from the mix_rgb_emission_node to the Emission Strength input of the BSDF node
206206
mix_rgb_emission_node = find_node(nodes, 'MIX_RGB', 'MixRGBEmissionNode')
207207
if mix_rgb_emission_node:
208208
try:
209-
emissionStrength_input_index = 20
210-
links.new(mix_rgb_emission_node.outputs[0], principled_bsdf_node.inputs[emissionStrength_input_index])
211-
print(f"Linked {mix_rgb_emission_node.name} to {principled_bsdf_node.name} [Emission Input {emissionStrength_input_index}]")
212-
except IndexError as e:
213-
print(f"Failed to create link: {mix_rgb_emission_node.name} [0] -> {principled_bsdf_node.name} [{emissionStrength_input_index}]. Error: {e}")
209+
if is_blender_4():
210+
emission_strength_input_name = "Emission Strength"
211+
emission_strength_input = principled_bsdf_node.inputs.get(emission_strength_input_name)
212+
else:
213+
emission_strength_input_index = 20
214+
emission_strength_input = principled_bsdf_node.inputs[emission_strength_input_index]
215+
216+
if emission_strength_input is not None:
217+
links.new(mix_rgb_emission_node.outputs[0], emission_strength_input)
218+
print(f"Linked {mix_rgb_emission_node.name} to {principled_bsdf_node.name} [{emission_strength_input_name if is_blender_4() else emission_strength_input_index}]")
219+
else:
220+
print(f"Emission Strength input not found in {principled_bsdf_node.name}")
221+
except Exception as e:
222+
print(f"Failed to create link: {mix_rgb_emission_node.name} [0] -> {principled_bsdf_node.name} [{emission_strength_input_name if is_blender_4() else emission_strength_input_index}]. Error: {e}")
214223
else:
215224
print("Mix RGB Emission Node not found")
216225

0 commit comments

Comments
 (0)