Alpha problem


I’m beginning with shaders, and want to do a simple thing for the moment, but what I did has a so strange behaviour that I’m going to be crazy.

I want to decrease alpha from 1 to 0 in the x direction, starting to a certain x, called here “xi”.

It works when

  • xi=0.5 (so the right half of my pad has the decrease)
  • xi=0 (so all the pad has the decrease)
  • xi=1 (no decrease at all)
    For all other values, it doesn’t work, or I should say it works as if the x=1 was more at right : alpha vanishes, but not until 0 !

Another strange thing is that when I manipulate other members of the Color class, like r, g or b, (this was to debug) this time alpha vanishes to 0, but not starting at 1 : as if this time the x=0 was more at left.

I attached my effect and a very basic patch to see the effect.
Try to change “xi”, then try to set “debug” to 1, to see what I explained.

Thank you for your help, hoping I didn’t do a dummy thing or forget an obvious element.

Matthieu (2.1 kB)

hello, this is due to the shader 1.4 profile, there all values are clamped between -1 and 1. just swtch to 2.0 profile.

i would also replace the if with a saturate, becuase ifs are rather slow in shaders. (3.2 kB)

Thank you !!!
Indeed it works perfectly now.