I am starting with the Unity Rendering Plugin for my task of rendering. However, I would like to execute the UnityRenderEvent function at the beginning of the frame, just after the call to glClear(). I tried to issue the GL.IssuePluginEvent(1) in the OnRenderObject function of the main camera, but that was with no success.
OnRenderObject is called after rendering. Your best bet would be Camera.OnPreRender, which will fire just before clear.
EDIT: there is also OnWillRender, but this is called during culling, way before rendering.
Is it for sure that the call to GL.IssuePluginEvent() in the Camera’s OnPreRender will be synchronized with the rendering thread and that it will execute before anything get’s rendered?
I was thinking to attach a gameobject to the camera node and into that node’s OnPreRender I will issue the GL.IssuePluginEvent(). This way I will have the rendering of the camera which executes glClear and then I will have the call to my Render Plugin.
What I want to achieve is to write a depth texture in the depth buffer at the beginning of the frame, just after the glClear(). Do you know another way to do it?
I want to load an image from file and to write it to the depth buffer for some augmented reality application and I don’t need render to texture or similar. I was thinking that glDrawPixels will work, but now I don’t know if that one is called after glClear().
just in case: you do understand that depth buffer is not your usual rgba image, right? 8)
if so you can do it in a bit different way - just set RenderTexture, do glDrawPixels, and grab depth buffer from RT and use it for your normal drawing. Just set camera clear mode to not clear and manage color clearing yourself when needed.
Hope that makes sense
I know what a depth buffer is. I’m using normal grayscale floating point textures. The trick with setting the camera clear mode not to clear did it. Very helpful, thanks a lot!