Comments (14)
I know I'm a bit late to the party, but last year I built an SVG renderer in WebGL to tackle the high CPU usage of rendering SVG animations.
@dionysiusmarquis is mostly right- rendering SVG exclusively in a GL context isn't trivial, and tesselating every vector shape would be computationally expensive.
Where we made a breakthrough was - you don't need to tesselate vector shapes. I wrote a quick document explaining how you can render SVG without tesselation
We stopped working on this last year because startup startup stuff, but occurred to me that the same idea could be useful to implement as a WebGL engine for Lottie animations, in cases where CPU usage needs to be reduced.
If there's interest in picking this up as a project, I'd be happy to open source what we have, though we didn't build a FULL svg renderer, so it may require a lot more work to actually be production ready.
Example
SVG Animation (~20% CPU Usage): https://files.vectorly.io/demo/sidebyside-v1/index.html
WebGL Animation (~1% CPU Usage): https://files.vectorly.io/demo/v0-2-simpsons-250kbps/index.html
You can profile the CPU Usage in Chrome
Why we built it:
Long story: https://www.youtube.com/watch?v=EvGA5qCfy9I
from lottie-web.
@mattdesl I will as soon as I add expressions.
They will change the json format and won't be compatible with the current one.
Regarding a canvas renderer, the plugin has one. But svg filters outperform canvas pixel manipulation.
I don't know if it's easy to implement similar svg filters in Webgl. I'll look into this. Any suggestions where to start?
from lottie-web.
What kind of filters do designers typically go for? I imagine a WebGL/Canvas2D renderer might be more limited, i.e. only implementing certain features, and maybe no support for filters at all, but providing greater performance for certain scenes.
from lottie-web.
@mattdesl I think AE alpha/luma track mattes are a must. I need to get a layer to work as a mask for another one.
next on the list would probably be blur effects, and some layer styles like strokes.
from lottie-web.
Is the canvas demo in the readme accurate? I've tried that code snippet, but it appears that the library is still generating a svg.
from lottie-web.
@Tolmark12 Have you changed the animType to 'canvas'?
from lottie-web.
@bodymovin No sir I did not π€¦ Working great now, sheesh!
from lottie-web.
Hi,
If you can export to svg, it can be self contained and added to more
content in a web page.
Any idea how to do the same in webgl?
Imagine I have a bigger scene, how to add the animation exported feom
bodymovin as an element in that scene?
Thanks
On Nov 17, 2015 04:54, "Mark" [email protected] wrote:
@bodymovin https://github.com/bodymovin No sir I did not π€¦
Working great now, sheesh!β
Reply to this email directly or view it on GitHub
#18 (comment).
from lottie-web.
@boulabiar There's also the canvas renderer. I guess you could render on a canvas outside the dom and then draw the result on the webgl.
But ideally, a webgl renderer would be the best option, where you could add the animation as a geometry or texture.
Right now, a webgl renderer is not on my pipeline. I explored some time ago integrating with three.js and was promising.
from lottie-web.
Rendering svg exclusively in GL context isn't trivial. You need to tesselate every vector -shape, -line⦠etc. See nanovg, libtess2. Tesselating in js will be very slow. Complex 2d vector graphics isn't really what GL is meant for.
from lottie-web.
Good news! Skia has a canvaskit package which can be used to play Lottie JSON in WebGL canvas
from lottie-web.
https://github.com/LottieFiles/glottie
from lottie-web.
@shaafiee - Ah, okay, well I'm glad there's already an existing project!
from lottie-web.
If there's interest in picking this up as a project, I'd be happy to open source what we have, though we didn't build a FULL svg renderer, so it may require a lot more work to actually be production ready.
@sb2702
If there is still a possibility to open source a basic example it can be very nice for future references and comparisons.
from lottie-web.
Related Issues (20)
- Using Node v21 not supported: breaks on typeof navigator check HOT 2
- Lottie web security vulnerability
- Validating JSON Files as Lottie Animations HOT 1
- Animation has strange artifacts when rendering with canvas renderer HOT 2
- Console Log Error: <rect> attribute transform: Expected number, "matrix(NaN,NaN,NaN,NaN,β¦"
- json import fails
- 'setDirection' not working when combined with 'playSegments'
- AE Bodymovin SVG SMIL export fails if using position animation with separated dimensions
- Which filters are supported by canvas types
- destination folder line length
- After Effects text layers without animators are rendered in single characters.
- Image display issue HOT 1
- My after effects's lottie plugin wont open
- Update property with JS HOT 1
- Not sure if bug or dumb β Lottie-Web does not seem to follow pause() method consistently
- Bug: Animation with multiple segments loops the last segment only HOT 5
- Add/Update Rive Export from Bodymovin
- I can't edit the text value of the text layer keyframe in After Effects.
- How to disable transform3d to svg? HOT 1
- Telegram stickers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lottie-web.