diff --git a/Packages/com.unity.render-pipelines.core/Runtime/XR/XRBuiltinShaderConstants.cs b/Packages/com.unity.render-pipelines.core/Runtime/XR/XRBuiltinShaderConstants.cs
index cbbd2cee2dc..df9f0be4d19 100644
--- a/Packages/com.unity.render-pipelines.core/Runtime/XR/XRBuiltinShaderConstants.cs
+++ b/Packages/com.unity.render-pipelines.core/Runtime/XR/XRBuiltinShaderConstants.cs
@@ -52,6 +52,11 @@ public static class XRBuiltinShaderConstants
///
static public readonly int unity_StereoWorldSpaceCameraPos = Shader.PropertyToID("unity_StereoWorldSpaceCameraPos");
+ ///
+ /// Cached unique id for unity_StereoEyeIndex
+ ///
+ static public readonly int unity_StereoEyeIndex = Shader.PropertyToID("unity_StereoEyeIndex");
+
// Pre-allocate arrays to avoid GC
static Matrix4x4[] s_cameraProjMatrix = new Matrix4x4[2];
static Matrix4x4[] s_invCameraProjMatrix = new Matrix4x4[2];
diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
index ded68994506..90794cc86f6 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
@@ -293,10 +293,11 @@ void RecordRenderGraph(RenderRequest renderRequest,
GenerateColorPyramid(m_RenderGraph, hdCamera, colorBuffer, distortionColorPyramid, FullScreenDebugMode.PreRefractionColorPyramid, distortionRendererList);
currentColorPyramid = distortionColorPyramid;
-
- // The color pyramid for distortion is not an history, so it need to be sampled appropriate RT handle scale. Thus we need to update it
- var newScale = new Vector4(RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y, 0, 0);
- m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = newScale;
+ // The color pyramid for distortion is not an history buffer, so it needs to be sampled using an appropriate RT handle scale. Thus we need to update the scale and the limit.
+ // It's relatively straightforward to update the scale because we store it in rtHandleScale but we miss the limit values. For now, we approximate them by setting them to the scale value.
+ // This is imperfect but resetting limit at (0, 0) gives worse results (UUM-130925).
+ var newScaleLimits = new Vector4(RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y, RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y);
+ m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = newScaleLimits;
PushGlobalCameraParams(m_RenderGraph, hdCamera);
}
diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute
index 284dffc4045..4ce006f356c 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute
+++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute
@@ -222,11 +222,8 @@ NeighborTapData GetNeighborTapDataSample_HR(uint2 groupThreadId, int2 offset)
return GetNeighborTapDataSample_HR(OffsetToLDSAdress_HR(groupThreadId, offset));
}
-NeighborTapData GetNeighborTapDataSample_HR_NOLDS(uint2 fulLResCoord, int2 offset)
+NeighborTapData GetNeighborTapDataSample_HR_NOLDS(uint2 tapCoord)
{
- int2 tapCoord = (fulLResCoord / 2 + offset) * 2;
- tapCoord = int2(clamp(tapCoord.x, 0, (int)_ScreenSize.x - 1), clamp(tapCoord.y, 0, (int)_ScreenSize.y - 1));
-
NeighborTapData outVal;
outVal.lighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, tapCoord / 2).xyz;
outVal.linearDepth = Linear01Depth(LOAD_TEXTURE2D_X(_DepthTexture, tapCoord).x, _ZBufferParams);
@@ -278,11 +275,15 @@ void IndirectDiffuseIntegrationUpscaleHalfRes(uint3 dispatchThreadId : SV_Dispat
{
for(int x = -HALF_RES_OUT_REGION_SIZE; x < HALF_RES_OUT_REGION_SIZE; ++x)
{
+ int2 tapCoord = (targetCoord / 2 + int2(x,y)) * 2;
+ if (any(tapCoord < 0) || any(tapCoord >= _ScreenSize.xy))
+ continue;
+
#ifndef WITHOUT_LDS
// Grab the neighbor data
NeighborTapData neighborData = GetNeighborTapDataSample_HR(groupThreadId, int2(x,y));
#else
- NeighborTapData neighborData = GetNeighborTapDataSample_HR_NOLDS(targetCoord, int2(x,y));
+ NeighborTapData neighborData = GetNeighborTapDataSample_HR_NOLDS(tapCoord);
#endif
// Evaluate the weight of this neighbor
float weight = EvaluateNeighborWeight(neighborData, normalData.normalWS, linearDepth);
@@ -416,6 +417,10 @@ void IndirectDiffuseIntegrationUpscaleFullRes(uint3 dispatchThreadId : SV_Dispat
{
for(int x = -FULL_RES_OUT_REGION_SIZE; x < FULL_RES_OUT_REGION_SIZE; ++x)
{
+ int2 tapCoord = targetCoord + int2(x,y);
+ if (any(tapCoord < 0) || any(tapCoord >= _ScreenSize.xy))
+ continue;
+
#ifndef WITHOUT_LDS
// Grab the neighbor data
NeighborTapData neighborData = GetNeighborTapDataSample_FR(groupThreadId, int2(x,y));
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs
index 612f62ee69a..961e14527b2 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs
@@ -178,20 +178,12 @@ internal void Render(RenderGraph graph, ContextContainer frameData, Renderer2DDa
Universal2DResourceData universal2DResourceData = frameData.Get();
UniversalCameraData cameraData = frameData.Get();
- DebugHandler debugHandler = ScriptableRenderPass.GetActiveDebugHandler(cameraData);
- var isDebugLightingActive = debugHandler?.IsLightingActive ?? true;
-
-#if UNITY_EDITOR
- if (cameraData.isSceneViewCamera && UnityEditor.SceneView.currentDrawingSceneView != null)
- isDebugLightingActive &= UnityEditor.SceneView.currentDrawingSceneView.sceneLighting;
-
- if (cameraData.camera.cameraType == CameraType.Preview)
- isDebugLightingActive = false;
-#endif
+ // Check for lighting in scene/prefab/preview camera
+ var isLightingActive = Renderer2D.s_IsLightingActive;
if (!layerBatch.lightStats.useLights ||
isVolumetric && !layerBatch.lightStats.useVolumetricLights ||
- !isDebugLightingActive)
+ !isLightingActive)
return;
// Render single RTs by for apis that don't support MRTs
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs
index 132a6ac9828..dc0455681cf 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs
@@ -37,7 +37,7 @@ private static void Execute(RasterGraphContext context, PassData passData)
RendererLighting.SetLightShaderGlobals(cmd, passData.lightBlendStyles, passData.blendStyleIndices);
#if UNITY_EDITOR
- if (passData.isLitView)
+ if (passData.isLightingActive)
#endif
{
if (passData.layerUseLights)
@@ -85,7 +85,7 @@ class PassData
internal bool activeDebugHandler;
#if UNITY_EDITOR
- internal bool isLitView; // Required for prefab view and preview camera
+ internal bool isLightingActive; // Required for prefab view and preview camera
#endif
}
@@ -98,35 +98,23 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
CommonResourceData commonResourceData = frameData.Get();
var layerBatch = layerBatches[batchIndex];
- bool isLitView = true;
-#if UNITY_EDITOR
- // Early out for prefabs
- if (cameraData.isSceneViewCamera && UnityEditor.SceneView.currentDrawingSceneView != null)
- isLitView = UnityEditor.SceneView.currentDrawingSceneView.sceneLighting;
-
- // Early out for preview camera
- if (cameraData.cameraType == CameraType.Preview)
- isLitView = false;
-
- DebugHandler debugHandler = GetActiveDebugHandler(cameraData);
- if (debugHandler != null)
- isLitView = debugHandler.IsLightingActive;
-#endif
+ // Check for lighting in scene/prefab/preview camera
+ var isLightingActive = Renderer2D.s_IsLightingActive;
// Preset global light textures for first batch
if (batchIndex == 0)
{
using (var builder = graph.AddRasterRenderPass(k_SetLightBlendTexture, out var passData, m_SetLightBlendTextureProfilingSampler))
{
- if (layerBatch.lightStats.useLights && isLitView)
+ if (layerBatch.lightStats.useLights && isLightingActive)
{
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
for (var i = 0; i < passData.lightTextures.Length; i++)
builder.UseTexture(passData.lightTextures[i]);
}
- SetGlobalLightTextures(graph, builder, passData.lightTextures, ref layerBatch, rendererData, isLitView);
+ SetGlobalLightTextures(graph, builder, passData.lightTextures, ref layerBatch, rendererData, isLightingActive);
builder.AllowPassCulling(false);
builder.AllowGlobalStateModification(true);
@@ -146,7 +134,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
passData.isSceneLit = rendererData.lightCullResult.IsSceneLit();
passData.layerUseLights = layerBatch.lightStats.useLights;
#if UNITY_EDITOR
- passData.isLitView = isLitView;
+ passData.isLightingActive = isLightingActive;
#endif
var drawSettings = CreateDrawingSettings(k_ShaderTags, renderingData, cameraData, lightData, SortingCriteria.CommonTransparent);
@@ -171,7 +159,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
builder.UseRendererList(passData.rendererList);
}
- if (passData.layerUseLights && isLitView)
+ if (passData.layerUseLights && isLightingActive)
{
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
for (var i = 0; i < passData.lightTextures.Length; i++)
@@ -192,7 +180,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
// Post set global light textures for next renderer pass
var nextBatch = batchIndex + 1;
if (nextBatch < universal2DResourceData.lightTextures.Length)
- SetGlobalLightTextures(graph, builder, universal2DResourceData.lightTextures[nextBatch], ref layerBatches[nextBatch], rendererData, isLitView);
+ SetGlobalLightTextures(graph, builder, universal2DResourceData.lightTextures[nextBatch], ref layerBatches[nextBatch], rendererData, isLightingActive);
builder.SetRenderFunc((PassData data, RasterGraphContext context) =>
{
@@ -201,9 +189,9 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
}
}
- void SetGlobalLightTextures(RenderGraph graph, IRasterRenderGraphBuilder builder, TextureHandle[] lightTextures, ref LayerBatch layerBatch, Renderer2DData rendererData, bool isLitView)
+ void SetGlobalLightTextures(RenderGraph graph, IRasterRenderGraphBuilder builder, TextureHandle[] lightTextures, ref LayerBatch layerBatch, Renderer2DData rendererData, bool isLightingActive)
{
- if (isLitView)
+ if (isLightingActive)
{
if (layerBatch.lightStats.useLights)
{
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs
index e64f7ca07a6..31f129ddee5 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs
@@ -31,6 +31,7 @@ internal sealed partial class Renderer2D : ScriptableRenderer
int m_BatchCount;
bool ppcUpscaleRT = false;
+ static internal bool s_IsLightingActive;
private struct ImportResourceSummary
{
@@ -202,8 +203,10 @@ ImportResourceSummary GetImportResourceSummary(RenderGraph renderGraph, Universa
void InitializeLayerBatches()
{
Universal2DResourceData resourceData = frameData.Get();
+ UniversalCameraData cameraData = frameData.Get();
m_LayerBatches = LayerUtility.CalculateBatches(m_Renderer2DData, out m_BatchCount);
+ s_IsLightingActive = IsSceneViewOrPreviewLightingActive(cameraData);
// Initialize textures dependent on batch size
if (resourceData.normalsTexture.Length != m_BatchCount)
@@ -857,5 +860,21 @@ private void CleanupRenderGraphResources()
m_CameraSortingLayerHandle?.Release();
Light2DLookupTexture.Release();
}
+
+ static internal bool IsSceneViewOrPreviewLightingActive(UniversalCameraData cameraData)
+ {
+ DebugHandler debugHandler = ScriptableRenderPass.GetActiveDebugHandler(cameraData);
+ var isLightingActive = debugHandler?.IsLightingActive ?? true;
+
+#if UNITY_EDITOR
+ if (cameraData.isSceneViewCamera && UnityEditor.SceneView.currentDrawingSceneView != null)
+ isLightingActive &= UnityEditor.SceneView.currentDrawingSceneView.sceneLighting;
+
+ if (cameraData.isPreviewCamera && cameraData.camera.name == "Preview Scene Camera")
+ isLightingActive = false;
+#endif
+
+ return isLightingActive;
+ }
}
}
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs
index 8d600c9f0ad..6e461febff0 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs
@@ -1106,7 +1106,7 @@ void LensFlareDataDriven(ref UniversalCameraData cameraData, CommandBuffer cmd,
Matrix4x4 gpuVPXR = GL.GetGPUProjectionMatrix(cameraData.GetProjectionMatrixNoJitter(xrIdx), true) * cameraData.GetViewMatrix(xrIdx);
LensFlareCommonSRP.DoLensFlareDataDrivenCommon(
- m_Materials.lensFlareDataDriven, camera, pixelRect, cameraData.xr, cameraData.xr.multipassId,
+ m_Materials.lensFlareDataDriven, camera, pixelRect, cameraData.xr, xrIdx,
(float)m_Descriptor.width, (float)m_Descriptor.height,
usePanini, paniniDistance, paniniCropToFit, true,
camera.transform.position,
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPassRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPassRenderGraph.cs
index b2d3c21ca00..059d9c06c92 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPassRenderGraph.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPassRenderGraph.cs
@@ -1255,7 +1255,7 @@ public void RenderLensFlareDataDriven(RenderGraph renderGraph, UniversalResource
Matrix4x4 nonJitteredViewProjMatrix_k = GL.GetGPUProjectionMatrix(data.cameraData.GetProjectionMatrixNoJitter(xrIdx), true) * data.cameraData.GetViewMatrix(xrIdx);
LensFlareCommonSRP.DoLensFlareDataDrivenCommon(
- data.material, data.cameraData.camera, data.viewport, xr, data.cameraData.xr.multipassId,
+ data.material, data.cameraData.camera, data.viewport, xr, xrIdx,
data.width, data.height,
data.usePanini, data.paniniDistance, data.paniniCropToFit,
true,
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs b/Packages/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs
index 13f1429eec7..54467bd2467 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs
@@ -292,6 +292,10 @@ void SetPerCameraShaderVariables(RasterCommandBuffer cmd, UniversalCameraData ca
cameraHeight = (float)cameraTargetSizeCopy.y;
useRenderPassEnabled = false;
+
+ // Multi-pass needs to set unity_StereoEyeIndex builtin param for skybox-panoramic.shader to work correctly (UUM-120719)
+ if (!cameraData.xr.singlePassEnabled)
+ cmd.SetGlobalVector(XRBuiltinShaderConstants.unity_StereoEyeIndex, new Vector4(cameraData.xr.multipassId, 0, 0, 0));
}
if (camera.allowDynamicResolution)
diff --git a/Packages/com.unity.render-pipelines.universal/Samples~/URPPackageSamples/RendererFeatures/DepthBlit/DepthBlitCopyDepthPass.cs b/Packages/com.unity.render-pipelines.universal/Samples~/URPPackageSamples/RendererFeatures/DepthBlit/DepthBlitCopyDepthPass.cs
index 1d126cff0bd..eadf2a979db 100644
--- a/Packages/com.unity.render-pipelines.universal/Samples~/URPPackageSamples/RendererFeatures/DepthBlit/DepthBlitCopyDepthPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Samples~/URPPackageSamples/RendererFeatures/DepthBlit/DepthBlitCopyDepthPass.cs
@@ -133,8 +133,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer
builder.SetRenderFunc((PassData data, RasterGraphContext context) =>
{
// Enable an MSAA shader keyword based on the source texture MSAA sample count
+ // when depth must be resolved manually in the copy shader
RTHandle sourceTex = data.source;
- int cameraSamples = sourceTex.rt.antiAliasing;
+ int cameraSamples = sourceTex.rt.bindTextureMS ? sourceTex.rt.antiAliasing : 1;
context.cmd.SetKeyword(data.keyword_DepthMsaa2, cameraSamples == 2);
context.cmd.SetKeyword(data.keyword_DepthMsaa4, cameraSamples == 4);
context.cmd.SetKeyword(data.keyword_DepthMsaa8, cameraSamples == 8);