BradLarson / OculusRiftSceneKit

A simple attempt at adding Oculus Rift support to Scene Kit
BSD 2-Clause "Simplified" License
117 stars 18 forks source link

Rendering Twice #1

Open mgatelabs opened 9 years ago

mgatelabs commented 9 years ago

Hello,

I have dissected, rewritten and analyzed your code and I have a question about when you call renderStereoscopicScene. In your render method, you call for each eye to be rendered, from my experience, SCNRender is single threaded, and will always complete one after the other, but back on point, after the LEFT has finished, the RIGHT will finish and call, renderStereoscopicScene, since LEFT was "ready". Then at the end of the render method you call renderStereoscopicScene again, which basically means double render.

I have written my own VR library for iOS using SceneKit and heavily base some parts off ALPS-VR for Unity, but I only have it render "once", which brings up an interesting issue. The first time, SCNRenderer is used, it messes up the image and makes it appear stretched. Is that why you opted to have it render twice, so the issue can be corrected. For my code I have it render an extra blank scene into a tiny viewport, so the issue is resolved with a single extra render.

mgatelabs commented 9 years ago

I have spoken with Apple support about my iOS VR code and they were able to correct the SceneKit rendering errors. The fix is to bind the texture before you call the render method, not while in the render method. When you bind inside the render method, its already setup all the matrix operations based upon the bound view port, so when you double render, its corrected because it was already setup before. SceneKit rendering at least on iOS is single threaded.