Page MenuHome

Scene time input node
Closed, ResolvedPublicTO DO

Description

Currently, to access the scene's time in geometry nodes, one has to use a #frame driver.
People have gotten used to doing this, but there is no particular reason it has to be complicated.

Instead, we should add a "Time" node that gives the current scene time, in frames and seconds.

Details

The node should have two single value outputs:

  • Frame The current scene frame
  • Seconds The current scene time in seconds (the name is the unit since there is no other way to make that clearly visible.

Implementation

Implementation wise the node itself should be fairly trivial. The more complex part is probably making the object reevaluate when the scene time changes.

  • To get the current time from the depsgraph use DEG_get_ctime(...).
  • To get the current depsgraph use GeoNodeExecParams::depsgraph().
  • In updateDepsgraph in MOD_nodes.cc, the node group has to be scanned for a Scene Time node, and if available a relation has to be added to the depsgraph. Maybe a new function next to DEG_add_node_tree_relation has to be added for that (e.g. DEG_add_scene_time_relation).

Further Questions

Node name: "Time" is a bit vague when there could possibly be other sources of time in the future-- simulation time, object time. So Scene Time might be a better more explicit name.

Revisions and Commits

Event Timeline

Hans Goudey (HooglyBoogly) renamed this task from Time input node to Scene time input node.Nov 15 2021, 6:44 PM
Hans Goudey (HooglyBoogly) changed the task status from Needs Triage to Confirmed.
Hans Goudey (HooglyBoogly) created this task.

Sounds good 👍🏻 a reminder to me or someone else to rename the compositor time node to "time curve node".

https://docs.blender.org/manual/en/latest/compositing/types/input/time.html

Can we add the scene framerate also? This way we can easily calculate time in seconds (or any other unit) rather than in frames.

This way we can easily calculate time in seconds (or any other unit) rather than in frames.

Isn't that what the seconds output is for though? Anyway, I don't really think framerate should be exposed that way, since it can be problematic if changing the framerate for rendering can change arbitrary things in some node tree.

My bad I didn't see the seconds output, I thought there was only frames.

@Johnny Matthews (guitargeek) @Hans Goudey (HooglyBoogly) will this stay a Geometry Nodes exclusive? It would be useful in Shader Nodes too(like a few other GN exclusives)