diff --git a/fixture.py b/fixture.py index c8c5b2e..70b5b1f 100644 --- a/fixture.py +++ b/fixture.py @@ -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: @@ -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" diff --git a/material.py b/material.py index fad83d9..369fc83 100644 --- a/material.py +++ b/material.py @@ -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)