2
$\begingroup$

I'm complete beginner in blender...I'm trying to animate an image every 10 frame... what i did was import an image as a plane and change it to sequence in shader editor then I import 3 images...i set the frame=3 offset=2 then turn on auto refresh and cyclic but when i play it the images are animated every 1 frame is there a way to make it animate every 10 frames?

$\endgroup$
1
  • 1
    $\begingroup$ I'm not sure whether you can connect the output from geometry nodes to drivers in Blender, having never had much to do with either, but my immediate thought having programmed other software would be to add a driver to the image frame offset which increases by one every 10 frames in the timeline and then resets to zero every 3 iterations using the geometry scene time node. Someone with more knowledge than me might know if it's possible or not! $\endgroup$
    – John Eason
    Oct 25, 2022 at 23:23

2 Answers 2

2
$\begingroup$

Thx to John Eason for his idea, you can set this formula:

-frame + 1 if frame % 30 == 0 else -frame+(frame % 30)/10

into the offset of your image texture:

enter image description here

enter image description here

set start frame to 1 and frames to a high number.

result:

enter image description here

tbh i can explain this:

-frame+(frame % 30)/10

which just uses the modulo of frame with 30, so it basically counts from 0 to 29. Then i divide this by 10 to get a full integer every 10th frame. And i subtract the real frame from it to reset it for every frame.

I cannot explain this:

-frame + 1 if frame % 30 == 0 else

which i had to set it before so that it works. I think it has to do with the start frame at 1. But if you set it to 0, it messes all up. But i am sure some other guys can explain that to you ;)

$\endgroup$
4
  • 1
    $\begingroup$ Even easier than I thought1 I didn't realise you could use relatively complicated multiple statements on the Expression line in the driver editor! :^) $\endgroup$
    – John Eason
    Oct 26, 2022 at 8:26
  • $\begingroup$ Yes you can 👍🏻Blender surprised me too every day 😉 $\endgroup$
    – Chris
    Oct 26, 2022 at 8:28
  • 1
    $\begingroup$ "Then i divide this by 10 to get a full integer" - those integers aren't all divisible by 10, and you don't use integer division //, so the result of dividing by 10 will be floats with up to 1 decimal point, e.g. ${12}\over{10} = 1.2$. "And i subtract the real frame from it to reset it for every frame." - yes, first you subtract current frame, to make sure the frame number displayed is $0$ on each frame; then you calculate the actual frame number to display. Problem is, on frame $30$ you will subtract that $30$ and try to display frame 0… Aaah you know what, I'll elaborate in an answer $\endgroup$ Oct 26, 2022 at 9:20
  • $\begingroup$ @MarkusvonBroady: ah ok, that was my mistake. thanks! $\endgroup$
    – Chris
    Oct 26, 2022 at 12:27
2
$\begingroup$

Solution

Let's say you want to display frames 2-7, starting at frame 3, cyclically. Normally you'd do it this way:

If you want 2x playback speed, then this setup will work:

#(frame-start)*speed % frames + offset

Left side has 2x speed, right side has normal speed:

You can test it out – after opening .blend, ✲ CtrlF12, then assign the video to the Image Textures (make it a single user copy for each )

Sequence Settings 101

Let's describe these 3 options:

  • Frames – specifies how many frames from the video/image sequence will be displayed. If you don't change these settings during the animation, then only that number of frames from the video will ever be displayed - maybe less, if your Blender animation is too short to show them all. Think of it as importing a video to a video editor, and then making a video stripe out of it by cutting its ends (or extending them = adding frame holds).
  • Start Frame – this frame of your animation in Blender is the first frame of loaded sequence. Think of it as placing a video stripe in the video editor – Start Frame is the x position of that stripe on the timeline. For example, if two of your objects collide at frame 100, load an explosion video and set Start Frame to 100. This value wraps around: setting it to $x$ is the same as setting it to $x - frames$ or $x + frames%$. The settings below will have the same effect (of course only if cyclic is enabled):

  • Offset – when cutting a stripe out of the video, define the position of that stripe. This is the only drivable field out of the 3. If cyclic is disabled, it has a reverse effect to the previous field: incrementing the Start Frame by $x$ is the same as decrementing this field by $x$ and vice—versa – decrementing this field by $x$ is the same as incrementing Start Frame by $x$ [I hope you don't mind the joke]. The logic of that is simple, moving the video forward has the same effect as starting the video earlier. There is a caveat, however: if cyclic is enabled, it still doesn't wrap, due to how the video stripes are created:

So when the stripe is created, the frames beyond the original video's bounds are interpolated in the extend mode, by showing the frames on the boundary.

Explanation of the solution

  1. Get the current frame and based on it calculate which frame in the loaded sequence you want to display. The first frame in the video sequence has index $= 0$.
FORMULA F R A M E N U M B E R S
frame -3 -2 -1 0 1 2 3 4 5 6 7 8 9
max(2, frame) 2 2 2 2 2 2 3 4 5 6 7 8 9
clamp(frame, 2, 5) 2 2 2 2 2 2 3 4 5 5 5 5 5
frame*2 -6 -4 -2 0 2 4 6 8 10 12 14 16 18
fmod(frame*2, 10) -6 -4 -2 0 2 4 6 8 0 2 4 6 8
fmod(frame*2, 10) + 10 4 6 8 10 12 14 16 18 10 12 14 16 18
fmod(fmod(frame*2,10)+10, 10) 4 6 8 0 2 4 6 8 0 2 4 6 8
frame*2 % 10 4 6 8 0 2 4 6 8 0 2 4 6 8
(frame-1)*2 % 10 2 4 6 8 0 2 4 6 8 0 2 4 6
(frame-2)*2 % 10 0 2 4 6 8 0 2 4 6 8 0 2 4
  1. Create a single frame strip at the calculated position in the sequence So what I'm doing is just take a stripe of length 1, the Start Frame and Cyclic options then become irrelevant, and then calculate the frame to be displayed and use the Offset to position the stripe on that frame.

Chris'es solution has a few problems

The formula

-frame + 1 if frame % 30 == 0 else -frame+(frame % 30)/10

doesn't seem exactly right:

If I divide by 1 (no change of speed), this is what I get from frame -3 to frame 25: (the blurry digits are the video)

So it starts correctly at the specified frame (but displays the last frame before that, not first frame), goes only to (last frame − start frame) in each cycle, and pads the cycles with the first frame.

$\endgroup$
2
  • $\begingroup$ I'm being dim. As far as OP is concerned, all I can see needed is... Frames:1, Start Frame:1, Offset: (frame//10)%3, with maybe a + something to start farther down the sequence. You're better than me at this stuff. Are you doing something more general, here? $\endgroup$
    – Robin Betts
    Oct 26, 2022 at 16:44
  • 1
    $\begingroup$ @RobinBetts yes, it's a general solution, you can take a look at the updated answer. $\endgroup$ Oct 26, 2022 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .