- Home /
Shadows and the camera projection matrix
Hi all,
I've built an application in the free version of Unity which allows several instances to connect to a server over a LAN. Each client sees the scene through the server's camera. From here, the server modifies values of the clients' projection matrices so that the client windows can be positioned around each other to draw one whole merged image from all the windows. Eventually this will be used with several projectors to get a high-res scene.
Upon activating my Unity Pro trial and activating shadows, I have found that the clients with modified projection matrices have either flickering shadows (soft and hard), or have weird dark/light distortions around where shadows should and shouldn't be.
There are 2 methods of modifying the matrix which I am using:
'Sliding' the visible portion of the viewing plane sideways, for projecting onto a flat surface. This creates an asymmetric viewing frustum.
Applying a rotation matrix to the projection matrix, used for projecting onto a curved surface or dome: http://i432.photobucket.com/albums/qq43/shwhjw/projection.png
The sliding method causes shadow flickering, with shadows flickering more and more as the visible portion moves further along the X axis (in camera space).
The rotation method causes the shadows to completely fudge up, and it's kinda hard to explain. They are never where they should be, unlike the sliding method where they just flicker in the correct place. The shadows move, disappear and distort as the camera moves around. Even rotating by 1 degree is enough to make a horrible dark stripe appear over part of the image. When no rotation is applied, the shadows are correct.
I was wondering if the shadows are computed using values in the camera's projection matrix? I know shadows have a lot to do with projection, but I thought only the light direction would come into it, not the camera projection?
I'm using deferred lighting as I want other types of lights to cast shadows too.
Does anybody have any ideas?
Thanks, Simon.
[1]: http://i432.photobucket.com/albums/qq43/shwhjw/projection.png
FYI it's a directional light I'm using at the moment.
Just tried it with forward rendering. It causes the rotation method's shadows to just flicker ins$$anonymous$$d of distort and such.
Also there seems to be an area on the right side of the screen in which shadows are never rendered, which grows as the amount of rotation is increased. Like they're being sheared off.