Jump to: Board index » General » Fusion

Expression for Count up to a certain number

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

ToteMusik

  • Posts: 4
  • Joined: Tue Dec 28, 2021 4:08 pm
  • Real Name: Tobias Krellmann

Expression for Count up to a certain number

PostTue Dec 28, 2021 4:27 pm

Hello,

I'm trying to solve one task, but can't find a solution.
I have a counter, that counts to a specific number, and it works pretty well, as long as I use it in this way.

Code: Select all
Text(floor(time^2*22500/comp.RenderEnd^2))


The issue is, that I have a fusion clip that's longer than I want the animation to run, and comp.RenderEnd plays the animation until the end of the fusion clip.

Found this post, but it does not work for me.
Expression for count up with a set stop number

I need to adjust the starting and ending-point/timeframe.

For example: Start at TF 102 from 0 and count to 22500 until TF 289 and stay there.

Thanks for your advice.
Online

Sander de Regt

  • Posts: 3945
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Expression for Count up to a certain number

PostTue Dec 28, 2021 4:46 pm

I don't know how to write this in code, but I think you'll want to use some sort of if (or iif) statement, that basically says: if the number is lower than (the desired end number) show that number, else show the desired end number. I don't think it will be difficult to weite out, but my expression skills are failing me atm.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

ToteMusik

  • Posts: 4
  • Joined: Tue Dec 28, 2021 4:08 pm
  • Real Name: Tobias Krellmann

Re: Expression for Count up to a certain number

PostTue Dec 28, 2021 4:52 pm

Yes, I don't know either. ;)

Yes, I don't know either. ;)

That's why I ask. I'm not a hero when it comes to coding.

In the post I mentioned, there was this snipped.

Code: Select all
iif(time>=88, 88, time)


But I don't know how to rewrite it, to fit my requirements.
Offline

Frank Feijen

  • Posts: 168
  • Joined: Tue Dec 13, 2016 10:04 am
  • Location: Vilvoorde, Belgium

Re: Expression for Count up to a certain number

PostTue Dec 28, 2021 5:02 pm

Wouldn't it be simpler to omit comp.Renderend in this case?
Offline

xunile

  • Posts: 3109
  • Joined: Mon Apr 23, 2018 5:21 am
  • Real Name: Eric Eisenmann

Re: Expression for Count up to a certain number

PostTue Dec 28, 2021 6:58 pm

This isn't necessarily the best way, but I did it with 2 nodes, a Custom Tool node and a Text+ node. I added the Custom Tool node then set the NumberIn1 to the first part of the range, in your example 102. I then set the NumberIn2 to 289. I then right-clicked on the NumberIn3 and clicked on Expression. I then entered the following expression.

Code: Select all
iif(time < 102 , 0 , floor(((c1.NumberIn1 + (time - c1.NumberIn1) )/ c1.NumberIn2) * 22500) )


I then switched to the Text+ node and chose expression for the text entry box. I entered the following expression.

Code: Select all
iif( c1.NumberIn3 > 22500 , 22500 , c1.NumberIn3)


This allowed me to enter any two numbers for NumberIn1 and NumberIn2 and it will count from 0 to 22500 and stop after it gets to the second number.


Here are the two nodes if you just want to copy and paste them into your Node Editor.

Code: Select all
{
   Tools = ordered() {
      Text2 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            GlobalOut = Input { Value = 397, },
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            UseFrameFormatSettings = Input { Value = 1, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            StyledText = Input {
               Value = "22500",
               Expression = "iif( c1.NumberIn3 > 22500 , 22500 , c1.NumberIn3)",
            },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalJustificationNew = Input { Value = 3, },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = ""
               },
            },
         },
         ViewInfo = OperatorInfo { Pos = { 213.333, -61.1213 } },
      },
      c1 = Custom {
         NameSet = true,
         Inputs = {
            NumberIn1 = Input { Value = 102, },
            NumberIn2 = Input { Value = 289, },
            NumberIn3 = Input { Expression = "iif(time < 102 , 0 , floor(((c1.NumberIn1 + (time - c1.NumberIn1) )/ c1.NumberIn2) * 22500) ) ", },
            LUTIn1 = Input {
               SourceOp = "c1LUTIn1",
               Source = "Value",
            },
            LUTIn2 = Input {
               SourceOp = "c1LUTIn2",
               Source = "Value",
            },
            LUTIn3 = Input {
               SourceOp = "c1LUTIn3",
               Source = "Value",
            },
            LUTIn4 = Input {
               SourceOp = "c1LUTIn4",
               Source = "Value",
            },
            NumberControls = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 615.333, -54.4546 } },
      },
      c1LUTIn1 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 0, Blue = 0 },
         NameSet = true,
      },
      c1LUTIn2 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 204, Blue = 0 },
         NameSet = true,
      },
      c1LUTIn3 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 0, Blue = 204 },
         NameSet = true,
      },
      c1LUTIn4 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 204, Blue = 204 },
         NameSet = true,
      }
   }
}
Attachments
2021-12-28.png
2021-12-28.png (357.31 KiB) Viewed 1191 times
2021-12-28 (1).png
2021-12-28 (1).png (372.6 KiB) Viewed 1191 times
Win 10 Home | Intel i7 - 10700f 64 GB 1 TB GB SSD 2 TB SSD
RTX-3060 12 GB | Resolve Studio 18.6.6| Fusion Studio 18.6.6

Win 10 Home | Intel Core I7-7700HQ 32 GB 1 TB NVME SSD 1 TB SATA SSD
GTX-1060-6GB | Resolve 17.4.6
Offline

ToteMusik

  • Posts: 4
  • Joined: Tue Dec 28, 2021 4:08 pm
  • Real Name: Tobias Krellmann

Re: Expression for Count up to a certain number

PostWed Dec 29, 2021 9:54 am

Hi Eric,

thank you very much, for your great example!
Posted an answer before, but the forum did not post it.

It's works quite well, with one little exception.

I can set 0, but when I start at TF 102 for example, the count up will not start at 0. It starts at ~7900. I guess it's because it's counting the TFs before and jumps to that number.

That's a little issue, but I can life with that.

Great work! Thanks again.
Offline

xunile

  • Posts: 3109
  • Joined: Mon Apr 23, 2018 5:21 am
  • Real Name: Eric Eisenmann

Re: Expression for Count up to a certain number

PostWed Dec 29, 2021 5:02 pm

You're welcome, glad I could help. It starts at 0 but then does jump to a high number because the range of frames it is working with is pretty low. It uses the ratio between the start and end frame to create the count. If you use the following code in the custom tool it will start lower at around 900. You can tweak it to lower it more but since it is a simulated count it should look ok at 30 fps.

Code: Select all
iif(time < 102 , 0 , floor((time ^  3) * 22500 / c1.NumberIn2 ^ 3))
Win 10 Home | Intel i7 - 10700f 64 GB 1 TB GB SSD 2 TB SSD
RTX-3060 12 GB | Resolve Studio 18.6.6| Fusion Studio 18.6.6

Win 10 Home | Intel Core I7-7700HQ 32 GB 1 TB NVME SSD 1 TB SATA SSD
GTX-1060-6GB | Resolve 17.4.6
Offline

ToteMusik

  • Posts: 4
  • Joined: Tue Dec 28, 2021 4:08 pm
  • Real Name: Tobias Krellmann

Re: Expression for Count up to a certain number

PostWed Dec 29, 2021 5:37 pm

Thank you again, and this will work great for me, and my animation works, like I want it to do! :D
I'll just expand the range, that's ok.

Return to Fusion

Who is online

Users browsing this forum: No registered users and 19 guests