11namespace UnityEngine . Rendering . PostProcessing
22{
3+ #if UNITY_2017_2_OR_NEWER
4+ using XRSettings = UnityEngine . XR . XRSettings ;
5+ #elif UNITY_5_6_OR_NEWER
6+ using XRSettings = UnityEngine . VR . VRSettings ;
7+ #endif
8+
39 // Context object passed around all post-fx in a frame
410 public sealed class PostProcessRenderContext
511 {
612 // -----------------------------------------------------------------------------------------
713 // The following should be filled by the render pipeline
814
915 // Camera currently rendering
10- private Camera m_camera ;
16+ Camera m_Camera ;
1117 public Camera camera
1218 {
13- get
14- {
15- return this . m_camera ;
16- }
17-
19+ get { return m_Camera ; }
1820 set
1921 {
20- this . m_camera = value ;
22+ m_Camera = value ;
2123
22- if ( XR . XRSettings . isDeviceActive )
24+ if ( XRSettings . isDeviceActive )
2325 {
24- RenderTextureDescriptor xrDesc = XR . XRSettings . eyeTextureDesc ;
25- m_width = xrDesc . width ;
26- m_height = xrDesc . height ;
27-
28- m_xrSinglePass = ( xrDesc . vrUsage == VRTextureUsage . TwoEyes ) ;
26+ #if UNITY_2017_2_OR_NEWER
27+ RenderTextureDescriptor xrDesc = XRSettings . eyeTextureDesc ;
28+ width = xrDesc . width ;
29+ height = xrDesc . height ;
30+ #else
31+ width = m_Camera . pixelWidth * 2 ;
32+ height = m_Camera . pixelHeight ;
33+ #endif
2934
3035 if ( camera . stereoActiveEye == Camera . MonoOrStereoscopicEye . Right )
31- m_xrActiveEye = ( int ) Camera . StereoscopicEye . Right ;
36+ xrActiveEye = ( int ) Camera . StereoscopicEye . Right ;
3237
33- m_xrSingleEyeWidth = XR . XRSettings . eyeTextureWidth ;
38+ xrSingleEyeWidth = XRSettings . eyeTextureWidth ;
39+ xrSingleEyeHeight = XRSettings . eyeTextureHeight ;
3440 }
3541 else
3642 {
37- m_width = m_camera . pixelWidth ;
38- m_height = m_camera . pixelHeight ;
39- m_xrSingleEyeWidth = m_width ;
43+ width = m_Camera . pixelWidth ;
44+ height = m_Camera . pixelHeight ;
45+ xrSingleEyeWidth = width ;
4046 }
4147 }
4248 }
@@ -78,39 +84,19 @@ public Camera camera
7884 public PostProcessDebugLayer debugLayer { get ; internal set ; }
7985
8086 // Current camera width in pixels
81- private int m_width ;
82- public int width
83- {
84- get { return m_width ; }
85- }
87+ public int width { get ; private set ; }
8688
8789 // Current camera height in pixels
88- private int m_height ;
89- public int height
90- {
91- get { return m_height ; }
92- }
93-
94- // Is XR running in single-pass stereo mode?
95- private bool m_xrSinglePass ;
96- public bool xrSinglePass
97- {
98- get { return m_xrSinglePass ; }
99- }
90+ public int height { get ; private set ; }
10091
10192 // Current active rendering eye (for XR)
102- private int m_xrActiveEye ;
103- public int xrActiveEye
104- {
105- get { return m_xrActiveEye ; }
106- }
93+ public int xrActiveEye { get ; private set ; }
10794
10895 // Current single eye width in pixels (for XR)
109- private int m_xrSingleEyeWidth ;
110- public int singleEyeWidth
111- {
112- get { return m_xrSingleEyeWidth ; }
113- }
96+ public int xrSingleEyeWidth { get ; private set ; }
97+
98+ // Current single eye height in pixels (for XR)
99+ public int xrSingleEyeHeight { get ; private set ; }
114100
115101 // Are we currently rendering in the scene view?
116102 public bool isSceneView { get ; internal set ; }
@@ -124,13 +110,13 @@ public int singleEyeWidth
124110
125111 public void Reset ( )
126112 {
127- m_camera = null ;
128- m_width = 0 ;
129- m_height = 0 ;
113+ m_Camera = null ;
114+ width = 0 ;
115+ height = 0 ;
130116
131- m_xrSinglePass = false ;
132- m_xrActiveEye = ( int ) Camera . StereoscopicEye . Left ;
133- m_xrSingleEyeWidth = 0 ;
117+ xrActiveEye = ( int ) Camera . StereoscopicEye . Left ;
118+ xrSingleEyeWidth = 0 ;
119+ xrSingleEyeHeight = 0 ;
134120
135121 command = null ;
136122 source = 0 ;
0 commit comments