Re: [css shaders] Request for additional UA uniform variables

On 13/10/2011, at 4:16 AM, Chris Subagio wrote:

> First, I'd like you to consider a clock parameter. 
> 
> This would be a constantly increasing value that you could use for ambient animations, like say a waving flag or lapping waves.
> 
> Ideally this u_clock would be something like a (float) seconds since 1970, unix style. Someone might find a neat use for the actual absolute time, versus just an incrementing number. Unfortunately the precision on these constant registers can vary wildly from hardware to hardware, and it's unlikely that such large numbers would work. So perhaps running time since page load would be sufficient, with some way to also pass in the absolute clock time when the page was loaded?
> 
> As an optimization, the clock parameter could be an option enabled from the filter declaration (defaulted to off!), effectively switching the element from a transition only animation to an ambient animation.


I think this should be done with a parameter to the shader and animated via CSS.

Just adding it automatically is saying "please redraw this as often as possible for the entire time the effect is applied" which could kill battery. It's much better to be explicit. For example:

filter: shader("flag.vs", "flag.fs", ….. timeoffset 0);
animation: wave-the-flag 3s 10;  /* wave the flag over 3s, repeat 10 times */

keyframes {

from {
   filter: shader("flag.vs", "flag.fs", ….. timeoffset 0);
}

to {
   filter: shader("flag.vs", "flag.fs", ….. timeoffset 1);
}

}

(Yes, my syntax is wrong but you should get the idea)

This way you could have the wave apply on hover, etc.

Dean

Received on Saturday, 15 October 2011 00:16:07 UTC