Hi,
I am new to Unity, and I am trying to figure out if it is possible to render a background image via a plugin.
I need to render the incoming images from a camera as the background to my AR app. The target platform is iOS. I have no need of the images as textures inside of unity. I have to have control of the texture handles, and access to the raw image in the plugin.
What I would like to do is have my plugin fully manage the texture, quad, and the associated drawing, so I would do the following:
-
create the texture and quad to render it to in my plugin
-
somewhere in unity (update() in a script attached to the main camera?) call my plugin.
-
have my plugin
-
update the texture
-
set up orthographic projection
-
render the textured quad
-
return to unity to draw the whole 3d scene.
Currently I am doing the following in a script attached to the main camera:
- creating a plane at the main camera’s far clipping distance
- applying a material with a texture.
- then every frame I am sending the texture’s handle to my plugin.
- In the plugin I am uploading the image to the texture.
It works, but it is slow (or rather, not as fast as I can make it).
Prior to using unity I have done the following:
- render 3d scene to an offscreen FBO
- set up orthographic projection
- render background image to a quad
- render 3d scene texture to another quad on top of the background quad.
- display the results on the screen.