# How to invert a value in animation nodes?

Do somone know how to realize that: I want to control the value on the light strength of my shader in the my node tree with the amplitude of a sound file. This works perfectly fine in the animation node Plugin. But now i would love to invert the light strength. That means when the light goes on, on the first (original) material, the light on the inverted material should go off.

Is my question understandable :D ?

I hope so.

Greets and ty 4 all replies

• max - amplitude? Apr 30, 2019 at 17:27
• Hey Omar:) I can freely choose the amplitude. The files come directly from my DAW and are limited at dBFs 0. The specific track i was talking about in my question were the solo stem of my instrumet bus. So i guess his in avarage lvl is like -12 to -6 DbFs. Apr 30, 2019 at 18:36
• I mean, all you have to do is subtract the computed amplitude from the maximum amplitude you define. Apr 30, 2019 at 18:41
• Can you please clarify what you want to do? May 3, 2019 at 7:22

If I understand your question correctly, the answer is very simple. You probably recall that any number times negative one also becomes negative. (n * -1 = -n)

So whatever value you want to invert, just run it through a Math node set to Multiply, and set the other value to -1. In the following example, a Math node is being used to flip geometry along its X axis: The concept is the same when dealing with color in Material nodes, and also Compositor nodes. So it might help you to look at those as well and compare. Although in those editors there is a handy Invert node that saves us time so we don't need to process the inversion of color or alpha channels using Math nodes. But if we were to use Math nodes, the same result could be achieved. You can compare the different node setups below: In the example of the arrow, the range is -1 to 1, with the center being 0.

In the example of the colors, each channel has a range of 0.0 to 1.0 with the center being 0.5. So here we use an additional Math node set to Add, to keep the values in a positive range. (If you try this on geometry such as the arrow, the geometry will scale to 0 and you will see nothing.) So the method of inversion will depend on the range of values you are trying to invert. I hope this makes it clear for you.

If it helps, you can play with the .blend of the images above. 