(Using Blender 4.2.1)
Approach
A classical approach with GeometryNodes modifiers to save CPU time and memory when displaying numbers is to use an Instance on Points
node to spawn digits instead of using Value to String
then String to Curves
nodes for each number. In the present case of a grid, this technique can be combined with an other Instance on Points
node to set the points where digits are placed, avoiding a Repeat Zone
.
Setup and results
For the demonstration, a 25x25 grid is added in Object Mode. It is rotated around X axis such that the first faces are at the top instead of the bottom. This transformation is applied.
The GeometryNodes modifier displaying the numbers (i.e. faces index) is not added to the grid, but to the default cube. The grid is specified as an input parameter of the modifier. This way, grid and numbers can be visualized independently.
Resources
GeometryNodes modifier
1. An Instance on Points
node is used to pick digits stored in a collection (see pink contour) to spawn them at points generated by an other Instance on Points
node (see red contour). Instance Index is computed from the integer to display and the digit rank (see green contour).
2. Curves outlining the digits from 0 to 9 are generated by a single String to Curves
node. These are output as superimposed Instances with index ranging from 0 to 9 also. In the same String, the last character is the blank space (so not visible in the screen capture...), with instance index 10. For rendering purpose, curves are filled with N-gons and are receiving the material "Black".
3. Points are generated at the location of each digit making the grid of integers, with an Instance on Points
node spawning a line of 3 vertices per face of the input object. With 3 vertices, numbers from 1 to 999 can be displayed. To support different digits, those vertices have to be converted to individual mesh elements using a Realize Instances
node.
4. The coordinates of the input object faces center are recovered by a Mesh to Points
node set in Faces domain. It is to notice that the Transform Space property of the Object Info
node providing this object geometry is set to Relative for the labels to follow the object displacement.
5. A Mesh Line
made of 3 vertices aligned with X axis extending from -1 to 1 is initialized. It is to notice that it is slightly offset in Z direction to avoid Z-fighting between faces and labels. Then it is successively shifted in X direction to make 3 instances collected by a Geometry to Instance
node. The first instance of index 0 is centered on middle digit ; the second instance of index 1 is centered on the space between middle and last digits ; the third instance of index 2 is centered on last digit.
6. The spacing of digits is scaled with a Transform Geometry
node to be adjusted to the font and the faces size.
7. To center on a face the associated number (i.e. its Index + 1), one of the 3 instances shifted at step 5 is picked, according how many digits are required. Using a cascade of Switch
nodes, the instance of index 2 is picked for numbers lower than 10, the instance of index 1 is picked otherwise for numbers lower than 100, the instance of index 0 is picked otherwise.
8. At step 3, a triplet of spawning points is generated for each number $n$ to display, one point per digit. Let $i$ be the Index of such a point. For a given value of $n$ (starting at 1), $i$ is between $3(n-1)$ and $3(n-1)+2$. Consequently, the value of $n$ for a given value of $i$ is computed as the integer part of $\frac{1}{3}(n+3)$.
9. Let $j$ be the rank of a digit (from right to left, starting at 0) and $d_j$ be this digit value. The value of $n$ is defined as: $$\begin{array}{rcl} n & = & 100 \times d_2 + 10 \times d_1 + d_0 \\
\mbox{} & = & 10^2 \times d_2 + 10^1 \times d_1 + 10^0 \times d_0
\end{array}$$
For a given value of $n$, $d_2$ is at Index $i=3(n-1)$, $d_1$ is at Index $i=3(n-1)+1$, $d_0$ is at Index $i=3(n-1)+2$. So $d_j$ is at Index $i=3(n-1)+2-j$. Consequently, $2-j$ is the remainder of the division of $(i+3)$ by $3$.
10. Dividing $n$ by $10^j$ yields:
$$10^{(2-j)} \times d_2 + 10^{(1-j)} \times d_1 + 10^{(0-j)} \times d_0$$
Consequently, $d_j$ is the integer part modulo 10 of this expression.
11. Leading zeros for numbers lower than 10 and 100 are replaced by blank space (stored as the instance of index 10) using a cascade of Switch
nodes.