-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Add Support for Configurable Rendering Context (2D and WebGL) #10449
Comments
That would be an entirely different library to be honest. Webgl is born with 3d in mind, doesn't have rich TEXT functionalities, all the code to transform a custom font into polygons would be to be built as for code to draw beizer curvers and random paths, different fill methods. What makes you think it would be faster that much faster? The code that needs to elaborate all this geometry would still be JS. Sure you could run the jumping bunny test much faster but when you go to generic drawing like text editing it wouldn't be so faster, geometry data would need to be rebuilt each key stroke and sent to the gpu every time. You could draw way more rectangles and polygons on screen at once, i m sure. |
Thank you for the response 😀 However, my main use case is rendering heavy 1080p video content from the Fabric.js canvas. I record the canvas using MediaRecorder, but when dealing with complex scenes, animations, and effects, performance becomes a major bottleneck. Since WebGL can significantly improve rendering performance for large-scale tasks, I was exploring ways to leverage GPU acceleration while keeping Fabric.js as the primary engine. What I Have Tried So Far
Modifying Fabric.js for WebGL Context
Since my architecture is entirely browser-based, I cannot offload rendering to Node.js or server-side processing. After recording the video with MediaRecorder, I use FFmpeg to convert WebM to MP4. Do you have any advice on handling video processing more efficiently in the browser? Any guidance or suggestions would be greatly appreciated. Thanks for your time 😀 |
CheckList
Description
Currently, Fabric.js utilizes the 2D rendering context (CanvasRenderingContext2D) for drawing operations on the main canvas. While it employs WebGL for image filtering through the WebglFilterBackend, there is no option to render the main canvas using a WebGL context. This limitation restricts performance enhancements that could be achieved through GPU acceleration.
Current State
Introduce a feature that allows developers to choose the rendering context for the main canvas, either '2d' or 'webgl'. This could be implemented as an option during the initialization of the Fabric.js canvas, for example:
const canvas = new fabric.Canvas('canvas-id', {
renderingContext: 'webgl' // or '2d'
});
Performance Improvement: Utilizing WebGL for rendering can leverage GPU acceleration, leading to smoother interactions and faster rendering, especially with complex scenes or a large number of objects.
Enhanced Capabilities: A WebGL context would enable advanced graphical effects and transformations that are challenging to achieve with the 2D context.
Additional Context
Implement checks to ensure the user's browser supports WebGL before initializing the canvas with a WebGL context.
The text was updated successfully, but these errors were encountered: