Lighting problem with deferred rendering path and custom camera projection matrix

Hello,

I’m currently looking on how to create a mirror effect.

I’m using a camera to create a reflection view, so i setup a custom projection matrix like this :

camera.projectionMatrix *= Matrix4x4.Scale (new Vector3 (-1.0f, 1.0f, 1.0f));

And also invert culling :

GL.invertCulling = true;

I noticed however that when i’m using deferred rendering path and a custom matrix for the camera at the same time, the lighting is not correct.

I have join a little scene to illustrate the problem and made a screenshot of it :

Bottom right viewport is too dark, i’ve also noticed that when i turn off environment reflections other three become dark as well :

3048164--228624--3.png

So maybe something has to do with this setting not been taken into account.

If anyone have an idea on how to fix this, you’re welcome, i’m using Unity 5.6.

I can post here the CSharp script (included in the join package) if you wish.

That’s my first post here so I hope this is the right category to post it.

Thanks

PS : sorry for my English, i know it is far from perfect :wink:

3048164–228626–LightingTest.unitypackage (114 KB)

Replying to say I have a very similar problem. I use custom projection matrices to create off-center cameras as in this example : Cg Programming/Unity/Projection for Virtual Reality - Wikibooks, open books for an open world. While this works very well in forward rendering, lighting is wrong when I switch to deferred rendering. As shown in the previous post, everything seems darker, I also noticed that spotlights disappear.

If I make the frustum perfectly symmetrical with the custom projection matrix it sometimes work but is very unstable and makes lighting flicker when the camera moves.

I found the solution to my problem, I had a wrong scaling on the distance value “d” ([2,3]) as described here. Re-using the example from Unity documentation worked.
This seems to be what was responsible for wrong lighting in deferred rendering in my case.