diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
index 0d05b85aff6..6cd96a853f2 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
@@ -54,7 +54,6 @@ class RenderGraphDebugParams
public bool tagResourceNamesWithRG;
public bool clearRenderTargetsAtCreation;
public bool clearRenderTargetsAtRelease;
- public bool unbindGlobalTextures;
public bool logFrameInformation;
public bool logResources;
@@ -64,7 +63,6 @@ public void RegisterDebug()
list.Add(new DebugUI.BoolField { displayName = "Tag Resources with RG", getter = () => tagResourceNamesWithRG, setter = value => tagResourceNamesWithRG = value });
list.Add(new DebugUI.BoolField { displayName = "Clear Render Targets at creation", getter = () => clearRenderTargetsAtCreation, setter = value => clearRenderTargetsAtCreation = value });
list.Add(new DebugUI.BoolField { displayName = "Clear Render Targets at release", getter = () => clearRenderTargetsAtRelease, setter = value => clearRenderTargetsAtRelease = value });
- list.Add(new DebugUI.BoolField { displayName = "Unbind Global Textures", getter = () => unbindGlobalTextures, setter = value => unbindGlobalTextures = value });
list.Add(new DebugUI.Button { displayName = "Log Frame Information", action = () => logFrameInformation = true });
list.Add(new DebugUI.Button { displayName = "Log Resources", action = () => logResources = true });
@@ -267,11 +265,10 @@ public void PurgeUnusedResources()
/// Any pass writing to an imported texture will be considered having side effects and can't be automatically pruned.
///
/// External RTHandle that needs to be imported.
- /// Optional property that allows you to specify a Shader property name to use for automatic resource binding.
/// A new TextureHandle.
- public TextureHandle ImportTexture(RTHandle rt, int shaderProperty = 0)
+ public TextureHandle ImportTexture(RTHandle rt)
{
- return m_Resources.ImportTexture(rt, shaderProperty);
+ return m_Resources.ImportTexture(rt);
}
///
@@ -288,22 +285,20 @@ public TextureHandle ImportBackbuffer(RenderTargetIdentifier rt)
/// Create a new Render Graph Texture resource.
///
/// Texture descriptor.
- /// Optional property that allows you to specify a Shader property name to use for automatic resource binding.
/// A new TextureHandle.
- public TextureHandle CreateTexture(in TextureDesc desc, int shaderProperty = 0)
+ public TextureHandle CreateTexture(in TextureDesc desc)
{
- return m_Resources.CreateTexture(desc, shaderProperty);
+ return m_Resources.CreateTexture(desc);
}
///
/// Create a new Render Graph Texture resource using the descriptor from another texture.
///
/// Texture from which the descriptor should be used.
- /// Optional property that allows you to specify a Shader property name to use for automatic resource binding.
/// A new TextureHandle.
- public TextureHandle CreateTexture(TextureHandle texture, int shaderProperty = 0)
+ public TextureHandle CreateTexture(TextureHandle texture)
{
- return m_Resources.CreateTexture(m_Resources.GetTextureResourceDesc(texture.handle), shaderProperty);
+ return m_Resources.CreateTexture(m_Resources.GetTextureResourceDesc(texture.handle));
}
///
@@ -899,10 +894,6 @@ void PreRenderPassExecute(in CompiledPassInfo passInfo, RenderGraphContext rgCon
// TODO RENDERGRAPH merge clear and setup here if possible
RenderGraphPass pass = passInfo.pass;
- // TODO RENDERGRAPH remove this when we do away with auto global texture setup
- // (can't put it in the profiling scope otherwise it might be executed on compute queue which is not possible for global sets)
- m_Resources.PreRenderPassSetGlobalTextures(rgContext, pass.resourceReadLists[(int)RenderGraphResourceType.Texture]);
-
foreach (var texture in passInfo.resourceCreateList[(int)RenderGraphResourceType.Texture])
m_Resources.CreateAndClearTexture(rgContext, texture);
@@ -944,9 +935,6 @@ void PostRenderPassExecute(CommandBuffer mainCmd, ref CompiledPassInfo passInfo,
rgContext.cmd = mainCmd; // Restore the main command buffer.
}
- if (m_DebugParameters.unbindGlobalTextures)
- m_Resources.PostRenderPassUnbindGlobalTextures(rgContext, pass.resourceReadLists[(int)RenderGraphResourceType.Texture]);
-
m_RenderGraphPool.ReleaseAllTempAlloc();
foreach (var texture in passInfo.resourceReleaseList[(int)RenderGraphResourceType.Texture])
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs
index 4b93e5392ac..0633c1a92cd 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs
@@ -73,7 +73,7 @@ public TextureHandle WriteTexture(in TextureHandle input)
/// A new transient TextureHandle.
public TextureHandle CreateTransientTexture(in TextureDesc desc)
{
- var result = m_Resources.CreateTexture(desc, 0, m_RenderPass.index);
+ var result = m_Resources.CreateTexture(desc, m_RenderPass.index);
m_RenderPass.AddTransientResource(result.handle);
return result;
}
@@ -87,7 +87,7 @@ public TextureHandle CreateTransientTexture(in TextureDesc desc)
public TextureHandle CreateTransientTexture(in TextureHandle texture)
{
var desc = m_Resources.GetTextureResourceDesc(texture.handle);
- var result = m_Resources.CreateTexture(desc, 0, m_RenderPass.index);
+ var result = m_Resources.CreateTexture(desc, m_RenderPass.index);
m_RenderPass.AddTransientResource(result.handle);
return result;
}
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
index 8847f3825d3..2de34972e8a 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
@@ -33,7 +33,6 @@ class IRenderGraphResource
{
public bool imported;
public int cachedHash;
- public int shaderProperty;
public int transientPassIndex;
public bool wasReleased;
@@ -41,7 +40,6 @@ public virtual void Reset()
{
imported = false;
cachedHash = -1;
- shaderProperty = 0;
transientPassIndex = -1;
wasReleased = false;
}
@@ -209,12 +207,11 @@ internal int GetResourceTransientIndex(in ResourceHandle res)
}
// Texture Creation/Import APIs are internal because creation should only go through RenderGraph
- internal TextureHandle ImportTexture(RTHandle rt, int shaderProperty = 0)
+ internal TextureHandle ImportTexture(RTHandle rt)
{
int newHandle = AddNewResource(m_Resources[(int)RenderGraphResourceType.Texture], out TextureResource texResource);
texResource.resource = rt;
texResource.imported = true;
- texResource.shaderProperty = shaderProperty;
return new TextureHandle(newHandle);
}
@@ -246,13 +243,12 @@ internal TextureHandle ImportBackbuffer(RenderTargetIdentifier rt)
return result;
}
- internal TextureHandle CreateTexture(in TextureDesc desc, int shaderProperty = 0, int transientPassIndex = -1)
+ internal TextureHandle CreateTexture(in TextureDesc desc, int transientPassIndex = -1)
{
ValidateTextureDesc(desc);
int newHandle = AddNewResource(m_Resources[(int)RenderGraphResourceType.Texture], out TextureResource texResource);
texResource.desc = desc;
- texResource.shaderProperty = shaderProperty;
texResource.transientPassIndex = transientPassIndex;
return new TextureHandle(newHandle);
}
@@ -408,32 +404,6 @@ internal void CreateComputeBuffer(RenderGraphContext rgContext, int index)
}
}
- void SetGlobalTextures(RenderGraphContext rgContext, List textures, bool bindDummyTexture)
- {
- foreach (var resource in textures)
- {
- var resourceDesc = GetTextureResource(resource);
- if (resourceDesc.shaderProperty != 0)
- {
- if (resourceDesc.resource != null)
- {
- rgContext.cmd.SetGlobalTexture(resourceDesc.shaderProperty, bindDummyTexture ? TextureXR.GetMagentaTexture() : resourceDesc.resource);
- }
- }
- }
- }
-
-
- internal void PreRenderPassSetGlobalTextures(RenderGraphContext rgContext, List textures)
- {
- SetGlobalTextures(rgContext, textures, false);
- }
-
- internal void PostRenderPassUnbindGlobalTextures(RenderGraphContext rgContext, List textures)
- {
- SetGlobalTextures(rgContext, textures, true);
- }
-
internal void ReleaseTexture(RenderGraphContext rgContext, int index)
{
var resource = m_Resources[(int)RenderGraphResourceType.Texture][index] as TextureResource;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
index eb004e6f66f..28dd942da11 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader
@@ -63,7 +63,6 @@ Shader "Hidden/HDRP/OpaqueAtmosphericScattering"
float2 positionSS = input.positionCS.xy;
float3 V = GetSkyViewDirWS(positionSS);
float depth = LoadCameraDepth(positionSS);
- float3 surfColor = LOAD_TEXTURE2D_X(_ColorTexture, (int2)positionSS).rgb;
float3 volColor, volOpacity;
AtmosphericScatteringCompute(input, V, depth, volColor, volOpacity);
@@ -77,7 +76,6 @@ Shader "Hidden/HDRP/OpaqueAtmosphericScattering"
float2 positionSS = input.positionCS.xy;
float3 V = GetSkyViewDirWS(positionSS);
float depth = LOAD_TEXTURE2D_X_MSAA(_DepthTextureMS, (int2)positionSS, sampleIndex).x;
- float3 surfColor = LOAD_TEXTURE2D_X_MSAA(_ColorTextureMS, (int2)positionSS, sampleIndex).rgb;
float3 volColor, volOpacity;
AtmosphericScatteringCompute(input, V, depth, volColor, volOpacity);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
index 51dc68f4f0f..31a19c957b1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
@@ -7,7 +7,7 @@ partial class AmbientOcclusionSystem
{
TextureHandle CreateAmbientOcclusionTexture(RenderGraph renderGraph)
{
- return renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { enableRandomWrite = true, colorFormat = GraphicsFormat.R8_UNorm, name = "Ambient Occlusion" }, HDShaderIDs._AmbientOcclusionTexture);
+ return renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { enableRandomWrite = true, colorFormat = GraphicsFormat.R8_UNorm, name = "Ambient Occlusion" });
}
public TextureHandle Render(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthPyramid, TextureHandle normalBuffer, TextureHandle motionVectors, int frameCount, in HDUtils.PackedMipChainInfo depthMipInfo)
@@ -33,12 +33,12 @@ public TextureHandle Render(RenderGraph renderGraph, HDCamera hdCamera, TextureH
var aoParameters = PrepareRenderAOParameters(hdCamera, historySize * rtScaleForHistory, frameCount, depthMipInfo);
var packedData = RenderAO(renderGraph, aoParameters, depthPyramid, normalBuffer);
- result = DenoiseAO(renderGraph, aoParameters, motionVectors, packedData, currentHistory, outputHistory);
+ result = DenoiseAO(renderGraph, aoParameters, depthPyramid, motionVectors, packedData, currentHistory, outputHistory);
}
}
else
{
- result = renderGraph.ImportTexture(TextureXR.GetBlackTexture(), HDShaderIDs._AmbientOcclusionTexture);
+ result = renderGraph.ImportTexture(TextureXR.GetBlackTexture());
}
return result;
}
@@ -88,6 +88,7 @@ class DenoiseAOPassData
TextureHandle DenoiseAO( RenderGraph renderGraph,
in RenderAOParameters parameters,
+ TextureHandle depthTexture,
TextureHandle motionVectors,
TextureHandle aoPackedData,
TextureHandle currentHistory,
@@ -129,6 +130,7 @@ TextureHandle DenoiseAO( RenderGraph renderGraph,
data.packedDataBlurred,
data.currentHistory,
data.outputHistory,
+ data.motionVectors,
data.denoiseOutput,
ctx.cmd);
});
@@ -137,17 +139,18 @@ TextureHandle DenoiseAO( RenderGraph renderGraph,
return passData.denoiseOutput;
}
- return UpsampleAO(renderGraph, parameters, denoiseOutput);
+ return UpsampleAO(renderGraph, parameters, denoiseOutput, depthTexture);
}
class UpsampleAOPassData
{
public RenderAOParameters parameters;
+ public TextureHandle depthTexture;
public TextureHandle input;
public TextureHandle output;
}
- TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters parameters, TextureHandle input)
+ TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters parameters, TextureHandle input, TextureHandle depthTexture)
{
using (var builder = renderGraph.AddRenderPass("Upsample GTAO", out var passData, ProfilingSampler.Get(HDProfileId.UpSampleSSAO)))
{
@@ -155,12 +158,13 @@ TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters paramete
passData.parameters = parameters;
passData.input = builder.ReadTexture(input);
+ passData.depthTexture = builder.ReadTexture(depthTexture);
passData.output = builder.WriteTexture(CreateAmbientOcclusionTexture(renderGraph));
builder.SetRenderFunc(
(UpsampleAOPassData data, RenderGraphContext ctx) =>
{
- UpsampleAO(data.parameters, data.input, data.output, ctx.cmd);
+ UpsampleAO(data.parameters, data.depthTexture, data.input, data.output, ctx.cmd);
});
return passData.output;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs
index c0f3f1cca03..8e8a6cd763f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs
@@ -299,7 +299,7 @@ internal void InitRaytracing(HDRenderPipeline renderPipeline)
internal bool IsActive(HDCamera camera, AmbientOcclusion settings) => camera.frameSettings.IsEnabled(FrameSettingsField.SSAO) && settings.intensity.value > 0f;
- internal void Render(CommandBuffer cmd, HDCamera camera, ScriptableRenderContext renderContext, RTHandle depthTexture, RTHandle normalBuffer, in ShaderVariablesRaytracing globalRTCB, int frameCount)
+ internal void Render(CommandBuffer cmd, HDCamera camera, ScriptableRenderContext renderContext, RTHandle depthTexture, RTHandle normalBuffer, RTHandle motionVectors, in ShaderVariablesRaytracing globalRTCB, int frameCount)
{
var settings = camera.volumeStack.GetComponent();
@@ -314,7 +314,7 @@ internal void Render(CommandBuffer cmd, HDCamera camera, ScriptableRenderContext
m_RaytracingAmbientOcclusion.RenderAO(camera, cmd, m_AmbientOcclusionTex, globalRTCB, renderContext, frameCount);
else
{
- Dispatch(cmd, camera, depthTexture, normalBuffer, frameCount);
+ Dispatch(cmd, camera, depthTexture, normalBuffer, motionVectors, frameCount);
PostDispatchWork(cmd, camera);
}
}
@@ -516,6 +516,7 @@ static void DenoiseAO( in RenderAOParameters parameters,
RTHandle packedDataBlurredTex,
RTHandle packedHistoryTex,
RTHandle packedHistoryOutputTex,
+ RTHandle motionVectors,
RTHandle aoOutputTex,
CommandBuffer cmd)
{
@@ -560,12 +561,14 @@ static void DenoiseAO( in RenderAOParameters parameters,
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOPackedBlurred, packedDataBlurredTex);
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOPackedHistory, packedHistoryTex);
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOOutputHistory, packedHistoryOutputTex);
+ cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._CameraMotionVectorsTexture, motionVectors);
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._OcclusionTexture, aoOutputTex);
cmd.DispatchCompute(blurCS, parameters.denoiseKernelTemporal, threadGroupX, threadGroupY, parameters.viewCount);
}
}
static void UpsampleAO( in RenderAOParameters parameters,
+ RTHandle depthTexture,
RTHandle input,
RTHandle output,
CommandBuffer cmd)
@@ -578,6 +581,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
{
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAndBlurKernel, HDShaderIDs._AOPackedData, input);
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAndBlurKernel, HDShaderIDs._OcclusionTexture, output);
+ cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAndBlurKernel, HDShaderIDs._CameraDepthTexture, depthTexture);
const int groupSizeX = 8;
const int groupSizeY = 8;
@@ -590,6 +594,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
{
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAOKernel, HDShaderIDs._AOPackedData, input);
cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAOKernel, HDShaderIDs._OcclusionTexture, output);
+ cmd.SetComputeTextureParam(parameters.upsampleAndBlurAOCS, parameters.upsampleAOKernel, HDShaderIDs._CameraDepthTexture, depthTexture);
const int groupSizeX = 8;
const int groupSizeY = 8;
@@ -599,7 +604,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
}
}
- internal void Dispatch(CommandBuffer cmd, HDCamera camera, RTHandle depthTexture, RTHandle normalBuffer, int frameCount)
+ internal void Dispatch(CommandBuffer cmd, HDCamera camera, RTHandle depthTexture, RTHandle normalBuffer, RTHandle motionVectors, int frameCount)
{
var settings = camera.volumeStack.GetComponent();
if (IsActive(camera, settings))
@@ -625,14 +630,14 @@ internal void Dispatch(CommandBuffer cmd, HDCamera camera, RTHandle depthTexture
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DenoiseSSAO)))
{
var output = m_RunningFullRes ? m_AmbientOcclusionTex : m_FinalHalfRes;
- DenoiseAO(aoParameters, m_PackedDataTex, m_PackedDataBlurred, currentHistory, historyOutput, output, cmd);
+ DenoiseAO(aoParameters, m_PackedDataTex, m_PackedDataBlurred, currentHistory, historyOutput, motionVectors, output, cmd);
}
if (!m_RunningFullRes)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.UpSampleSSAO)))
{
- UpsampleAO(aoParameters, settings.temporalAccumulation.value ? m_FinalHalfRes : m_PackedDataTex, m_AmbientOcclusionTex, cmd);
+ UpsampleAO(aoParameters, depthTexture, settings.temporalAccumulation.value ? m_FinalHalfRes : m_PackedDataTex, m_AmbientOcclusionTex, cmd);
}
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
index c0ae47a28b5..c22bc4b2499 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
@@ -100,10 +100,10 @@ class RenderShadowsPassData
public ShadowDrawingSettings shadowDrawSettings;
}
- TextureHandle AllocateMomentAtlas(RenderGraph renderGraph, string name, int shaderID = 0)
+ TextureHandle AllocateMomentAtlas(RenderGraph renderGraph, string name)
{
return renderGraph.CreateTexture(new TextureDesc(width / 2, height / 2)
- { colorFormat = GraphicsFormat.R32G32_SFloat, useMipMap = true, autoGenerateMips = false, name = name, enableRandomWrite = true }, shaderID);
+ { colorFormat = GraphicsFormat.R32G32_SFloat, useMipMap = true, autoGenerateMips = false, name = name, enableRandomWrite = true });
}
internal TextureHandle RenderShadows(RenderGraph renderGraph, CullingResults cullResults, in ShaderVariablesGlobal globalCB, FrameSettings frameSettings, string shadowPassName)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
index 82fa896ae5b..a0ea0620acb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
@@ -10,8 +10,11 @@ public partial class HDRenderPipeline
{
struct LightingBuffers
{
+ // TODO RENDERGRAPH: Those two buffers aren't really lighting buffers but only used for SSS
+ // We should probably move them out of here.
public TextureHandle sssBuffer;
public TextureHandle diffuseLightingBuffer;
+
public TextureHandle ambientOcclusionBuffer;
public TextureHandle ssrLightingBuffer;
public TextureHandle contactShadowsBuffer;
@@ -28,6 +31,13 @@ static LightingBuffers ReadLightingBuffers(in LightingBuffers buffers, RenderGra
return result;
}
+ static void BindGlobalLightingBuffers(in LightingBuffers buffers, CommandBuffer cmd)
+ {
+ cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, buffers.ambientOcclusionBuffer);
+ cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, buffers.ssrLightingBuffer);
+ cmd.SetGlobalTexture(HDShaderIDs._ContactShadowTexture, buffers.contactShadowsBuffer);
+ }
+
class BuildGPULightListPassData
{
public BuildGPULightListParameters buildGPULightListParameters;
@@ -251,6 +261,7 @@ class DeferredLightingPassData
public int gbufferCount;
public int lightLayersTextureIndex;
+ public int shadowMaskTextureIndex;
public TextureHandle[] gbuffer = new TextureHandle[8];
public ComputeBufferHandle lightListBuffer;
@@ -301,6 +312,7 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph,
passData.lightingBuffers = ReadLightingBuffers(lightingBuffers, builder);
passData.lightLayersTextureIndex = gbuffer.lightLayersTextureIndex;
+ passData.shadowMaskTextureIndex = gbuffer.shadowMaskTextureIndex;
passData.gbufferCount = gbuffer.gBufferCount;
for (int i = 0; i < gbuffer.gBufferCount; ++i)
passData.gbuffer[i] = builder.ReadTexture(gbuffer.mrt[i]);
@@ -343,11 +355,14 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph,
else
context.cmd.SetGlobalTexture(HDShaderIDs._LightLayersTexture, TextureXR.GetWhiteTexture());
+ if (data.shadowMaskTextureIndex != -1)
+ context.cmd.SetGlobalTexture(HDShaderIDs._ShadowMaskTexture, data.gbuffer[data.shadowMaskTextureIndex]);
+ else
+ context.cmd.SetGlobalTexture(HDShaderIDs._ShadowMaskTexture, TextureXR.GetWhiteTexture());
+
// TODO RENDERGRAPH: Remove these SetGlobal and properly send these textures to the deferred passes and bind them directly to compute shaders.
// This can wait that we remove the old code path.
- context.cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, data.lightingBuffers.ambientOcclusionBuffer);
- context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.lightingBuffers.ssrLightingBuffer);
- context.cmd.SetGlobalTexture(HDShaderIDs._ContactShadowTexture, data.lightingBuffers.contactShadowsBuffer);
+ BindGlobalLightingBuffers(data.lightingBuffers, context.cmd);
if (data.parameters.enableTile)
{
@@ -432,7 +447,7 @@ TextureHandle RenderSSR( RenderGraph renderGraph,
passData.hitPointsTexture = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true)
{ colorFormat = GraphicsFormat.R16G16_UNorm, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Hit_Point_Texture" });
passData.lightingTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
- { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Lighting_Texture" }, HDShaderIDs._SsrLightingTexture));
+ { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Lighting_Texture" }));
//passData.hitPointsTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
// { colorFormat = GraphicsFormat.ARGBFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Debug_Texture" }));
@@ -479,7 +494,7 @@ class RenderContactShadowPassData
TextureHandle RenderContactShadows(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthTexture, in BuildGPULightListOutput lightLists, int firstMipOffsetY)
{
if (!WillRenderContactShadow())
- return renderGraph.ImportTexture(TextureXR.GetClearTexture(), HDShaderIDs._ContactShadowTexture);
+ return renderGraph.defaultResources.clearTextureXR;
TextureHandle result;
using (var builder = renderGraph.AddRenderPass("Contact Shadows", out var passData))
@@ -494,7 +509,7 @@ TextureHandle RenderContactShadows(RenderGraph renderGraph, HDCamera hdCamera, T
passData.lightList = builder.ReadComputeBuffer(lightLists.lightList);
passData.depthTexture = builder.ReadTexture(depthTexture);
passData.contactShadowsTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
- { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, clearBuffer = clearBuffer, clearColor = Color.clear, name = "ContactShadowsBuffer" }, HDShaderIDs._ContactShadowTexture));
+ { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, clearBuffer = clearBuffer, clearColor = Color.clear, name = "ContactShadowsBuffer" }));
result = passData.contactShadowsTexture;
@@ -589,7 +604,7 @@ TextureHandle VolumetricLightingPass(RenderGraph renderGraph, HDCamera hdCamera,
Vector3Int viewportSize = ComputeVolumetricViewportSize(hdCamera, ref tileSize);
// TODO RENDERGRAPH: Auto-scale of 3D RTs is not supported yet so we need to find a better solution for this. Or keep it as is?
- passData.lightingBuffer = builder.WriteTexture(renderGraph.ImportTexture(m_LightingBuffer, HDShaderIDs._VBufferLighting));
+ passData.lightingBuffer = builder.WriteTexture(renderGraph.ImportTexture(m_LightingBuffer));
if (passData.parameters.enableReprojection)
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
index 5a6d58332b7..402c2be2dbf 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
@@ -97,7 +97,7 @@ TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa)
{
TextureDesc normalDesc = new TextureDesc(Vector2.one, true, true)
{ colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer" };
- return renderGraph.CreateTexture(normalDesc, msaa ? HDShaderIDs._NormalTextureMS : HDShaderIDs._NormalBufferTexture);
+ return renderGraph.CreateTexture(normalDesc);
}
TextureHandle CreateDecalPrepassBuffer(RenderGraph renderGraph, bool msaa)
@@ -111,7 +111,7 @@ TextureHandle CreateMotionVectorBuffer(RenderGraph renderGraph, bool msaa, bool
{
TextureDesc motionVectorDesc = new TextureDesc(Vector2.one, true, true)
{ colorFormat = Builtin.GetMotionVectorFormat(), bindTextureMS = msaa, enableMSAA = msaa, clearBuffer = clear, clearColor = Color.clear, name = msaa ? "Motion Vectors MSAA" : "Motion Vectors" };
- return renderGraph.CreateTexture(motionVectorDesc, HDShaderIDs._CameraMotionVectorsTexture);
+ return renderGraph.CreateTexture(motionVectorDesc);
}
// TODO RENDERGRAPH: in someplaces we auto bind and in others we have to generate MRT because of discrepancy with non render graph path.
@@ -288,7 +288,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
if (msaa)
{
passData.depthAsColorBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
- { colorFormat = GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, bindTextureMS = true, enableMSAA = true, name = "DepthAsColorMSAA" }, HDShaderIDs._DepthTextureMS));
+ { colorFormat = GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, bindTextureMS = true, enableMSAA = true, name = "DepthAsColorMSAA" }));
}
if (passData.hasDepthDeferredPass)
@@ -404,6 +404,7 @@ struct GBufferOutput
public TextureHandle[] mrt;
public int gBufferCount;
public int lightLayersTextureIndex;
+ public int shadowMaskTextureIndex;
}
void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, GBufferPassData passData, TextureHandle sssBuffer, ref PrepassOutput prepassOutput, FrameSettings frameSettings, RenderGraphBuilder builder)
@@ -430,27 +431,28 @@ void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, GBufferPass
#if UNITY_2020_2_OR_NEWER
, fastMemoryDesc = gbufferFastMemDesc
#endif
- }, HDShaderIDs._GBufferTexture[2]), 2);
+ }), 2);
passData.gbufferRT[3] = builder.UseColorBuffer(renderGraph.CreateTexture(
new TextureDesc(Vector2.one, true, true) { colorFormat = Builtin.GetLightingBufferFormat(), clearBuffer = clearGBuffer, clearColor = Color.clear, name = "GBuffer3"
#if UNITY_2020_2_OR_NEWER
, fastMemoryDesc = gbufferFastMemDesc
#endif
- }, HDShaderIDs._GBufferTexture[3]), 3);
+ }), 3);
prepassOutput.gbuffer.lightLayersTextureIndex = -1;
+ prepassOutput.gbuffer.shadowMaskTextureIndex = -1;
int currentIndex = 4;
if (lightLayers)
{
passData.gbufferRT[currentIndex] = builder.UseColorBuffer(renderGraph.CreateTexture(
- new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = clearGBuffer, clearColor = Color.clear, name = "LightLayers" }, HDShaderIDs._LightLayersTexture), currentIndex);
+ new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = clearGBuffer, clearColor = Color.clear, name = "LightLayers" }), currentIndex);
prepassOutput.gbuffer.lightLayersTextureIndex = currentIndex++;
}
if (shadowMasks)
{
passData.gbufferRT[currentIndex] = builder.UseColorBuffer(renderGraph.CreateTexture(
- new TextureDesc(Vector2.one, true, true) { colorFormat = Builtin.GetShadowMaskBufferFormat(), clearBuffer = clearGBuffer, clearColor = Color.clear, name = "ShadowMasks" }, HDShaderIDs._ShadowMaskTexture), currentIndex);
- currentIndex++;
+ new TextureDesc(Vector2.one, true, true) { colorFormat = Builtin.GetShadowMaskBufferFormat(), clearBuffer = clearGBuffer, clearColor = Color.clear, name = "ShadowMasks" }), currentIndex);
+ prepassOutput.gbuffer.shadowMaskTextureIndex = currentIndex++;
}
prepassOutput.gbuffer.gBufferCount = currentIndex;
@@ -603,7 +605,7 @@ void CopyDepthBufferIfNeeded(RenderGraph renderGraph, HDCamera hdCamera, ref Pre
using (var builder = renderGraph.AddRenderPass("Copy depth buffer", out var passData, ProfilingSampler.Get(HDProfileId.CopyDepthBuffer)))
{
passData.inputDepth = builder.ReadTexture(output.resolvedDepthBuffer);
- passData.outputDepth = builder.WriteTexture(renderGraph.CreateTexture(m_DepthPyramidDesc, HDShaderIDs._CameraDepthTexture));
+ passData.outputDepth = builder.WriteTexture(renderGraph.CreateTexture(m_DepthPyramidDesc));
passData.GPUCopy = m_GPUCopy;
passData.width = hdCamera.actualWidth;
passData.height = hdCamera.actualHeight;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
index 4cff68277ba..3fca931cd83 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
@@ -34,7 +34,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest,
TextureHandle backBuffer = m_RenderGraph.ImportBackbuffer(target.id);
TextureHandle colorBuffer = CreateColorBuffer(m_RenderGraph, hdCamera, msaa);
m_NonMSAAColorBuffer = CreateColorBuffer(m_RenderGraph, hdCamera, false);
- TextureHandle currentColorPyramid = m_RenderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain), HDShaderIDs._ColorPyramidTexture);
+ TextureHandle currentColorPyramid = m_RenderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain));
LightingBuffers lightingBuffers = new LightingBuffers();
lightingBuffers.diffuseLightingBuffer = CreateDiffuseLightingBuffer(m_RenderGraph, msaa);
@@ -168,7 +168,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest,
RenderForwardEmissive(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, cullingResults);
- RenderSky(m_RenderGraph, hdCamera, colorBuffer, volumetricLighting, prepassOutput.depthBuffer, prepassOutput.depthPyramidTexture);
+ RenderSky(m_RenderGraph, hdCamera, colorBuffer, volumetricLighting, prepassOutput.depthBuffer, msaa ? prepassOutput.depthAsColor : prepassOutput.depthPyramidTexture);
// Send all the geometry graphics buffer to client systems if required (must be done after the pyramid and before the transparent depth pre-pass)
SendGeometryGraphicsBuffers(m_RenderGraph, prepassOutput.normalBuffer, prepassOutput.depthPyramidTexture, hdCamera);
@@ -179,7 +179,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest,
// No need for old stencil values here since from transparent on different features are tagged
ClearStencilBuffer(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer);
- colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, currentColorPyramid, gpuLightListOutput, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovBuffers);
+ colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, currentColorPyramid, volumetricLighting, gpuLightListOutput, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovBuffers);
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector))
{
@@ -397,26 +397,36 @@ class ForwardPassData
public TextureHandle[] renderTarget = new TextureHandle[3];
public int renderTargetCount;
public TextureHandle depthBuffer;
- public TextureHandle ssrLlightingBuffer;
public ComputeBufferHandle lightListBuffer;
public ComputeBufferHandle perVoxelOffset;
public ComputeBufferHandle perTileLogBaseTweak;
public FrameSettings frameSettings;
- public bool decalsEnabled;
- public bool renderMotionVecForTransparent;
- public DBufferOutput? dbuffer;
}
- void PrepareForwardPassData(RenderGraph renderGraph,
- RenderGraphBuilder builder,
- ForwardPassData data,
- bool opaque,
- FrameSettings frameSettings,
- RendererListDesc rendererListDesc,
- in BuildGPULightListOutput lightLists,
- TextureHandle depthBuffer,
- ShadowResult shadowResult,
- DBufferOutput? dbuffer = null)
+ class ForwardOpaquePassData : ForwardPassData
+ {
+ public DBufferOutput dbuffer;
+ public LightingBuffers lightingBuffers;
+ }
+
+ class ForwardTransparentPassData : ForwardPassData
+ {
+ public bool decalsEnabled;
+ public bool renderMotionVecForTransparent;
+ public TextureHandle transparentSSRLighting;
+ public TextureHandle volumetricLighting;
+
+ }
+
+ void PrepareCommonForwardPassData( RenderGraph renderGraph,
+ RenderGraphBuilder builder,
+ ForwardPassData data,
+ bool opaque,
+ FrameSettings frameSettings,
+ RendererListDesc rendererListDesc,
+ in BuildGPULightListOutput lightLists,
+ TextureHandle depthBuffer,
+ ShadowResult shadowResult)
{
bool useFptl = frameSettings.IsEnabled(FrameSettingsField.FPTLForForwardOpaque) && opaque;
@@ -430,14 +440,8 @@ void PrepareForwardPassData(RenderGraph renderGraph,
}
data.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite);
data.rendererList = builder.UseRendererList(renderGraph.CreateRendererList(rendererListDesc));
- // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered
- // decal datas count is 0 if no decals affect transparency
- data.decalsEnabled = (frameSettings.IsEnabled(FrameSettingsField.Decals)) && (DecalSystem.m_DecalDatasCount > 0);
- data.renderMotionVecForTransparent = NeedMotionVectorForTransparent(frameSettings);
HDShadowManager.ReadShadowResult(shadowResult, builder);
- if (dbuffer != null)
- data.dbuffer = ReadDBuffer(dbuffer.Value, builder);
}
// Guidelines: In deferred by default there is no opaque in forward. However it is possible to force an opaque material to render in forward
@@ -458,11 +462,11 @@ void RenderForwardOpaque( RenderGraph renderGraph,
{
bool debugDisplay = m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled();
- using (var builder = renderGraph.AddRenderPass( debugDisplay ? "Forward Opaque Debug" : "Forward Opaque",
+ using (var builder = renderGraph.AddRenderPass( debugDisplay ? "Forward Opaque Debug" : "Forward Opaque",
out var passData,
debugDisplay ? ProfilingSampler.Get(HDProfileId.ForwardOpaqueDebug) : ProfilingSampler.Get(HDProfileId.ForwardOpaque)))
{
- PrepareForwardPassData(renderGraph, builder, passData, true, hdCamera.frameSettings, PrepareForwardOpaqueRendererList(cullResults, hdCamera), lightLists, depthBuffer, shadowResult, dbuffer);
+ PrepareCommonForwardPassData(renderGraph, builder, passData, true, hdCamera.frameSettings, PrepareForwardOpaqueRendererList(cullResults, hdCamera), lightLists, depthBuffer, shadowResult);
// In case of forward SSS we will bind all the required target. It is up to the shader to write into it or not.
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.SubsurfaceScattering))
@@ -478,18 +482,19 @@ void RenderForwardOpaque( RenderGraph renderGraph,
passData.renderTargetCount = 1;
}
- ReadLightingBuffers(lightingBuffers, builder);
+ passData.dbuffer = ReadDBuffer(dbuffer, builder);
+ passData.lightingBuffers = ReadLightingBuffers(lightingBuffers, builder);
builder.SetRenderFunc(
- (ForwardPassData data, RenderGraphContext context) =>
+ (ForwardOpaquePassData data, RenderGraphContext context) =>
{
// TODO RENDERGRAPH: replace with UseColorBuffer when removing old rendering (SetRenderTarget is called inside RenderForwardRendererList because of that).
var mrt = context.renderGraphPool.GetTempArray(data.renderTargetCount);
for (int i = 0; i < data.renderTargetCount; ++i)
mrt[i] = data.renderTarget[i];
- if (data.dbuffer != null)
- BindDBufferGlobalData(data.dbuffer.Value, context);
+ BindDBufferGlobalData(data.dbuffer, context);
+ BindGlobalLightingBuffers(data.lightingBuffers, context.cmd);
RenderForwardRendererList(data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, true, context.renderContext, context.cmd);
});
@@ -501,6 +506,7 @@ void RenderForwardTransparent( RenderGraph renderGraph,
TextureHandle colorBuffer,
TextureHandle motionVectorBuffer,
TextureHandle depthBuffer,
+ TextureHandle volumetricLighting,
TextureHandle ssrLighting,
TextureHandle? colorPyramid,
in BuildGPULightListOutput lightLists,
@@ -526,18 +532,20 @@ void RenderForwardTransparent( RenderGraph renderGraph,
profilingId = preRefractionPass ? HDProfileId.ForwardPreRefraction : HDProfileId.ForwardTransparent;
}
- using (var builder = renderGraph.AddRenderPass(passName, out var passData, ProfilingSampler.Get(profilingId)))
+ using (var builder = renderGraph.AddRenderPass(passName, out var passData, ProfilingSampler.Get(profilingId)))
{
- PrepareForwardPassData(renderGraph, builder, passData, false, hdCamera.frameSettings, PrepareForwardTransparentRendererList(cullResults, hdCamera, preRefractionPass), lightLists, depthBuffer, shadowResult);
-
- passData.ssrLlightingBuffer = builder.ReadTexture(ssrLighting);
-
- bool renderMotionVecForTransparent = NeedMotionVectorForTransparent(hdCamera.frameSettings);
+ PrepareCommonForwardPassData(renderGraph, builder, passData, false, hdCamera.frameSettings, PrepareForwardTransparentRendererList(cullResults, hdCamera, preRefractionPass), lightLists, depthBuffer, shadowResult);
+ // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered
+ // decal datas count is 0 if no decals affect transparency
+ passData.decalsEnabled = (hdCamera.frameSettings.IsEnabled(FrameSettingsField.Decals)) && (DecalSystem.m_DecalDatasCount > 0);
+ passData.renderMotionVecForTransparent = NeedMotionVectorForTransparent(hdCamera.frameSettings);
+ passData.volumetricLighting = builder.ReadTexture(volumetricLighting);
+ passData.transparentSSRLighting = builder.ReadTexture(ssrLighting);
passData.renderTargetCount = 2;
passData.renderTarget[0] = builder.WriteTexture(colorBuffer);
- if (renderMotionVecForTransparent)
+ if (passData.renderMotionVecForTransparent)
{
passData.renderTarget[1] = builder.WriteTexture(motionVectorBuffer);
}
@@ -555,7 +563,7 @@ void RenderForwardTransparent( RenderGraph renderGraph,
}
builder.SetRenderFunc(
- (ForwardPassData data, RenderGraphContext context) =>
+ (ForwardTransparentPassData data, RenderGraphContext context) =>
{
// TODO: replace with UseColorBuffer when removing old rendering.
var mrt = context.renderGraphPool.GetTempArray(data.renderTargetCount);
@@ -569,7 +577,8 @@ void RenderForwardTransparent( RenderGraph renderGraph,
context.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, data.perVoxelOffset);
context.cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, data.perTileLogBaseTweak);
- context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.ssrLlightingBuffer);
+ context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.transparentSSRLighting);
+ context.cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, data.volumetricLighting);
RenderForwardRendererList( data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, false, context.renderContext, context.cmd);
});
@@ -738,6 +747,7 @@ TextureHandle RenderTransparency( RenderGraph renderGraph,
HDCamera hdCamera,
TextureHandle colorBuffer,
TextureHandle currentColorPyramid,
+ TextureHandle volumetricLighting,
in BuildGPULightListOutput lightLists,
ref PrepassOutput prepassOutput,
ShadowResult shadowResult,
@@ -760,7 +770,7 @@ TextureHandle RenderTransparency( RenderGraph renderGraph,
RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforePreRefraction, aovRequest, aovBuffers);
// Render pre-refraction objects
- RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, ssrLightingBuffer, null, lightLists, shadowResult, cullingResults, true);
+ RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, volumetricLighting, ssrLightingBuffer, null, lightLists, shadowResult, cullingResults, true);
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.Refraction))
{
@@ -772,7 +782,7 @@ TextureHandle RenderTransparency( RenderGraph renderGraph,
RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforeTransparent, aovRequest, aovBuffers);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
- RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false);
+ RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, volumetricLighting, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false);
colorBuffer = ResolveMSAAColor(renderGraph, hdCamera, colorBuffer, m_NonMSAAColorBuffer);
@@ -966,6 +976,7 @@ class RenderSkyPassData
public HDCamera hdCamera;
public TextureHandle volumetricLighting;
public TextureHandle colorBuffer;
+ public TextureHandle depthTexture;
public TextureHandle depthStencilBuffer;
public TextureHandle intermediateBuffer;
public DebugDisplaySettings debugDisplaySettings;
@@ -987,14 +998,13 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu
passData.hdCamera = hdCamera;
passData.volumetricLighting = builder.ReadTexture(volumetricLighting);
passData.colorBuffer = builder.WriteTexture(colorBuffer);
+ passData.depthTexture = builder.WriteTexture(depthTexture);
passData.depthStencilBuffer = builder.WriteTexture(depthStencilBuffer);
passData.intermediateBuffer = builder.CreateTransientTexture(colorBuffer);
passData.debugDisplaySettings = m_CurrentDebugDisplaySettings;
passData.skyManager = m_SkyManager;
passData.frameCount = m_FrameCount;
- builder.ReadTexture(depthTexture);
-
builder.SetRenderFunc(
(RenderSkyPassData data, RenderGraphContext context) =>
{
@@ -1006,7 +1016,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu
if (Fog.IsFogEnabled(data.hdCamera) || Fog.IsPBRFogEnabled(data.hdCamera))
{
var pixelCoordToViewDirWS = data.hdCamera.mainViewConstants.pixelCoordToViewDirWS;
- data.skyManager.RenderOpaqueAtmosphericScattering(context.cmd, data.hdCamera, data.colorBuffer, data.volumetricLighting, data.intermediateBuffer, data.depthStencilBuffer, pixelCoordToViewDirWS, data.hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
+ data.skyManager.RenderOpaqueAtmosphericScattering(context.cmd, data.hdCamera, data.colorBuffer, data.depthTexture, data.volumetricLighting, data.intermediateBuffer, data.depthStencilBuffer, pixelCoordToViewDirWS, data.hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
}
});
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 1bf6d41933b..fc95a564c36 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -2625,12 +2625,13 @@ void Callback(CommandBuffer c, HDGPUAsyncTaskParams a)
{
var depthTexture = m_SharedRTManager.GetDepthTexture();
var normalBuffer = m_SharedRTManager.GetNormalBuffer();
+ var motionVectors = m_SharedRTManager.GetMotionVectorsBuffer();
SSAOTask.Start(cmd, asyncParams, AsyncSSAODispatch, !haveAsyncTaskWithShadows);
haveAsyncTaskWithShadows = true;
void AsyncSSAODispatch(CommandBuffer c, HDGPUAsyncTaskParams a)
- => m_AmbientOcclusionSystem.Dispatch(c, a.hdCamera, depthTexture, normalBuffer, a.frameCount);
+ => m_AmbientOcclusionSystem.Dispatch(c, a.hdCamera, depthTexture, normalBuffer, motionVectors, a.frameCount);
}
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderShadowMaps)))
@@ -2694,7 +2695,7 @@ void Callback(CommandBuffer c, HDCamera cam)
}
if (!hdCamera.frameSettings.SSAORunsAsync())
- m_AmbientOcclusionSystem.Render(cmd, hdCamera, renderContext, m_SharedRTManager.GetDepthTexture(), m_SharedRTManager.GetNormalBuffer(), m_ShaderVariablesRayTracingCB, m_FrameCount);
+ m_AmbientOcclusionSystem.Render(cmd, hdCamera, renderContext, m_SharedRTManager.GetDepthTexture(), m_SharedRTManager.GetNormalBuffer(), m_SharedRTManager.GetMotionVectorsBuffer(), m_ShaderVariablesRayTracingCB, m_FrameCount);
// Run the contact shadows here as they need the light list
HDUtils.CheckRTCreated(m_ContactShadowBuffer);
@@ -4123,7 +4124,7 @@ void RenderSky(HDCamera hdCamera, CommandBuffer cmd)
if (Fog.IsFogEnabled(hdCamera) || Fog.IsPBRFogEnabled(hdCamera))
{
var pixelCoordToViewDirWS = hdCamera.mainViewConstants.pixelCoordToViewDirWS;
- m_SkyManager.RenderOpaqueAtmosphericScattering(cmd, hdCamera, colorBuffer, m_LightingBuffer, intermediateBuffer, depthBuffer, pixelCoordToViewDirWS, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
+ m_SkyManager.RenderOpaqueAtmosphericScattering(cmd, hdCamera, colorBuffer, m_SharedRTManager.GetDepthTexture(msaaEnabled), m_LightingBuffer, intermediateBuffer, depthBuffer, pixelCoordToViewDirWS, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
}
}
@@ -4633,6 +4634,7 @@ static void RenderSSR( in RenderSSRParameters parameters,
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._ColorPyramidTexture, previousColorPyramid);
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._SsrClearCoatMaskTexture, clearCoatMask);
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._CameraMotionVectorsTexture, motionVectorsBuffer);
+ cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._NormalBufferTexture, normalBuffer);
ConstantBuffer.Push(cmd, parameters.cb, cs, HDShaderIDs._ShaderVariablesScreenSpaceReflection);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
index a68ed110d27..fd153c0fb7e 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
@@ -932,6 +932,7 @@ public void RenderSky(HDCamera hdCamera, Light sunLight, RTHandle colorBuffer, R
public void RenderOpaqueAtmosphericScattering(CommandBuffer cmd, HDCamera hdCamera,
RTHandle colorBuffer,
+ RTHandle depthTexture,
RTHandle volumetricLighting,
RTHandle intermediateBuffer,
RTHandle depthBuffer,
@@ -940,16 +941,16 @@ public void RenderOpaqueAtmosphericScattering(CommandBuffer cmd, HDCamera hdCame
using (new ProfilingScope(m_BuiltinParameters.commandBuffer, ProfilingSampler.Get(HDProfileId.OpaqueAtmosphericScattering)))
{
m_OpaqueAtmScatteringBlock.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, pixelCoordToViewDirWS);
- if (isMSAA)
- m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._ColorTextureMS, colorBuffer);
- else
- m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._ColorTexture, colorBuffer);
+ m_OpaqueAtmScatteringBlock.SetTexture(isMSAA ? HDShaderIDs._DepthTextureMS : HDShaderIDs._CameraDepthTexture, depthTexture);
+
// The texture can be null when volumetrics are disabled.
if (volumetricLighting != null)
m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._VBufferLighting, volumetricLighting);
if (Fog.IsPBRFogEnabled(hdCamera))
{
+ m_OpaqueAtmScatteringBlock.SetTexture(isMSAA? HDShaderIDs._ColorTextureMS : HDShaderIDs._ColorTexture, colorBuffer);
+
// Color -> Intermediate.
HDUtils.DrawFullScreen(cmd, m_OpaqueAtmScatteringMaterial, intermediateBuffer, depthBuffer, m_OpaqueAtmScatteringBlock, isMSAA ? 3 : 2);
// Intermediate -> Color.