Material editor: power(0, 0.1) = 0.25118

I noticed that my particles never fade to black even tho the particle alpha curve is properly set up and the vertex color values are used in the related material. That led me to the realization that in the material editor lower exponents in the power function start to produce non-zero output for a zero input value.
For example power(0, 0.1) seems to be equal to 0.25118. I presume it’s a floating point precision issue. What is the proper workaround?

Hi ZoltanE -

Take a Floor or Ceil node (which ever you are more comfortable using, but for an Alpha control I would use Floor) and feed in the results from your Power Node.

Eric Ketchum

But that operation would turn the alpha’s gradual change into a binary one, no?

I think so.

One workaround would be to use power(input, 0.1) * clamp(ceil(input), 0, 1)
You can get rid of the clamp node if you don’t expect your input to be outside the 0…1 range.

Yep this it does make sure that the low end ends up being zero. The sudden jump to mid gray as soon as the input becomes larger than 0.000000 is not really visible in my case (at least at the current frame rate) but would be still a problem at slower transitions.

The attached image shows a formula which avoids the jump but makes the curve a bit deformed at the beginning (and also costs more instructions). The function plot is not to scale but gives you and idea about the difference between the original power function (green) and the tweaked one (red).