This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,128 @@
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Class that holds settings related to texture resources for the 2D renderer.
/// </summary>
public class Universal2DResourceData : UniversalResourceDataBase
{
TextureHandle[][] CheckAndGetTextureHandle(ref TextureHandle[][] handle)
{
if (!CheckAndWarnAboutAccessibility())
return new TextureHandle[][] { new TextureHandle[] { TextureHandle.nullHandle } };
return handle;
}
void CheckAndSetTextureHandle(ref TextureHandle[][] handle, in TextureHandle[][] newHandle)
{
if (!CheckAndWarnAboutAccessibility())
return;
if (handle == null || handle.Length != newHandle.Length)
handle = new TextureHandle[newHandle.Length][];
for (int i = 0; i < newHandle.Length; i++)
handle[i] = newHandle[i];
}
/// <summary>
/// Light textures per sorting layer. Written to by the Light2D pass.
/// </summary>
public TextureHandle[][] lightTextures
{
get => CheckAndGetTextureHandle(ref _lightTextures);
set => CheckAndSetTextureHandle(ref _lightTextures, value);
}
private TextureHandle[][] _lightTextures = new TextureHandle[0][];
/// <summary>
/// Normal textures per sorting layer. Written to by the Normal pass.
/// </summary>
public TextureHandle[] normalsTexture
{
get => CheckAndGetTextureHandle(ref _cameraNormalsTexture);
set => CheckAndSetTextureHandle(ref _cameraNormalsTexture, value);
}
private TextureHandle[] _cameraNormalsTexture = new TextureHandle[0];
/// <summary>
/// Normal depth texture. Written to by the Normal pass.
/// </summary>
public TextureHandle normalsDepth
{
get => CheckAndGetTextureHandle(ref _normalsDepth);
set => CheckAndSetTextureHandle(ref _normalsDepth, value);
}
private TextureHandle _normalsDepth;
/// <summary>
/// Shadow textures per sorting layer. Written to by the Light2D pass.
/// </summary>
public TextureHandle[][] shadowTextures
{
get => CheckAndGetTextureHandle(ref _shadowTextures);
set => CheckAndSetTextureHandle(ref _shadowTextures, value);
}
private TextureHandle[][] _shadowTextures = new TextureHandle[0][];
/// <summary>
/// Shadow depth texture. Written to by the Shadow pass.
/// </summary>
public TextureHandle shadowDepth
{
get => CheckAndGetTextureHandle(ref _shadowDepth);
set => CheckAndSetTextureHandle(ref _shadowDepth, value);
}
private TextureHandle _shadowDepth;
internal TextureHandle upscaleTexture
{
get => CheckAndGetTextureHandle(ref _upscaleTexture);
set => CheckAndSetTextureHandle(ref _upscaleTexture, value);
}
private TextureHandle _upscaleTexture;
/// <summary>
/// Camera Sorting Layer Texture. Written to by the CopyCameraSortingLayerPass pass.
/// </summary>
public TextureHandle cameraSortingLayerTexture
{
get => CheckAndGetTextureHandle(ref _cameraSortingLayerTexture);
set => CheckAndSetTextureHandle(ref _cameraSortingLayerTexture, value);
}
private TextureHandle _cameraSortingLayerTexture;
/// <summary>
/// Rendering Layers Texture. Can be written to by the Light2D pass.
/// </summary>
public TextureHandle renderingLayersTexture
{
get => CheckAndGetTextureHandle(ref _renderingLayersTexture);
internal set => CheckAndSetTextureHandle(ref _renderingLayersTexture, value);
}
private TextureHandle _renderingLayersTexture;
/// <inheritdoc />
public override void Reset()
{
_normalsDepth = TextureHandle.nullHandle;
_shadowDepth = TextureHandle.nullHandle;
_upscaleTexture = TextureHandle.nullHandle;
_cameraSortingLayerTexture = TextureHandle.nullHandle;
_renderingLayersTexture = TextureHandle.nullHandle;
for (int i = 0; i < _cameraNormalsTexture.Length; i++)
_cameraNormalsTexture[i] = TextureHandle.nullHandle;
for (int i = 0; i < _shadowTextures.Length; i++)
for (int j = 0; j < _shadowTextures[i].Length; j++)
_shadowTextures[i][j] = TextureHandle.nullHandle;
for (int i = 0; i < _lightTextures.Length; i++)
for (int j = 0; j < _lightTextures[i].Length; j++)
_lightTextures[i][j] = TextureHandle.nullHandle;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2c3de1a926cfe8f4697ce0ff97e18ef3
@@ -0,0 +1,706 @@
using System;
using System.Collections.Generic;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Class that holds settings related to camera.
/// </summary>
public partial class UniversalCameraData : ContextItem
{
// Internal camera data as we are not yet sure how to expose View in stereo context.
// We might change this API soon.
Matrix4x4 m_ViewMatrix;
Matrix4x4 m_ProjectionMatrix;
Matrix4x4 m_JitterMatrix;
internal void SetViewAndProjectionMatrix(Matrix4x4 viewMatrix, Matrix4x4 projectionMatrix)
{
m_ViewMatrix = viewMatrix;
m_ProjectionMatrix = projectionMatrix;
m_JitterMatrix = Matrix4x4.identity;
}
internal void SetViewProjectionAndJitterMatrix(Matrix4x4 viewMatrix, Matrix4x4 projectionMatrix, Matrix4x4 jitterMatrix)
{
m_ViewMatrix = viewMatrix;
m_ProjectionMatrix = projectionMatrix;
m_JitterMatrix = jitterMatrix;
}
#if ENABLE_VR && ENABLE_XR_MODULE
private bool m_CachedRenderIntoTextureXR;
private bool m_InitBuiltinXRConstants;
#endif
// Helper function to populate builtin stereo matricies as well as URP stereo matricies
internal void PushBuiltinShaderConstantsXR(RasterCommandBuffer cmd, bool renderIntoTexture)
{
#if ENABLE_VR && ENABLE_XR_MODULE
// Multipass always needs update to prevent wrong view projection matrix set by other passes
bool needsUpdate = !m_InitBuiltinXRConstants || m_CachedRenderIntoTextureXR != renderIntoTexture || !xr.singlePassEnabled;
if (needsUpdate && xr.enabled )
{
var projection0 = GetProjectionMatrix();
var view0 = GetViewMatrix();
cmd.SetViewProjectionMatrices(view0, projection0);
if (xr.singlePassEnabled)
{
var projection1 = GetProjectionMatrix(1);
var view1 = GetViewMatrix(1);
XRBuiltinShaderConstants.UpdateBuiltinShaderConstants(view0, projection0, renderIntoTexture, 0);
XRBuiltinShaderConstants.UpdateBuiltinShaderConstants(view1, projection1, renderIntoTexture, 1);
XRBuiltinShaderConstants.SetBuiltinShaderConstants(cmd);
}
else
{
// Update multipass worldSpace camera pos
Vector3 worldSpaceCameraPos = Matrix4x4.Inverse(GetViewMatrix(0)).GetColumn(3);
cmd.SetGlobalVector(ShaderPropertyId.worldSpaceCameraPos, worldSpaceCameraPos);
//Multipass uses the same value as a normal render, and doesn't use the value set for stereo,
//which is why you need to set a value like unity_MatrixInvV.
//The values below should be the same as set in the SetCameraMatrices function in ScriptableRenderer.cs.
Matrix4x4 gpuProjectionMatrix = GetGPUProjectionMatrix(renderIntoTexture); // TODO: invProjection might NOT match the actual projection (invP*P==I) as the target flip logic has diverging paths.
Matrix4x4 inverseViewMatrix = Matrix4x4.Inverse(view0);
Matrix4x4 inverseProjectionMatrix = Matrix4x4.Inverse(gpuProjectionMatrix);
Matrix4x4 inverseViewProjection = inverseViewMatrix * inverseProjectionMatrix;
// There's an inconsistency in handedness between unity_matrixV and unity_WorldToCamera
// Unity changes the handedness of unity_WorldToCamera (see Camera::CalculateMatrixShaderProps)
// we will also change it here to avoid breaking existing shaders. (case 1257518)
Matrix4x4 worldToCameraMatrix = Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)) * view0;
Matrix4x4 cameraToWorldMatrix = worldToCameraMatrix.inverse;
cmd.SetGlobalMatrix(ShaderPropertyId.worldToCameraMatrix, worldToCameraMatrix);
cmd.SetGlobalMatrix(ShaderPropertyId.cameraToWorldMatrix, cameraToWorldMatrix);
cmd.SetGlobalMatrix(ShaderPropertyId.inverseViewMatrix, inverseViewMatrix);
cmd.SetGlobalMatrix(ShaderPropertyId.inverseProjectionMatrix, inverseProjectionMatrix);
cmd.SetGlobalMatrix(ShaderPropertyId.inverseViewAndProjectionMatrix, inverseViewProjection);
}
m_CachedRenderIntoTextureXR = renderIntoTexture;
m_InitBuiltinXRConstants = true;
}
#endif
}
/// <summary>
/// Returns the camera view matrix.
/// </summary>
/// <param name="viewIndex"> View index in case of stereo rendering. By default <c>viewIndex</c> is set to 0. </param>
/// <returns> The camera view matrix. </returns>
public Matrix4x4 GetViewMatrix(int viewIndex = 0)
{
#if ENABLE_VR && ENABLE_XR_MODULE
if (xr.enabled)
return xr.GetViewMatrix(viewIndex);
#endif
return m_ViewMatrix;
}
/// <summary>
/// Returns the camera projection matrix. Might be jittered for temporal features.
/// </summary>
/// <param name="viewIndex"> View index in case of stereo rendering. By default <c>viewIndex</c> is set to 0. </param>
/// <returns> The camera projection matrix. </returns>
public Matrix4x4 GetProjectionMatrix(int viewIndex = 0)
{
#if ENABLE_VR && ENABLE_XR_MODULE
if (xr.enabled)
return m_JitterMatrix * xr.GetProjMatrix(viewIndex);
#endif
return m_JitterMatrix * m_ProjectionMatrix;
}
internal Matrix4x4 GetProjectionMatrixNoJitter(int viewIndex = 0)
{
#if ENABLE_VR && ENABLE_XR_MODULE
if (xr.enabled)
return xr.GetProjMatrix(viewIndex);
#endif
return m_ProjectionMatrix;
}
internal Matrix4x4 GetGPUProjectionMatrix(bool renderIntoTexture, int viewIndex = 0)
{
return GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture);
}
// The jitter matrix is Matrix4x4.Translate(offsetX, offsetY, 0), so the offsets sit in column 3.
// Jitter values are in NDC space (-1 to 1).
internal Vector2 jitter => new Vector2(m_JitterMatrix.m03, m_JitterMatrix.m13);
/// <summary>
/// The camera component.
/// </summary>
public Camera camera;
/// <summary>
/// Returns the scaled width of the Camera
/// By obtaining the pixelWidth of the camera and taking into account the render scale
/// The min dimension is 1.
/// </summary>
public int scaledWidth;
/// <summary>
/// Returns the scaled height of the Camera
/// By obtaining the pixelHeight of the camera and taking into account the render scale
/// The min dimension is 1.
/// </summary>
public int scaledHeight;
#if ENABLE_UPSCALER_FRAMEWORK
// The hardware dynamic resolution (ScalableBufferManager) scale captured once per camera at setup, so upscaler
// passes read a stable per-camera value instead of the live, global, mid-frame-mutable SBM factors (which other
// passes could change between the camera color being aliased and the upscaler reading it). Vector2.one when the
// camera does not use hardware dynamic resolution.
internal Vector2 hardwareDynamicResolutionScale;
#endif
// NOTE: This is internal instead of private to allow ref return in the old CameraData compatibility property.
// We can make this private when it is removed.
//
// A (non-owning) reference of full writable camera history for internal and injected render passes.
// Only passes/code executing inside the pipeline should have access.
// Use the "historyManager" property below to access.
internal UniversalCameraHistory m_HistoryManager;
/// <summary>
/// The camera history texture manager. Used to access camera history from a ScriptableRenderPass.
/// </summary>
/// <seealso cref="ScriptableRenderPass"/>
public UniversalCameraHistory historyManager { get => m_HistoryManager; set => m_HistoryManager = value; }
/// <summary>
/// The camera render type used for camera stacking.
/// <see cref="CameraRenderType"/>
/// </summary>
public CameraRenderType renderType;
/// <summary>
/// Controls the final target texture for a camera. If null camera will resolve rendering to screen.
/// </summary>
public RenderTexture targetTexture;
/// <summary>
/// Render texture settings used to create intermediate camera textures for rendering.
/// </summary>
public RenderTextureDescriptor cameraTargetDescriptor;
internal RenderTargetInfo backbufferColor;
internal RenderTargetInfo backbufferDepth;
internal Rect pixelRect;
internal bool useScreenCoordOverride;
internal Vector4 screenSizeOverride;
internal Vector4 screenCoordScaleBias;
internal int pixelWidth;
internal int pixelHeight;
internal float aspectRatio;
/// <summary>
/// Render scale to apply when creating camera textures. Scaled extents are rounded down to integers.
/// </summary>
public float renderScale;
internal ImageScalingMode imageScalingMode;
#if ENABLE_UPSCALER_FRAMEWORK
/// <summary>
/// The final resolved upscaler hash after 'Automatic' has been processed.
/// </summary>
internal int resolvedUpscalerHash; // hash generated by Shader.PropertyToID()
[Obsolete("upscalingFilter is no longer used #from(6000.3)")]
#endif
internal ImageUpscalingFilter upscalingFilter;
internal bool fsrOverrideSharpness;
internal float fsrSharpness;
internal HDRColorBufferPrecision hdrColorBufferPrecision;
/// <summary>
/// True if this camera should clear depth buffer. This setting only applies to cameras of type <c>CameraRenderType.Overlay</c>
/// <seealso cref="CameraRenderType"/>
/// </summary>
public bool clearDepth;
/// <summary>
/// The camera type.
/// <seealso cref="UnityEngine.CameraType"/>
/// </summary>
public CameraType cameraType;
/// <summary>
/// True if this camera is drawing to a viewport that maps to the entire screen.
/// </summary>
public bool isDefaultViewport;
/// <summary>
/// True if this camera should render to high dynamic range color targets.
/// </summary>
public bool isHdrEnabled;
/// <summary>
/// True if this camera allow color conversion and encoding for high dynamic range displays.
/// </summary>
public bool allowHDROutput;
/// <summary>
/// True if this camera can write the alpha channel. Post-processing uses this. Requires the color target to have an alpha channel.
/// </summary>
public bool isAlphaOutputEnabled;
/// <summary>
/// True if this camera requires to write _CameraDepthTexture.
/// </summary>
public bool requiresDepthTexture;
/// <summary>
/// True if this camera requires to copy camera color texture to _CameraOpaqueTexture.
/// </summary>
public bool requiresOpaqueTexture;
/// <summary>
/// Returns true if post processing passes require depth texture.
/// </summary>
public bool postProcessingRequiresDepthTexture;
/// <summary>
/// Returns true if XR rendering is enabled.
/// </summary>
public bool xrRendering;
// True if GPU occlusion culling should be used when rendering this camera.
internal bool useGPUOcclusionCulling;
internal bool requireSrgbConversion
{
get
{
#if ENABLE_VR && ENABLE_XR_MODULE
// 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.
if (xr.enabled)
return !xr.renderTargetDesc.sRGB && (xr.renderTargetDesc.graphicsFormat == GraphicsFormat.R8G8B8A8_UNorm || xr.renderTargetDesc.graphicsFormat == GraphicsFormat.B8G8R8A8_UNorm) && (QualitySettings.activeColorSpace == ColorSpace.Linear);
#endif
return targetTexture == null && Display.main.requiresSrgbBlitToBackbuffer;
}
}
/// <summary>
/// True if the camera rendering is for regular in-game.
/// </summary>
public bool isGameCamera => cameraType == CameraType.Game;
/// <summary>
/// True if the camera rendering is for the scene window in the editor.
/// </summary>
public bool isSceneViewCamera => cameraType == CameraType.SceneView;
/// <summary>
/// True if the camera rendering is for the preview window in the editor.
/// </summary>
public bool isPreviewCamera => cameraType == CameraType.Preview;
internal bool isRenderPassSupportedCamera => (cameraType == CameraType.Game || cameraType == CameraType.Reflection);
internal bool resolveToScreen => targetTexture == null && resolveFinalTarget && (cameraType == CameraType.Game || camera.cameraType == CameraType.VR);
/// <summary>
/// True if the Camera should output to an HDR display.
/// </summary>
public bool isHDROutputActive
{
get
{
bool hdrDisplayOutputActive = UniversalRenderPipeline.HDROutputForMainDisplayIsActive();
#if ENABLE_VR && ENABLE_XR_MODULE
// If we are rendering to xr then we need to look at the XR Display rather than the main non-xr display.
if (xr.enabled)
hdrDisplayOutputActive = xr.isHDRDisplayOutputActive;
#endif
return hdrDisplayOutputActive && allowHDROutput && resolveToScreen;
}
}
/// <summary>
/// True if the last camera in the stack outputs to an HDR screen
/// </summary>
internal bool stackLastCameraOutputToHDR;
/// <summary>
/// HDR Display information about the current display this camera is rendering to.
/// </summary>
public HDROutputUtils.HDRDisplayInformation hdrDisplayInformation
{
get
{
HDROutputUtils.HDRDisplayInformation displayInformation;
#if ENABLE_VR && ENABLE_XR_MODULE
// If we are rendering to xr then we need to look at the XR Display rather than the main non-xr display.
if (xr.enabled)
{
displayInformation = xr.hdrDisplayOutputInformation;
}
else
#endif
{
HDROutputSettings displaySettings = HDROutputSettings.main;
displayInformation = new HDROutputUtils.HDRDisplayInformation(displaySettings.maxFullFrameToneMapLuminance,
displaySettings.maxToneMapLuminance,
displaySettings.minToneMapLuminance,
displaySettings.paperWhiteNits);
}
return displayInformation;
}
}
/// <summary>
/// HDR Display Color Gamut
/// </summary>
public ColorGamut hdrDisplayColorGamut
{
get
{
#if ENABLE_VR && ENABLE_XR_MODULE
// If we are rendering to xr then we need to look at the XR Display rather than the main non-xr display.
if (xr.enabled)
{
return xr.hdrDisplayOutputColorGamut;
}
else
#endif
{
HDROutputSettings displaySettings = HDROutputSettings.main;
return displaySettings.displayColorGamut;
}
}
}
/// <summary>
/// True if the Camera should render overlay UI.
/// </summary>
public bool rendersOverlayUI => SupportedRenderingFeatures.active.rendersUIOverlay && resolveToScreen;
/// <summary>
/// Makes the Camera render the offscreen overlay UI needed for HDR outputs.
/// URP shares the offscreen texture between cameras once the first base camera renders it.
/// </summary>
internal bool rendersOffscreenUI;
/// <summary>
/// Makes the Camera blit the offscreen overlay UI cover for HDR outputs.
/// The offscreen UI cover prepass ensures the overlay UI covers the entire display even when the combined camera viewports do not fill the screen.
/// </summary>
internal bool blitsOffscreenUICover;
/// <summary>
/// True is the handle has its content flipped on the y axis.
/// This happens only with certain rendering APIs.
/// On those platforms, any handle will have its content flipped unless rendering to a backbuffer, however,
/// the scene view will always be flipped.
/// When transitioning from a flipped space to a non-flipped space - or vice-versa - the content must be flipped
/// in the shader:
/// shouldPerformYFlip = IsHandleYFlipped(source) != IsHandleYFlipped(target)
/// </summary>
/// <param name="handle">Handle to check the flipped status on.</param>
/// <returns>True is the content is flipped in y.</returns>
public bool IsHandleYFlipped(RTHandle handle)
{
if (!SystemInfo.graphicsUVStartsAtTop)
return true;
if (cameraType == CameraType.SceneView || cameraType == CameraType.Preview)
return true;
var handleID = new RenderTargetIdentifier(handle.nameID, 0, CubemapFace.Unknown, 0);
bool isBackbuffer = handleID == BuiltinRenderTextureType.CameraTarget || handleID == BuiltinRenderTextureType.Depth;
#if ENABLE_VR && ENABLE_XR_MODULE
if (xr.enabled)
isBackbuffer |= handleID == new RenderTargetIdentifier(xr.renderTarget, 0, CubemapFace.Unknown, 0);
#endif
return !isBackbuffer;
}
/// <summary>
/// True if the render target's projection matrix is flipped. This happens when the pipeline is rendering
/// to a render texture in non OpenGL platforms. If you are doing a custom Blit pass to copy camera textures
/// (_CameraColorTexture, _CameraDepthAttachment) you need to check this flag to know if you should flip the
/// matrix when rendering with for cmd.Draw* and reading from camera textures.
/// </summary>
/// <param name="color">Color render target to check whether the matrix is flipped.</param>
/// <param name="depth">Depth render target which is used if color is null. By default <c>depth</c> is set to null.</param>
/// <returns> True if the render target's projection matrix is flipped. </returns>
public bool IsRenderTargetProjectionMatrixFlipped(RTHandle color, RTHandle depth = null)
{
if (!SystemInfo.graphicsUVStartsAtTop)
return true;
return targetTexture != null || IsHandleYFlipped(color ?? depth);
}
/// <summary>
/// Returns true if temporal anti-aliasing has been requested
/// Use IsTemporalAAEnabled() to ensure that TAA is active at runtime
/// </summary>
/// <returns>True if TAA is requested</returns>
internal bool IsTemporalAARequested()
{
return antialiasing == AntialiasingMode.TemporalAntiAliasing;
}
/// <summary>
/// Returns true if the pipeline and the given camera are configured to render with temporal anti-aliasing post processing enabled
///
/// Once selected, TAA necessitates some pre-requisites from the pipeline to run, mostly from the camera itself.
/// </summary>
/// <returns>True if TAA is enabled</returns>
internal bool IsTemporalAAEnabled()
{
UniversalAdditionalCameraData additionalCameraData;
camera.TryGetComponent(out additionalCameraData);
return IsTemporalAARequested() // Requested
&& postProcessEnabled // Postprocessing Enabled
&& (taaHistory != null) // Initialized
&& (cameraTargetDescriptor.msaaSamples == 1) // No MSAA
&& !(additionalCameraData?.renderType == CameraRenderType.Overlay || additionalCameraData?.cameraStack.Count > 0) // No Camera stack
&& !camera.allowDynamicResolution // No Dynamic Resolution
&& renderer.SupportsMotionVectors(); // Motion Vectors implemented
}
/// <summary>
/// Returns true if the STP upscaler has been requested
/// Use IsSTPEnabled() to ensure that STP upscaler is active at runtime, it necessitates TAA pre-processing
/// </summary>
/// <returns>True if STP is requested</returns>
internal bool IsSTPRequested()
{
return (imageScalingMode == ImageScalingMode.Upscaling) &&
#if ENABLE_UPSCALER_FRAMEWORK
(resolvedUpscalerHash == UniversalRenderPipeline.k_UpscalerHash_STP)
#else
(upscalingFilter == ImageUpscalingFilter.STP)
#endif
;
}
/// <summary>
/// Returns true if the pipeline and the given camera are configured to render with the STP upscaler
///
/// 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
/// TAA when STP is requested to ensure that most TAA logic remains active. A side effect of this behavior is that STP inherits all of the same configuration
/// restrictions as TAA and effectively cannot run if IsTemporalAAEnabled() returns false. The post processing pass logic that executes STP handles this
/// situation and STP should behave identically to TAA in cases where TAA support requirements aren't met at runtime.
/// </summary>
/// <returns>True if STP is enabled</returns>
internal bool IsSTPEnabled()
{
return IsSTPRequested() && IsTemporalAAEnabled();
}
/// <summary>
/// The sorting criteria used when drawing opaque objects by the internal URP render passes.
/// When a GPU supports hidden surface removal, URP will rely on that information to avoid sorting opaque objects front to back and
/// benefit for more optimal static batching.
/// </summary>
/// <seealso cref="SortingCriteria"/>
public SortingCriteria defaultOpaqueSortFlags;
/// <summary>
/// XRPass holds the render target information and a list of XRView.
/// XRView contains the parameters required to render (projection and view matrices, viewport, etc)
/// </summary>
public XRPass xr { get; internal set; }
internal XRPassUniversal xrUniversal => xr as XRPassUniversal;
/// <summary>
/// Maximum shadow distance visible to the camera. When set to zero shadows will be disable for that camera.
/// </summary>
public float maxShadowDistance;
/// <summary>
/// True if post-processing is enabled for this camera.
/// </summary>
public bool postProcessEnabled;
/// <summary>
/// True if post-processing is enabled for any camera in this camera's stack.
/// </summary>
internal bool stackAnyPostProcessingEnabled;
/// <summary>
/// Provides set actions to the renderer to be triggered at the end of the render loop for camera capture.
/// </summary>
public IEnumerator<Action<RenderTargetIdentifier, CommandBuffer>> captureActions;
/// <summary>
/// The camera volume layer mask.
/// </summary>
public LayerMask volumeLayerMask;
/// <summary>
/// The camera volume trigger.
/// </summary>
public Transform volumeTrigger;
/// <summary>
/// If set to true, the integrated post-processing stack will replace any NaNs generated by render passes prior to post-processing with black/zero.
/// Enabling this option will cause a noticeable performance impact. It should be used while in development mode to identify NaN issues.
/// </summary>
public bool isStopNaNEnabled;
/// <summary>
/// If set to true a final post-processing pass will be applied to apply dithering.
/// This can be combined with post-processing antialiasing.
/// <seealso cref="antialiasing"/>
/// </summary>
public bool isDitheringEnabled;
/// <summary>
/// Controls the anti-aliasing mode used by the integrated post-processing stack.
/// When any other value other than <c>AntialiasingMode.None</c> is chosen, a final post-processing pass will be applied to apply anti-aliasing.
/// This pass can be combined with dithering.
/// <see cref="AntialiasingMode"/>
/// <seealso cref="isDitheringEnabled"/>
/// </summary>
public AntialiasingMode antialiasing;
/// <summary>
/// Controls the anti-alising quality of the anti-aliasing mode.
/// <see cref="antialiasingQuality"/>
/// <seealso cref="AntialiasingMode"/>
/// </summary>
public AntialiasingQuality antialiasingQuality;
/// <summary>
/// Returns the current renderer used by this camera.
/// <see cref="ScriptableRenderer"/>
/// </summary>
public ScriptableRenderer renderer;
/// <summary>
/// True if this camera is resolving rendering to the final camera render target.
/// When rendering a stack of cameras only the last camera in the stack will resolve to camera target.
/// </summary>
public bool resolveFinalTarget;
/// <summary>
/// Camera position in world space.
/// </summary>
public Vector3 worldSpaceCameraPos;
/// <summary>
/// Final background color in the active color space.
/// </summary>
public Color backgroundColor;
/// <summary>
/// Persistent TAA data, primarily for the accumulation texture.
/// </summary>
internal TaaHistory taaHistory;
/// <summary>
/// The STP history data. It contains both persistent state and textures.
/// </summary>
internal StpHistory stpHistory;
// TAA settings.
internal TemporalAA.Settings taaSettings;
// Sub-pixel jitter applied to the projection matrix this frame.
// Computed once during camera setup, read by upscalers during post-process.
internal Vector2 subpixelJitter;
// Post-process history reset has been triggered for this camera.
internal bool resetHistory
{
get => taaSettings.resetHistoryFrames != 0;
}
/// <summary>
/// Camera at the top of the overlay camera stack. If no stack, it equals the camera field present above.
/// </summary>
public Camera baseCamera;
/// <summary>
/// Returns true if the baseCamera field is the last base camera being rendered to the frame.
/// While the last camera in a camera stack implies a last overlay camera, this indicates the last of all input base cameras.
/// </summary>
internal bool isLastBaseCamera;
///<inheritdoc/>
public override void Reset()
{
m_ViewMatrix = default;
m_ProjectionMatrix = default;
m_JitterMatrix = default;
#if ENABLE_VR && ENABLE_XR_MODULE
m_CachedRenderIntoTextureXR = false;
m_InitBuiltinXRConstants = false;
#endif
camera = null;
renderType = CameraRenderType.Base;
targetTexture = null;
cameraTargetDescriptor = default;
backbufferColor = default;
backbufferDepth = default;
pixelRect = default;
useScreenCoordOverride = false;
screenSizeOverride = default;
screenCoordScaleBias = default;
pixelWidth = 0;
pixelHeight = 0;
aspectRatio = 0.0f;
renderScale = 1.0f;
imageScalingMode = ImageScalingMode.None;
#if ENABLE_UPSCALER_FRAMEWORK
resolvedUpscalerHash = -1;
hardwareDynamicResolutionScale = Vector2.one;
#else
upscalingFilter = ImageUpscalingFilter.Point;
#endif
fsrOverrideSharpness = false;
fsrSharpness = 0.0f;
hdrColorBufferPrecision = HDRColorBufferPrecision._32Bits;
clearDepth = false;
cameraType = CameraType.Game;
isDefaultViewport = false;
isHdrEnabled = false;
allowHDROutput = false;
isAlphaOutputEnabled = false;
requiresDepthTexture = false;
requiresOpaqueTexture = false;
postProcessingRequiresDepthTexture = false;
xrRendering = false;
useGPUOcclusionCulling = false;
defaultOpaqueSortFlags = SortingCriteria.None;
xr = default;
maxShadowDistance = 0.0f;
postProcessEnabled = false;
captureActions = default;
volumeLayerMask = 0;
volumeTrigger = default;
isStopNaNEnabled = false;
isDitheringEnabled = false;
antialiasing = AntialiasingMode.None;
antialiasingQuality = AntialiasingQuality.Low;
renderer = null;
resolveFinalTarget = false;
worldSpaceCameraPos = default;
backgroundColor = Color.black;
taaHistory = null;
stpHistory = null;
taaSettings = default;
subpixelJitter = default;
baseCamera = null;
isLastBaseCamera = false;
stackAnyPostProcessingEnabled = false;
stackLastCameraOutputToHDR = false;
rendersOffscreenUI = false;
blitsOffscreenUICover = false;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e28016542c8e4854a545aa24a49c882e
timeCreated: 1689238907
@@ -0,0 +1,83 @@
using System;
using Unity.Collections;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Class that holds settings related to lights.
/// </summary>
public class UniversalLightData : ContextItem
{
/// <summary>
/// Holds the main light index from the <c>VisibleLight</c> list returned by culling. If there's no main light in the scene, <c>mainLightIndex</c> is set to -1.
/// The main light is the directional light assigned as Sun source in light settings or the brightest directional light.
/// <seealso cref="CullingResults"/>
/// </summary>
public int mainLightIndex;
/// <summary>
/// The number of additional lights visible by the camera.
/// </summary>
public int additionalLightsCount;
/// <summary>
/// Maximum amount of lights that can be shaded per-object. This value only affects forward rendering.
/// </summary>
public int maxPerObjectAdditionalLightsCount;
/// <summary>
/// List of visible lights returned by culling.
/// </summary>
public NativeArray<VisibleLight> visibleLights;
/// <summary>
/// True if additional lights should be shaded in vertex shader, otherwise additional lights will be shaded per pixel.
/// </summary>
public bool shadeAdditionalLightsPerVertex;
/// <summary>
/// True if mixed lighting is supported.
/// </summary>
public bool supportsMixedLighting;
/// <summary>
/// True if box projection is enabled for reflection probes.
/// </summary>
public bool reflectionProbeBoxProjection;
/// <summary>
/// True if blending is enabled for reflection probes.
/// </summary>
public bool reflectionProbeBlending;
/// <summary>
/// True if reflection probe atlas is enabled.
/// </summary>
public bool reflectionProbeAtlas;
/// <summary>
/// True if light layers are enabled.
/// </summary>
public bool supportsLightLayers;
/// <summary>
/// True if additional lights enabled.
/// </summary>
public bool supportsAdditionalLights;
/// <inheritdoc/>
public override void Reset()
{
mainLightIndex = -1;
additionalLightsCount = 0;
maxPerObjectAdditionalLightsCount = 0;
visibleLights = default;
shadeAdditionalLightsPerVertex = false;
supportsMixedLighting = false;
reflectionProbeBoxProjection = false;
reflectionProbeBlending = false;
supportsLightLayers = false;
supportsAdditionalLights = false;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fdd7cd5780dc4df69afb5e3c7c41ef8c
timeCreated: 1689238919
@@ -0,0 +1,65 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Settings used for Post Processing.
/// </summary>
public class UniversalPostProcessingData : ContextItem
{
/// <summary>
/// True if post-processing effect is enabled while rendering the camera stack.
/// </summary>
public bool isEnabled;
/// <summary>
/// The <c>ColorGradingMode</c> to use.
/// </summary>
/// <seealso cref="ColorGradingMode"/>
public ColorGradingMode gradingMode;
/// <summary>
/// The size of the Look Up Table (LUT)
/// </summary>
public int lutSize;
/// <summary>
/// True if fast approximation functions are used when converting between the sRGB and Linear color spaces, false otherwise.
/// </summary>
public bool useFastSRGBLinearConversion;
/// <summary>
/// Returns true if Screen Space Lens Flare are supported by this asset, false otherwise.
/// </summary>
public bool supportScreenSpaceLensFlare;
/// <summary>
/// Returns true if Data Driven Lens Flare are supported by this asset, false otherwise.
/// </summary>
public bool supportDataDrivenLensFlare;
#if ENABLE_UPSCALER_FRAMEWORK
/// <summary>
/// Returns null if there isn't an active upscaler
/// </summary>
internal IUpscaler activeUpscaler;
#endif
/// <summary>
/// Empty function added for the IDisposable interface.
/// </summary>
public override void Reset()
{
isEnabled = default;
gradingMode = ColorGradingMode.LowDynamicRange;
lutSize = 0;
useFastSRGBLinearConversion = false;
supportScreenSpaceLensFlare = false;
supportDataDrivenLensFlare = false;
#if ENABLE_UPSCALER_FRAMEWORK
activeUpscaler = null;
#endif
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 154f2df7349f45fa897e03ab12ec09b4
timeCreated: 1689238927
@@ -0,0 +1,84 @@
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Contains the data for general renderer settings.
/// </summary>
public class UniversalRenderingData : ContextItem
{
/// <summary>
/// Returns culling results that exposes handles to visible objects, lights and probes.
/// You can use this to draw objects with <c>ScriptableRenderContext.DrawRenderers</c>
/// <see cref="CullingResults"/>
/// <seealso cref="ScriptableRenderContext"/>
/// </summary>
public CullingResults cullResults;
// True when cullResults was reused from a previous pass.
// Consumers should avoid mutating the culling state.
internal bool reuseCullingResult;
/// <summary>
/// True if the pipeline supports dynamic batching.
/// This settings doesn't apply when drawing shadow casters. Dynamic batching is always disabled when drawing shadow casters.
/// </summary>
[System.Obsolete("supportsDynamicBatching is obsolete.", true)]
public bool supportsDynamicBatching;
/// <summary>
/// Holds per-object data that are requested when drawing
/// <see cref="PerObjectData"/>
/// </summary>
public PerObjectData perObjectData;
/// <summary>
/// The Rendering mode used by the renderer in the current frame.
/// Note that this may sometimes be different from what is set in the Renderer asset,
/// for example when the hardware not capable of deferred rendering or when doing wireframe rendering.
/// </summary>
public RenderingMode renderingMode { get; internal set; }
/// <summary>
/// The layer mask set on the renderer to filter prepass objects.
/// </summary>
public LayerMask prepassLayerMask { get; internal set; }
/// <summary>
/// The layer mask set on the renderer to filter opaque objects.
/// </summary>
public LayerMask opaqueLayerMask { get; internal set; }
/// <summary>
/// The layer mask set on the renderer to filter transparent objects.
/// </summary>
public LayerMask transparentLayerMask { get; internal set; }
/// <summary>
/// True if the Stencil Lod Cross fade is enabled.
/// </summary>
public bool stencilLodCrossFadeEnabled { get; internal set; }
#if URP_SCREEN_SPACE_REFLECTION
/// <summary>
/// True if per-pixel smoothness should be written to the alpha channel of the CameraDepthNormals texture, if it exists.
/// Used for screen space reflections.
/// </summary>
public bool writesSmoothnessToDepthNormalsAlpha { get; internal set; }
#endif
/// <inheritdoc/>
public override void Reset()
{
cullResults = default;
reuseCullingResult = default;
perObjectData = default;
renderingMode = default;
stencilLodCrossFadeEnabled = default;
prepassLayerMask = -1;
opaqueLayerMask = -1;
transparentLayerMask = -1;
#if URP_SCREEN_SPACE_REFLECTION
writesSmoothnessToDepthNormalsAlpha = false;
#endif
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4ae95b242bca4cbc9098ad3ca788d0cc
timeCreated: 1689241542
@@ -0,0 +1,102 @@
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Base class for URP texture data.
/// </summary>
public abstract class UniversalResourceDataBase : ContextItem
{
/// <summary>
/// Options for the active color &amp; depth target texture.
/// </summary>
internal enum ActiveID
{
/// <summary>The camera buffer.</summary>
Camera,
/// <summary>The backbuffer.</summary>
BackBuffer
}
internal bool isAccessible { get; set; }
internal void InitFrame()
{
isAccessible = true;
}
internal void EndFrame()
{
isAccessible = false;
}
/// <summary>
/// Updates the texture handle if the texture is accessible.
/// </summary>
/// <param name="handle">Handle to update.</param>
/// <param name="newHandle">Handle of the new data.</param>
protected void CheckAndSetTextureHandle(ref TextureHandle handle, in TextureHandle newHandle)
{
if (!CheckAndWarnAboutAccessibility())
return;
handle = newHandle;
}
/// <summary>
/// Fetches the texture handle if the texture is accessible.
/// </summary>
/// <param name="handle">Handle to the texture you want to retrieve</param>
/// <returns>Returns the handle if the texture is accessible and a null handle otherwise.</returns>
protected TextureHandle CheckAndGetTextureHandle(ref TextureHandle handle)
{
if (!CheckAndWarnAboutAccessibility())
return TextureHandle.nullHandle;
return handle;
}
/// <summary>
/// Updates the texture handles if the texture is accessible. The current and new handles needs to be of the same size.
/// </summary>
/// <param name="handle">Handles to update.</param>
/// <param name="newHandle">Handles of the new data.</param>
protected void CheckAndSetTextureHandle(ref TextureHandle[] handle, in TextureHandle[] newHandle)
{
if (!CheckAndWarnAboutAccessibility())
return;
if (handle == null || handle.Length != newHandle.Length)
handle = new TextureHandle[newHandle.Length];
for (int i = 0; i < newHandle.Length; i++)
handle[i] = newHandle[i];
}
/// <summary>
/// Fetches the texture handles if the texture is accessible.
/// </summary>
/// <param name="handle">Handles to the texture you want to retrieve</param>
/// <returns>Returns the handles if the texture is accessible and a null handle otherwise.</returns>
protected TextureHandle[] CheckAndGetTextureHandle(ref TextureHandle[] handle)
{
if (!CheckAndWarnAboutAccessibility())
return new []{TextureHandle.nullHandle};
return handle;
}
/// <summary>
/// Check if the texture is accessible.
/// </summary>
/// <returns>Returns true if the texture is accessible and false otherwise.</returns>
protected bool CheckAndWarnAboutAccessibility()
{
if (!isAccessible)
Debug.LogError("Trying to access Universal Resources outside of the current frame setup.");
return isAccessible;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f3b2d17925485ca479775f22b1fa74a4
@@ -0,0 +1,398 @@
using System;
using UnityEngine.Rendering.RenderGraphModule;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Class that holds settings related to texture resources.
/// </summary>
public class UniversalResourceData : UniversalResourceDataBase
{
/// <summary>
/// The active color target ID.
/// </summary>
internal ActiveID activeColorID { get; set; }
/// <summary>
/// Returns the current active color target texture. To be referenced at RenderGraph pass recording time, not in passes render functions.
/// </summary>
/// <value>Returns the active color texture between the front and back buffer.</value>
public TextureHandle activeColorTexture
{
get
{
if (!CheckAndWarnAboutAccessibility())
return TextureHandle.nullHandle;
switch (activeColorID)
{
case ActiveID.Camera:
return cameraColor;
case ActiveID.BackBuffer:
return backBufferColor;
default:
throw new ArgumentOutOfRangeException();
}
}
}
/// <summary>
/// Switch the active color and depth texture to the backbuffer. Once switched, isActiveTargetBackBuffer will return true.
/// The activeColorTexture and activeDepthTexture will then return the backbuffer. This should be called after a render pass
/// that blits/copies the cameraColor to the backbuffer is recorded in the render graph. The following passes will then
/// automatically use the backbuffer as active color and depth. URP will not add the final blit pass if this method is called before
/// that render pass.
/// </summary>
public void SwitchActiveTexturesToBackbuffer()
{
activeColorID = UniversalResourceData.ActiveID.BackBuffer;
activeDepthID = UniversalResourceData.ActiveID.BackBuffer;
}
/// <summary>
/// The active depth target ID.
/// </summary>
internal ActiveID activeDepthID { get; set; }
/// <summary>
/// Returns the current active color target texture. To be referenced at RenderGraph pass recording time, not in passes render functions.
/// </summary>
/// <value>TextureHandle</value>
public TextureHandle activeDepthTexture
{
get
{
if (!CheckAndWarnAboutAccessibility())
return TextureHandle.nullHandle;
switch (activeDepthID)
{
case ActiveID.Camera:
return cameraDepth;
case ActiveID.BackBuffer:
return backBufferDepth;
default:
throw new ArgumentOutOfRangeException();
}
}
}
/// <summary>
/// True if the current active target is the backbuffer. To be referenced at RenderGraph pass recording time, not in passes render functions.
/// </summary>
/// <value>Returns true if the backbuffer is currently in use and false otherwise.</value>
public bool isActiveTargetBackBuffer
{
get
{
if (!isAccessible)
{
Debug.LogError("Trying to access frameData outside of the current frame setup.");
return false;
}
return activeColorID == UniversalResourceData.ActiveID.BackBuffer;
}
}
/// <summary>
/// The backbuffer color used to render directly to screen. All passes can write to it depending on frame setup.
/// </summary>
public TextureHandle backBufferColor
{
get => CheckAndGetTextureHandle(ref _backBufferColor);
internal set => CheckAndSetTextureHandle(ref _backBufferColor, value);
}
private TextureHandle _backBufferColor;
/// <summary>
/// The backbuffer depth used to render directly to screen. All passes can write to it depending on frame setup.
/// </summary>
public TextureHandle backBufferDepth
{
get => CheckAndGetTextureHandle(ref _backBufferDepth);
internal set => CheckAndSetTextureHandle(ref _backBufferDepth, value);
}
private TextureHandle _backBufferDepth;
// intermediate camera targets
/// <summary>
/// Main offscreen camera color target. All passes can write to it depending on frame setup.
/// Can hold multiple samples if MSAA is enabled.
/// </summary>
public TextureHandle cameraColor
{
get => CheckAndGetTextureHandle(ref _cameraColor);
set => CheckAndSetTextureHandle(ref _cameraColor, value);
}
private TextureHandle _cameraColor;
/// <summary>
/// Main offscreen camera depth target. All passes can write to it depending on frame setup.
/// Can hold multiple samples if MSAA is enabled.
/// </summary>
public TextureHandle cameraDepth
{
get => CheckAndGetTextureHandle(ref _cameraDepth);
set => CheckAndSetTextureHandle(ref _cameraDepth, value);
}
private TextureHandle _cameraDepth;
// shadows
/// <summary>
/// Main shadow map.
/// </summary>
public TextureHandle mainShadowsTexture
{
get => CheckAndGetTextureHandle(ref _mainShadowsTexture);
set => CheckAndSetTextureHandle(ref _mainShadowsTexture, value);
}
private TextureHandle _mainShadowsTexture;
/// <summary>
/// Additional shadow map.
/// </summary>
public TextureHandle additionalShadowsTexture
{
get => CheckAndGetTextureHandle(ref _additionalShadowsTexture);
set => CheckAndSetTextureHandle(ref _additionalShadowsTexture, value);
}
private TextureHandle _additionalShadowsTexture;
// GBuffer targets
/// <summary>
/// GBuffer. Written to by the GBuffer pass.
/// </summary>
public TextureHandle[] gBuffer
{
get => CheckAndGetTextureHandle(ref _gBuffer);
set => CheckAndSetTextureHandle(ref _gBuffer, value);
}
private TextureHandle[] _gBuffer = new TextureHandle[RenderGraphUtils.GBufferSize];
// camera opaque/depth/normal
/// <summary>
/// Camera opaque texture. Contains a copy of CameraColor if the CopyColor pass is executed.
/// </summary>
public TextureHandle cameraOpaqueTexture
{
get => CheckAndGetTextureHandle(ref _cameraOpaqueTexture);
internal set => CheckAndSetTextureHandle(ref _cameraOpaqueTexture, value);
}
private TextureHandle _cameraOpaqueTexture;
/// <summary>
/// Camera depth texture. Contains the scene depth if the CopyDepth or Depth Prepass passes are executed.
/// </summary>
public TextureHandle cameraDepthTexture
{
get => CheckAndGetTextureHandle(ref _cameraDepthTexture);
internal set => CheckAndSetTextureHandle(ref _cameraDepthTexture, value);
}
private TextureHandle _cameraDepthTexture;
/// <summary>
/// Camera normals texture. Contains the scene depth if the DepthNormals Prepass pass is executed.
/// </summary>
public TextureHandle cameraNormalsTexture
{
get => CheckAndGetTextureHandle(ref _cameraNormalsTexture);
internal set => CheckAndSetTextureHandle(ref _cameraNormalsTexture, value);
}
private TextureHandle _cameraNormalsTexture;
// motion vector
/// <summary>
/// Motion Vector Color. Written to by the Motion Vector passes.
/// </summary>
public TextureHandle motionVectorColor
{
get => CheckAndGetTextureHandle(ref _motionVectorColor);
set => CheckAndSetTextureHandle(ref _motionVectorColor, value);
}
private TextureHandle _motionVectorColor;
/// <summary>
/// Motion Vector Depth. Written to by the Motion Vector passes.
/// </summary>
public TextureHandle motionVectorDepth
{
get => CheckAndGetTextureHandle(ref _motionVectorDepth);
set => CheckAndSetTextureHandle(ref _motionVectorDepth, value);
}
private TextureHandle _motionVectorDepth;
// postFx
/// <summary>
/// Internal Color LUT. Written to by the InternalLUT pass.
/// </summary>
public TextureHandle internalColorLut
{
get => CheckAndGetTextureHandle(ref _internalColorLut);
set => CheckAndSetTextureHandle(ref _internalColorLut, value);
}
private TextureHandle _internalColorLut;
/// <summary>
/// Bloom. A glow for very bright highlights. Written to by the Bloom pass. Additively composited in the Uber pass.
/// It does not contain bloom specific alpha information and can be considered as a premultiplied alpha texture for advanced compositing.
/// </summary>
internal TextureHandle bloom
{
get => CheckAndGetTextureHandle(ref _bloom);
set => CheckAndSetTextureHandle(ref _bloom, value);
}
private TextureHandle _bloom;
/// <summary>
/// After Post Process Color is obsolete.
/// </summary>
[Obsolete("AfterPostProcessColor has never been implemented. Use cameraColor instead.", false)]
public TextureHandle afterPostProcessColor
{
get => CheckAndGetTextureHandle(ref _afterPostProcessColor);
internal set => CheckAndSetTextureHandle(ref _afterPostProcessColor, value);
}
private TextureHandle _afterPostProcessColor;
/// <summary>
/// Overlay UI Texture. The DrawScreenSpaceUI pass writes to this texture when rendering off-screen.
/// </summary>
public TextureHandle overlayUITexture
{
get => CheckAndGetTextureHandle(ref _overlayUITexture);
internal set => CheckAndSetTextureHandle(ref _overlayUITexture, value);
}
private TextureHandle _overlayUITexture;
// rendering layers
/// <summary>
/// Rendering Layers Texture. Can be written to by the DrawOpaques pass or DepthNormals prepass based on settings.
/// </summary>
public TextureHandle renderingLayersTexture
{
get => CheckAndGetTextureHandle(ref _renderingLayersTexture);
internal set => CheckAndSetTextureHandle(ref _renderingLayersTexture, value);
}
private TextureHandle _renderingLayersTexture;
// decals
/// <summary>
/// DBuffer. Written to by the Decals pass.
/// </summary>
public TextureHandle[] dBuffer
{
get => CheckAndGetTextureHandle(ref _dBuffer);
set => CheckAndSetTextureHandle(ref _dBuffer, value);
}
private TextureHandle[] _dBuffer = new TextureHandle[RenderGraphUtils.DBufferSize];
/// <summary>
/// DBufferDepth. Written to by the Decals pass.
/// </summary>
public TextureHandle dBufferDepth
{
get => CheckAndGetTextureHandle(ref _dBufferDepth);
set => CheckAndSetTextureHandle(ref _dBufferDepth, value);
}
private TextureHandle _dBufferDepth;
/// <summary>
/// Screen Space Ambient Occlusion texture. Written to by the SSAO pass.
/// </summary>
public TextureHandle ssaoTexture
{
get => CheckAndGetTextureHandle(ref _ssaoTexture);
internal set => CheckAndSetTextureHandle(ref _ssaoTexture, value);
}
private TextureHandle _ssaoTexture;
/// <summary>
/// Screen Space irradiance texture.
/// </summary>
internal TextureHandle irradianceTexture
{
get => CheckAndGetTextureHandle(ref _irradianceTexture);
set => CheckAndSetTextureHandle(ref _irradianceTexture, value);
}
private TextureHandle _irradianceTexture;
#if URP_SCREEN_SPACE_REFLECTION
/// <summary>
/// Screen Space reflection texture.
/// </summary>
internal TextureHandle ssrTexture
{
get => CheckAndGetTextureHandle(ref _ssrTexture);
set => CheckAndSetTextureHandle(ref _ssrTexture, value);
}
private TextureHandle _ssrTexture;
#endif
/// <summary>
/// STP debug visualization written to by the STP upscaler.
/// </summary>
internal TextureHandle stpDebugView
{
get => CheckAndGetTextureHandle(ref _stpDebugView);
set => CheckAndSetTextureHandle(ref _stpDebugView, value);
}
private TextureHandle _stpDebugView;
//Due to camera stacking, we sometimes need to set a specific (persistent) target texture as destination.
//We cannot create an RG managed texture for the destination in that case as output/destination.
//If we woulnd't have camera stacking, then the backbuffer would be the only other persistent destination.
//The usage of this destination is currently limited to the Uberpost processing pass.
internal TextureHandle destinationCameraColor
{
get => CheckAndGetTextureHandle(ref _destinationCameraColor);
set => CheckAndSetTextureHandle(ref _destinationCameraColor, value);
}
private TextureHandle _destinationCameraColor;
/// <inheritdoc />
public override void Reset()
{
_backBufferColor = TextureHandle.nullHandle;
_backBufferDepth = TextureHandle.nullHandle;
_cameraColor = TextureHandle.nullHandle;
_cameraDepth = TextureHandle.nullHandle;
_mainShadowsTexture = TextureHandle.nullHandle;
_additionalShadowsTexture = TextureHandle.nullHandle;
_cameraOpaqueTexture = TextureHandle.nullHandle;
_cameraDepthTexture = TextureHandle.nullHandle;
_cameraNormalsTexture = TextureHandle.nullHandle;
_motionVectorColor = TextureHandle.nullHandle;
_motionVectorDepth = TextureHandle.nullHandle;
_internalColorLut = TextureHandle.nullHandle;
_bloom = TextureHandle.nullHandle;
_afterPostProcessColor = TextureHandle.nullHandle;
_overlayUITexture = TextureHandle.nullHandle;
_renderingLayersTexture = TextureHandle.nullHandle;
_dBufferDepth = TextureHandle.nullHandle;
_ssaoTexture = TextureHandle.nullHandle;
_irradianceTexture = TextureHandle.nullHandle;
#if URP_SCREEN_SPACE_REFLECTION
_ssrTexture = TextureHandle.nullHandle;
#endif
_stpDebugView = TextureHandle.nullHandle;
_destinationCameraColor = TextureHandle.nullHandle;
for (int i = 0; i < _gBuffer.Length; i++)
_gBuffer[i] = TextureHandle.nullHandle;
for (int i = 0; i < _dBuffer.Length; i++)
_dBuffer[i] = TextureHandle.nullHandle;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: eeb1feab11794b99b3f42243ad341369
timeCreated: 1689679478
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using Unity.Collections;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Container class for various data used for shadows in URP.
/// </summary>
public class UniversalShadowData : ContextItem
{
/// <summary>
/// True if main light shadows are enabled.
/// </summary>
public bool supportsMainLightShadows;
/// <summary>
/// True if additional lights shadows are enabled in the URP Asset
/// </summary>
internal bool mainLightShadowsEnabled;
/// <summary>
/// The width of the main light shadow map.
/// </summary>
public int mainLightShadowmapWidth;
/// <summary>
/// The height of the main light shadow map.
/// </summary>
public int mainLightShadowmapHeight;
/// <summary>
/// The number of shadow cascades.
/// </summary>
public int mainLightShadowCascadesCount;
/// <summary>
/// The split between cascades.
/// </summary>
public Vector3 mainLightShadowCascadesSplit;
/// <summary>
/// Main light last cascade shadow fade border.
/// Value represents the width of shadow fade that ranges from 0 to 1.
/// Where value 0 is used for no shadow fade.
/// </summary>
public float mainLightShadowCascadeBorder;
/// <summary>
/// True if additional lights shadows are enabled.
/// </summary>
public bool supportsAdditionalLightShadows;
/// <summary>
/// True if additional lights shadows are enabled in the URP Asset
/// </summary>
internal bool additionalLightShadowsEnabled;
/// <summary>
/// The width of the additional light shadow map.
/// </summary>
public int additionalLightsShadowmapWidth;
/// <summary>
/// The height of the additional light shadow map.
/// </summary>
public int additionalLightsShadowmapHeight;
/// <summary>
/// True if soft shadows are enabled.
/// </summary>
public bool supportsSoftShadows;
/// <summary>
/// The number of bits used.
/// </summary>
public int shadowmapDepthBufferBits;
/// <summary>
/// A list of shadow bias.
/// </summary>
public List<Vector4> bias;
/// <summary>
/// A list of resolution for the shadow maps.
/// </summary>
public List<int> resolution;
internal bool isKeywordAdditionalLightShadowsEnabled;
internal bool isKeywordSoftShadowsEnabled;
internal int mainLightShadowResolution;
internal int mainLightRenderTargetWidth;
internal int mainLightRenderTargetHeight;
internal NativeArray<URPLightShadowCullingInfos> visibleLightsShadowCullingInfos;
internal AdditionalLightsShadowAtlasLayout shadowAtlasLayout;
#if ENABLE_VR && ENABLE_XR_MODULE
/// <summary>True when this camera pass should reuse the shadow map rendered in the previous XR pass.</summary>
internal bool useCachedShadowMap;
/// <summary>True when the camera is in a QuadView XR setup that supports shadow map caching.</summary>
internal bool supportShadowMapCaching;
#endif
/// <inheritdoc/>
public override void Reset()
{
supportsMainLightShadows = false;
mainLightShadowmapWidth = 0;
mainLightShadowmapHeight = 0;
mainLightShadowCascadesCount = 0;
mainLightShadowCascadesSplit = Vector3.zero;
mainLightShadowCascadeBorder = 0.0f;
supportsAdditionalLightShadows = false;
additionalLightsShadowmapWidth = 0;
additionalLightsShadowmapHeight = 0;
supportsSoftShadows = false;
shadowmapDepthBufferBits = 0;
bias?.Clear();
resolution?.Clear();
isKeywordAdditionalLightShadowsEnabled = false;
isKeywordSoftShadowsEnabled = false;
mainLightShadowResolution = 0;
mainLightRenderTargetWidth = 0;
mainLightRenderTargetHeight = 0;
visibleLightsShadowCullingInfos = default;
shadowAtlasLayout = default;
#if ENABLE_VR && ENABLE_XR_MODULE
useCachedShadowMap = false;
supportShadowMapCaching = false;
#endif
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 85f55bae7fe6496f98478ff084b619ce
timeCreated: 1689238954