Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/natrender.git 
README Markdown
Copy this to your project's README.md
## Installation
Add **NatRender** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/natrender.git
```
[](https://www.pkglnk.dev/pkg/natrender)README
NatRender
NatRender is a lightweight graphics utility library for Unity Engine. Features include:
- High performance pixel buffer readbacks from the GPU on iOS and Android (including OpenGL ES3).
- Running delegates on Unity's render thread.
Setup Instructions
NatShare should be installed using the Unity Package Manager. In your manifest.json file, add the following dependency:
{
"dependencies": {
"com.natsuite.natrender": "git+https://github.com/natsuite/NatRender"
}
}
Pixel Buffer Readbacks
NatRender provides lightweight primitives for performing pixel buffer readbacks from textures on the GPU. This is exposed through implementations the IReadback interface. Currently, NatRender provides the following implementations:
GLESReadbackfor Android when rendering with OpenGL ES3.MTLReadbackfor iOS when rendering with Metal.AsyncReadbackfor platforms that support Unity's async readbacks.SyncReadbackfor all platforms. Note that this implementation has the worst performance.
Once you create a readback, you can request the pixel data by calling the Readback method:
// Starting with some texture you want to readback
var texture = ...;
// Create readback
var readback = new GLESReadback(...) or new MLTReadback(...) or ...;
// Issue request
readback.Request(texture, (NativeArray<byte> pixelBuffer) => {
// Do stuff with pixel buffer
});
// And when you're done remember to dispose
readback.Dispose();
Running on the Render Thread
NatRender also provides a way to run an Action on Unity's render thread. This is useful for performing native rendering or doing anything that requires being on the primary render thread:
RenderThread.Run(() => {
// We're on Unity's render thread
Debug.Log("Hello from the render thread");
});
Requirements
- Unity 2019.2+
- Android API level 24+
- iOS 13+
Resources
Thank you very much!
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In