Capturing WebGL content normally requires a graphics card, but you can still grab frames or record video on machines without a GPU—like some virtual machines, remote desktops, or older laptops. This guide shows you how to use software rendering (SwiftShader) and headless browser tools to capture WebGL output as images or video, using only the CPU.
What You’ll Need
- A computer running Windows, macOS, or Linux (no dedicated GPU required)
- Node.js installed (for Puppeteer method) or Python 3 (for Selenium method)
- Google Chrome or Chromium browser (version 79 or newer)
- Basic familiarity with the command line
Step-by-Step
- Enable SwiftShader in Chrome. SwiftShader is a software rasterizer built into Chromium that renders WebGL on the CPU. Launch Chrome from the command line with the flag
--use-gl=swiftshader. For example, on Windows:chrome.exe --use-gl=swiftshader, on macOS:open -a "Google Chrome" --args --use-gl=swiftshader, on Linux:google-chrome --use-gl=swiftshader. This forces all WebGL contexts to use software rendering. - Verify WebGL is working. Open a WebGL test page like
https://get.webgl.org/in that Chrome window. You should see a spinning cube. If you see an error, check the console (F12) for messages about SwiftShader failing to initialize—usually due to missing system libraries. - Use Puppeteer to automate capture. If you need to capture frames automatically, install Puppeteer via npm:
npm install puppeteer. Then write a script that launches Chrome with the SwiftShader flag, navigates to your WebGL page, waits for the scene to render, and takes a screenshot usingpage.screenshot(). - Record video with Puppeteer. Use the
page.screenshot()method in a loop while moving the camera or animating the scene, saving each frame as a PNG. Then use a tool like FFmpeg to combine frames into a video:ffmpeg -i frame-%04d.png -c:v libx264 output.mp4. - Alternative: Use Selenium with Python. If you prefer Python, install Selenium and the Chrome driver. Set Chrome options to include
--use-gl=swiftshader. Then usedriver.get_screenshot_as_file()to capture frames. - Capture directly from the browser. If you only need a few screenshots, you can use the browser’s built-in screenshot tool (right-click > “Capture screenshot”) or the developer tools (F12 > Ctrl+Shift+P > “Capture full size screenshot”). This works because SwiftShader is already active.
- Optimize performance. Software rendering is slow. Reduce the canvas resolution in your WebGL app (e.g., set
canvas.width=640instead of 1920). Also disable antialiasing and shadows in your WebGL settings to speed up rendering.
Common Mistakes
- Forgetting the flag. Launching Chrome normally without
--use-gl=swiftshaderwill fall back to the default GPU path, which fails on machines without a GPU. - Using an outdated Chrome. SwiftShader support has improved over time; older versions may crash or not support WebGL2. Update to the latest stable Chrome.
- Not waiting for the scene to load. Taking a screenshot immediately after page load often captures a blank or partially rendered canvas. Use
page.waitForTimeout()or wait for a specific element to appear. - Ignoring the console. WebGL errors are logged to the browser console. If you don’t check it, you might think the capture failed when it’s actually a shader compilation error.
Tips
- For video capture, consider using
page.mouseto simulate camera rotation for a more dynamic result. - Use
--disable-gpualong with--use-gl=swiftshaderto ensure no GPU interference. - If you need transparent backgrounds, set
--default-background-color=00000000in Puppeteer’s screenshot options. - Test with a simple WebGL scene first to confirm the setup works before attempting complex captures.
Troubleshooting
- WebGL not available. If you see “WebGL is not supported” even with the flag, try adding
--enable-unsafe-swiftshader(Chrome 90+). This allows SwiftShader to be used even when the GPU is blocked. - Black screenshots. This often happens when the canvas is not fully rendered. Increase the wait time or use
page.evaluate()to check if the WebGL context is ready. - Slow performance. Software rendering is CPU-intensive. Close other applications, reduce the canvas size, and consider using a lower frame rate for video (e.g., 15 fps instead of 30).
- Puppeteer errors. If Puppeteer fails to launch Chrome, ensure the executable path is correct. You can specify the path in
puppeteer.launch({executablePath: 'C:\Path\To\chrome.exe'}). - FFmpeg not found. Install FFmpeg from the official website and add it to your system PATH, or use the full path in the command.
Frequently Asked Questions
Can I capture WebGL without any GPU at all?
Yes, SwiftShader is a complete software implementation of WebGL. It runs entirely on the CPU, so no GPU is needed. However, performance will be significantly slower than hardware acceleration.
Does this work for WebGL2?
Yes, SwiftShader supports WebGL2 in recent Chrome versions. If you encounter issues, ensure you’re using the latest Chrome and add the --enable-unsafe-swiftshader flag if necessary.
Can I capture video with audio?
Yes, but you’ll need to capture audio separately (e.g., using a virtual audio cable) and merge it with the video using FFmpeg. The method described here only captures the visual canvas.
Is there a way to capture WebGL without writing code?
Yes, you can use browser extensions like “Full Page Screen Capture” that work with SwiftShader, but they may not support video recording. For video, you’ll need a screen recorder like OBS, which can capture the browser window even with software rendering.
Why is my capture so slow?
Software rendering uses the CPU to simulate a GPU, which is much slower. To improve performance, reduce the canvas resolution, disable heavy effects, and close other programs to free up CPU resources.
Can I use this method on a headless server?
Yes, you can use Puppeteer’s headless mode with the SwiftShader flag. Headless Chrome supports SwiftShader, so you can capture WebGL on a server without a display or GPU.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Gmail Notifications Not Working? Fixes That Work
- Fix Thumbnails Not Showing on Network Drives in Windows 11
- Stop Skype Auto-Start in Windows: 5 Fixes
- Fix Windows PowerShell Popping Up
- Print iMessage or Text Conversations on iPhone & iPad
- Madden 20 Crashes on PC: Solved?