-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thread here: https://2dimensions.slack.com/archives/CHMAP278R/p1709934972246289  Uses PLS when draft extensions are enabled in Chrome!  Details on how it works and how to patch Unity's emscripten here (part of this PR which will push downstream): https://github.com/rive-app/rive/blob/unity_webgl/packages/runtime_unity/public/WEBGL.md Diffs= bcf6451f4 Unity webgl! (#6816) Co-authored-by: Luigi Rosso <[email protected]>
- Loading branch information
1 parent
2b0f0d9
commit 029f7c3
Showing
21 changed files
with
729 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4461675b5e89a3901bf9ad325a4fb507678d622f | ||
bcf6451f442d7d55ed423982b58204e93c1d8791 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,16 @@ A Unity runtime library for [Rive](https://rive.app). This is currently a **tech | |
|
||
Currently supported platforms and backends include: | ||
|
||
- [WebGL](WEBGL.md) | ||
- Metal on Mac | ||
- Metal on iOS | ||
- D3D11 on Windows | ||
- OpenGL on Windows | ||
- OpenGL on Android | ||
|
||
Planned support for: | ||
|
||
- D3D12 | ||
- WebGL | ||
- Vulkan | ||
|
||
### Feature Support | ||
|
@@ -63,6 +64,7 @@ [email protected]:rive-app/rive-unity.git?path=package#v0.1.69 | |
``` | ||
|
||
Or through HTTP: | ||
|
||
``` | ||
https://github.com/rive-app/rive-unity.git?path=package#v0.1.69 | ||
``` | ||
|
@@ -72,7 +74,7 @@ You can also add it manually to your projects `Packages/manifest.json` file: | |
```json | ||
{ | ||
"dependencies": { | ||
"app.rive.rive-unity": "[email protected]:rive-app/rive-unity.git?path=package#v0.1.69", | ||
"app.rive.rive-unity": "[email protected]:rive-app/rive-unity.git?path=package#v0.1.69" | ||
} | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Rive Unity WebGL | ||
|
||
Rive's WebGL Renderer has two modes: | ||
|
||
## PLS | ||
|
||
Uses [an extension](https://registry.khronos.org/webgl/extensions/WEBGL_shader_pixel_local_storage/) we helped pioneer and implement into modern browsers. If the user has this enabled we'll prioritize using this extension for best performance and quality. Enable [WebGL Draft Extensions](https://www.wikihow.tech/Enable-WebGL-Draft-Extensions-in-Google-Chrome) to use this today! | ||
|
||
This is our best-in-class solution for both quality and performance, supporting all Rive features including advanced blend modes. | ||
|
||
## MSAA | ||
|
||
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; | ||
} | ||
// ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
package/Runtime/Libraries/WebGL/librive_decoders_wasm.a.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.