- Home /
Binding EGLImage to RenderTexture (or setting NativeTexturePtr)
I'm trying to get a Unity Camera to render to an EGLImage with some help from a native plugin. I'm running this on Android with OpenGL ES 3.2, using a native plugin to create ANativeWindowBuffer and an EGLImageKHR from that. Now, I'm trying to figure out how to use glEGLImageTargetTexture2DOES with a RenderTexture.
Texture2D has CreateExternalTexture static method, which is really what I'd like to use, but Camera.targetTexture only accepts a RenderTexture and there does not appear to be a way of creating one out of a native OpenGL texture object.
Creating a RenderTexture in Unity and then calling glEGLImageTargetTexture2DOES on GetNativeTexturePtr() works, but only for a single frame. For some reason, the binding is reset after each frame, so I have to reassociate the texture with my image each time and I'm not really sure what the performance implications of this are. Is there a cleaner way of either creating a RenderTexture out of an existing OpenGL object, or changing Unity's RenderTexture instance so that the changes persist across frames?
Your answer
Follow this Question
Related Questions
Native Rendering Plugin with UI Image 0 Answers
Execute native plugins in edit mode? 1 Answer
URP Bokeh DoF not showing in render texture 0 Answers
RenderTexture.Create failed: format unsupported 0 Answers
Rendering an HD PNG off-screen? 0 Answers