# Round values of a f-curve to be either 0 or 1

I would like to transform my baked f-curve in blender. I already scaled it so it's values are between 0 and 1 using the envelope-modifier. Now i want to transform the f-curve in a way that all values under 0.5 will be set to 0 and all above will be set to 1.0 (so basically rounding the values). Is there a way to achieve this using the f-curve modifiers? I can only think of an difficult solution concluding writing a script.

Add an Envelope Modifier with the following settings:

Reference Value: 0.5
Min: -0.5
Max: 0.5

Add a control point to the Envelope and use Min and Max bounds of “large” absolute value, but between the allowed range of -10000 and 10000, e.g.:

Frame: 0
Min: -9998
Max: 10000

Finally, add a Limits Modifier with Minimum Y of 0 and Maximum Y of 1.

The control point's Min and Max values are important when you care about the rounding of the input value 0.5.

• With Min and Max equally distant away from the reference value of 0.5, the input value of 0.5 will not be modified.
e.g. Min = -9999, Max = 10000.
• I used a slightly larger value of -9998 for Min so that the input of 0.5 will be rounded up.
• You can use a slightly smaller value like -9999 to round the input of 0.5 down.

The size of the bounds will determine how well this method works for values which are close to the reference value. F-Curves with easing near it or keyframes obtained by simulation or experiment might produce numbers which will not be pushed all the way to the intended limits.
For example the image below shows the result of a sinusoidal ease-out over frames 0 to 10 with input values 0.499 to 0.5. Frame 9 ends up with a value of about 0.75 instead of 0.

It's not possible to change the control point's bounds beyond 10000, but if you work with values close to 0.5 you could duplicate the envelope modifier:

• He, thank you for your answer! works great :)I actually tried this before but did not use numbers that were "large" enough. Does the fact that it works with a 1000 mean that the "accuracy" of an f-curve is 0.001? Nevertheless thank you again! :) – marvin Mar 5 '17 at 18:30
• @marvin I edited the answer to try to explain importance of larger numbers and I hope this answers your question. In the original answer I intended to use 1000 instead of a number a few orders of magnitude larger simply to avoid having to count digits. I assumed the maximum values to be the range of Python's float. As it turned out this is not the case. I can't think of any reason not to enter values that don't exhaust the allowed range of 10000. – binweg Mar 5 '17 at 20:54