2
$\begingroup$

I need to display a bunch of fish instances with randomized scale.

randomized scale fish

They are generated with geonodes. Under each fish, I need to display its ( randomly generated ) scale. As you may know using a random value to feed a {value to string} node generates an error.

using a random value to feed a  {value to string} node generates an error

Here, the string to curve would generate a text instance to be displayed under its corresponding fish.

Now I still can enter all scales manually ... but ... but ... you know.

Any idea to solve this problem ?

Thanks !

$\endgroup$
3
  • $\begingroup$ Since the Value to String Node only accepts a single value, this currently does not seem to work in GN. But there is at least a solution with the (free) Animation Nodes Addon, which can be linked to GN: blender.stackexchange.com/questions/251470/… $\endgroup$
    – LaserLars
    Commented May 26, 2023 at 12:05
  • 1
    $\begingroup$ Thanks Lars, but my problem is not to display a random number only. This number must also be the scale of my fish. Ad I don't see how I can use your solution to connect scale and text $\endgroup$
    – Nicolas
    Commented May 26, 2023 at 15:14
  • $\begingroup$ Yes, I had assumed that there is some way to pass a 'scale' value/field/attribute from AN to GN and back, but I must admit I didn't check it thoroughly. Maybe my answer below is of some use? $\endgroup$
    – LaserLars
    Commented May 26, 2023 at 15:21

3 Answers 3

5
$\begingroup$

Here is another solution...

This may look cumbersome (to be honest it is), but basically this solution is relatively simple.

Since Geometry Nodes can only create text with the String to Curves node, which does not accept fields as input, you would have to do the following:

  1. Since the String to Curves node outputs each digit as an instance, simply create the numbers $0-9$ as well as the dot and reset their position to $(0,0,0)$.
  2. Then simply instantiate curves at the desired points, which themselves consist of as many points as the number of digits of your numbers (in this example I use four digits, as this allows numbers with two decimal places to be represented).
  3. At the points of these curves then instantiate the previously created numbers. By using the index of the points of each spline, and additionally the option Pick Instance as well as Instance Index you can then pick the desired number.

This could look something like this:

enter image description here enter image description here

Useful note: In case you are wondering why this works when I use a float value as Instance Index: Funnily enough, when using the Instance on Points node, the float value is not rounded up or down, but always rounded down, so all decimal places are truncated.


(Blender 3.4+)


Update 1

...and here is a further development of this approach, which can also handle different and multi-digit numerical values (currently no negative values though).

I'm working on it, but I thought it would be good to share this variant:

enter image description here enter image description here


(Blender 3.4+)

$\endgroup$
1
  • 1
    $\begingroup$ Great solution to instance the digits 0-9! Good to see there is actually a fully automatic solution. Btw: Nice trick, doing 'text formatting' with a curve line... I bet this will come in handy sooner or later :-) $\endgroup$
    – LaserLars
    Commented May 30, 2023 at 8:35
4
$\begingroup$

I found a decent solution, or let's call it a workaround :

Fish with grads

It is based on the Animation Nodes addon : It creates a collection of 100 texts : 0.0 ; 0.1 ; 0.2 ; ... 10.0.

The collection is named : "Animation Nodes Object Container" (sorry not very self explanatory ...)

Creation of a set of texts

Then in Geonodes, we calculate the which text must be displayed, in fact, its index. Off course the collection of texts are well ordered and index order corresponds to number order !

Here is this calculus : My scales vary from 0 to 1.5. I want to map this interval to my set of indexes : [ 0 ; 1 ; 2 ... 99 ].

enter image description here

As you guess, I haven't invented anything here myself. Sources : Animation nodes

$\endgroup$
4
  • $\begingroup$ In fact, this can be used to display many kinds of values. So I think that the title of this post is too restrictive. Is there a way to change it to : Geonode : "Display varying values as texts" ? ... or too any better title you could suggest ? $\endgroup$
    – Nicolas
    Commented May 28, 2023 at 17:15
  • $\begingroup$ "I would like to share the .blend with this nice logo but how ??" See here: blend-exchange.com $\endgroup$
    – LaserLars
    Commented May 30, 2023 at 6:32
  • $\begingroup$ Thanks lars ! Now my .blend is available ( although it is not so interesting compared to the others ...) $\endgroup$
    – Nicolas
    Commented May 30, 2023 at 7:21
  • $\begingroup$ Oh, I wouldn't say that. I think we all learned something while exploring your issue. And later, hopefully, others can profit from the variety of solutions here :-) $\endgroup$
    – LaserLars
    Commented May 30, 2023 at 8:13
2
$\begingroup$

There is actually some way to do this in GN, but it only works for a limited number of objects, since you have to manually connect a sub-group for every instance. It's still more flexible than typing numbers by hand (especially when these numbers are changing dynamically):

enter image description here

The trick is to extract from the Random Value's field data a single value via Sample Index Node, convert it into a string and join the digits (and letters) together into one 'dimension instance'. Don't forget to check Pick Instance in the Instance on Points node.

This is how it looks inside the 'Sampler' group:

enter image description here

I know, it's a bit clumsy. But afaik, it's the closest we can get for now.

Here's the file for reference:

$\endgroup$
1
  • 1
    $\begingroup$ Thanks again Lars, good idea ! My problem is that there is many more fish in this project than can be seen in my screenshot. So I am going to try something else. One option is Python script instead of geonodes that may not be quite mature yet ... $\endgroup$
    – Nicolas
    Commented May 27, 2023 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .