brendan-duncan / webgl_recorder

Debugging tool for Unity WebGL
MIT License
0 stars 0 forks source link

WebGL Recorder

WebGL Recorder is a debugging tool for WebGL.

It is a playback recorder, designed to capture all WebGL commands and data, with the ability to play back the commands to recreate the render.

It captures all WebGL commands, buffers, and textures, over a given number of frames. It will then generate an HTML file containing javascript with all of the WebGL commands recorded. This generated HTML file can be opened in the browser to play back the recording.

This can be used to diagnose issues with WebGL rendering by eliminating everything but the raw WebGL commands. This is also very helpful for submitting self-contained reproduction examples for bug reports.

Using With Unity

Using From HTML

Load From CDN

You can load the script through a CDN so you don't have to store it locally and make sure you're always using the latest version of the recorder.

<script src="https://cdn.jsdelivr.net/gh/brendan-duncan/webgl_recorder/webgl_recorder.js"></script>

Load From Local Script Reference

If you prefer to host your own version, copy the script to your project and load it by adding the following to your project's HTML.

<script src="https://github.com/brendan-duncan/webgl_recorder/raw/main/webgl_recorder.js"></script>

Start The Recorder

Once the recorder script has been loaded in your app, you can instantiate the recorder by using the following:

<script>
    new WebGLRecorder();
</script>

Because the recorder needs to record all commands and data, it starts recording as soon as it is contructed, and will continue recording for the maximum number of frames. The recorder should be created before any rendering code starts so it has a chance to wrap WebGL.

The recording will download automatically as an HTML file with embedded Javascript after the maximum number of frames have been recorded.

You can optionally configure the recorder

<script>
    new WebGLRecorder({
        "frames": 100,
        "export": "WebGLRecord",
        "width": 800,
        "height": 600,
        "lines": 0
    });
</script>

Where

Play The Recording

The recording is a self-contained HTML file so you don't need a local server to view it.

Open the downloaded HTML file in a browser to play back the recording.