Skip to content

Commit

Permalink
Remove WebGL Unity instructions for patching Emscripten
Browse files Browse the repository at this point in the history
We have an internal workaround now that doesn't require a patch.

Diffs=
ba00a6765 Remove WebGL Unity instructions for patching Emscripten (#7297)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Jun 14, 2024
1 parent 323601a commit 2776735
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1b9405cdd82b93628579edf5f8d1ab08b7bc018a
ba00a6765c58cd3e7fd895c1b84dddabe6993029
38 changes: 0 additions & 38 deletions WEBGL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,3 @@ This is our best-in-class solution for both quality and performance, supporting
A fallback that will work on all modern browsers supporting WebGL 2. Anti-aliasing quality and playback performance won't be quite as high as PLS but will still be very good.

All Rive features are supported, however performance will be impacted when using advanced blend modes.

# ⚠️ Patching Emscripten

Rive's shaders use features Unity's WebGL shader pre-processor doesn't handle. We provide a patch that must be applied once to your local Unity install in order for it to bypass the shader preprocessor when loading Rive shaders.

## Locate Unity's Emscripten

Unity's emscripten installation is based on the location of the installed Unity Engine. For example, on Mac version 2022.3.10f1 will be located here:

```
/Applications/Unity/Hub/Editor/2022.3.10f1/PlaybackEngines/WebGLSupport/BuildTools/Emscripten
```

## Patching library_c_processor.js

Apply the patch to library_c_processor.js

```
patch -u -b /Applications/Unity/Hub/Editor/2022.3.10f1/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emscripten/src/library_c_preprocessor.js -i ./rive_unity_webgl_patch.diff
```

## Manually patching library_c_processor.js

The patch may not be compatible with your version of Unity, in this case you can manually make the change.

- Find library_c_processor.js in the paths provided above and open it in your code/text editor.

- Find where preprocess_c_code is defined: `$preprocess_c_code: function(code, defs = {}) {`

- Make it early out if it detects the shader is a Rive shader (it'll include GL_ANGLE_shader_pixel_local_storage) by returning the un-altered shader source:

```
$preprocess_c_code: function(code, defs = {}) {
if(code.indexOf('GL_ANGLE_shader_pixel_local_storage') != -1) {
return code;
}
// ...
```

0 comments on commit 2776735

Please sign in to comment.