Skip to content

Commit

Permalink
wip start gobos
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Aug 25, 2024
1 parent ea4394e commit 810f2da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
11 changes: 6 additions & 5 deletions fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,16 +1139,17 @@ def updateGobo(self, gobo1, current_frame):

for light in self.lights: #CYCLES
light_obj = light.object
gobo_rotation = light_obj.data.node_tree.nodes.get("Gobo1Rotation")
if gobo1[1]<128: # half for indexing
light_obj.driver_remove("rotation_euler")
light_obj.rotation_euler[2] = (gobo1[1]/62.0-1)*360*(math.pi/360)
gobo_rotation.inputs[3].driver_remove("rotation_euler")
gobo_rotation.inputs[3].default_value = (gobo1[1]/62.0-1)*360*(math.pi/360)
else: # half for rotation
driver = light_obj.driver_add("rotation_euler", 2)
driver = gobo_rotation.inputs[3].driver_add("rotation_euler")
value = gobo1[1]-128-62 # rotating in both direction, slowest in the middle
driver.driver.expression=f"frame*{value*0.005}"

if current_frame and self.dmx_cache_dirty:
light_obj.keyframe_insert(data_path='rotation_euler', frame=current_frame)
gobo_rotation.inputs[3].keyframe_insert(data_path='rotation_euler', frame=current_frame)

def updatePosition(self, geometry = None, x=None, y=None, z=None, current_frame=None):
if geometry is None:
Expand Down Expand Up @@ -1402,7 +1403,7 @@ def set_gobo(self, index=-1, current_frame=None):

for light in self.lights: # CYCLES
light_obj = light.object
texture = light_obj.data.node_tree.nodes.get("Image Texture")
texture = light_obj.data.node_tree.nodes.get("Gobo1Texture")
if texture.image is None:
texture.image = gobos.image
texture.image.source = "SEQUENCE"
Expand Down
29 changes: 25 additions & 4 deletions material.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,40 @@ def set_light_nodes(light):
light_node = light_obj.data.node_tree.nodes.get(LIGHT_NODE)

# set gobo node
image = light_obj.data.node_tree.nodes.new(SHADER_NODE_TEX_IMAGE)
image.name = "Image Texture"
gobo_image_rotate = light_obj.data.node_tree.nodes.new("ShaderNodeVectorRotate")
gobo_image_rotate.name = "Gobo1Rotation"
gobo_image_rotate.rotation_type = "Z_AXIS"
gobo_image_rotate.invert = True
gobo_image_rotate.inputs[1].default_value[:2] = [0.5] * 2
gobo_image = light_obj.data.node_tree.nodes.new(SHADER_NODE_TEX_IMAGE)
gobo_image.name = "Gobo1Texture"
gobo_geometry_node = light_obj.data.node_tree.nodes.new("ShaderNodeNewGeometry")

gobo_geometry_node.location = (-694.17, 457.04)
gobo_image_rotate.location = (-405.22, 486.14)

light_obj.data.node_tree.links.new(gobo_geometry_node.outputs[5], gobo_image_rotate.inputs[0])
light_obj.data.node_tree.links.new(gobo_image_rotate.outputs[0], gobo_image.inputs[0])

# gobo mix
gobo_mix = light_obj.data.node_tree.nodes.new(SHADER_NODE_MIX)
gobo_mix.data_type = "RGBA"
gobo_mix.blend_type = "DARKEN"
gobo_mix.name = "Mix"
gobo_mix.inputs[0].default_value = 1
light_obj.data.node_tree.links.new(gobo_image.outputs[0], gobo_mix.inputs["A"])

mix = light_obj.data.node_tree.nodes.new(SHADER_NODE_MIX)
mix.data_type = "RGBA"
mix.blend_type = "DARKEN"
mix.name = "Mix"
mix.inputs[0].default_value = 1

light_obj.data.node_tree.links.new(mix.outputs["Result"], emission.inputs[0])
light_obj.data.node_tree.links.new(image.outputs[0], mix.inputs["A"])
light_obj.data.node_tree.links.new(gobo_mix.outputs["Result"], mix.inputs["A"])

image.location = (10.80, 591.25)
gobo_image.location = (-221.73, 486.83)
gobo_mix.location = (82.07, 489.56)
mix.location = (319.60, 489.01)
emission.location = (529.09, 509.87)
light_node.location = (733.60, 536.36)
Expand Down

0 comments on commit 810f2da

Please sign in to comment.