No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UniversalCameraData.cs 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine.Experimental.Rendering;
  4. namespace UnityEngine.Rendering.Universal
  5. {
  6. /// <summary>
  7. /// Class that holds settings related to camera.
  8. /// </summary>
  9. public class UniversalCameraData : ContextItem
  10. {
  11. // Internal camera data as we are not yet sure how to expose View in stereo context.
  12. // We might change this API soon.
  13. Matrix4x4 m_ViewMatrix;
  14. Matrix4x4 m_ProjectionMatrix;
  15. Matrix4x4 m_JitterMatrix;
  16. internal void SetViewAndProjectionMatrix(Matrix4x4 viewMatrix, Matrix4x4 projectionMatrix)
  17. {
  18. m_ViewMatrix = viewMatrix;
  19. m_ProjectionMatrix = projectionMatrix;
  20. m_JitterMatrix = Matrix4x4.identity;
  21. }
  22. internal void SetViewProjectionAndJitterMatrix(Matrix4x4 viewMatrix, Matrix4x4 projectionMatrix, Matrix4x4 jitterMatrix)
  23. {
  24. m_ViewMatrix = viewMatrix;
  25. m_ProjectionMatrix = projectionMatrix;
  26. m_JitterMatrix = jitterMatrix;
  27. }
  28. #if ENABLE_VR && ENABLE_XR_MODULE
  29. private bool m_CachedRenderIntoTextureXR;
  30. private bool m_InitBuiltinXRConstants;
  31. #endif
  32. // Helper function to populate builtin stereo matricies as well as URP stereo matricies
  33. internal void PushBuiltinShaderConstantsXR(RasterCommandBuffer cmd, bool renderIntoTexture)
  34. {
  35. #if ENABLE_VR && ENABLE_XR_MODULE
  36. // Multipass always needs update to prevent wrong view projection matrix set by other passes
  37. bool needsUpdate = !m_InitBuiltinXRConstants || m_CachedRenderIntoTextureXR != renderIntoTexture || !xr.singlePassEnabled;
  38. if (needsUpdate && xr.enabled )
  39. {
  40. var projection0 = GetProjectionMatrix();
  41. var view0 = GetViewMatrix();
  42. cmd.SetViewProjectionMatrices(view0, projection0);
  43. if (xr.singlePassEnabled)
  44. {
  45. var projection1 = GetProjectionMatrix(1);
  46. var view1 = GetViewMatrix(1);
  47. XRBuiltinShaderConstants.UpdateBuiltinShaderConstants(view0, projection0, renderIntoTexture, 0);
  48. XRBuiltinShaderConstants.UpdateBuiltinShaderConstants(view1, projection1, renderIntoTexture, 1);
  49. XRBuiltinShaderConstants.SetBuiltinShaderConstants(cmd);
  50. }
  51. else
  52. {
  53. // Update multipass worldSpace camera pos
  54. Vector3 worldSpaceCameraPos = Matrix4x4.Inverse(GetViewMatrix(0)).GetColumn(3);
  55. cmd.SetGlobalVector(ShaderPropertyId.worldSpaceCameraPos, worldSpaceCameraPos);
  56. }
  57. m_CachedRenderIntoTextureXR = renderIntoTexture;
  58. m_InitBuiltinXRConstants = true;
  59. }
  60. #endif
  61. }
  62. /// <summary>
  63. /// Returns the camera view matrix.
  64. /// </summary>
  65. /// <param name="viewIndex"> View index in case of stereo rendering. By default <c>viewIndex</c> is set to 0. </param>
  66. /// <returns> The camera view matrix. </returns>
  67. public Matrix4x4 GetViewMatrix(int viewIndex = 0)
  68. {
  69. #if ENABLE_VR && ENABLE_XR_MODULE
  70. if (xr.enabled)
  71. return xr.GetViewMatrix(viewIndex);
  72. #endif
  73. return m_ViewMatrix;
  74. }
  75. /// <summary>
  76. /// Returns the camera projection matrix. Might be jittered for temporal features.
  77. /// </summary>
  78. /// <param name="viewIndex"> View index in case of stereo rendering. By default <c>viewIndex</c> is set to 0. </param>
  79. /// <returns> The camera projection matrix. </returns>
  80. public Matrix4x4 GetProjectionMatrix(int viewIndex = 0)
  81. {
  82. #if ENABLE_VR && ENABLE_XR_MODULE
  83. if (xr.enabled)
  84. return m_JitterMatrix * xr.GetProjMatrix(viewIndex);
  85. #endif
  86. return m_JitterMatrix * m_ProjectionMatrix;
  87. }
  88. internal Matrix4x4 GetProjectionMatrixNoJitter(int viewIndex = 0)
  89. {
  90. #if ENABLE_VR && ENABLE_XR_MODULE
  91. if (xr.enabled)
  92. return xr.GetProjMatrix(viewIndex);
  93. #endif
  94. return m_ProjectionMatrix;
  95. }
  96. /// <summary>
  97. /// Returns the camera GPU projection matrix. This contains platform specific changes to handle y-flip and reverse z. Includes camera jitter if required by active features.
  98. /// Similar to <c>GL.GetGPUProjectionMatrix</c> but queries URP internal state to know if the pipeline is rendering to render texture.
  99. /// For more info on platform differences regarding camera projection check: https://docs.unity3d.com/Manual/SL-PlatformDifferences.html
  100. /// </summary>
  101. /// <param name="viewIndex"> View index in case of stereo rendering. By default <c>viewIndex</c> is set to 0. </param>
  102. /// <seealso cref="GL.GetGPUProjectionMatrix(Matrix4x4, bool)"/>
  103. /// <returns></returns>
  104. public Matrix4x4 GetGPUProjectionMatrix(int viewIndex = 0)
  105. {
  106. // Disable obsolete warning for internal usage
  107. #pragma warning disable CS0618
  108. // GetGPUProjectionMatrix takes a projection matrix and returns a GfxAPI adjusted version, does not set or get any state.
  109. return m_JitterMatrix * GL.GetGPUProjectionMatrix(GetProjectionMatrixNoJitter(viewIndex), IsCameraProjectionMatrixFlipped());
  110. #pragma warning restore CS0618
  111. }
  112. /// <summary>
  113. /// Returns the camera GPU projection matrix. This contains platform specific changes to handle y-flip and reverse z. Does not include any camera jitter.
  114. /// Similar to <c>GL.GetGPUProjectionMatrix</c> but queries URP internal state to know if the pipeline is rendering to render texture.
  115. /// For more info on platform differences regarding camera projection check: https://docs.unity3d.com/Manual/SL-PlatformDifferences.html
  116. /// </summary>
  117. /// <param name="viewIndex"> View index in case of stereo rendering. By default <c>viewIndex</c> is set to 0. </param>
  118. /// <seealso cref="GL.GetGPUProjectionMatrix(Matrix4x4, bool)"/>
  119. /// <returns></returns>
  120. public Matrix4x4 GetGPUProjectionMatrixNoJitter(int viewIndex = 0)
  121. {
  122. // Disable obsolete warning for internal usage
  123. #pragma warning disable CS0618
  124. // GetGPUProjectionMatrix takes a projection matrix and returns a GfxAPI adjusted version, does not set or get any state.
  125. return GL.GetGPUProjectionMatrix(GetProjectionMatrixNoJitter(viewIndex), IsCameraProjectionMatrixFlipped());
  126. #pragma warning restore CS0618
  127. }
  128. internal Matrix4x4 GetGPUProjectionMatrix(bool renderIntoTexture, int viewIndex = 0)
  129. {
  130. return m_JitterMatrix * GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture);
  131. }
  132. /// <summary>
  133. /// The camera component.
  134. /// </summary>
  135. public Camera camera;
  136. /// <summary>
  137. /// Returns the scaled width of the Camera
  138. /// By obtaining the pixelWidth of the camera and taking into account the render scale
  139. /// The min dimension is 1.
  140. /// </summary>
  141. public int scaledWidth => Mathf.Max(1, (int)(camera.pixelWidth * renderScale));
  142. /// <summary>
  143. /// Returns the scaled height of the Camera
  144. /// By obtaining the pixelHeight of the camera and taking into account the render scale
  145. /// The min dimension is 1.
  146. /// </summary>
  147. public int scaledHeight => Mathf.Max(1, (int)(camera.pixelHeight * renderScale));
  148. // NOTE: This is internal instead of private to allow ref return in the old CameraData compatibility property.
  149. // We can make this private when it is removed.
  150. //
  151. // A (non-owning) reference of full writable camera history for internal and injected render passes.
  152. // Only passes/code executing inside the pipeline should have access.
  153. // Use the "historyManager" property below to access.
  154. internal UniversalCameraHistory m_HistoryManager;
  155. /// <summary>
  156. /// The camera history texture manager. Used to access camera history from a ScriptableRenderPass.
  157. /// </summary>
  158. /// <seealso cref="ScriptableRenderPass"/>
  159. public UniversalCameraHistory historyManager { get => m_HistoryManager; set => m_HistoryManager = value; }
  160. /// <summary>
  161. /// The camera render type used for camera stacking.
  162. /// <see cref="CameraRenderType"/>
  163. /// </summary>
  164. public CameraRenderType renderType;
  165. /// <summary>
  166. /// Controls the final target texture for a camera. If null camera will resolve rendering to screen.
  167. /// </summary>
  168. public RenderTexture targetTexture;
  169. /// <summary>
  170. /// Render texture settings used to create intermediate camera textures for rendering.
  171. /// </summary>
  172. public RenderTextureDescriptor cameraTargetDescriptor;
  173. internal Rect pixelRect;
  174. internal bool useScreenCoordOverride;
  175. internal Vector4 screenSizeOverride;
  176. internal Vector4 screenCoordScaleBias;
  177. internal int pixelWidth;
  178. internal int pixelHeight;
  179. internal float aspectRatio;
  180. /// <summary>
  181. /// Render scale to apply when creating camera textures. Scaled extents are rounded down to integers.
  182. /// </summary>
  183. public float renderScale;
  184. internal ImageScalingMode imageScalingMode;
  185. internal ImageUpscalingFilter upscalingFilter;
  186. internal bool fsrOverrideSharpness;
  187. internal float fsrSharpness;
  188. internal HDRColorBufferPrecision hdrColorBufferPrecision;
  189. /// <summary>
  190. /// True if this camera should clear depth buffer. This setting only applies to cameras of type <c>CameraRenderType.Overlay</c>
  191. /// <seealso cref="CameraRenderType"/>
  192. /// </summary>
  193. public bool clearDepth;
  194. /// <summary>
  195. /// The camera type.
  196. /// <seealso cref="UnityEngine.CameraType"/>
  197. /// </summary>
  198. public CameraType cameraType;
  199. /// <summary>
  200. /// True if this camera is drawing to a viewport that maps to the entire screen.
  201. /// </summary>
  202. public bool isDefaultViewport;
  203. /// <summary>
  204. /// True if this camera should render to high dynamic range color targets.
  205. /// </summary>
  206. public bool isHdrEnabled;
  207. /// <summary>
  208. /// True if this camera allow color conversion and encoding for high dynamic range displays.
  209. /// </summary>
  210. public bool allowHDROutput;
  211. /// <summary>
  212. /// True if this camera can write the alpha channel. Post-processing uses this. Requires the color target to have an alpha channel.
  213. /// </summary>
  214. public bool isAlphaOutputEnabled;
  215. /// <summary>
  216. /// True if this camera requires to write _CameraDepthTexture.
  217. /// </summary>
  218. public bool requiresDepthTexture;
  219. /// <summary>
  220. /// True if this camera requires to copy camera color texture to _CameraOpaqueTexture.
  221. /// </summary>
  222. public bool requiresOpaqueTexture;
  223. /// <summary>
  224. /// Returns true if post processing passes require depth texture.
  225. /// </summary>
  226. public bool postProcessingRequiresDepthTexture;
  227. /// <summary>
  228. /// Returns true if XR rendering is enabled.
  229. /// </summary>
  230. public bool xrRendering;
  231. // True if GPU occlusion culling should be used when rendering this camera.
  232. internal bool useGPUOcclusionCulling;
  233. internal bool requireSrgbConversion
  234. {
  235. get
  236. {
  237. #if ENABLE_VR && ENABLE_XR_MODULE
  238. // For some XR platforms we need to encode in SRGB but can't use a _SRGB format texture, only required for 8bit per channel 32 bit formats.
  239. if (xr.enabled)
  240. return !xr.renderTargetDesc.sRGB && (xr.renderTargetDesc.graphicsFormat == GraphicsFormat.R8G8B8A8_UNorm || xr.renderTargetDesc.graphicsFormat == GraphicsFormat.B8G8R8A8_UNorm) && (QualitySettings.activeColorSpace == ColorSpace.Linear);
  241. #endif
  242. return targetTexture == null && Display.main.requiresSrgbBlitToBackbuffer;
  243. }
  244. }
  245. /// <summary>
  246. /// True if the camera rendering is for regular in-game.
  247. /// </summary>
  248. public bool isGameCamera => cameraType == CameraType.Game;
  249. /// <summary>
  250. /// True if the camera rendering is for the scene window in the editor.
  251. /// </summary>
  252. public bool isSceneViewCamera => cameraType == CameraType.SceneView;
  253. /// <summary>
  254. /// True if the camera rendering is for the preview window in the editor.
  255. /// </summary>
  256. public bool isPreviewCamera => cameraType == CameraType.Preview;
  257. internal bool isRenderPassSupportedCamera => (cameraType == CameraType.Game || cameraType == CameraType.Reflection);
  258. internal bool resolveToScreen => targetTexture == null && resolveFinalTarget && (cameraType == CameraType.Game || camera.cameraType == CameraType.VR);
  259. /// <summary>
  260. /// True if the Camera should output to an HDR display.
  261. /// </summary>
  262. public bool isHDROutputActive
  263. {
  264. get
  265. {
  266. bool hdrDisplayOutputActive = UniversalRenderPipeline.HDROutputForMainDisplayIsActive();
  267. #if ENABLE_VR && ENABLE_XR_MODULE
  268. // If we are rendering to xr then we need to look at the XR Display rather than the main non-xr display.
  269. if (xr.enabled)
  270. hdrDisplayOutputActive = xr.isHDRDisplayOutputActive;
  271. #endif
  272. return hdrDisplayOutputActive && allowHDROutput && resolveToScreen;
  273. }
  274. }
  275. /// <summary>
  276. /// True if the last camera in the stack outputs to an HDR screen
  277. /// </summary>
  278. internal bool stackLastCameraOutputToHDR;
  279. /// <summary>
  280. /// HDR Display information about the current display this camera is rendering to.
  281. /// </summary>
  282. public HDROutputUtils.HDRDisplayInformation hdrDisplayInformation
  283. {
  284. get
  285. {
  286. HDROutputUtils.HDRDisplayInformation displayInformation;
  287. #if ENABLE_VR && ENABLE_XR_MODULE
  288. // If we are rendering to xr then we need to look at the XR Display rather than the main non-xr display.
  289. if (xr.enabled)
  290. {
  291. displayInformation = xr.hdrDisplayOutputInformation;
  292. }
  293. else
  294. #endif
  295. {
  296. HDROutputSettings displaySettings = HDROutputSettings.main;
  297. displayInformation = new HDROutputUtils.HDRDisplayInformation(displaySettings.maxFullFrameToneMapLuminance,
  298. displaySettings.maxToneMapLuminance,
  299. displaySettings.minToneMapLuminance,
  300. displaySettings.paperWhiteNits);
  301. }
  302. return displayInformation;
  303. }
  304. }
  305. /// <summary>
  306. /// HDR Display Color Gamut
  307. /// </summary>
  308. public ColorGamut hdrDisplayColorGamut
  309. {
  310. get
  311. {
  312. #if ENABLE_VR && ENABLE_XR_MODULE
  313. // If we are rendering to xr then we need to look at the XR Display rather than the main non-xr display.
  314. if (xr.enabled)
  315. {
  316. return xr.hdrDisplayOutputColorGamut;
  317. }
  318. else
  319. #endif
  320. {
  321. HDROutputSettings displaySettings = HDROutputSettings.main;
  322. return displaySettings.displayColorGamut;
  323. }
  324. }
  325. }
  326. /// <summary>
  327. /// True if the Camera should render overlay UI.
  328. /// </summary>
  329. public bool rendersOverlayUI => SupportedRenderingFeatures.active.rendersUIOverlay && resolveToScreen;
  330. /// <summary>
  331. /// True is the handle has its content flipped on the y axis.
  332. /// This happens only with certain rendering APIs.
  333. /// On those platforms, any handle will have its content flipped unless rendering to a backbuffer, however,
  334. /// the scene view will always be flipped.
  335. /// When transitioning from a flipped space to a non-flipped space - or vice-versa - the content must be flipped
  336. /// in the shader:
  337. /// shouldPerformYFlip = IsHandleYFlipped(source) != IsHandleYFlipped(target)
  338. /// </summary>
  339. /// <param name="handle">Handle to check the flipped status on.</param>
  340. /// <returns>True is the content is flipped in y.</returns>
  341. public bool IsHandleYFlipped(RTHandle handle)
  342. {
  343. if (!SystemInfo.graphicsUVStartsAtTop)
  344. return true;
  345. if (cameraType == CameraType.SceneView || cameraType == CameraType.Preview)
  346. return true;
  347. var handleID = new RenderTargetIdentifier(handle.nameID, 0, CubemapFace.Unknown, 0);
  348. bool isBackbuffer = handleID == BuiltinRenderTextureType.CameraTarget || handleID == BuiltinRenderTextureType.Depth;
  349. #if ENABLE_VR && ENABLE_XR_MODULE
  350. if (xr.enabled)
  351. isBackbuffer |= handleID == new RenderTargetIdentifier(xr.renderTarget, 0, CubemapFace.Unknown, 0);
  352. #endif
  353. return !isBackbuffer;
  354. }
  355. /// <summary>
  356. /// True if the camera device projection matrix is flipped. This happens when the pipeline is rendering
  357. /// to a render texture in non OpenGL platforms. If you are doing a custom Blit pass to copy camera textures
  358. /// (_CameraColorTexture, _CameraDepthAttachment) you need to check this flag to know if you should flip the
  359. /// matrix when rendering with for cmd.Draw* and reading from camera textures.
  360. /// </summary>
  361. /// <returns> True if the camera device projection matrix is flipped. </returns>
  362. public bool IsCameraProjectionMatrixFlipped()
  363. {
  364. if (!SystemInfo.graphicsUVStartsAtTop)
  365. return false;
  366. // Users only have access to CameraData on URP rendering scope. The current renderer should never be null.
  367. var renderer = ScriptableRenderer.current;
  368. Debug.Assert(renderer != null, "IsCameraProjectionMatrixFlipped is being called outside camera rendering scope.");
  369. // Disable obsolete warning for internal usage
  370. #pragma warning disable CS0618
  371. if (renderer != null)
  372. return IsHandleYFlipped(renderer.cameraColorTargetHandle) || targetTexture != null;
  373. #pragma warning restore CS0618
  374. return true;
  375. }
  376. /// <summary>
  377. /// True if the render target's projection matrix is flipped. This happens when the pipeline is rendering
  378. /// to a render texture in non OpenGL platforms. If you are doing a custom Blit pass to copy camera textures
  379. /// (_CameraColorTexture, _CameraDepthAttachment) you need to check this flag to know if you should flip the
  380. /// matrix when rendering with for cmd.Draw* and reading from camera textures.
  381. /// </summary>
  382. /// <param name="color">Color render target to check whether the matrix is flipped.</param>
  383. /// <param name="depth">Depth render target which is used if color is null. By default <c>depth</c> is set to null.</param>
  384. /// <returns> True if the render target's projection matrix is flipped. </returns>
  385. public bool IsRenderTargetProjectionMatrixFlipped(RTHandle color, RTHandle depth = null)
  386. {
  387. if (!SystemInfo.graphicsUVStartsAtTop)
  388. return true;
  389. return targetTexture != null || IsHandleYFlipped(color ?? depth);
  390. }
  391. internal bool IsTemporalAAEnabled()
  392. {
  393. UniversalAdditionalCameraData additionalCameraData;
  394. camera.TryGetComponent(out additionalCameraData);
  395. return (antialiasing == AntialiasingMode.TemporalAntiAliasing) // Enabled
  396. && postProcessEnabled // Postprocessing Enabled
  397. && (taaHistory != null) // Initialized
  398. && (cameraTargetDescriptor.msaaSamples == 1) // No MSAA
  399. && !(additionalCameraData?.renderType == CameraRenderType.Overlay || additionalCameraData?.cameraStack.Count > 0) // No Camera stack
  400. && !camera.allowDynamicResolution // No Dynamic Resolution
  401. && renderer.SupportsMotionVectors(); // Motion Vectors implemented
  402. }
  403. /// <summary>
  404. /// Returns true if the pipeline is configured to render with the STP upscaler
  405. ///
  406. /// When STP runs, it relies on much of the existing TAA infrastructure provided by URP's native TAA. Due to this, URP forces the anti-aliasing mode to
  407. /// TAA when STP is enabled to ensure that most TAA logic remains active. A side effect of this behavior is that STP inherits all of the same configuration
  408. /// restrictions as TAA and effectively cannot run if IsTemporalAAEnabled() returns false. The post processing pass logic that executes STP handles this
  409. /// situation and STP should behave identically to TAA in cases where TAA support requirements aren't met at runtime.
  410. /// </summary>
  411. /// <returns>True if STP is enabled</returns>
  412. internal bool IsSTPEnabled()
  413. {
  414. return (imageScalingMode == ImageScalingMode.Upscaling) && (upscalingFilter == ImageUpscalingFilter.STP);
  415. }
  416. /// <summary>
  417. /// The sorting criteria used when drawing opaque objects by the internal URP render passes.
  418. /// When a GPU supports hidden surface removal, URP will rely on that information to avoid sorting opaque objects front to back and
  419. /// benefit for more optimal static batching.
  420. /// </summary>
  421. /// <seealso cref="SortingCriteria"/>
  422. public SortingCriteria defaultOpaqueSortFlags;
  423. /// <summary>
  424. /// XRPass holds the render target information and a list of XRView.
  425. /// XRView contains the parameters required to render (projection and view matrices, viewport, etc)
  426. /// </summary>
  427. public XRPass xr { get; internal set; }
  428. internal XRPassUniversal xrUniversal => xr as XRPassUniversal;
  429. /// <summary>
  430. /// Maximum shadow distance visible to the camera. When set to zero shadows will be disable for that camera.
  431. /// </summary>
  432. public float maxShadowDistance;
  433. /// <summary>
  434. /// True if post-processing is enabled for this camera.
  435. /// </summary>
  436. public bool postProcessEnabled;
  437. /// <summary>
  438. /// True if post-processing is enabled for any camera in this camera's stack.
  439. /// </summary>
  440. internal bool stackAnyPostProcessingEnabled;
  441. /// <summary>
  442. /// Provides set actions to the renderer to be triggered at the end of the render loop for camera capture.
  443. /// </summary>
  444. public IEnumerator<Action<RenderTargetIdentifier, CommandBuffer>> captureActions;
  445. /// <summary>
  446. /// The camera volume layer mask.
  447. /// </summary>
  448. public LayerMask volumeLayerMask;
  449. /// <summary>
  450. /// The camera volume trigger.
  451. /// </summary>
  452. public Transform volumeTrigger;
  453. /// <summary>
  454. /// If set to true, the integrated post-processing stack will replace any NaNs generated by render passes prior to post-processing with black/zero.
  455. /// Enabling this option will cause a noticeable performance impact. It should be used while in development mode to identify NaN issues.
  456. /// </summary>
  457. public bool isStopNaNEnabled;
  458. /// <summary>
  459. /// If set to true a final post-processing pass will be applied to apply dithering.
  460. /// This can be combined with post-processing antialiasing.
  461. /// <seealso cref="antialiasing"/>
  462. /// </summary>
  463. public bool isDitheringEnabled;
  464. /// <summary>
  465. /// Controls the anti-aliasing mode used by the integrated post-processing stack.
  466. /// When any other value other than <c>AntialiasingMode.None</c> is chosen, a final post-processing pass will be applied to apply anti-aliasing.
  467. /// This pass can be combined with dithering.
  468. /// <see cref="AntialiasingMode"/>
  469. /// <seealso cref="isDitheringEnabled"/>
  470. /// </summary>
  471. public AntialiasingMode antialiasing;
  472. /// <summary>
  473. /// Controls the anti-alising quality of the anti-aliasing mode.
  474. /// <see cref="antialiasingQuality"/>
  475. /// <seealso cref="AntialiasingMode"/>
  476. /// </summary>
  477. public AntialiasingQuality antialiasingQuality;
  478. /// <summary>
  479. /// Returns the current renderer used by this camera.
  480. /// <see cref="ScriptableRenderer"/>
  481. /// </summary>
  482. public ScriptableRenderer renderer;
  483. /// <summary>
  484. /// True if this camera is resolving rendering to the final camera render target.
  485. /// When rendering a stack of cameras only the last camera in the stack will resolve to camera target.
  486. /// </summary>
  487. public bool resolveFinalTarget;
  488. /// <summary>
  489. /// Camera position in world space.
  490. /// </summary>
  491. public Vector3 worldSpaceCameraPos;
  492. /// <summary>
  493. /// Final background color in the active color space.
  494. /// </summary>
  495. public Color backgroundColor;
  496. /// <summary>
  497. /// Persistent TAA data, primarily for the accumulation texture.
  498. /// </summary>
  499. internal TaaHistory taaHistory;
  500. /// <summary>
  501. /// The STP history data. It contains both persistent state and textures.
  502. /// </summary>
  503. internal StpHistory stpHistory;
  504. // TAA settings.
  505. internal TemporalAA.Settings taaSettings;
  506. // Post-process history reset has been triggered for this camera.
  507. internal bool resetHistory
  508. {
  509. get => taaSettings.resetHistoryFrames != 0;
  510. }
  511. /// <summary>
  512. /// Camera at the top of the overlay camera stack
  513. /// </summary>
  514. public Camera baseCamera;
  515. ///<inheritdoc/>
  516. public override void Reset()
  517. {
  518. m_ViewMatrix = default;
  519. m_ProjectionMatrix = default;
  520. m_JitterMatrix = default;
  521. #if ENABLE_VR && ENABLE_XR_MODULE
  522. m_CachedRenderIntoTextureXR = false;
  523. m_InitBuiltinXRConstants = false;
  524. #endif
  525. camera = null;
  526. renderType = CameraRenderType.Base;
  527. targetTexture = null;
  528. cameraTargetDescriptor = default;
  529. pixelRect = default;
  530. useScreenCoordOverride = false;
  531. screenSizeOverride = default;
  532. screenCoordScaleBias = default;
  533. pixelWidth = 0;
  534. pixelHeight = 0;
  535. aspectRatio = 0.0f;
  536. renderScale = 1.0f;
  537. imageScalingMode = ImageScalingMode.None;
  538. upscalingFilter = ImageUpscalingFilter.Point;
  539. fsrOverrideSharpness = false;
  540. fsrSharpness = 0.0f;
  541. hdrColorBufferPrecision = HDRColorBufferPrecision._32Bits;
  542. clearDepth = false;
  543. cameraType = CameraType.Game;
  544. isDefaultViewport = false;
  545. isHdrEnabled = false;
  546. allowHDROutput = false;
  547. isAlphaOutputEnabled = false;
  548. requiresDepthTexture = false;
  549. requiresOpaqueTexture = false;
  550. postProcessingRequiresDepthTexture = false;
  551. xrRendering = false;
  552. useGPUOcclusionCulling = false;
  553. defaultOpaqueSortFlags = SortingCriteria.None;
  554. xr = default;
  555. maxShadowDistance = 0.0f;
  556. postProcessEnabled = false;
  557. captureActions = default;
  558. volumeLayerMask = 0;
  559. volumeTrigger = default;
  560. isStopNaNEnabled = false;
  561. isDitheringEnabled = false;
  562. antialiasing = AntialiasingMode.None;
  563. antialiasingQuality = AntialiasingQuality.Low;
  564. renderer = null;
  565. resolveFinalTarget = false;
  566. worldSpaceCameraPos = default;
  567. backgroundColor = Color.black;
  568. taaHistory = null;
  569. stpHistory = null;
  570. taaSettings = default;
  571. baseCamera = null;
  572. stackAnyPostProcessingEnabled = false;
  573. stackLastCameraOutputToHDR = false;
  574. }
  575. }
  576. }