lightning-js / renderer

Lightning 3 Renderer
Apache License 2.0
57 stars 23 forks source link

Animations for non-pure-number properties and effects #402

Open m-hall opened 1 month ago

m-hall commented 1 month ago

This is a request/proposal, and I wanted to get some advice for this before I take a look at possibly contributing a change myself.

My goal right now, is to allow gradient effects to animate their colors.

However, I think if I go down this road, it would make sense to allow any effect uniforms to have the ability to define their own animations calculations.

My proposal is to add an animate function to the ShaderEffectUniform. The definition would be something like: animate?: (start: T, end: T, progress) => T

This would (in theory) allow any uniform to define how the values are to be interpolated. eg. allowing a number[] to be animated Of course, the current method would be a backup for any uniform that does not define this property.

Ideally, if this works out, then I think it could be useful to allow animations on many style and shader properties that are not just single numbers, and enable custom effects to define their own interpolation as well.

erikhaandrikman commented 1 month ago

Thanks for your proposal :) We haven’t investigated the possibility of implementing animation on shader uniforms yet, but it sounds like a really useful feature. Adding a ShaderEffectUniform to handle interpolation is interesting and could open up the way to more dynamic effects.

If you'd like to contribute, that would be really helpful!

jfboeve commented 1 month ago

Hi @m-hall we are currently busy with an overhaul of the current shader system, that being said I think it would make more sense to implement a feature to the CoreAnimation to support interpolating arrays containing numbers. If you'd like to help us in that way I think it would also resolve your problem with gradient effects!