cancel
Showing results for 
Search instead for 
Did you mean: 

OVR SDK 0.4 Unity Deferred Lighting Broken

owenwp
Expert Protege
Because 0.4 has switched over to a completely custom camera projection matrix, deferred lighting and realtime shadows no longer work, because those systems ignore the custom matrix and use the fov and clip plane parameters passed in through the normal camera APIs. The reason is the need for the projection inverse matrix, which Unity will not compute automatically. Edit: shadows seem to work in forward rendering, which is odd since they didn't in the past when this problem occurred in the 0.2x sdk. More edit: Oddly, spot lights with narrow spot angles AND small point lights are broken in forward rendering, with the edges of the light being cut off, perhaps by a scissors rectangle.

There are a few possible solutions:

* Get Unity to modify the engine to support custom projection by performing a generalized inverse of the projection matrix if one is supplied. This would be the best solution and would banish bugs like this forever, though I wouldn't hold my breath for them to get it done.

* Make the off-center projection optional. The developer guide covers this exact use case where an engine does not support off-center projection (as Unity does not, at least not out of the box) and would be the solution that best follows your own published recommendations. It looks like ovrHmd_ConfigureRendering is not implemented in Unity yet, and would be required for this to work if I am reading things right. It might be wise to implement this even if Unity fixes their bug, because some devs may add other effects that could be broken by off-center projection.

* Go back to how the off-center projection was handled in the old SDK, by applying a translation to the existing projection matrix provided by Unity. My theory is this works because Unity appears to pre-compute the inverses of affine transforms (inverse of a translation is another translation with the vector negated for example) and compose them in reverse when you multiply matrices. (when you do out=mat1*mat2 it also does outInv=mat2Inv*mat1Inv) Of course this would mean complicating the API, so it may not be desirable.
55 REPLIES 55

excelynx
Honored Guest
There's some discussion of this over in this thread too: https://developer.oculusvr.com/forums/viewtopic.php?f=37&t=10892
VisiR - Virtual Reality Music Visualisation

kersk
Expert Protege
This seems pretty spot on.

Our ideal solution here is to work with Unity to see if we can get this fixed in the engine.

We're working to get this resolved one way or another as soon as we can.

excelynx
Honored Guest
"kersk" wrote:
This seems pretty spot on.

Our ideal solution here is to work with Unity to see if we can get this fixed in the engine.

We're working to get this resolved one way or another as soon as we can.


That's awesome news! Thanks for the update kersk. 🙂
VisiR - Virtual Reality Music Visualisation

davehampson
Honored Guest
"kersk" wrote:
This seems pretty spot on.

Our ideal solution here is to work with Unity to see if we can get this fixed in the engine.

We're working to get this resolved one way or another as soon as we can.


Dave from Unity support here.
Do you happen to know the bug ID so I can track this and perhaps try and get it into one of our patch releases?

*edit* I found a bug (617638) which refers to the problem but there is no example project. I'll keep looking but in the meantime would anyone be able to submit a small repro project with a few detailed repro steps?

Will Unity QA need a DK1 or DK2 to reproduce this issue? I presume they'll have a DK1.

*edit 2*
Just checked and Unity QA do have a DK1. I will have a DK2 on Thursday so I can repro if it needs a DK2. Best possible case, if someone can make a small repro case that doesn't need a headset at all.
Just let me know the case number 😉

boone188
Honored Guest
Can someone try this fix? Seems to have resolved the issue for me.
DeferredRenderingFix.zip

ad2003
Honored Guest
works in editor - or do I have to check in a build?

edit: WORKS also in build!
My first unity steps: In A Distance | download/post: http://goo.gl/N90bUU A video collection of oculus rift related stuff: http://oculus.quitebeyond.de

Anticleric
Expert Protege
"boone188" wrote:
Can someone try this fix? Seems to have resolved the issue for me.
DeferredRenderingFix.zip


It works!
Seems very bright though. And the image effects still black the camera.
Getting there though. Thanks Boone!

Serk
Explorer
Can confirm it works, and the image effects making the screen go black. I dint notice it being any brighter, though.

Anticleric
Expert Protege
"Serk" wrote:
Can confirm it works, and the image effects making the screen go black. I dint notice it being any brighter, though.


You're right. Was on my old prefab. Looks like I have to replace all of my cameras again. When I drop in a new one it looks fine. Still need those image effects though.