Skip to content

Commit

Permalink
Merge pull request #25 from kwnetzwelt/master
Browse files Browse the repository at this point in the history
Fix VR usage: use camera projection matrix by current camera (for Unity 2017.2 or newer)
  • Loading branch information
SlightlyMad authored Nov 19, 2017
2 parents 9d073a4 + 75417c6 commit d20b6f9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Assets/Scripts/VolumetricLightRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,19 @@ void ChangeResolution()
/// </summary>
public void OnPreRender()
{
// use very low value for near clip plane to simplify cone/frustum intersection

// use very low value for near clip plane to simplify cone/frustum intersection
Matrix4x4 proj = Matrix4x4.Perspective(_camera.fieldOfView, _camera.aspect, 0.01f, _camera.farClipPlane);
proj = GL.GetGPUProjectionMatrix(proj, true);

#if UNITY_2017_2_OR_NEWER
if (UnityEngine.XR.XRSettings.enabled)
{
// when using VR override the used projection matrix
proj = Camera.current.projectionMatrix;
}
#endif

proj = GL.GetGPUProjectionMatrix(proj, true);
_viewProj = proj * _camera.worldToCameraMatrix;

_preLightPass.Clear();
Expand Down

0 comments on commit d20b6f9

Please sign in to comment.