Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sine wave driving RGBA value trouble

  • sine wave driving RGBA value trouble

    Posted by John Hammond on February 15, 2009 at 3:05 pm
    //generate wave
    red = Math.sin(time*10);
    
    //normalise to 0 - 155
    rednorm = linear(red,-1,1,0,255);
    
    //rgba array
    [rednorm,255,255,255];

    Hi,
    Im having a little trouble with getting the RGBA values of a ‘fill’ effect to be controlled by a sine wave..

    I was hoping for the R value to peridically ramp from 0 to 255 smoothly, creating a smooth change in colour over time. (see my code below).

    Instead my fill colour stays white and flickers on cyan for a split second then goes straight back to white, with no smooth graduation in colour.

    Can’t get my head around why this shouldn’t work, but I am a newb to expressions so please excuse me!

    Filip Vandueren replied 17 years, 2 months ago 3 Members · 6 Replies
  • 6 Replies
  • Filip Vandueren

    February 15, 2009 at 4:50 pm

    Hi John,

    The colors are expressed with 1 as maximum, not 255. So just change the code and it should work.

  • Paul Hennell

    February 15, 2009 at 8:09 pm

    Do you know why that is Filip? I encountered the same problem a week ago, trying to make a levels effect flash and eventually realised the input white had to be 0~1 not 0~255 like it says.

    It’s most confusing, I’m just wondering if there’s any logic behind it.


    Only in after effects do children get to pick and whip their parents.
    https://hennell-online.co.uk

  • Filip Vandueren

    February 16, 2009 at 12:06 am

    It’s just a convention I guess.

    Though from a programming perspective it does make sense: 0= off (black), 1=on (white).
    The accuracy with which you express inbetween values is arbitrary, 8 bits, 16 bits, 32 bits.

    What would happen if you work in 16 bits per channel, should you rewrite all your expressions to work with a maximum of 65535 ?

    You can choose to express all colors in After Effects as in the range 0-1 by setting the viewing preferences in the info palette.

    In 32 bpc mode, this is the standard way of expressing values, because values can also go below 0 and above 1. It’s easier to understand that 1.5 is 50% super-white than thinking what the hell a value of 21384161439 is 😉

  • John Hammond

    February 16, 2009 at 10:57 am

    Thank you all!
    I’ll try that when I get home. The was indeed very simple. It seems like it makes sense using 0 – 1 instead of 0 – 255, for the reasons you mentioned. Also, in this case, I can leave out the normalise line of code now.
    Thanks
    John

  • Paul Hennell

    February 16, 2009 at 5:47 pm

    Hadn’t thought of the advantages it brings to colour modes, it makes good sense when you explain that.

    Still, sensible though it may be, It could be more user friendly – you expect expressions to have to return the same value as the default option not something completely different…

    Thanks for the info though, always good to understand what’s going on.


    Only in after effects do children get to pick and whip their parents.
    https://hennell-online.co.uk

  • Filip Vandueren

    February 16, 2009 at 10:57 pm

    You’ll still need the normalize, as negative values won’t make any sense.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy