VL delta time

Just been trying to mess with the particle system, and it seems to be frame rate dependent, so how do we get a delta time or similar, I looked at current time and frame difference but that outputs time or something and I couldn’t use it as a multiply because its the wrong type. I dont have to mess much, you know deadlines etc, so I’ll do it in vvvv and pass it in I guess.

hei cat, please use some more words. just as you don’t have much time to mess, we don’t have that time to guess what you’re trying to do. we’d really love to help you get into vl but you need to allow us to help you…


from what? to do what?

if those are nodes you’re referring to please spell out their full names, so we don’t have to guess and make possible wrong assumptions.

And you dont have time to document… ;)

The help patch particle system from girlpower
Delta time as with all particle systems that add x per frame you need to scale it by the time it takes to draw a frame, other wise patch running at 30fps looks radically different to patch running at 120, for example.
I tried as above.
I dont know the names because you’ve changed the name of just about every node and given it takes me 4 or 5 attempts to even create a link I have little patience with vl ( I have changed link snap settings, but its starting the link that is tricky, not finishing it, its fine in vvvv on my tablet, almost impossible in VL, if you have a tablet in the office, it would be great for you to try it too)

why not zoom in and then pan a bit…?

the node you are looking for is called TimeDifference. it is a member operation of the IFrameClock interface. if you don’t connect a clock to it’s input, VL will set the default clock of the runtime, which is probably what you are looking for.

if your particle system should run in an arbitrary mainloop you just create an input for the frame clock and then the user of the particle system can input another frame clock.

so you’ve been pretty close with the IClock and FrameDifference… ;)

If you manage to do simple, separated bits of logic with a general purpose, even if they’re not “perfect”, please sew a patch that does “something easy to understand” and post it in “I made this simple thing in VL”. If there are things about VL that are not immediately understandable, please also add useful hints and tips (e.g., the first example in that thread needs a specific vvvversion).
Thank you.

P.S. I don’t how this post sounds like. My English feels rubbish this morning. I hope that you understand it’s just for the better.

So we wait for a zoomable interface, always thinking we can zoom out and see more of the graph, but in fact, we need to zoom into nodes that are already bigger, so we can use them as easily as vvvv?
Thanks for the clock info, but I thought VL ran in the same mainloop as vvvv (from reading other threads) so why does it need a connection from vvvv?
Also what is output from frame difference, looks like a float, but can’t be used as a float? Can I cast it to a float? Why can values not be converted between types (if that is the problem, automatically, ie if you need a conversion auto add a convertor node? On this line if something need to be converted to or from a spread, can VL not suggest a conversion node to make the connection and insert it for you?) Obviously if its not the right node to use, I should look at the ones you suggest, but what is the difference between iclock and iFrameClock?
@h99 your post makes perfect sense to me :) I’d have to clean up the curses that pepper my VL patch first… ;)

it doesn’t need any input from vvvv. the default clock is the one from VL which is the one of vvvv, if nothing is connected. i only ment that if you want to put your particle in VL into another mainloop, then you would need to connect the clock of that other mainloop/thread to the input.

do you see the type if you hover over the pins? it should tell you Float 64 and you probably work with Float 32 which is the default number type. this is also the reason why there is the convenience node TimeDifference (Float32) that outputs a Float32.

time in general needs to have higher precision as most 2d/3d math, so time is internally 64bit. but for the TimeDifference if should not cause any trouble. for more info and why this is important, read this blog post: https://vvvv.org/blog/integer-and-primitive-types-in-vl

if that would be done automatically you would lose 32 bits of precision without knowing it and that can lead to bugs in the program that are almost impossible to find.
however, you can connect a Float32 to a Float64 becasue in this direction nothing gets lost and the type system would not complain.

yes converters in links are totally planned. just not implemented yet because it’s very easy to solve with a ToFloat32 node in your case above. and all other conversions are there too of course.

this conversion is a bit different of course, but could work similar but we also have a more general approach in mind for value <-> spread conversions.

glad you asked, in short, IFrameClock is an IClock with the extra feature of the TimeDifference.

longer explanation: this is called a type hierarchy, IClock is the ancestor of the IFrameClock, this means IFrameClock inherits all features of IClock but adds more (TimeDifference in this case). it also means that all inputs that accept an IClock will also accept an IFrameClock (but not the other way around).

the is another good example of this is Sequence and Spread. Sequence is the most simple data collection there is, it does’t even know its count. Spread is a descendant of Sequence. in fact there are a few ancestors in between, like List for example, which all add some features (nodes) like Count, GetItem and so on. way down in the hierarchy there is Spread with lots of specialized functionality. the big win here is that all nodes that accept Sequence or List also accept a Spread, so you get tons of nodes that work with Spread for free…

conclusion: the type system is one of the biggest killer feature in VL and you need to get used to it and use it to your advantage. make your own meaningful types and always ask yourself what type is the data at a given point in your patch. in vvvv the question of what type data has wasn’t that present, but it gives you a lot more information and understanding about your patch compared to value spreads everywhere in vvvv…

1 Like

@tonfilm Could you shed some light? In my naivete, I see a contradiction between this

and this

As I understand it, a converter in link it’s something that already happens in vvvv, although in a different way, because a float output gets converted to integer when linked to an integer IOBox.
Wouldn’t a converter in link be an automatic conversion, anyway? Or it is another kind of link (not the one between two nodes)?
Sorry for the pedantry.
Thank you.

vvvv only has ‘sub types’. internally every number is Float64, you only get it represented differently in the UI, so no conversion at all there.

vl is a programming language that supports all native CPU number types. we picked Float32 as the default, since it is sufficient for 99% of daily tasks. but ‘time’ for example needs higher precision…

yes, the link would have a visual indicator that a conversion with potential information loss happens.[quote=“h99, post:8, topic:15630”]
Sorry for the pedantry.
no worries, programming is often about details, happy to help.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.