I decided to use Blender's render image for the draft of the manga. It is assumed that the render image for each key frame will be pasted into the manga creation software in correspondence with "1 frame = 1 key frame".
Normally, comic frames have different aspect ratios for each frame. However, Blender does not allow you to set the resolution for each keyframe. You have to use the same resolution for all keyframes or switch manually frame by frame. Both are inconvenient.
Therefore, I thought about how to set the resolution for each key frame. Blender allows you to set a string ** marker ** in keyframes, so I decided to record the aspect ratio of the resolution there.
In general horizontal reading manga, the vertical and horizontal size of the frame is indefinite, but this time it is a vertical reading manga, and it is assumed that the width of the frame is always constant at 2480px. The method of specifying the height and width at the same time is supplemented at the end.
Y = 2480 * 1.5 = 3720 px
.In the Timeline panel, press M to add a marker to the keyframe and Ctrl + M to enter the aspect ratio as the marker name.
Enter the number Y / X
this time. For example, X: Y = 4: 3 is 0.75
, 1: 1 is 1
, and 1: 2 is 2
.
By the way, you can set multiple markers in one frame, but in this program, the first value found will be used as the aspect ratio.
Then open the Text Editor panel and enter the following code.
set_resolution_from_marker.py
import bpy
RESOLUTION_X = 2480
DEFAULT_RATIO = 1.0
def find_ratio_from_current_keyframe():
#Search for the marker set for the current keyframe from all markers
marker_items = bpy.context.scene.timeline_markers.items()
current = bpy.data.scenes["Scene"].frame_current
markers = [item[0] for item in marker_items if item[1].frame == current]
#Returns the default ratio if the marker does not exist
if len(markers) < 1:
print(f"No marker is set to current keyframe. Now ratio is {DEFAULT_RATIO}.")
return DEFAULT_RATIO
print("Found marker(s): ", markers)
#Converts the marker string to a number and returns it
for m in markers:
try:
ratio = float(m)
print("Ratio is set to ", ratio)
return ratio
except ValueError as e:
print(e)
continue
#Returns the default ratio if there are no markers that can be converted to numbers
print(f"Marker is set to current keyframe but not valid number. Now ratio is {DEFAULT_RATIO}.")
return DEFAULT_RATIO
def update_resolution(scene):
scene.render.resolution_x = RESOLUTION_X
scene.render.resolution_y = RESOLUTION_X * find_ratio_from_current_keyframe()
#Set callback to update resolution when changing keyframes
bpy.app.handlers.frame_change_pre.append(update_resolution)
ℹ️ Brief commentary
DEFAULT_RATIO
is returned. This time it is 1
(= aspect ratio 1: 1).update_resolution ()
every time a keyframe changes to change the resolution.Run "Run Script (Alt + P)" in the Text Editor panel.
After that, Resolution X & Y is set automatically every time you switch keyframes.
This time it was a slightly special case of "X = 2480px fixed", but if you want to set X and Y at the same time, you can easily handle it by changing the marker notation and Python script.
For example, write 1280,720
in the marker, split the string with commas in a Python script, and assign the first value to X and the second value to Y.
I could not do it. This is because the driver cannot set any of the values under the Scene property, including Resolution.
I couldn't find a callback that could be called at that time: disappointed: Sorry for your inconvenience, but please advance the keyframe by one with the arrow keys and move it back.
Recommended Posts