5
$\begingroup$

Is it somehow possible to put an attribute value in From Min/From Max?

enter image description here

What i want is to have control over e.g. scales of all distributed instances.

i want to scale them randomly...

e.g. from start frame between 20 to 100 and with end frame between 120 and 150 and scale randomly.

So every instance should scale different (different time + duration).

$\endgroup$
3
  • 1
    $\begingroup$ I think not. Those are fixed float parameters, not per-element. Can you give an idea of your particular case? Maybe there's another way. $\endgroup$
    – Robin Betts
    Commented Jun 15, 2021 at 10:32
  • $\begingroup$ Not as far as I know. $\endgroup$ Commented Jun 15, 2021 at 10:33
  • $\begingroup$ @RobinBetts: i improved my question. See example here: [1]: i.sstatic.net/c9y8y.gif. there i scaled each individually randomly...but it was a pain in the ass with a lot of nodes :( if i could have attributes, it would be much easier $\endgroup$
    – Chris
    Commented Jun 15, 2021 at 10:49

1 Answer 1

6
$\begingroup$

The Map Range operation is basically a shortcut to a number of mathematical atomic operations.

You can emulate its behaviour by using regular Attribute Math Nodes.

Using the formula from the first link I suggested, I laid out the algorithm :

output = output_start + ((output_end - output_start) / (input_end - input_start)) * (input - input_start)
<=>
output = To Min + (To Max - To Min) / (From Max - From Min) * (input - From Min)

We then just need to do the operations linearly.

Let's create a node group in order to reuse it wherever we want.

enter image description here

First operation, calculate input - From Min

enter image description here

Then, From Max - From Min

enter image description here

To Max - To Min

enter image description here

(To Max - To Min) / (From Max - From Min)

enter image description here

(To Max - To Min) / (From Max - From Min) * (input - From Min)

enter image description here

Finally, (To Max - To Min) / (From Max - From Min) * (input - From Min) + To Min :

enter image description here

for the sake of tidiness, remove the unneeded attributes, and output the geometry.

enter image description here

Here's a simple setup to generate a bunch of attributes to test out our node group.

enter image description here

Plug everything up, and use a control regular Map Range node to test it.

enter image description here

Use the new Spreadsheet Editor to analyse the data.

enter image description here

It's the same, yay !

Caveats, possible improvements :

  • This group only accepts attributes. You could theoretically tweak it to accept floats with a Switch node (Blender 3.00 +), but the sheer number of possible configurations would make the node group very big and convoluted.
  • This is a linear interpolation, meaning you would need to change the algorithm to add a damping coefficient if you want a smoother interpolation.
  • Add an Attribute Clamp node at the end if you want the possibility to clamp output

Grab the file to test out the node group :

and here the attribute clamp node:

enter image description here

$\endgroup$
6
  • $\begingroup$ looks very promising...i check this out...!! $\endgroup$
    – Chris
    Commented Jun 15, 2021 at 11:14
  • 1
    $\begingroup$ Of course. Perfect. $\endgroup$
    – Robin Betts
    Commented Jun 15, 2021 at 11:15
  • $\begingroup$ That's amazing! Thank you Gorgious! Works perfect...!! Just a little comment ;) The attribute clamp as it is wouldn't help, because it doesn't allow attributes in min and max, right? so i would have to "rebuild" this on my own like you did with the map range node. Or am i missing something? $\endgroup$
    – Chris
    Commented Jun 15, 2021 at 11:30
  • 1
    $\begingroup$ @Chris Sure thing, thanks :) $\endgroup$
    – Gorgious
    Commented Jun 15, 2021 at 12:19
  • 1
    $\begingroup$ by the way: your answer freed me from felt 40 superfluous nodes....! ;) $\endgroup$
    – Chris
    Commented Jun 15, 2021 at 12:20

You must log in to answer this question.

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