Blender Geometry Nodes has a number of nodes for working with text strings. There are nodes that allow us to convert numbers into text, and replace substrings in a text string. As an example, let’s implement a “countdown” from ten to zero words.
Add a cube to the scene, append a Geometry Nodes modifier to it, and initialize the initial node tree.
Add a Value to String (shift + a – Text – Value to String) and a String to Curves (shift + a – Text – String to Curves) nodes. Link them to the main branch of the node tree.
The number from the “Value” field of the Value to String node is converted to text, as curve.
To make a “countdown”, we need two initial numbers. The total number of the timeline frames to map it into the range from ten to zero. And the current frame number, to get the according number from the range.
There is no node for getting the total number of frames in Geometry Nodes, but we can easily get it with the driver.
Open the N-Panel in the Geometry Nodes area and switch to the Group tab. In the input group, by pressing the button with a plus sign, add a new field and name it “frame_end”.
In the modifier panel, in the field that appears, type a link to the scene property, which stores the number of timeline frames. Be sure to put the “#” in front:
1 |
#bpy.context.scene.frame_end |
This way we quickly create a driver and associate it with the scene property we need.
If we link the appeared “frame_end” output of the Group Output node with the “Value” input of the Value to String node, we will see the number of timeline frames.
To make a “countdown” from ten to zero, we need to split the available timeline frames into ten intervals.
Add a Math node (shift + a – Utilities – Math) and switch it to the “Divide” mode. Insert it after the Group Output node. In the remaining free lower field, type “10”.
At the output of this node, we get the number of frames in the gap.
If the current frame number is divided by the received value, we will get what interval the timeline cursor is currently in.
The current frame can be obtained with the Scene Time node (shift + a – Input – Scene Time).
Add another Math node (shift + a – Utilities – Math) in the “Divide” mode. Link the value from the “Frame” output of the System Time node with its upper input, and the result from the previous Divide node with its lower input.
Moving the cursor on the timeline, we can make sure that the value of our countdown changes from 0 to 10.
To reverse it from ten to zero, add another Math node (shift + a – Utilities – Math) in the “Subtract” mode after the second division node.
Type “10” in its upper field, and link its lower field with the result of the last division.
Now the countdown value changes from ten to zero, as we want.
Now we have to turn the numbers into text.
Add a Replace String node (shift + a – Text – Replace String) and paste it after the Value to String node.
In the upper field, we need to specify what kind of text will be replaced. Type “10” into this field (in this case, it is a string of two characters, one and zero).
In the bottom field, we need to specify what the text the top field will be replaced with. Type “TEN” into it.
Add nine more of the same nodes sequentially to replace each number from nine to zero into text.
Now, when we slide frames of the timeline, we see the “countdown” in words, not numbers.
To make letters visible on render, add a Fill Curve node (shift + a – Curve – Fill Curve) and a Set Material node (shift + a – Material – Set Material) after the String to Curve node. And assign the appropriate material.
Now, we can start the animation by pressing the spacebar.