Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 6fe582b

Browse files
author
Sebastian Sille
committed
Import_3ds: Improved light nodes setup
Gobo bitmap got a mapping and texture coordinate node Light color animations are imported to a RGB node
1 parent e8c1acd commit 6fe582b

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

io_scene_3ds/import_3ds.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,11 @@ def read_track_angle(track_chunk):
952952
links.new(bitmap_mix.outputs[0], nodes['Background'].inputs[0])
953953
links.new(bitmapnode.outputs[0], bitmap_mix.inputs[1])
954954
links.new(bitmapping.outputs[0], bitmapnode.inputs[0])
955-
if coordinates and not bitmapping.inputs['Vector'].is_linked:
955+
if not coordinates:
956+
coordinates = nodes.new(type='ShaderNodeTexCoord')
957+
coordinates.location = (-1200, 260)
958+
if not bitmapping.inputs['Vector'].is_linked:
956959
links.new(coordinates.outputs[0], bitmapping.inputs[0])
957-
links.new(coordinates.outputs[2], bitmapping.inputs[1])
958960
new_chunk.bytes_read += read_str_len
959961

960962
# If gradient chunk:
@@ -990,7 +992,6 @@ def read_track_angle(track_chunk):
990992
links.new(gradientnode.outputs[0], nodes['Background'].inputs[0])
991993
if mappingnode and not mappingnode.inputs['Vector'].is_linked:
992994
links.new(coordinate.outputs[0], mappingnode.inputs[0])
993-
links.new(coordinate.outputs[2], mappingnode.inputs[1])
994995
gradientnode.color_ramp.elements.new(read_float(new_chunk))
995996
read_chunk(file, temp_chunk)
996997
if temp_chunk.ID == COLOR_F:
@@ -1237,15 +1238,22 @@ def read_track_angle(track_chunk):
12371238
gobo_name, read_str_len = read_string(file)
12381239
new_chunk.bytes_read += read_str_len
12391240
projection = nodes.new(type='ShaderNodeTexImage')
1240-
projection.label = gobo_name
1241-
projection.location = (-480, 420)
1241+
promapping = nodes.new(type='ShaderNodeMapping')
1242+
protxcoord = nodes.new(type='ShaderNodeTexCoord')
1243+
projection.label = "Gobo: " + gobo_name
1244+
protxcoord.label = "Gobo Coordinate"
1245+
projection.location = (-480, 440)
1246+
promapping.location = (-720, 440)
1247+
protxcoord.location = (-940, 400)
12421248
projection.image = load_image(gobo_name, dirname, place_holder=False, recursive=IMAGE_SEARCH, check_existing=True)
12431249
emitnode = next((node for node in nodes if node.type == 'EMISSION'), False)
12441250
emit = emitnode if emitnode else nodes.new(type='ShaderNodeEmission')
12451251
emit.label = "Projector"
12461252
emit.location = (80, 300)
12471253
emit.inputs[0].default_value[:3] = mix.inputs[2].default_value[:3] = rgb.outputs[0].default_value[:3] = contextLamp.data.color
12481254
links.new(emit.outputs[0], nodes['Light Output'].inputs[0])
1255+
links.new(promapping.outputs[0] ,projection.inputs[0])
1256+
links.new(protxcoord.outputs[2] ,promapping.inputs[0])
12491257
links.new(projection.outputs[0], mix.inputs[1])
12501258
links.new(mix.outputs[0], emit.inputs[0])
12511259
links.new(rgb.outputs[0], mix.inputs[2])
@@ -1414,21 +1422,19 @@ def read_track_angle(track_chunk):
14141422
child.data.color = read_track_data(new_chunk)[0]
14151423
child.data.use_nodes = True
14161424
tree = child.data.node_tree
1417-
emitnode = next((nd for nd in tree.nodes if nd.type == 'EMISSION'), False)
1425+
emitnode = tree.nodes.get("Emission")
1426+
emitnode.inputs[0].default_value[:3] = child.data.color
14181427
colornode = next((nd for nd in tree.nodes if nd.type == 'RGB'), False)
1419-
if emitnode:
1420-
emitnode.inputs[0].default_value[:3] = child.data.color
1421-
if colornode:
1422-
colornode.outputs[0].default_value[:3] = child.data.color
1428+
if not colornode:
1429+
colornode = tree.nodes.new('ShaderNodeRGB')
1430+
colornode.location = (-380, 100)
1431+
tree.links.new(colornode.outputs[0], emitnode.inputs[0])
1432+
colornode.outputs[0].default_value[:3] = child.data.color
14231433
for keydata in keyframe_data.items():
14241434
child.data.color = keydata[1]
14251435
child.data.keyframe_insert(data_path="color", frame=keydata[0])
1426-
if emitnode:
1427-
emitnode.inputs[0].default_value[:3] = keydata[1]
1428-
tree.keyframe_insert(data_path="nodes[\"Emission\"].inputs[0].default_value", frame=keydata[0])
1429-
if colornode:
1430-
colornode.outputs[0].default_value[:3] = keydata[1]
1431-
tree.keyframe_insert(data_path="nodes[\"RGB\"].outputs[0].default_value", frame=keydata[0])
1436+
colornode.outputs[0].default_value[:3] = keydata[1]
1437+
tree.keyframe_insert(data_path="nodes[\"RGB\"].outputs[0].default_value", frame=keydata[0])
14321438
contextTrack_flag = False
14331439

14341440
elif KEYFRAME and new_chunk.ID == POS_TRACK_TAG and tracktype == 'OBJECT': # Translation

0 commit comments

Comments
 (0)