Proper scroll speed units + scene fps accounted for

This commit is contained in:
William Herald Snyder 2022-10-03 08:38:13 -04:00
parent 188b270ad1
commit 69e959e7a3
1 changed files with 36 additions and 37 deletions

View File

@ -118,6 +118,7 @@ to provide an exact emulation"""
texture_input_nodes = []
surface_output_nodes = []
diffuse_texture_path = mat_props.diffuse_map
if diffuse_texture_path and os.path.exists(diffuse_texture_path):
@ -161,7 +162,6 @@ to provide an exact emulation"""
surface_output_nodes.append(tuple(("Emission", emission)))
surfaces_output = None
if (len(surface_output_nodes) == 1):
surfaces_output = surface_output_nodes[0][1]
@ -188,13 +188,15 @@ to provide an exact emulation"""
vector_add = material.node_tree.nodes.new("ShaderNodeVectorMath")
# Add keyframes
scroll_speed_divisor = 360.0
for i in range(4):
vector_add.inputs[1].default_value[0] = i * mat_props.scroll_speed_u
vector_add.inputs[1].keyframe_insert("default_value", index=0, frame=i * scroll_speed_divisor)
scroll_per_sec_divisor = 255.0
frame_step = 60.0
fps = bpy.context.scene.render.fps
for i in range(2):
vector_add.inputs[1].default_value[0] = i * mat_props.scroll_speed_u * frame_step / scroll_per_sec_divisor
vector_add.inputs[1].keyframe_insert("default_value", index=0, frame=i * frame_step * fps)
vector_add.inputs[1].default_value[1] = i * mat_props.scroll_speed_v
vector_add.inputs[1].keyframe_insert("default_value", index=1, frame=i * scroll_speed_divisor)
vector_add.inputs[1].default_value[1] = i * mat_props.scroll_speed_v * frame_step / scroll_per_sec_divisor
vector_add.inputs[1].keyframe_insert("default_value", index=1, frame=i * frame_step * fps)
material.node_tree.links.new(vector_add.inputs[0], uv_input.outputs[0])
@ -209,9 +211,6 @@ to provide an exact emulation"""
for kf in fcurve.keyframe_points.values():
kf.interpolation = 'LINEAR'
'''
else: