diff --git a/com.unity.render-pipelines.core/Runtime/Common/ConstantBuffer.cs.meta b/com.unity.render-pipelines.core/Runtime/Common/ConstantBuffer.cs.meta
index 647bc354cee..59534e5dfd3 100644
--- a/com.unity.render-pipelines.core/Runtime/Common/ConstantBuffer.cs.meta
+++ b/com.unity.render-pipelines.core/Runtime/Common/ConstantBuffer.cs.meta
@@ -1,5 +1,9 @@
fileFormatVersion: 2
+<<<<<<< HEAD:com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.meta
+guid: 61649e120aa78c04e8b44d1c5af17d35
+=======
guid: 6d9f50d0a621c534987e1e47d723d06e
+>>>>>>> 8f57f3a16bc29eb6b6995b083fc3fc9a89e9ea88:com.unity.render-pipelines.core/Runtime/Common/ConstantBuffer.cs.meta
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
index 8c6d32f3ec5..83734e5133b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
@@ -5,6 +5,45 @@
namespace UnityEngine.Rendering.HighDefinition
{
+ [GenerateHLSL(needAccessors = false, generateCBuffer = true)]
+ unsafe struct ShaderVariablesDebugDisplay
+ {
+ [HLSLArray(32, typeof(Vector4))]
+ public fixed float _DebugRenderingLayersColors[32 * 4];
+ [HLSLArray(11, typeof(ShaderGenUInt4))]
+ public fixed uint _DebugViewMaterialArray[11 * 4]; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
+
+ public int _DebugLightingMode; // Match enum DebugLightingMode
+ public int _DebugLightLayersMask;
+ public int _DebugShadowMapMode;
+ public int _DebugMipMapMode; // Match enum DebugMipMapMode
+
+ public int _DebugFullScreenMode;
+ public float _DebugTransparencyOverdrawWeight;
+ public int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
+ public int _ColorPickerMode; // Match enum ColorPickerDebugMode
+
+ public Vector4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
+ public Vector4 _DebugLightingSmoothness; // x == bool override, y == override value
+ public Vector4 _DebugLightingNormal; // x == bool override
+ public Vector4 _DebugLightingAmbientOcclusion; // x == bool override, y == override value
+ public Vector4 _DebugLightingSpecularColor; // x == bool override, yzw = specular color
+ public Vector4 _DebugLightingEmissiveColor; // x == bool override, yzw = emissive color
+ public Vector4 _DebugLightingMaterialValidateHighColor; // user can specific the colors for the validator error conditions
+ public Vector4 _DebugLightingMaterialValidateLowColor;
+ public Vector4 _DebugLightingMaterialValidatePureMetalColor;
+ public Vector4 _MousePixelCoord; // xy unorm, zw norm
+ public Vector4 _MouseClickPixelCoord; // xy unorm, zw norm
+
+ public float _DebugExposure;
+ public int _MatcapMixAlbedo;
+ public float _MatcapViewScale;
+ public int _DebugSingleShadowIndex;
+
+ public int _DebugProbeVolumeMode;
+ public Vector3 _DebugDisplayPad0;
+ }
+
///
/// Full Screen Debug Mode.
///
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
index 4349a804e4a..527e6c9998c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
@@ -35,5 +35,37 @@
#define FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR (25)
#define FULLSCREENDEBUGMODE_MAX_MATERIAL_FULL_SCREEN_DEBUG (26)
+// Generated from UnityEngine.Rendering.HighDefinition.ShaderVariablesDebugDisplay
+// PackingRules = Exact
+CBUFFER_START(ShaderVariablesDebugDisplay)
+ float4 _DebugRenderingLayersColors[32];
+ uint4 _DebugViewMaterialArray[11];
+ int _DebugLightingMode;
+ int _DebugLightLayersMask;
+ int _DebugShadowMapMode;
+ int _DebugMipMapMode;
+ int _DebugFullScreenMode;
+ float _DebugTransparencyOverdrawWeight;
+ int _DebugMipMapModeTerrainTexture;
+ int _ColorPickerMode;
+ float4 _DebugLightingAlbedo;
+ float4 _DebugLightingSmoothness;
+ float4 _DebugLightingNormal;
+ float4 _DebugLightingAmbientOcclusion;
+ float4 _DebugLightingSpecularColor;
+ float4 _DebugLightingEmissiveColor;
+ float4 _DebugLightingMaterialValidateHighColor;
+ float4 _DebugLightingMaterialValidateLowColor;
+ float4 _DebugLightingMaterialValidatePureMetalColor;
+ float4 _MousePixelCoord;
+ float4 _MouseClickPixelCoord;
+ float _DebugExposure;
+ int _MatcapMixAlbedo;
+ float _MatcapViewScale;
+ int _DebugSingleShadowIndex;
+ int _DebugProbeVolumeMode;
+ float3 _DebugDisplayPad0;
+CBUFFER_END
+
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl
index 65b7996b1ee..a865aa8d2ab 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl
@@ -11,39 +11,6 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/MipMapDebug.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/ColorPickerDebug.cs.hlsl"
-CBUFFER_START(UnityDebugDisplay)
-// Set of parameters available when switching to debug shader mode
-int _DebugLightingMode; // Match enum DebugLightingMode
-int _DebugLightLayersMask;
-float4 _DebugRenderingLayersColors[32];
-int _DebugShadowMapMode;
-float _DebugViewMaterialArray[11]; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
-int _DebugMipMapMode; // Match enum DebugMipMapMode
-int _DebugMipMapModeTerrainTexture; // Match enum DebugMipMapModeTerrainTexture
-int _ColorPickerMode; // Match enum ColorPickerDebugMode
-int _DebugProbeVolumeMode; // Match enum ProbeVolumeDebugMode
-int _DebugStep;
-int _DebugDepthPyramidMip;
-int _DebugFullScreenMode;
-float _DebugTransparencyOverdrawWeight;
-float4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
-float4 _DebugLightingSmoothness; // x == bool override, y == override value
-float4 _DebugLightingNormal; // x == bool override
-float4 _DebugLightingAmbientOcclusion; // x == bool override, y == override value
-float4 _DebugLightingSpecularColor; // x == bool override, yzw = specular color
-float4 _DebugLightingEmissiveColor; // x == bool override, yzw = emissive color
-float4 _DebugLightingMaterialValidateHighColor; // user can specific the colors for the validator error conditions
-float4 _DebugLightingMaterialValidateLowColor;
-float4 _DebugLightingMaterialValidatePureMetalColor;
-float4 _MousePixelCoord; // xy unorm, zw norm
-float4 _MouseClickPixelCoord; // xy unorm, zw norm
-float _DebugExposure;
-int _MatcapMixAlbedo;
-int _MatcapViewScale;
-uint _DebugContactShadowLightIndex;
-int _DebugSingleShadowIndex;
-CBUFFER_END
-
// Local shader variables
static DirectionalShadowType g_DebugShadowAttenuation = 0;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader
index a6ad34ffcbc..7d16243a47c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader
@@ -29,6 +29,8 @@ Shader "Hidden/HDRP/DebugFullScreen"
CBUFFER_START (UnityDebug)
float _FullScreenDebugMode;
float _TransparencyOverdrawMaxPixelCost;
+ uint _DebugContactShadowLightIndex;
+ int _DebugDepthPyramidMip;
CBUFFER_END
TEXTURE2D_X(_DebugFullScreenTexture);
@@ -304,14 +306,14 @@ Shader "Hidden/HDRP/DebugFullScreen"
float linearDepth = frac(posInput.linearDepth * 0.1);
return float4(linearDepth.xxx, 1.0);
}
-
+
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW)
{
float4 color = (float4)0;
-
+
float pixelCost = SAMPLE_TEXTURE2D_X(_DebugFullScreenTexture, s_point_clamp_sampler, input.texcoord).r;
if ((pixelCost > 0.001))
- color.rgb = HsvToRgb(float3(0.66 * saturate(1.0 - (1.0 / _TransparencyOverdrawMaxPixelCost) * pixelCost), 1.0, 1.0));//
+ color.rgb = HsvToRgb(float3(0.66 * saturate(1.0 - (1.0 / _TransparencyOverdrawMaxPixelCost) * pixelCost), 1.0, 1.0));//
return color;
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewMaterialGBuffer.shader b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewMaterialGBuffer.shader
index 88922d713ca..5c08908d09c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewMaterialGBuffer.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewMaterialGBuffer.shader
@@ -74,7 +74,7 @@ Shader "Hidden/HDRP/DebugViewMaterialGBuffer"
// - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported)
// - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty)
// So here if the buffer is of size zero, it is the same as if we give in a 0 buffer index.
- int bufferIndex = int(_DebugViewMaterialArray[0]) >= 1 ? int(_DebugViewMaterialArray[1]) : 0;
+ int bufferIndex = _DebugViewMaterialArray[0].x >= 1 ? _DebugViewMaterialArray[1].x : 0;
if (bufferIndex == DEBUGVIEWGBUFFER_DEPTH)
{
float linearDepth = frac(posInput.linearDepth * 0.1);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
index 8de7e0f0406..c113acf19eb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs
@@ -26,7 +26,7 @@ class LightCookieManager
internal const int k_MinCookieSize = 2;
readonly Material m_MaterialFilterAreaLights;
- MaterialPropertyBlock m_MPBFilterAreaLights;
+ MaterialPropertyBlock m_MPBFilterAreaLights = new MaterialPropertyBlock();
readonly Material m_CubeToPanoMaterial;
@@ -159,11 +159,12 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
// Start by copying the source texture to the array slice's mip 0
{
- cmd.SetGlobalTexture(s_texSource, source);
- cmd.SetGlobalInt(s_sourceMipLevel, 0);
+ m_MPBFilterAreaLights.SetInt(s_sourceMipLevel, 0);
+ m_MPBFilterAreaLights.SetTexture(s_texSource, source);
+
cmd.SetRenderTarget(m_TempRenderTexture0, 0);
cmd.SetViewport(new Rect(0, 0, viewportWidth, viewportHeight));
- cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 0, MeshTopology.Triangles, 3, 1);
+ cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 0, MeshTopology.Triangles, 3, 1, m_MPBFilterAreaLights);
}
// Then operate on all the remaining mip levels
@@ -177,13 +178,14 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
viewportWidth = Mathf.Max(1, viewportWidth >> 1);
targetWidth = Mathf.Max(1, targetWidth >> 1);
+ m_MPBFilterAreaLights.SetTexture(s_texSource, m_TempRenderTexture0);
+ m_MPBFilterAreaLights.SetInt(s_sourceMipLevel, mipIndex - 1);
+ m_MPBFilterAreaLights.SetVector(s_sourceSize, sourceSize);
+ m_MPBFilterAreaLights.SetVector(s_uvLimits, uvLimits);
+
cmd.SetRenderTarget(m_TempRenderTexture1, mipIndex-1); // Temp texture is already 1 mip lower than source
cmd.SetViewport(new Rect(0, 0, viewportWidth, viewportHeight));
- cmd.SetGlobalTexture(s_texSource, m_TempRenderTexture0);
- cmd.SetGlobalInt(s_sourceMipLevel, mipIndex-1); // Use previous mip as source
- cmd.SetGlobalVector(s_sourceSize, sourceSize);
- cmd.SetGlobalVector(s_uvLimits, uvLimits);
- cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 1, MeshTopology.Triangles, 3, 1);
+ cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 1, MeshTopology.Triangles, 3, 1, m_MPBFilterAreaLights);
}
sourceWidth = targetWidth;
@@ -195,13 +197,14 @@ Texture FilterAreaLightTexture(CommandBuffer cmd, Texture source)
viewportHeight = Mathf.Max(1, viewportHeight >> 1);
targetHeight = Mathf.Max(1, targetHeight >> 1);
+ m_MPBFilterAreaLights.SetTexture(s_texSource, m_TempRenderTexture1);
+ m_MPBFilterAreaLights.SetInt(s_sourceMipLevel, mipIndex - 1);
+ m_MPBFilterAreaLights.SetVector(s_sourceSize, sourceSize);
+ m_MPBFilterAreaLights.SetVector(s_uvLimits, uvLimits);
+
cmd.SetRenderTarget(m_TempRenderTexture0, mipIndex);
cmd.SetViewport(new Rect(0, 0, viewportWidth, viewportHeight));
- cmd.SetGlobalTexture(s_texSource, m_TempRenderTexture1);
- cmd.SetGlobalInt(s_sourceMipLevel, mipIndex-1);
- cmd.SetGlobalVector(s_sourceSize, sourceSize);
- cmd.SetGlobalVector(s_uvLimits, uvLimits);
- cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 2, MeshTopology.Triangles, 3, 1);
+ cmd.DrawProcedural(Matrix4x4.identity, m_MaterialFilterAreaLights, 2, MeshTopology.Triangles, 3, 1, m_MPBFilterAreaLights);
}
sourceHeight = targetHeight;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
index 736f5e1c946..f51c0cda105 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
@@ -229,11 +229,11 @@ unsafe struct ShaderVariablesLightList
public uint g_BaseFeatureFlags;
public int g_iNumSamplesMSAA;
- public int _EnvLightIndexShift;
- public int _DecalIndexShift;
+ public uint _EnvLightIndexShift;
+ public uint _DecalIndexShift;
- public int _DensityVolumeIndexShift;
- public int _ProbeVolumeIndexShift;
+ public uint _DensityVolumeIndexShift;
+ public uint _ProbeVolumeIndexShift;
}
internal struct ProcessedLightData
@@ -2050,8 +2050,6 @@ void AddBoxVolumeDataAndBound(OrientedBBox obb, LightCategory category, LightFea
m_lightList.lightsPerView[viewIndex].bounds.Add(bound);
m_lightList.lightsPerView[viewIndex].lightVolumes.Add(volumeData);
}
-
-
}
internal int GetCurrentShadowCount()
@@ -2763,21 +2761,10 @@ bool PrepareLightsForGPU(CommandBuffer cmd, HDCamera hdCamera, CullingResults cu
}
}
- UpdateDataBuffers();
+ PushLightDataGlobalParams(cmd);
}
m_enableBakeShadowMask = m_enableBakeShadowMask && hdCamera.frameSettings.IsEnabled(FrameSettingsField.Shadowmask);
-
- // We push this parameter here because we know that normal/deferred shadows are not yet rendered
- if (debugDisplaySettings.data.lightingDebugSettings.shadowDebugMode == ShadowMapDebugMode.SingleShadow)
- {
- int shadowIndex = (int)debugDisplaySettings.data.lightingDebugSettings.shadowMapIndex;
-
- if (debugDisplaySettings.data.lightingDebugSettings.shadowDebugUseSelection)
- shadowIndex = m_DebugSelectedLightShadowIndex;
- cmd.SetGlobalInt(HDShaderIDs._DebugSingleShadowIndex, shadowIndex);
- }
-
return m_enableBakeShadowMask;
}
@@ -3163,7 +3150,7 @@ static bool DeferredUseComputeAsPixel(FrameSettings frameSettings)
return frameSettings.IsEnabled(FrameSettingsField.DeferredTile) && (!frameSettings.IsEnabled(FrameSettingsField.ComputeLightEvaluation) || k_PreferFragment);
}
- unsafe BuildGPULightListParameters PrepareBuildGPULightListParameters(HDCamera hdCamera)
+ unsafe BuildGPULightListParameters PrepareBuildGPULightListParameters(HDCamera hdCamera, bool buildForProbeVolumes)
{
BuildGPULightListParameters parameters = new BuildGPULightListParameters();
@@ -3216,18 +3203,18 @@ unsafe BuildGPULightListParameters PrepareBuildGPULightListParameters(HDCamera h
cb.g_screenSize = hdCamera.screenSize; // TODO remove and use global one.
cb.g_viDimensions = new Vector2Int((int)hdCamera.screenSize.x, (int)hdCamera.screenSize.y);
- cb.g_iNrVisibLights = m_TotalLightCount;
+ cb.g_iNrVisibLights = buildForProbeVolumes ? m_probeVolumeCount : m_TotalLightCount;
cb.g_isOrthographic = camera.orthographic ? 1u : 0u;
cb.g_BaseFeatureFlags = 0; // Filled for each individual pass.
cb.g_iNumSamplesMSAA = (int)hdCamera.msaaSamples;
- cb._EnvLightIndexShift = m_lightList.lights.Count;
- cb._DecalIndexShift = m_lightList.lights.Count + m_lightList.envLights.Count;
- cb._DensityVolumeIndexShift = m_lightList.lights.Count + m_lightList.envLights.Count + decalDatasCount;
+ cb._EnvLightIndexShift = (uint)m_lightList.lights.Count;
+ cb._DecalIndexShift = (uint)(m_lightList.lights.Count + m_lightList.envLights.Count);
+ cb._DensityVolumeIndexShift = (uint)(m_lightList.lights.Count + m_lightList.envLights.Count + decalDatasCount);
int probeVolumeIndexShift = (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.LightLoop)
? (m_lightList.lights.Count + m_lightList.envLights.Count + decalDatasCount + m_densityVolumeCount)
: 0;
- cb._ProbeVolumeIndexShift = probeVolumeIndexShift;
+ cb._ProbeVolumeIndexShift = (uint)probeVolumeIndexShift;
parameters.lightListCB = m_ShaderVariablesLightListCB;
parameters.runLightList = m_TotalLightCount > 0;
@@ -3349,10 +3336,6 @@ static void PushProbeVolumeLightListGlobalParams(in LightLoopGlobalParameters pa
{
Camera camera = param.hdCamera.camera;
- // Set up custom probe volume clustered lighting for evaluating probe volumes during GBuffer / Forward material pass.
- cmd.SetGlobalInt(HDShaderIDs._NumTileBigTileX, GetNumTileBigTileX(param.hdCamera));
- cmd.SetGlobalInt(HDShaderIDs._NumTileBigTileY, GetNumTileBigTileY(param.hdCamera));
-
if (param.hdCamera.frameSettings.IsEnabled(FrameSettingsField.BigTilePrepass))
cmd.SetGlobalBuffer(HDShaderIDs.g_vBigTileLightList, param.tileAndClusterData.probeVolumesBigTileLightList);
@@ -3368,7 +3351,10 @@ static void ClearLightListsProbeVolumes(
in BuildGPULightListResources resources,
CommandBuffer cmd)
{
- if(parameters.probeVolumesClearLightLists && !parameters.probeVolumesRunLightList)
+ // ClearLightLists is the first pass, we push the global parameters for light list building here.
+ ConstantBuffer.PushGlobal(cmd, parameters.lightListCB, HDShaderIDs._ShaderVariablesLightList);
+
+ if (parameters.probeVolumesClearLightLists && !parameters.probeVolumesRunLightList)
{
// Note we clear the whole content and not just the header since it is fast enough, happens only in one frame and is a bit more robust
// to changes to the inner workings of the lists.
@@ -3400,7 +3386,7 @@ void BuildGPULightListProbeVolumesCommon(HDCamera hdCamera, CommandBuffer cmd)
{
// TODO: (Nick): These parameters can be cached and shared between BuildGPULightListProbeVolumesCommon and BuildGPULightListsCommon.
// Currently, we are generated them twice.
- var parameters = PrepareBuildGPULightListParameters(hdCamera);
+ var parameters = PrepareBuildGPULightListParameters(hdCamera, buildForProbeVolumes: true);
var resources = PrepareBuildGPULightListResources(
m_TileAndClusterData,
m_SharedRTManager.GetDepthStencilBuffer(hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)),
@@ -3495,7 +3481,7 @@ void BuildGPULightListsCommon(HDCamera hdCamera, CommandBuffer cmd)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.BuildLightList)))
{
- var parameters = PrepareBuildGPULightListParameters(hdCamera);
+ var parameters = PrepareBuildGPULightListParameters(hdCamera, buildForProbeVolumes: false);
var resources = PrepareBuildGPULightListResources(
m_TileAndClusterData,
m_SharedRTManager.GetDepthStencilBuffer(hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)),
@@ -3525,30 +3511,6 @@ void BuildGPULightLists(HDCamera hdCamera, CommandBuffer cmd)
PushLightLoopGlobalParams(globalParams, cmd);
}
- void BindLightDataParameters(HDCamera hdCamera, CommandBuffer cmd)
- {
- var globalParams = PrepareLightDataGlobalParameters(hdCamera);
- PushLightDataGlobalParams(globalParams, cmd);
- }
-
- void UpdateDataBuffers()
- {
- m_LightLoopLightData.directionalLightData.SetData(m_lightList.directionalLights);
- m_LightLoopLightData.lightData.SetData(m_lightList.lights);
- m_LightLoopLightData.envLightData.SetData(m_lightList.envLights);
- m_LightLoopLightData.decalData.SetData(DecalSystem.m_DecalDatas, 0, 0, Math.Min(DecalSystem.m_DecalDatasCount, m_MaxDecalsOnScreen)); // don't add more than the size of the buffer
-
- // These two buffers have been set in Rebuild(). At this point, view 0 contains combined data from all views
- m_TileAndClusterData.convexBoundsBuffer.SetData(m_lightList.lightsPerView[0].bounds);
- m_TileAndClusterData.lightVolumeDataBuffer.SetData(m_lightList.lightsPerView[0].lightVolumes);
-
- if (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.MaterialPass)
- {
- m_TileAndClusterData.probeVolumesConvexBoundsBuffer.SetData(m_lightList.lightsPerView[0].probeVolumesBounds);
- m_TileAndClusterData.probeVolumesLightVolumeDataBuffer.SetData(m_lightList.lightsPerView[0].probeVolumesLightVolumes);
- }
- }
-
HDAdditionalLightData GetHDAdditionalLightData(Light light)
{
HDAdditionalLightData add = null;
@@ -3564,24 +3526,6 @@ HDAdditionalLightData GetHDAdditionalLightData(Light light)
return add;
}
- struct LightDataGlobalParameters
- {
- public HDCamera hdCamera;
- public LightList lightList;
- public LightLoopTextureCaches textureCaches;
- public LightLoopLightData lightData;
- }
-
- LightDataGlobalParameters PrepareLightDataGlobalParameters(HDCamera hdCamera)
- {
- LightDataGlobalParameters parameters = new LightDataGlobalParameters();
- parameters.hdCamera = hdCamera;
- parameters.lightList = m_lightList;
- parameters.textureCaches = m_TextureCaches;
- parameters.lightData = m_LightLoopLightData;
- return parameters;
- }
-
struct ShadowGlobalParameters
{
public HDCamera hdCamera;
@@ -3662,22 +3606,32 @@ unsafe void UpdateShaderVariablesGlobalLightLoop(ref ShaderVariablesGlobal cb, H
cb._EnableSSRefraction = hdCamera.frameSettings.IsEnabled(FrameSettingsField.Refraction) ? 1u : 0u;
}
- static void PushLightDataGlobalParams(in LightDataGlobalParameters param, CommandBuffer cmd)
+ void PushLightDataGlobalParams(CommandBuffer cmd)
{
- using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.PushLightDataGlobalParameters)))
- {
- cmd.SetGlobalTexture(HDShaderIDs._CookieAtlas, param.textureCaches.lightCookieManager.atlasTexture);
- cmd.SetGlobalTexture(HDShaderIDs._CookieCubeTextures, param.textureCaches.lightCookieManager.cubeCache);
- cmd.SetGlobalTexture(HDShaderIDs._EnvCubemapTextures, param.textureCaches.reflectionProbeCache.GetTexCache());
- cmd.SetGlobalTexture(HDShaderIDs._Env2DTextures, param.textureCaches.reflectionPlanarProbeCache.GetTexCache());
+ m_LightLoopLightData.directionalLightData.SetData(m_lightList.directionalLights);
+ m_LightLoopLightData.lightData.SetData(m_lightList.lights);
+ m_LightLoopLightData.envLightData.SetData(m_lightList.envLights);
+ m_LightLoopLightData.decalData.SetData(DecalSystem.m_DecalDatas, 0, 0, Math.Min(DecalSystem.m_DecalDatasCount, m_MaxDecalsOnScreen)); // don't add more than the size of the buffer
- cmd.SetGlobalBuffer(HDShaderIDs._LightDatas, param.lightData.lightData);
- cmd.SetGlobalBuffer(HDShaderIDs._EnvLightDatas, param.lightData.envLightData);
- cmd.SetGlobalBuffer(HDShaderIDs._DecalDatas, param.lightData.decalData);
+ // These two buffers have been set in Rebuild(). At this point, view 0 contains combined data from all views
+ m_TileAndClusterData.convexBoundsBuffer.SetData(m_lightList.lightsPerView[0].bounds);
+ m_TileAndClusterData.lightVolumeDataBuffer.SetData(m_lightList.lightsPerView[0].lightVolumes);
- // Directional lights are made available immediately after PrepareLightsForGPU for the PBR sky.
- cmd.SetGlobalBuffer(HDShaderIDs._DirectionalLightDatas, param.lightData.directionalLightData);
+ if (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.MaterialPass)
+ {
+ m_TileAndClusterData.probeVolumesConvexBoundsBuffer.SetData(m_lightList.lightsPerView[0].probeVolumesBounds);
+ m_TileAndClusterData.probeVolumesLightVolumeDataBuffer.SetData(m_lightList.lightsPerView[0].probeVolumesLightVolumes);
}
+
+ cmd.SetGlobalTexture(HDShaderIDs._CookieAtlas, m_TextureCaches.lightCookieManager.atlasTexture);
+ cmd.SetGlobalTexture(HDShaderIDs._CookieCubeTextures, m_TextureCaches.lightCookieManager.cubeCache);
+ cmd.SetGlobalTexture(HDShaderIDs._EnvCubemapTextures, m_TextureCaches.reflectionProbeCache.GetTexCache());
+ cmd.SetGlobalTexture(HDShaderIDs._Env2DTextures, m_TextureCaches.reflectionPlanarProbeCache.GetTexCache());
+
+ cmd.SetGlobalBuffer(HDShaderIDs._LightDatas, m_LightLoopLightData.lightData);
+ cmd.SetGlobalBuffer(HDShaderIDs._EnvLightDatas, m_LightLoopLightData.envLightData);
+ cmd.SetGlobalBuffer(HDShaderIDs._DecalDatas, m_LightLoopLightData.decalData);
+ cmd.SetGlobalBuffer(HDShaderIDs._DirectionalLightDatas, m_LightLoopLightData.directionalLightData);
}
static void PushShadowGlobalParams(in ShadowGlobalParameters param, CommandBuffer cmd)
@@ -3698,9 +3652,6 @@ static void PushLightLoopGlobalParams(in LightLoopGlobalParameters param, Comman
{
Camera camera = param.hdCamera.camera;
- cmd.SetGlobalInt(HDShaderIDs._NumTileBigTileX, GetNumTileBigTileX(param.hdCamera));
- cmd.SetGlobalInt(HDShaderIDs._NumTileBigTileY, GetNumTileBigTileY(param.hdCamera));
-
if (param.hdCamera.frameSettings.IsEnabled(FrameSettingsField.BigTilePrepass))
cmd.SetGlobalBuffer(HDShaderIDs.g_vBigTileLightList, param.tileAndClusterData.bigTileLightList);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl
index 7e14845c238..d103a40977a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl
@@ -103,10 +103,10 @@ CBUFFER_START(ShaderVariablesLightList)
uint g_isOrthographic;
uint g_BaseFeatureFlags;
int g_iNumSamplesMSAA;
- int _EnvLightIndexShift;
- int _DecalIndexShift;
- int _DensityVolumeIndexShift;
- int _ProbeVolumeIndexShift;
+ uint _EnvLightIndexShift;
+ uint _DecalIndexShift;
+ uint _DensityVolumeIndexShift;
+ uint _ProbeVolumeIndexShift;
CBUFFER_END
//
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolume.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolume.cs
index 7238b18e7e2..e5b42e8642c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolume.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolume.cs
@@ -601,6 +601,9 @@ private void SetupProbePositions()
private static bool ShouldDrawGizmos(ProbeVolume probeVolume)
{
+ if (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.Disabled)
+ return false;
+
UnityEditor.SceneView sceneView = UnityEditor.SceneView.currentDrawingSceneView;
if (sceneView == null)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs
index dcb2388ce93..108509dce40 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs
@@ -333,14 +333,14 @@ unsafe void UpdateShaderVariablesGlobalProbeVolumes(ref ShaderVariablesGlobal cb
cb._ProbeVolumeAmbientProbeFallbackPackedCoeffs[i * 4 + j] = s_AmbientProbeFallbackPackedCoeffs[i][j];
}
- void PushProbeVolumesGlobalParams(HDCamera hdCamera, CommandBuffer cmd, int frameIndex)
+ void PushProbeVolumesGlobalParams(HDCamera hdCamera, CommandBuffer cmd)
{
if (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.Disabled)
return;
if (!m_SupportProbeVolume)
{
- PushProbeVolumesGlobalParamsDefault(hdCamera, cmd, frameIndex);
+ PushProbeVolumesGlobalParamsDefault(hdCamera, cmd);
return;
}
@@ -350,7 +350,7 @@ void PushProbeVolumesGlobalParams(HDCamera hdCamera, CommandBuffer cmd, int fram
cmd.SetGlobalTexture(HDShaderIDs._ProbeVolumeAtlasOctahedralDepth, m_ProbeVolumeAtlasOctahedralDepthRTHandle);
}
- internal void PushProbeVolumesGlobalParamsDefault(HDCamera hdCamera, CommandBuffer cmd, int frameIndex)
+ internal void PushProbeVolumesGlobalParamsDefault(HDCamera hdCamera, CommandBuffer cmd)
{
cmd.SetGlobalBuffer(HDShaderIDs._ProbeVolumeBounds, s_VisibleProbeVolumeBoundsBufferDefault);
cmd.SetGlobalBuffer(HDShaderIDs._ProbeVolumeDatas, s_VisibleProbeVolumeDataBufferDefault);
@@ -417,7 +417,18 @@ internal bool EnsureProbeVolumeInAtlas(ScriptableRenderContext renderContext, Co
cmd.SetComputeVectorParam(s_ProbeVolumeAtlasBlitCS, HDShaderIDs._ProbeVolumeAtlasBias,
volume.parameters.bias
);
-
+ cmd.SetComputeVectorParam(s_ProbeVolumeAtlasBlitCS, HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCount, new Vector4(
+ s_ProbeVolumeAtlasWidth,
+ s_ProbeVolumeAtlasHeight,
+ s_ProbeVolumeAtlasDepth,
+ m_ProbeVolumeAtlasSHRTDepthSliceCount
+ ));
+ cmd.SetComputeVectorParam(s_ProbeVolumeAtlasBlitCS, HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCountInverse, new Vector4(
+ 1.0f / (float)s_ProbeVolumeAtlasWidth,
+ 1.0f / (float)s_ProbeVolumeAtlasHeight,
+ 1.0f / (float)s_ProbeVolumeAtlasDepth,
+ 1.0f / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount
+ ));
Debug.Assert(data.Length == size, "ProbeVolume: The probe volume baked data and its resolution are out of sync! Volume data length is " + data.Length + ", but resolution size is " + size + ".");
Debug.Assert(size < s_MaxProbeVolumeProbeCount, "ProbeVolume: probe volume baked data size exceeds the currently max supported blitable size. Volume data size is " + size + ", but s_MaxProbeVolumeProbeCount is " + s_MaxProbeVolumeProbeCount + ". Please decrease ProbeVolume resolution, or increase ProbeVolumeLighting.s_MaxProbeVolumeProbeCount.");
@@ -484,7 +495,24 @@ internal bool EnsureProbeVolumeInAtlasOctahedralDepth(ScriptableRenderContext re
cmd.SetComputeVectorParam(s_ProbeVolumeAtlasOctahedralDepthBlitCS, HDShaderIDs._ProbeVolumeAtlasOctahedralDepthScaleBias,
volume.parameters.octahedralDepthScaleBias
);
-
+ cmd.SetComputeVectorParam(s_ProbeVolumeAtlasOctahedralDepthBlitCS, HDShaderIDs._ProbeVolumeAtlasOctahedralDepthResolutionAndInverse, new Vector4(
+ m_ProbeVolumeAtlasOctahedralDepthRTHandle.rt.width,
+ m_ProbeVolumeAtlasOctahedralDepthRTHandle.rt.height,
+ 1.0f / (float)m_ProbeVolumeAtlasOctahedralDepthRTHandle.rt.width,
+ 1.0f / (float)m_ProbeVolumeAtlasOctahedralDepthRTHandle.rt.height
+ ));
+ cmd.SetComputeVectorParam(s_ProbeVolumeAtlasOctahedralDepthBlitCS, HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCount, new Vector4(
+ s_ProbeVolumeAtlasWidth,
+ s_ProbeVolumeAtlasHeight,
+ s_ProbeVolumeAtlasDepth,
+ m_ProbeVolumeAtlasSHRTDepthSliceCount
+ ));
+ cmd.SetComputeVectorParam(s_ProbeVolumeAtlasOctahedralDepthBlitCS, HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCountInverse, new Vector4(
+ 1.0f / (float)s_ProbeVolumeAtlasWidth,
+ 1.0f / (float)s_ProbeVolumeAtlasHeight,
+ 1.0f / (float)s_ProbeVolumeAtlasDepth,
+ 1.0f / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount
+ ));
Debug.Assert(dataOctahedralDepth.Length == size, "ProbeVolume: The probe volume baked data and its resolution are out of sync! Volume data length is " + dataOctahedralDepth.Length + ", but resolution size is " + size + ".");
s_ProbeVolumeAtlasOctahedralDepthBuffer.SetData(dataOctahedralDepth);
@@ -702,6 +730,8 @@ ProbeVolumeList PrepareVisibleProbeVolumeList(ScriptableRenderContext renderCont
}
}
+ PushProbeVolumesGlobalParams(hdCamera, cmd);
+
return probeVolumes;
}
}
@@ -794,6 +824,19 @@ void DisplayProbeVolumeAtlas(CommandBuffer cmd, Material debugMaterial, float sc
propertyBlock.SetVector(HDShaderIDs._TextureViewScale, textureViewScale);
propertyBlock.SetVector(HDShaderIDs._TextureViewBias, textureViewBias);
propertyBlock.SetVector(HDShaderIDs._TextureViewResolution, textureViewResolution);
+ cmd.SetGlobalVector(HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCount, new Vector4(
+ s_ProbeVolumeAtlasWidth,
+ s_ProbeVolumeAtlasHeight,
+ s_ProbeVolumeAtlasDepth,
+ m_ProbeVolumeAtlasSHRTDepthSliceCount
+ ));
+ cmd.SetGlobalVector(HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCountInverse, new Vector4(
+ 1.0f / (float)s_ProbeVolumeAtlasWidth,
+ 1.0f / (float)s_ProbeVolumeAtlasHeight,
+ 1.0f / (float)s_ProbeVolumeAtlasDepth,
+ 1.0f / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount
+ ));
+
propertyBlock.SetTexture(HDShaderIDs._AtlasTextureOctahedralDepth, m_ProbeVolumeAtlasOctahedralDepthRTHandle);
propertyBlock.SetVector(HDShaderIDs._AtlasTextureOctahedralDepthScaleBias, atlasTextureOctahedralDepthScaleBias);
propertyBlock.SetVector(HDShaderIDs._ValidRange, validRange);
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 a0146b42f43..a5f2607b370 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
@@ -276,14 +276,6 @@ struct RenderAOParameters
public int upsampleAndBlurKernel;
public int upsampleAOKernel;
- public Vector4 aoParams0;
- public Vector4 aoParams1;
- public Vector4 aoParams2;
- public Vector4 aoParams3;
- public Vector4 aoParams4;
- public Vector4 firstAndSecondMipOffsets;
- public Vector4 aoBufferInfo;
- public Vector4 toViewSpaceProj;
public Vector2 runningRes;
public int viewCount;
public bool historyReady;
@@ -291,16 +283,18 @@ struct RenderAOParameters
public int outputHeight;
public bool fullResolution;
public bool runAsync;
- public bool motionVectorDisabled;
public bool temporalAccumulation;
public bool bilateralUpsample;
+ public ShaderVariablesAmbientOcclusion cb;
}
RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties rtHandleProperties, Vector2 historySize, int frameCount)
{
var parameters = new RenderAOParameters();
+ ref var cb = ref parameters.cb;
+
// Grab current settings
var settings = camera.volumeStack.GetComponent();
parameters.fullResolution = settings.fullResolution;
@@ -308,25 +302,25 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
if (parameters.fullResolution)
{
parameters.runningRes = new Vector2(camera.actualWidth, camera.actualHeight);
- parameters.aoBufferInfo = new Vector4(camera.actualWidth, camera.actualHeight, 1.0f / camera.actualWidth, 1.0f / camera.actualHeight);
+ cb._AOBufferSize = new Vector4(camera.actualWidth, camera.actualHeight, 1.0f / camera.actualWidth, 1.0f / camera.actualHeight);
}
else
{
parameters.runningRes = new Vector2(camera.actualWidth, camera.actualHeight) * 0.5f;
- parameters.aoBufferInfo = new Vector4(camera.actualWidth * 0.5f, camera.actualHeight * 0.5f, 2.0f / camera.actualWidth, 2.0f / camera.actualHeight);
+ cb._AOBufferSize = new Vector4(camera.actualWidth * 0.5f, camera.actualHeight * 0.5f, 2.0f / camera.actualWidth, 2.0f / camera.actualHeight);
}
float invHalfTanFOV = -camera.mainViewConstants.projMatrix[1, 1];
float aspectRatio = parameters.runningRes.y / parameters.runningRes.x;
- parameters.aoParams0 = new Vector4(
+ cb._AOParams0 = new Vector4(
parameters.fullResolution ? 0.0f : 1.0f,
parameters.runningRes.y * invHalfTanFOV * 0.25f,
settings.radius.value,
settings.stepCount
);
- parameters.aoParams1 = new Vector4(
+ cb._AOParams1 = new Vector4(
settings.intensity.value,
1.0f / (settings.radius.value * settings.radius.value),
(frameCount / 6) % 4,
@@ -335,7 +329,7 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
// We start from screen space position, so we bake in this factor the 1 / resolution as well.
- parameters.toViewSpaceProj = new Vector4(
+ cb._AODepthToViewParams = new Vector4(
2.0f / (invHalfTanFOV * aspectRatio * parameters.runningRes.x),
2.0f / (invHalfTanFOV * parameters.runningRes.y),
1.0f / (invHalfTanFOV * aspectRatio),
@@ -345,9 +339,7 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
float scaleFactor = (parameters.runningRes.x * parameters.runningRes.y) / (540.0f * 960.0f);
float radInPixels = Mathf.Max(16, settings.maximumRadiusInPixels * Mathf.Sqrt(scaleFactor));
-
-
- parameters.aoParams2 = new Vector4(
+ cb._AOParams2 = new Vector4(
historySize.x,
historySize.y,
1.0f / (settings.stepCount + 1.0f),
@@ -367,7 +359,7 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
float uTolerance = Mathf.Pow(10f, upsampleTolerance);
float noiseFilterWeight = 1f / (Mathf.Pow(10f, 0.0f) + uTolerance);
- parameters.aoParams3 = new Vector4(
+ cb._AOParams3 = new Vector4(
bTolerance,
uTolerance,
noiseFilterWeight,
@@ -378,7 +370,7 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
const float maxUpperNudgeLimit = 5.0f;
const float minUpperNudgeLimit = 0.25f;
upperNudgeFactor = minUpperNudgeLimit + (upperNudgeFactor * (maxUpperNudgeLimit - minUpperNudgeLimit));
- parameters.aoParams4 = new Vector4(
+ cb._AOParams4 = new Vector4(
settings.directionCount,
upperNudgeFactor,
minUpperNudgeLimit,
@@ -387,7 +379,7 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
var hdrp = (RenderPipelineManager.currentPipeline as HDRenderPipeline);
var depthMipInfo = hdrp.sharedRTManager.GetDepthBufferMipChainInfo();
- parameters.firstAndSecondMipOffsets = new Vector4(depthMipInfo.mipLevelOffsets[1].x, depthMipInfo.mipLevelOffsets[1].y, depthMipInfo.mipLevelOffsets[2].x, depthMipInfo.mipLevelOffsets[2].y);
+ cb._FirstTwoDepthMipOffsets = new Vector4(depthMipInfo.mipLevelOffsets[1].x, depthMipInfo.mipLevelOffsets[1].y, depthMipInfo.mipLevelOffsets[2].x, depthMipInfo.mipLevelOffsets[2].y);
parameters.bilateralUpsample = settings.bilateralUpsample;
parameters.gtaoCS = m_Resources.shaders.GTAOCS;
@@ -440,24 +432,16 @@ RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties
m_HistoryReady = true; // assumes that if this is called, then render is done as well.
parameters.runAsync = camera.frameSettings.SSAORunsAsync();
- parameters.motionVectorDisabled = !camera.frameSettings.IsEnabled(FrameSettingsField.MotionVectors);
return parameters;
}
- static void RenderAO(in RenderAOParameters parameters,
- RTHandle packedDataTexture,
+ static void RenderAO(in RenderAOParameters parameters,
+ RTHandle packedDataTexture,
RenderPipelineResources resources,
- CommandBuffer cmd)
+ CommandBuffer cmd)
{
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._AOBufferSize, parameters.aoBufferInfo);
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._AODepthToViewParams, parameters.toViewSpaceProj);
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._AOParams0, parameters.aoParams0);
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._AOParams1, parameters.aoParams1);
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._AOParams2, parameters.aoParams2);
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._AOParams4, parameters.aoParams4);
- cmd.SetComputeVectorParam(parameters.gtaoCS, HDShaderIDs._FirstTwoDepthMipOffsets, parameters.firstAndSecondMipOffsets);
-
+ ConstantBuffer.Push(cmd, parameters.cb, parameters.gtaoCS, HDShaderIDs._ShaderVariablesAmbientOcclusion);
cmd.SetComputeTextureParam(parameters.gtaoCS, parameters.gtaoKernel, HDShaderIDs._AOPackedData, packedDataTexture);
const int groupSizeX = 8;
@@ -484,11 +468,7 @@ static void DenoiseAO( in RenderAOParameters parameters,
if (parameters.temporalAccumulation || parameters.fullResolution)
{
var blurCS = parameters.spatialDenoiseAOCS;
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams1, parameters.aoParams1);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams2, parameters.aoParams2);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams3, parameters.aoParams3);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams4, parameters.aoParams4);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOBufferSize, parameters.aoBufferInfo);
+ ConstantBuffer.Set(cmd, blurCS, HDShaderIDs._ShaderVariablesAmbientOcclusion);
// Spatial
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelSpatial, HDShaderIDs._AOPackedData, packedDataTex);
@@ -514,12 +494,7 @@ static void DenoiseAO( in RenderAOParameters parameters,
}
var blurCS = parameters.temporalDenoiseAOCS;
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams1, parameters.aoParams1);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams2, parameters.aoParams2);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams3, parameters.aoParams3);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOParams4, parameters.aoParams4);
- cmd.SetComputeVectorParam(blurCS, HDShaderIDs._AOBufferSize, parameters.aoBufferInfo);
-
+ ConstantBuffer.Set(cmd, blurCS, HDShaderIDs._ShaderVariablesAmbientOcclusion);
// Temporal
cmd.SetComputeTextureParam(blurCS, parameters.denoiseKernelTemporal, HDShaderIDs._AOPackedData, packedDataTex);
@@ -538,9 +513,7 @@ static void UpsampleAO( in RenderAOParameters parameters,
{
bool blurAndUpsample = !parameters.temporalAccumulation;
- cmd.SetComputeVectorParam(parameters.upsampleAndBlurAOCS, HDShaderIDs._AOBufferSize, parameters.aoBufferInfo);
- cmd.SetComputeVectorParam(parameters.upsampleAndBlurAOCS, HDShaderIDs._AOParams1, parameters.aoParams1);
- cmd.SetComputeVectorParam(parameters.upsampleAndBlurAOCS, HDShaderIDs._AOParams3, parameters.aoParams3);
+ ConstantBuffer.Set(cmd, parameters.upsampleAndBlurAOCS, HDShaderIDs._ShaderVariablesAmbientOcclusion);
if (blurAndUpsample)
{
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl
index 770213f9085..bd494f80341 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/GTAOCommon.hlsl
@@ -2,17 +2,7 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
-
-CBUFFER_START(GTAOUniformBuffer)
-float4 _AOBufferSize;
-float4 _AOParams0;
-float4 _AOParams1;
-float4 _AOParams2;
-float4 _AOParams3;
-float4 _AOParams4;
-float4 _FirstTwoDepthMipOffsets;
-float4 _AODepthToViewParams;
-CBUFFER_END
+#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl"
#define _AOBaseResMip (int)_AOParams0.x
#define _AOFOVCorrection _AOParams0.y
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute
index 1da1c537015..22e1eb447a8 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute
@@ -22,6 +22,7 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceLighting.hlsl"
+#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
@@ -52,24 +53,6 @@
StructuredBuffer _DepthPyramidMipLevelOffsets;
StructuredBuffer _CoarseStencilBuffer;
-CBUFFER_START(UnityScreenSpaceReflections)
- int _SsrStencilBit;
- int _SsrIterLimit;
- float _SsrThicknessScale;
- float _SsrThicknessBias;
-
- float _SsrRoughnessFadeEnd;
- float _SsrRoughnessFadeRcpLength;
- float _SsrRoughnessFadeEndTimesRcpLength;
- float _SsrEdgeFadeRcpLength;
-
- float4 _ColorPyramidUvScaleAndLimitPrevFrame;
-
- int _SsrDepthPyramidMaxMip;
- int _SsrColorPyramidMaxMip;
- int _SsrReflectsSky; // bool...
-CBUFFER_END
-
//--------------------------------------------------------------------------------------------------
// Implementation
//--------------------------------------------------------------------------------------------------
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs
new file mode 100644
index 00000000000..749905861ae
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs
@@ -0,0 +1,15 @@
+namespace UnityEngine.Rendering.HighDefinition
+{
+ [GenerateHLSL(needAccessors = false, generateCBuffer = true)]
+ unsafe struct ShaderVariablesAmbientOcclusion
+ {
+ public Vector4 _AOBufferSize;
+ public Vector4 _AOParams0;
+ public Vector4 _AOParams1;
+ public Vector4 _AOParams2;
+ public Vector4 _AOParams3;
+ public Vector4 _AOParams4;
+ public Vector4 _FirstTwoDepthMipOffsets;
+ public Vector4 _AODepthToViewParams;
+ }
+}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl
new file mode 100644
index 00000000000..4b26b4190a1
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl
@@ -0,0 +1,21 @@
+//
+// This file was automatically generated. Please don't edit by hand.
+//
+
+#ifndef SHADERVARIABLESAMBIENTOCCLUSION_CS_HLSL
+#define SHADERVARIABLESAMBIENTOCCLUSION_CS_HLSL
+// Generated from UnityEngine.Rendering.HighDefinition.ShaderVariablesAmbientOcclusion
+// PackingRules = Exact
+CBUFFER_START(ShaderVariablesAmbientOcclusion)
+ float4 _AOBufferSize;
+ float4 _AOParams0;
+ float4 _AOParams1;
+ float4 _AOParams2;
+ float4 _AOParams3;
+ float4 _AOParams4;
+ float4 _FirstTwoDepthMipOffsets;
+ float4 _AODepthToViewParams;
+CBUFFER_END
+
+
+#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl.meta
new file mode 100644
index 00000000000..b2ff43668c7
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 4f3f0e8f82d03e8408702e2c10ede656
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ preprocessorOverride: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.meta
new file mode 100644
index 00000000000..12690d4aec6
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7c03f6c0f9d8ed845a32d1b5bdc6223c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs
new file mode 100644
index 00000000000..d0be0791579
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs
@@ -0,0 +1,23 @@
+namespace UnityEngine.Rendering.HighDefinition
+{
+ [GenerateHLSL(needAccessors = false, generateCBuffer = true)]
+ unsafe struct ShaderVariablesScreenSpaceReflection
+ {
+ public float _SsrThicknessScale;
+ public float _SsrThicknessBias;
+ public int _SsrStencilBit;
+ public int _SsrIterLimit;
+
+ public float _SsrRoughnessFadeEnd;
+ public float _SsrRoughnessFadeRcpLength;
+ public float _SsrRoughnessFadeEndTimesRcpLength;
+ public float _SsrEdgeFadeRcpLength;
+
+ public Vector4 _ColorPyramidUvScaleAndLimitPrevFrame;
+
+ public int _SsrDepthPyramidMaxMip;
+ public int _SsrColorPyramidMaxMip;
+ public int _SsrReflectsSky;
+ public float _ScreenSpaceReflectionPad0;
+ }
+}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl
new file mode 100644
index 00000000000..c9eb01809ca
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl
@@ -0,0 +1,26 @@
+//
+// This file was automatically generated. Please don't edit by hand.
+//
+
+#ifndef SHADERVARIABLESSCREENSPACEREFLECTION_CS_HLSL
+#define SHADERVARIABLESSCREENSPACEREFLECTION_CS_HLSL
+// Generated from UnityEngine.Rendering.HighDefinition.ShaderVariablesScreenSpaceReflection
+// PackingRules = Exact
+CBUFFER_START(ShaderVariablesScreenSpaceReflection)
+ float _SsrThicknessScale;
+ float _SsrThicknessBias;
+ int _SsrStencilBit;
+ int _SsrIterLimit;
+ float _SsrRoughnessFadeEnd;
+ float _SsrRoughnessFadeRcpLength;
+ float _SsrRoughnessFadeEndTimesRcpLength;
+ float _SsrEdgeFadeRcpLength;
+ float4 _ColorPyramidUvScaleAndLimitPrevFrame;
+ int _SsrDepthPyramidMaxMip;
+ int _SsrColorPyramidMaxMip;
+ int _SsrReflectsSky;
+ float _ScreenSpaceReflectionPad0;
+CBUFFER_END
+
+
+#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl.meta
new file mode 100644
index 00000000000..cb4a7dad8fa
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.hlsl.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: b9e1731972b49b84cb07e584e3cf0867
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ preprocessorOverride: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.meta
new file mode 100644
index 00000000000..a0edc9ed090
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceReflection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 72d3feab56314d34b86052044f6a4653
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs
index 17c538d3adb..f555a01a0e2 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs
@@ -855,7 +855,10 @@ static void FilterVolumetricLighting(in VolumetricLightingParameters parameters,
void VolumetricLightingPass(HDCamera hdCamera, CommandBuffer cmd, int frameIndex)
{
if (!Fog.IsVolumetricFogEnabled(hdCamera))
+ {
+ cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, HDUtils.clearTexture3D);
return;
+ }
var parameters = PrepareVolumetricLightingParameters(hdCamera, frameIndex);
@@ -875,6 +878,8 @@ void VolumetricLightingPass(HDCamera hdCamera, CommandBuffer cmd, int frameIndex
// Let's filter out volumetric buffer
if (parameters.filterVolume)
FilterVolumetricLighting(parameters, m_DensityBufferHandle, m_LightingBufferHandle, cmd);
+
+ cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, m_LightingBufferHandle);
}
} // class VolumetricLightingModule
} // namespace UnityEngine.Rendering.HighDefinition
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index 6283a934cb1..721d597a27d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -566,7 +566,7 @@ internal static void CleanUnused()
s_Cleanup.Clear();
}
- unsafe internal void UpdateShaderVariableGlobalCB(ref ShaderVariablesGlobal cb, int frameCount)
+ unsafe internal void UpdateShaderVariablesGlobalCB(ref ShaderVariablesGlobal cb, int frameCount)
{
bool taaEnabled = frameSettings.IsEnabled(FrameSettingsField.Postprocess)
&& antialiasing == AntialiasingMode.TemporalAntialiasing
@@ -617,48 +617,31 @@ unsafe internal void UpdateShaderVariableGlobalCB(ref ShaderVariablesGlobal cb,
}
- // Set up UnityPerView CBuffer.
- internal void SetupGlobalParams(CommandBuffer cmd, int frameCount)
+ unsafe internal void UpdateShaderVariablesXRCB(ref ShaderVariablesXR cb)
{
- // XRTODO: qualify this code with xr.singlePassEnabled when compute shaders can use keywords
- if (true)
+ for (int i = 0; i < viewCount; i++)
{
- // Convert AoS to SoA for GPU constant buffer until we can use StructuredBuffer via command buffer
- // XRTODO: use the new API and remove this code
- for (int i = 0; i < viewCount; i++)
+ for (int j = 0; j < 16; ++j)
{
- m_XRViewMatrix[i] = m_XRViewConstants[i].viewMatrix;
- m_XRInvViewMatrix[i] = m_XRViewConstants[i].invViewMatrix;
- m_XRProjMatrix[i] = m_XRViewConstants[i].projMatrix;
- m_XRInvProjMatrix[i] = m_XRViewConstants[i].invProjMatrix;
- m_XRViewProjMatrix[i] = m_XRViewConstants[i].viewProjMatrix;
- m_XRInvViewProjMatrix[i] = m_XRViewConstants[i].invViewProjMatrix;
- m_XRNonJitteredViewProjMatrix[i] = m_XRViewConstants[i].nonJitteredViewProjMatrix;
- m_XRPrevViewProjMatrix[i] = m_XRViewConstants[i].prevViewProjMatrix;
- m_XRPrevInvViewProjMatrix[i] = m_XRViewConstants[i].prevInvViewProjMatrix;
- m_XRPrevViewProjMatrixNoCameraTrans[i] = m_XRViewConstants[i].prevViewProjMatrixNoCameraTrans;
- m_XRPixelCoordToViewDirWS[i] = m_XRViewConstants[i].pixelCoordToViewDirWS;
- m_XRWorldSpaceCameraPos[i] = m_XRViewConstants[i].worldSpaceCameraPos;
- m_XRWorldSpaceCameraPosViewOffset[i] = m_XRViewConstants[i].worldSpaceCameraPosViewOffset;
- m_XRPrevWorldSpaceCameraPos[i] = m_XRViewConstants[i].prevWorldSpaceCameraPos;
+ cb._XRViewMatrix[i * 16 + j] = m_XRViewConstants[i].viewMatrix[j];
+ cb._XRInvViewMatrix[i * 16 + j] = m_XRViewConstants[i].invViewMatrix[j];
+ cb._XRProjMatrix[i * 16 + j] = m_XRViewConstants[i].projMatrix[j];
+ cb._XRInvProjMatrix[i * 16 + j] = m_XRViewConstants[i].invProjMatrix[j];
+ cb._XRViewProjMatrix[i * 16 + j] = m_XRViewConstants[i].viewProjMatrix[j];
+ cb._XRInvViewProjMatrix[i * 16 + j] = m_XRViewConstants[i].invViewProjMatrix[j];
+ cb._XRNonJitteredViewProjMatrix[i * 16 + j] = m_XRViewConstants[i].nonJitteredViewProjMatrix[j];
+ cb._XRPrevViewProjMatrix[i * 16 + j] = m_XRViewConstants[i].prevViewProjMatrix[j];
+ cb._XRPrevInvViewProjMatrix[i * 16 + j] = m_XRViewConstants[i].prevInvViewProjMatrix[j];
+ cb._XRPrevViewProjMatrixNoCameraTrans[i * 16 + j] = m_XRViewConstants[i].prevViewProjMatrixNoCameraTrans[j];
+ cb._XRPixelCoordToViewDirWS[i * 16 + j] = m_XRViewConstants[i].pixelCoordToViewDirWS[j];
+ }
+ for (int j = 0; j < 3; ++j) // Inputs are vec3 but we align CB on float4
+ {
+ cb._XRWorldSpaceCameraPos[i * 4 + j] = m_XRViewConstants[i].worldSpaceCameraPos[j];
+ cb._XRWorldSpaceCameraPosViewOffset[i * 4 + j] = m_XRViewConstants[i].worldSpaceCameraPosViewOffset[j];
+ cb._XRPrevWorldSpaceCameraPos[i * 4 + j] = m_XRViewConstants[i].prevWorldSpaceCameraPos[j];
}
-
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRViewMatrix, m_XRViewMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRInvViewMatrix, m_XRInvViewMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRProjMatrix, m_XRProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRInvProjMatrix, m_XRInvProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRViewProjMatrix, m_XRViewProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRInvViewProjMatrix, m_XRInvViewProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRNonJitteredViewProjMatrix, m_XRNonJitteredViewProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRPrevViewProjMatrix, m_XRPrevViewProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRPrevInvViewProjMatrix, m_XRPrevInvViewProjMatrix);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRPrevViewProjMatrixNoCameraTrans, m_XRPrevViewProjMatrixNoCameraTrans);
- cmd.SetGlobalMatrixArray(HDShaderIDs._XRPixelCoordToViewDirWS, m_XRPixelCoordToViewDirWS);
- cmd.SetGlobalVectorArray(HDShaderIDs._XRWorldSpaceCameraPos, m_XRWorldSpaceCameraPos);
- cmd.SetGlobalVectorArray(HDShaderIDs._XRWorldSpaceCameraPosViewOffset, m_XRWorldSpaceCameraPosViewOffset);
- cmd.SetGlobalVectorArray(HDShaderIDs._XRPrevWorldSpaceCameraPos, m_XRPrevWorldSpaceCameraPos);
}
-
}
internal void AllocateAmbientOcclusionHistoryBuffer(float scaleFactor)
@@ -812,21 +795,6 @@ public RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSyst
float m_AmbientOcclusionResolutionScale = 0.0f; // Factor used to track if history should be reallocated for Ambient Occlusion
ViewConstants[] m_XRViewConstants;
- // XR View Constants arrays (required due to limitations of API for StructuredBuffer)
- Matrix4x4[] m_XRViewMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRInvViewMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRInvProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRViewProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRInvViewProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRNonJitteredViewProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRPrevViewProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRPrevInvViewProjMatrix = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRPrevViewProjMatrixNoCameraTrans = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Matrix4x4[] m_XRPixelCoordToViewDirWS = new Matrix4x4[ShaderConfig.s_XrMaxViews];
- Vector4[] m_XRWorldSpaceCameraPos = new Vector4[ShaderConfig.s_XrMaxViews];
- Vector4[] m_XRWorldSpaceCameraPosViewOffset = new Vector4[ShaderConfig.s_XrMaxViews];
- Vector4[] m_XRPrevWorldSpaceCameraPos = new Vector4[ShaderConfig.s_XrMaxViews];
// Recorder specific
IEnumerator> m_RecorderCaptureActions;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs
index 730222baa02..8d369531b2a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs
@@ -117,7 +117,6 @@ internal enum HDProfileId
// Profile sampler for prepare light for GPU
PrepareLightsForGPU,
- PushLightDataGlobalParameters,
// Profile sampler for shadow
PushShadowGlobalParameters,
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 c3d2f63d753..af2f4eff735 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
@@ -27,7 +27,6 @@ static void ReadLightingBuffers(LightingBuffers buffers, RenderGraphBuilder buil
class BuildGPULightListPassData
{
- public LightDataGlobalParameters lightDataGlobalParameters;
public ShadowGlobalParameters shadowGlobalParameters;
public LightLoopGlobalParameters lightLoopGlobalParameters;
@@ -45,10 +44,9 @@ void BuildGPULightList(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle
{
builder.EnableAsyncCompute(hdCamera.frameSettings.BuildLightListRunsAsync());
- passData.lightDataGlobalParameters = PrepareLightDataGlobalParameters(hdCamera);
passData.shadowGlobalParameters = PrepareShadowGlobalParameters(hdCamera);
passData.lightLoopGlobalParameters = PrepareLightLoopGlobalParameters(hdCamera);
- passData.buildGPULightListParameters = PrepareBuildGPULightListParameters(hdCamera);
+ passData.buildGPULightListParameters = PrepareBuildGPULightListParameters(hdCamera, buildForProbeVolumes: false);
// TODO: Move this inside the render function onces compute buffers are RenderGraph ready
passData.buildGPULightListResources = PrepareBuildGPULightListResources(m_TileAndClusterData, null, null, isGBufferNeeded: true);
passData.depthBuffer = builder.ReadTexture(depthStencilBuffer);
@@ -83,7 +81,6 @@ void BuildGPULightList(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle
BuildDispatchIndirectArguments(data.buildGPULightListParameters, data.buildGPULightListResources, tileFlagsWritten, context.cmd);
// TODO RENDERGRAPH WARNING: Note that the three sets of variables are bound here, but it should be handled differently.
- PushLightDataGlobalParams(data.lightDataGlobalParameters, context.cmd);
PushShadowGlobalParams(data.shadowGlobalParameters, context.cmd);
PushLightLoopGlobalParams(data.lightLoopGlobalParameters, context.cmd);
});
@@ -96,6 +93,7 @@ class PushGlobalCameraParamPassData
public HDCamera hdCamera;
public int frameCount;
public ShaderVariablesGlobal globalCB;
+ public ShaderVariablesXR xrCB;
}
@@ -106,13 +104,15 @@ void PushGlobalCameraParams(RenderGraph renderGraph, HDCamera hdCamera)
passData.hdCamera = hdCamera;
passData.frameCount = m_FrameCount;
passData.globalCB = m_ShaderVariablesGlobalCB;
+ passData.xrCB = m_ShaderVariablesXRCB;
builder.SetRenderFunc(
(PushGlobalCameraParamPassData data, RenderGraphContext context) =>
{
- data.hdCamera.UpdateShaderVariableGlobalCB(ref data.globalCB, data.frameCount);
- data.hdCamera.SetupGlobalParams(context.cmd, data.frameCount);
+ data.hdCamera.UpdateShaderVariablesGlobalCB(ref data.globalCB, data.frameCount);
ConstantBuffer.PushGlobal(context.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);
+ data.hdCamera.UpdateShaderVariablesXRCB(ref data.xrCB);
+ ConstantBuffer.PushGlobal(context.cmd, data.xrCB, HDShaderIDs._ShaderVariablesXR);
});
}
}
@@ -254,7 +254,7 @@ class RenderSSRPassData
}
TextureHandle RenderSSR( RenderGraph renderGraph,
- HDCamera hdCamera,
+ HDCamera hdCamera,
TextureHandle normalBuffer,
TextureHandle motionVectorsBuffer,
TextureHandle depthPyramid,
@@ -285,7 +285,7 @@ TextureHandle RenderSSR( RenderGraph renderGraph,
var colorPyramid = renderGraph.ImportTexture(hdCamera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain));
- passData.parameters = PrepareSSRParameters(hdCamera);
+ passData.parameters = PrepareSSRParameters(hdCamera, m_DepthBufferMipChainInfo);
passData.depthPyramid = builder.ReadTexture(depthPyramid);
passData.colorPyramid = builder.ReadTexture(colorPyramid);
passData.stencilBuffer = builder.ReadTexture(stencilBuffer);
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 196b69cb5be..cfae6bf8bca 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -176,6 +176,8 @@ internal static Volume GetOrCreateDefaultVolume()
// Constant Buffers
ShaderVariablesGlobal m_ShaderVariablesGlobalCB = new ShaderVariablesGlobal();
+ ShaderVariablesXR m_ShaderVariablesXRCB = new ShaderVariablesXR();
+ ShaderVariablesDebugDisplay m_ShaderVariablesDebugDisplayCB = new ShaderVariablesDebugDisplay();
// The current MSAA count
MSAASamples m_MSAASamples;
@@ -988,7 +990,7 @@ void Resize(HDCamera hdCamera)
void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
{
- hdCamera.UpdateShaderVariableGlobalCB(ref m_ShaderVariablesGlobalCB, m_FrameCount);
+ hdCamera.UpdateShaderVariablesGlobalCB(ref m_ShaderVariablesGlobalCB, m_FrameCount);
Fog.UpdateShaderVariablesGlobalCB(ref m_ShaderVariablesGlobalCB, hdCamera);
UpdateShaderVariablesGlobalSubsurface(ref m_ShaderVariablesGlobalCB, hdCamera);
UpdateShaderVariablesGlobalDecal(ref m_ShaderVariablesGlobalCB, hdCamera);
@@ -996,7 +998,6 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
m_ShadowManager.UpdateShaderVariablesGlobalCB(ref m_ShaderVariablesGlobalCB);
UpdateShaderVariablesGlobalLightLoop(ref m_ShaderVariablesGlobalCB, hdCamera);
UpdateShaderVariablesGlobalProbeVolumes(ref m_ShaderVariablesGlobalCB, hdCamera);
- PushProbeVolumesGlobalParams(hdCamera, cmd, m_FrameCount);
m_AmbientOcclusionSystem.UpdateShaderVariableGlobalCB(ref m_ShaderVariablesGlobalCB, hdCamera);
// Misc
@@ -1040,40 +1041,12 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
}
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
- }
-
- void PushGlobalParams(HDCamera hdCamera, CommandBuffer cmd)
- {
- using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.PushGlobalParameters)))
- {
- PushVolumetricLightingGlobalParams(hdCamera, cmd, m_FrameCount);
- PushProbeVolumesGlobalParams(hdCamera, cmd, m_FrameCount);
-
- // Set up UnityPerView CBuffer.
- hdCamera.SetupGlobalParams(cmd, m_FrameCount);
-
- // It will be overridden for transparent pass.
- cmd.SetGlobalInt(HDShaderIDs._ColorMaskTransparentVel, (int)UnityEngine.Rendering.ColorWriteMask.All);
-
- if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.MotionVectors))
- {
- cmd.SetGlobalTexture(HDShaderIDs._CameraMotionVectorsTexture, m_SharedRTManager.GetMotionVectorsBuffer());
- }
- else
- {
- cmd.SetGlobalTexture(HDShaderIDs._CameraMotionVectorsTexture, TextureXR.GetBlackTexture());
- }
-
- // Light loop stuff...
- if (hdCamera.IsSSREnabled())
- cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, m_SsrLightingTexture);
- else
- cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, TextureXR.GetClearTexture());
+ hdCamera.UpdateShaderVariablesXRCB(ref m_ShaderVariablesXRCB);
+ ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesXRCB, HDShaderIDs._ShaderVariablesXR);
- m_SkyManager.SetGlobalSkyData(cmd, hdCamera);
-
- }
+ // This one is not in a constant buffer because it's only used as a parameter for some shader's render states. It's not actually used inside shader code.
+ cmd.SetGlobalInt(HDShaderIDs._ColorMaskTransparentVel, (int)ColorWriteMask.All);
}
void CopyDepthBufferIfNeeded(HDCamera hdCamera, CommandBuffer cmd)
@@ -1990,8 +1963,6 @@ AOVRequestData aovRequest
bool enableBakeShadowMask = PrepareLightsForGPU(cmd, hdCamera, cullingResults, hdProbeCullingResults, densityVolumes, probeVolumes, m_CurrentDebugDisplaySettings, aovRequest);
UpdateShaderVariablesGlobalCB(hdCamera, cmd);
- // Let's bind as soon as possible the light data
- BindLightDataParameters(hdCamera, cmd);
// Do the same for ray tracing if allowed
if (m_RayTracingSupported)
@@ -2009,7 +1980,6 @@ AOVRequestData aovRequest
else
cmd.SetGlobalTexture(HDShaderIDs._SkyTexture, CoreUtils.magentaCubeTextureArray);
- PushGlobalParams(hdCamera, cmd);
VFXManager.ProcessCameraCommand(camera, cmd);
if (GL.wireframe)
@@ -2163,9 +2133,14 @@ void Callback(CommandBuffer c, HDCamera cam)
RenderCameraMotionVectors(cullingResults, hdCamera, renderContext, cmd);
}
+
+ if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.MotionVectors))
+ cmd.SetGlobalTexture(HDShaderIDs._CameraMotionVectorsTexture, m_SharedRTManager.GetMotionVectorsBuffer());
+ else
+ cmd.SetGlobalTexture(HDShaderIDs._CameraMotionVectorsTexture, TextureXR.GetBlackTexture());
+
#if UNITY_EDITOR
- var showGizmos = camera.cameraType == CameraType.SceneView ||
- (camera.targetTexture == null && camera.cameraType == CameraType.Game);
+ var showGizmos = camera.cameraType == CameraType.SceneView || (camera.targetTexture == null && camera.cameraType == CameraType.Game);
#endif
RenderTransparencyOverdraw(cullingResults, hdCamera, renderContext, cmd);
@@ -2252,7 +2227,7 @@ void AsyncSSAODispatch(CommandBuffer c, HDGPUAsyncTaskParams a)
// This call overwrites camera properties passed to the shader system.
RenderShadowMaps(renderContext, cmd, m_ShaderVariablesGlobalCB, cullingResults, hdCamera);
- hdCamera.UpdateShaderVariableGlobalCB(ref m_ShaderVariablesGlobalCB, m_FrameCount);
+ hdCamera.UpdateShaderVariablesGlobalCB(ref m_ShaderVariablesGlobalCB, m_FrameCount);
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
}
@@ -3425,7 +3400,8 @@ void RenderTransparencyOverdraw(CullingResults cull, HDCamera hdCamera, Scriptab
};
// High res transparent objects, drawing in m_DebugFullScreenTempBuffer
- cmd.SetGlobalFloat(HDShaderIDs._DebugTransparencyOverdrawWeight, 1.0f);
+ m_ShaderVariablesDebugDisplayCB._DebugTransparencyOverdrawWeight = 1.0f;
+ ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesDebugDisplayCB, HDShaderIDs._ShaderVariablesDebugDisplay);
var passNames = m_Asset.currentPlatformRenderPipelineSettings.supportTransparentBackface ? m_AllTransparentPassNames : m_TransparentNoBackfaceNames;
m_DebugFullScreenPropertyBlock.SetFloat(HDShaderIDs._TransparencyOverdrawMaxPixelCost, (float)m_DebugDisplaySettings.data.transparencyDebugSettings.maxPixelCost);
@@ -3435,7 +3411,8 @@ void RenderTransparencyOverdraw(CullingResults cull, HDCamera hdCamera, Scriptab
DrawTransparentRendererList(renderContext, cmd, hdCamera.frameSettings, rendererList);
// Low res transparent objects, copying result m_DebugTranparencyLowRes
- cmd.SetGlobalFloat(HDShaderIDs._DebugTransparencyOverdrawWeight, 0.25f);
+ m_ShaderVariablesDebugDisplayCB._DebugTransparencyOverdrawWeight = 0.25f;
+ ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesDebugDisplayCB, HDShaderIDs._ShaderVariablesDebugDisplay);
rendererList = RendererList.Create(CreateTransparentRendererListDesc(cull, hdCamera.camera, passNames, renderQueueRange: HDRenderQueue.k_RenderQueue_LowTransparent, stateBlock: stateBlock));
DrawTransparentRendererList(renderContext, cmd, hdCamera.frameSettings, rendererList);
PushFullScreenDebugTexture(hdCamera, cmd, m_CameraColorBuffer, FullScreenDebugMode.TransparencyOverdraw);
@@ -3854,24 +3831,14 @@ struct RenderSSRParameters
public int reprojectionKernel;
public int width, height, viewCount;
- public int maxIteration;
- public bool reflectSky;
- public float thicknessScale;
- public float thicknessBias;
- public float roughnessFadeEnd;
- public float roughnessFadeEndTimesRcpLength;
- public float roughnessFadeRcpLength;
- public float edgeFadeRcpLength;
-
- public int depthPyramidMipCount;
+
public ComputeBuffer offsetBufferData;
public ComputeBuffer coarseStencilBuffer;
- public Vector4 colorPyramidUVScaleAndLimit;
- public int colorPyramidMipCount;
- }
+ public ShaderVariablesScreenSpaceReflection cb;
+ }
- RenderSSRParameters PrepareSSRParameters(HDCamera hdCamera)
+ RenderSSRParameters PrepareSSRParameters(HDCamera hdCamera, in HDUtils.PackedMipChainInfo depthPyramid)
{
var volumeSettings = hdCamera.volumeStack.GetComponent();
var parameters = new RenderSSRParameters();
@@ -3886,28 +3853,26 @@ RenderSSRParameters PrepareSSRParameters(HDCamera hdCamera)
float n = hdCamera.camera.nearClipPlane;
float f = hdCamera.camera.farClipPlane;
-
- parameters.maxIteration = volumeSettings.rayMaxIterations;
- parameters.reflectSky = volumeSettings.reflectSky.value;
-
- float thickness = volumeSettings.depthBufferThickness.value;
- parameters.thicknessScale = 1.0f / (1.0f + thickness);
- parameters.thicknessBias = -n / (f - n) * (thickness * parameters.thicknessScale);
-
- var info = m_SharedRTManager.GetDepthBufferMipChainInfo();
- parameters.depthPyramidMipCount = info.mipLevelCount;
- parameters.offsetBufferData = info.GetOffsetBufferData(m_DepthPyramidMipLevelOffsetsBuffer);
- parameters.coarseStencilBuffer = m_SharedRTManager.GetCoarseStencilBuffer();
-
+ float thickness = volumeSettings.depthBufferThickness.value;
+
+ ref var cb = ref parameters.cb;
+ cb._SsrThicknessScale = 1.0f / (1.0f + thickness);
+ cb._SsrThicknessBias = -n / (f - n) * (thickness * cb._SsrThicknessScale);
+ cb._SsrIterLimit = volumeSettings.rayMaxIterations;
+ cb._SsrReflectsSky = volumeSettings.reflectSky.value ? 1 : 0;
+ cb._SsrStencilBit = (int)StencilUsage.TraceReflectionRay;
float roughnessFadeStart = 1 - volumeSettings.smoothnessFadeStart.value;
- parameters.roughnessFadeEnd = 1 - volumeSettings.minSmoothness.value;
- float roughnessFadeLength = parameters.roughnessFadeEnd - roughnessFadeStart;
- parameters.roughnessFadeEndTimesRcpLength = (roughnessFadeLength != 0) ? (parameters.roughnessFadeEnd * (1.0f / roughnessFadeLength)) : 1;
- parameters.roughnessFadeRcpLength = (roughnessFadeLength != 0) ? (1.0f / roughnessFadeLength) : 0;
- parameters.edgeFadeRcpLength = Mathf.Min(1.0f / volumeSettings.screenFadeDistance.value, float.MaxValue);
-
- parameters.colorPyramidUVScaleAndLimit = HDUtils.ComputeUvScaleAndLimit(hdCamera.historyRTHandleProperties.previousViewportSize, hdCamera.historyRTHandleProperties.previousRenderTargetSize);
- parameters.colorPyramidMipCount = hdCamera.colorPyramidHistoryMipCount;
+ cb._SsrRoughnessFadeEnd = 1 - volumeSettings.minSmoothness.value;
+ float roughnessFadeLength = cb._SsrRoughnessFadeEnd - roughnessFadeStart;
+ cb._SsrRoughnessFadeEndTimesRcpLength = (roughnessFadeLength != 0) ? (cb._SsrRoughnessFadeEnd * (1.0f / roughnessFadeLength)) : 1;
+ cb._SsrRoughnessFadeRcpLength = (roughnessFadeLength != 0) ? (1.0f / roughnessFadeLength) : 0;
+ cb._SsrEdgeFadeRcpLength = Mathf.Min(1.0f / volumeSettings.screenFadeDistance.value, float.MaxValue);
+ cb._ColorPyramidUvScaleAndLimitPrevFrame = HDUtils.ComputeUvScaleAndLimit(hdCamera.historyRTHandleProperties.previousViewportSize, hdCamera.historyRTHandleProperties.previousRenderTargetSize);
+ cb._SsrColorPyramidMaxMip = hdCamera.colorPyramidHistoryMipCount - 1;
+ cb._SsrDepthPyramidMaxMip = depthPyramid.mipLevelCount - 1;
+
+ parameters.offsetBufferData = depthPyramid.GetOffsetBufferData(m_DepthPyramidMipLevelOffsetsBuffer);
+ parameters.coarseStencilBuffer = m_SharedRTManager.GetCoarseStencilBuffer();
return parameters;
}
@@ -3926,17 +3891,6 @@ static void RenderSSR( in RenderSSRParameters parameters,
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.SsrTracing)))
{
- cmd.SetComputeIntParam(cs, HDShaderIDs._SsrIterLimit, parameters.maxIteration);
- cmd.SetComputeFloatParam(cs, HDShaderIDs._SsrThicknessScale, parameters.thicknessScale);
- cmd.SetComputeFloatParam(cs, HDShaderIDs._SsrThicknessBias, parameters.thicknessBias);
- cmd.SetComputeFloatParam(cs, HDShaderIDs._SsrRoughnessFadeEnd, parameters.roughnessFadeEnd);
- cmd.SetComputeFloatParam(cs, HDShaderIDs._SsrRoughnessFadeRcpLength, parameters.roughnessFadeRcpLength);
- cmd.SetComputeFloatParam(cs, HDShaderIDs._SsrRoughnessFadeEndTimesRcpLength, parameters.roughnessFadeEndTimesRcpLength);
- cmd.SetComputeIntParam(cs, HDShaderIDs._SsrDepthPyramidMaxMip, parameters.depthPyramidMipCount - 1);
- cmd.SetComputeFloatParam(cs, HDShaderIDs._SsrEdgeFadeRcpLength, parameters.edgeFadeRcpLength);
- cmd.SetComputeIntParam(cs, HDShaderIDs._SsrReflectsSky, parameters.reflectSky ? 1 : 0);
- cmd.SetComputeIntParam(cs, HDShaderIDs._SsrStencilBit, (int)StencilUsage.TraceReflectionRay);
-
// cmd.SetComputeTextureParam(cs, kernel, "_SsrDebugTexture", m_SsrDebugTexture);
cmd.SetComputeTextureParam(cs, parameters.tracingKernel, HDShaderIDs._CameraDepthTexture, depthPyramid);
cmd.SetComputeTextureParam(cs, parameters.tracingKernel, HDShaderIDs._SsrClearCoatMaskTexture, clearCoatMask);
@@ -3952,9 +3906,10 @@ static void RenderSSR( in RenderSSRParameters parameters,
}
cmd.SetComputeBufferParam(cs, parameters.tracingKernel, HDShaderIDs._CoarseStencilBuffer, parameters.coarseStencilBuffer);
-
cmd.SetComputeBufferParam(cs, parameters.tracingKernel, HDShaderIDs._DepthPyramidMipLevelOffsets, parameters.offsetBufferData);
+ ConstantBuffer.Push(cmd, parameters.cb, cs, HDShaderIDs._ShaderVariablesScreenSpaceReflection);
+
cmd.DispatchCompute(cs, parameters.tracingKernel, HDUtils.DivRoundUp(parameters.width, 8), HDUtils.DivRoundUp(parameters.height, 8), parameters.viewCount);
}
@@ -3966,8 +3921,7 @@ static void RenderSSR( in RenderSSRParameters parameters,
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._ColorPyramidTexture, previousColorPyramid);
cmd.SetComputeTextureParam(cs, parameters.reprojectionKernel, HDShaderIDs._SsrClearCoatMaskTexture, clearCoatMask);
- cmd.SetComputeVectorParam(cs, HDShaderIDs._ColorPyramidUvScaleAndLimitPrevFrame, parameters.colorPyramidUVScaleAndLimit);
- cmd.SetComputeIntParam(cs, HDShaderIDs._SsrColorPyramidMaxMip, parameters.colorPyramidMipCount - 1);
+ ConstantBuffer.Push(cmd, parameters.cb, cs, HDShaderIDs._ShaderVariablesScreenSpaceReflection);
cmd.DispatchCompute(cs, parameters.reprojectionKernel, HDUtils.DivRoundUp(parameters.width, 8), HDUtils.DivRoundUp(parameters.height, 8), parameters.viewCount);
}
@@ -3976,7 +3930,10 @@ static void RenderSSR( in RenderSSRParameters parameters,
void RenderSSR(HDCamera hdCamera, CommandBuffer cmd, ScriptableRenderContext renderContext)
{
if (!hdCamera.IsSSREnabled())
+ {
+ cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, TextureXR.GetClearTexture());
return;
+ }
var settings = hdCamera.volumeStack.GetComponent();
bool usesRaytracedReflections = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && settings.rayTracing.value;
@@ -3991,7 +3948,7 @@ void RenderSSR(HDCamera hdCamera, CommandBuffer cmd, ScriptableRenderContext ren
// Evaluate the clear coat mask texture based on the lit shader mode
RTHandle clearCoatMask = hdCamera.frameSettings.litShaderMode == LitShaderMode.Deferred ? m_GbufferManager.GetBuffer(2) : TextureXR.GetBlackTexture();
- var parameters = PrepareSSRParameters(hdCamera);
+ var parameters = PrepareSSRParameters(hdCamera, m_SharedRTManager.GetDepthBufferMipChainInfo());
RenderSSR(parameters, m_SharedRTManager.GetDepthTexture(), m_SsrHitPointTexture,
m_SharedRTManager.GetStencilBuffer(hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)), clearCoatMask, previousColorPyramid,
m_SsrLightingTexture, cmd, renderContext);
@@ -4003,6 +3960,7 @@ void RenderSSR(HDCamera hdCamera, CommandBuffer cmd, ScriptableRenderContext ren
}
}
+ cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, m_SsrLightingTexture);
PushFullScreenDebugTexture(hdCamera, cmd, m_SsrLightingTexture, FullScreenDebugMode.ScreenSpaceReflections);
}
@@ -4028,7 +3986,7 @@ void RenderSSRTransparent(HDCamera hdCamera, CommandBuffer cmd, ScriptableRender
// Evaluate the screen space reflection for the transparent pixels
var previousColorPyramid = hdCamera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain);
- var parameters = PrepareSSRParameters(hdCamera);
+ var parameters = PrepareSSRParameters(hdCamera, m_SharedRTManager.GetDepthBufferMipChainInfo());
RenderSSR(parameters, m_SharedRTManager.GetDepthTexture(), m_SsrHitPointTexture, m_SharedRTManager.GetStencilBuffer(), TextureXR.GetBlackTexture(), previousColorPyramid, m_SsrLightingTexture, cmd, renderContext);
// If color pyramid was not valid, we bind a black texture
@@ -4135,7 +4093,7 @@ void UpsampleTransparent(HDCamera hdCamera, CommandBuffer cmd)
}
}
- void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd)
+ unsafe void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd)
{
// See ShaderPassForward.hlsl: for forward shaders, if DEBUG_DISPLAY is enabled and no DebugLightingMode or DebugMipMapMod
// modes have been set, lighting is automatically skipped (To avoid some crashed due to lighting RT not set on console).
@@ -4172,40 +4130,56 @@ void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd)
debugLightingMode = DebugLightingMode.MatcapView;
}
- cmd.SetGlobalFloatArray(HDShaderIDs._DebugViewMaterial, m_CurrentDebugDisplaySettings.GetDebugMaterialIndexes());
- cmd.SetGlobalInt(HDShaderIDs._DebugLightingMode, (int)debugLightingMode);
- cmd.SetGlobalInt(HDShaderIDs._DebugLightLayersMask, (int)m_CurrentDebugDisplaySettings.GetDebugLightLayersMask());
- cmd.SetGlobalVectorArray(HDShaderIDs._DebugRenderingLayersColors, m_CurrentDebugDisplaySettings.data.lightingDebugSettings.debugRenderingLayersColors);
- cmd.SetGlobalInt(HDShaderIDs._DebugShadowMapMode, (int)m_CurrentDebugDisplaySettings.GetDebugShadowMapMode());
- cmd.SetGlobalInt(HDShaderIDs._DebugMipMapMode, (int)m_CurrentDebugDisplaySettings.GetDebugMipMapMode());
- cmd.SetGlobalInt(HDShaderIDs._DebugMipMapModeTerrainTexture, (int)m_CurrentDebugDisplaySettings.GetDebugMipMapModeTerrainTexture());
- cmd.SetGlobalInt(HDShaderIDs._ColorPickerMode, (int)m_CurrentDebugDisplaySettings.GetDebugColorPickerMode());
- cmd.SetGlobalInt(HDShaderIDs._DebugFullScreenMode, (int)m_CurrentDebugDisplaySettings.data.fullScreenDebugMode);
- cmd.SetGlobalInt(HDShaderIDs._DebugProbeVolumeMode, (int)m_CurrentDebugDisplaySettings.GetProbeVolumeDebugMode());
+ ref var cb = ref m_ShaderVariablesDebugDisplayCB;
+
+ var debugMaterialIndices = m_CurrentDebugDisplaySettings.GetDebugMaterialIndexes();
+ for (int i = 0; i < 11; ++i)
+ {
+ cb._DebugViewMaterialArray[i * 4] = (uint)debugMaterialIndices[i]; // Only x component is used.
+ }
+ for (int i = 0; i < 32; ++i)
+ {
+ for (int j = 0; j < 4; ++j)
+ cb._DebugRenderingLayersColors[i * 4 + j] = m_CurrentDebugDisplaySettings.data.lightingDebugSettings.debugRenderingLayersColors[i][j];
+ }
+
+ cb._DebugLightingMode = (int)debugLightingMode;
+ cb._DebugLightLayersMask = (int)m_CurrentDebugDisplaySettings.GetDebugLightLayersMask();
+ cb._DebugShadowMapMode = (int)m_CurrentDebugDisplaySettings.GetDebugShadowMapMode();
+ cb._DebugMipMapMode = (int)m_CurrentDebugDisplaySettings.GetDebugMipMapMode();
+ cb._DebugMipMapModeTerrainTexture = (int)m_CurrentDebugDisplaySettings.GetDebugMipMapModeTerrainTexture();
+ cb._ColorPickerMode = (int)m_CurrentDebugDisplaySettings.GetDebugColorPickerMode();
+ cb._DebugFullScreenMode = (int)m_CurrentDebugDisplaySettings.data.fullScreenDebugMode;
+ cb._DebugProbeVolumeMode = (int)m_CurrentDebugDisplaySettings.GetProbeVolumeDebugMode();
#if UNITY_EDITOR
- cmd.SetGlobalInt(HDShaderIDs._MatcapMixAlbedo, HDRenderPipelinePreferences.matcapViewMixAlbedo ? 1 : 0);
- cmd.SetGlobalFloat(HDShaderIDs._MatcapViewScale, HDRenderPipelinePreferences.matcapViewScale);
+ cb._MatcapMixAlbedo = HDRenderPipelinePreferences.matcapViewMixAlbedo ? 1 : 0;
+ cb._MatcapViewScale = HDRenderPipelinePreferences.matcapViewScale;
#else
- cmd.SetGlobalInt(HDShaderIDs._MatcapMixAlbedo, 0);
- cmd.SetGlobalFloat(HDShaderIDs._MatcapViewScale, 1.0f);
+ cb._MatcapMixAlbedo = 0;
+ cb._MatcapViewScale = 1.0f;
#endif
- cmd.SetGlobalVector(HDShaderIDs._DebugLightingAlbedo, debugAlbedo);
- cmd.SetGlobalVector(HDShaderIDs._DebugLightingSmoothness, debugSmoothness);
- cmd.SetGlobalVector(HDShaderIDs._DebugLightingNormal, debugNormal);
- cmd.SetGlobalVector(HDShaderIDs._DebugLightingAmbientOcclusion, debugAmbientOcclusion);
- cmd.SetGlobalVector(HDShaderIDs._DebugLightingSpecularColor, debugSpecularColor);
- cmd.SetGlobalVector(HDShaderIDs._DebugLightingEmissiveColor, debugEmissiveColor);
- cmd.SetGlobalColor(HDShaderIDs._DebugLightingMaterialValidateHighColor, materialDebugSettings.materialValidateHighColor);
- cmd.SetGlobalColor(HDShaderIDs._DebugLightingMaterialValidateLowColor, materialDebugSettings.materialValidateLowColor);
- cmd.SetGlobalColor(HDShaderIDs._DebugLightingMaterialValidatePureMetalColor, debugTrueMetalColor);
-
- cmd.SetGlobalVector(HDShaderIDs._MousePixelCoord, HDUtils.GetMouseCoordinates(hdCamera));
- cmd.SetGlobalVector(HDShaderIDs._MouseClickPixelCoord, HDUtils.GetMouseClickCoordinates(hdCamera));
- cmd.SetGlobalTexture(HDShaderIDs._DebugFont, defaultResources.textures.debugFontTex);
+ cb._DebugLightingAlbedo = debugAlbedo;
+ cb._DebugLightingSmoothness = debugSmoothness;
+ cb._DebugLightingNormal = debugNormal;
+ cb._DebugLightingAmbientOcclusion = debugAmbientOcclusion;
+ cb._DebugLightingSpecularColor = debugSpecularColor;
+ cb._DebugLightingEmissiveColor = debugEmissiveColor;
+ cb._DebugLightingMaterialValidateHighColor = materialDebugSettings.materialValidateHighColor;
+ cb._DebugLightingMaterialValidateLowColor = materialDebugSettings.materialValidateLowColor;
+ cb._DebugLightingMaterialValidatePureMetalColor = debugTrueMetalColor;
+
+ cb._MousePixelCoord = HDUtils.GetMouseCoordinates(hdCamera);
+ cb._MouseClickPixelCoord = HDUtils.GetMouseClickCoordinates(hdCamera);
// The DebugNeedsExposure test allows us to set a neutral value if exposure is not needed. This way we don't need to make various tests inside shaders but only in this function.
- cmd.SetGlobalFloat(HDShaderIDs._DebugExposure, m_CurrentDebugDisplaySettings.DebugNeedsExposure() ? lightingDebugSettings.debugExposure : 0.0f);
+ cb._DebugExposure = m_CurrentDebugDisplaySettings.DebugNeedsExposure() ? lightingDebugSettings.debugExposure : 0.0f;
+
+ cb._DebugSingleShadowIndex = m_CurrentDebugDisplaySettings.data.lightingDebugSettings.shadowDebugUseSelection ? m_DebugSelectedLightShadowIndex : (int)m_CurrentDebugDisplaySettings.data.lightingDebugSettings.shadowMapIndex;
+
+ ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesDebugDisplayCB, HDShaderIDs._ShaderVariablesDebugDisplay);
+
+ cmd.SetGlobalTexture(HDShaderIDs._DebugFont, defaultResources.textures.debugFontTex);
}
}
@@ -4351,6 +4325,9 @@ static void ResolveColorPickerDebug(in DebugParameters parameters,
parameters.colorPickerMaterial.SetColor(HDShaderIDs._ColorPickerFontColor, colorPickerDebugSettings.fontColor);
parameters.colorPickerMaterial.SetInt(HDShaderIDs._FalseColorEnabled, falseColorDebugSettings.falseColor ? 1 : 0);
parameters.colorPickerMaterial.SetVector(HDShaderIDs._FalseColorThresholds, falseColorThresholds);
+ parameters.colorPickerMaterial.SetVector(HDShaderIDs._MousePixelCoord, HDUtils.GetMouseCoordinates(parameters.hdCamera));
+ parameters.colorPickerMaterial.SetVector(HDShaderIDs._MouseClickPixelCoord, HDUtils.GetMouseClickCoordinates(parameters.hdCamera));
+
// The material display debug perform sRGBToLinear conversion as the final blit currently hardcodes a linearToSrgb conversion. As when we read with color picker this is not done,
// we perform it inside the color picker shader. But we shouldn't do it for HDR buffer.
parameters.colorPickerMaterial.SetFloat(HDShaderIDs._ApplyLinearToSRGB, parameters.debugDisplaySettings.IsDebugMaterialDisplayEnabled() ? 1.0f : 0.0f);
@@ -4649,7 +4626,7 @@ static void RenderAfterPostProcess( PostProcessParameters parameters,
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
// In order to avoid that we decide that objects rendered after Post processes while TAA is active will not benefit from the depth buffer so we disable it.
parameters.hdCamera.UpdateAllViewConstants(false);
- parameters.hdCamera.UpdateShaderVariableGlobalCB(ref parameters.globalCB, parameters.frameCount);
+ parameters.hdCamera.UpdateShaderVariablesGlobalCB(ref parameters.globalCB, parameters.frameCount);
UpdateOffscreenRenderingConstants(ref parameters.globalCB, true, 1);
ConstantBuffer.PushGlobal(cmd, parameters.globalCB, HDShaderIDs._ShaderVariablesGlobal);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
index f7040136eba..4b97f003150 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
@@ -98,7 +98,6 @@ static class HDShaderIDs
public static readonly int _BlurWeightsStorage = Shader.PropertyToID("_BlurWeightsStorage");
public static readonly int g_LayeredSingleIdxBuffer = Shader.PropertyToID("g_LayeredSingleIdxBuffer");
- public static readonly int _DebugProbeVolumeMode = Shader.PropertyToID("_DebugProbeVolumeMode");
public static readonly int g_depth_tex = Shader.PropertyToID("g_depth_tex");
public static readonly int g_vLayeredLightList = Shader.PropertyToID("g_vLayeredLightList");
@@ -128,14 +127,12 @@ static class HDShaderIDs
public static readonly int _DirectionalLightDatas = Shader.PropertyToID("_DirectionalLightDatas");
public static readonly int _LightDatas = Shader.PropertyToID("_LightDatas");
public static readonly int _EnvLightDatas = Shader.PropertyToID("_EnvLightDatas");
+
public static readonly int _ProbeVolumeBounds = Shader.PropertyToID("_ProbeVolumeBounds");
public static readonly int _ProbeVolumeDatas = Shader.PropertyToID("_ProbeVolumeDatas");
public static readonly int g_vProbeVolumesLayeredOffsetsBuffer = Shader.PropertyToID("g_vProbeVolumesLayeredOffsetsBuffer");
public static readonly int g_vProbeVolumesLightListGlobal = Shader.PropertyToID("g_vProbeVolumesLightListGlobal");
- public static readonly int _NumTileBigTileX = Shader.PropertyToID("_NumTileBigTileX");
- public static readonly int _NumTileBigTileY = Shader.PropertyToID("_NumTileBigTileY");
-
public static readonly int g_vLayeredOffsetsBuffer = Shader.PropertyToID("g_vLayeredOffsetsBuffer");
public static readonly int _LightListToClear = Shader.PropertyToID("_LightListToClear");
@@ -149,30 +146,11 @@ static class HDShaderIDs
public static readonly int _SliceIndex = Shader.PropertyToID("_SliceIndex");
public static readonly int _DebugContactShadowLightIndex = Shader.PropertyToID("_DebugContactShadowLightIndex");
- public static readonly int _DebugViewMaterial = Shader.PropertyToID("_DebugViewMaterialArray");
- public static readonly int _DebugLightingMode = Shader.PropertyToID("_DebugLightingMode");
- public static readonly int _DebugLightLayersMask = Shader.PropertyToID("_DebugLightLayersMask");
- public static readonly int _DebugRenderingLayersColors = Shader.PropertyToID("_DebugRenderingLayersColors");
- public static readonly int _DebugShadowMapMode = Shader.PropertyToID("_DebugShadowMapMode");
- public static readonly int _DebugLightingAlbedo = Shader.PropertyToID("_DebugLightingAlbedo");
- public static readonly int _DebugLightingSmoothness = Shader.PropertyToID("_DebugLightingSmoothness");
- public static readonly int _DebugLightingNormal = Shader.PropertyToID("_DebugLightingNormal");
- public static readonly int _DebugLightingAmbientOcclusion = Shader.PropertyToID("_DebugLightingAmbientOcclusion");
- public static readonly int _DebugLightingSpecularColor = Shader.PropertyToID("_DebugLightingSpecularColor");
- public static readonly int _DebugLightingEmissiveColor = Shader.PropertyToID("_DebugLightingEmissiveColor");
public static readonly int _AmbientOcclusionTexture = Shader.PropertyToID("_AmbientOcclusionTexture");
public static readonly int _AmbientOcclusionTextureRW = Shader.PropertyToID("_AmbientOcclusionTextureRW");
public static readonly int _MultiAmbientOcclusionTexture = Shader.PropertyToID("_MultiAmbientOcclusionTexture");
- public static readonly int _DebugMipMapMode = Shader.PropertyToID("_DebugMipMapMode");
- public static readonly int _DebugMipMapModeTerrainTexture = Shader.PropertyToID("_DebugMipMapModeTerrainTexture");
- public static readonly int _DebugSingleShadowIndex = Shader.PropertyToID("_DebugSingleShadowIndex");
public static readonly int _DebugDepthPyramidMip = Shader.PropertyToID("_DebugDepthPyramidMip");
public static readonly int _DebugDepthPyramidOffsets = Shader.PropertyToID("_DebugDepthPyramidOffsets");
- public static readonly int _DebugLightingMaterialValidateHighColor = Shader.PropertyToID("_DebugLightingMaterialValidateHighColor");
- public static readonly int _DebugLightingMaterialValidateLowColor = Shader.PropertyToID("_DebugLightingMaterialValidateLowColor");
- public static readonly int _DebugLightingMaterialValidatePureMetalColor = Shader.PropertyToID("_DebugLightingMaterialValidatePureMetalColor");
- public static readonly int _DebugFullScreenMode = Shader.PropertyToID("_DebugFullScreenMode");
- public static readonly int _DebugTransparencyOverdrawWeight = Shader.PropertyToID("_DebugTransparencyOverdrawWeight");
public static readonly int _UseTileLightList = Shader.PropertyToID("_UseTileLightList");
@@ -261,22 +239,6 @@ static class HDShaderIDs
public static readonly int _WorldSpaceCameraPos1 = Shader.PropertyToID("_WorldSpaceCameraPos1");
public static readonly int _ViewMatrix1 = Shader.PropertyToID("_ViewMatrix1");
- // XR View Constants
- public static readonly int _XRViewMatrix = Shader.PropertyToID("_XRViewMatrix");
- public static readonly int _XRInvViewMatrix = Shader.PropertyToID("_XRInvViewMatrix");
- public static readonly int _XRProjMatrix = Shader.PropertyToID("_XRProjMatrix");
- public static readonly int _XRInvProjMatrix = Shader.PropertyToID("_XRInvProjMatrix");
- public static readonly int _XRViewProjMatrix = Shader.PropertyToID("_XRViewProjMatrix");
- public static readonly int _XRInvViewProjMatrix = Shader.PropertyToID("_XRInvViewProjMatrix");
- public static readonly int _XRNonJitteredViewProjMatrix = Shader.PropertyToID("_XRNonJitteredViewProjMatrix");
- public static readonly int _XRPrevViewProjMatrix = Shader.PropertyToID("_XRPrevViewProjMatrix");
- public static readonly int _XRPrevInvViewProjMatrix = Shader.PropertyToID("_XRPrevInvViewProjMatrix");
- public static readonly int _XRPrevViewProjMatrixNoCameraTrans = Shader.PropertyToID("_XRPrevViewProjMatrixNoCameraTrans");
- public static readonly int _XRPixelCoordToViewDirWS = Shader.PropertyToID("_XRPixelCoordToViewDirWS");
- public static readonly int _XRWorldSpaceCameraPos = Shader.PropertyToID("_XRWorldSpaceCameraPos");
- public static readonly int _XRWorldSpaceCameraPosViewOffset = Shader.PropertyToID("_XRWorldSpaceCameraPosViewOffset");
- public static readonly int _XRPrevWorldSpaceCameraPos = Shader.PropertyToID("_XRPrevWorldSpaceCameraPos");
-
public static readonly int _ColorTexture = Shader.PropertyToID("_ColorTexture");
public static readonly int _DepthTexture = Shader.PropertyToID("_DepthTexture");
public static readonly int _DepthValuesTexture = Shader.PropertyToID("_DepthValuesTexture");
@@ -327,31 +289,24 @@ static class HDShaderIDs
};
public static readonly int _ShaderVariablesGlobal = Shader.PropertyToID("ShaderVariablesGlobal");
+ public static readonly int _ShaderVariablesXR = Shader.PropertyToID("ShaderVariablesXR");
public static readonly int _ShaderVariablesVolumetric = Shader.PropertyToID("ShaderVariablesVolumetric");
public static readonly int _ShaderVariablesLightList = Shader.PropertyToID("ShaderVariablesLightList");
+ public static readonly int _ShaderVariablesDebugDisplay = Shader.PropertyToID("ShaderVariablesDebugDisplay");
public static readonly int _SSSBufferTexture = Shader.PropertyToID("_SSSBufferTexture");
public static readonly int _NormalBufferTexture = Shader.PropertyToID("_NormalBufferTexture");
public static readonly int _RaytracePrepassBufferTexture = Shader.PropertyToID("_RaytracePrepassBufferTexture");
- public static readonly int _SsrIterLimit = Shader.PropertyToID("_SsrIterLimit");
- public static readonly int _SsrThicknessScale = Shader.PropertyToID("_SsrThicknessScale");
- public static readonly int _SsrThicknessBias = Shader.PropertyToID("_SsrThicknessBias");
- public static readonly int _SsrRoughnessFadeEnd = Shader.PropertyToID("_SsrRoughnessFadeEnd");
- public static readonly int _SsrRoughnessFadeRcpLength = Shader.PropertyToID("_SsrRoughnessFadeRcpLength");
- public static readonly int _SsrRoughnessFadeEndTimesRcpLength = Shader.PropertyToID("_SsrRoughnessFadeEndTimesRcpLength");
- public static readonly int _SsrDepthPyramidMaxMip = Shader.PropertyToID("_SsrDepthPyramidMaxMip");
- public static readonly int _SsrColorPyramidMaxMip = Shader.PropertyToID("_SsrColorPyramidMaxMip");
- public static readonly int _SsrEdgeFadeRcpLength = Shader.PropertyToID("_SsrEdgeFadeRcpLength");
+ public static readonly int _ShaderVariablesScreenSpaceReflection = Shader.PropertyToID("ShaderVariablesScreenSpaceReflection");
public static readonly int _SsrLightingTexture = Shader.PropertyToID("_SsrLightingTexture");
public static readonly int _SsrLightingTextureRW = Shader.PropertyToID("_SsrLightingTextureRW");
public static readonly int _SsrHitPointTexture = Shader.PropertyToID("_SsrHitPointTexture");
public static readonly int _SsrClearCoatMaskTexture = Shader.PropertyToID("_SsrClearCoatMaskTexture");
- public static readonly int _SsrStencilBit = Shader.PropertyToID("_SsrStencilBit");
- public static readonly int _SsrReflectsSky = Shader.PropertyToID("_SsrReflectsSky");
-
public static readonly int _DepthPyramidMipLevelOffsets = Shader.PropertyToID("_DepthPyramidMipLevelOffsets");
+ // Still used by ray tracing.
+ public static readonly int _SsrStencilBit = Shader.PropertyToID("_SsrStencilBit");
public static readonly int _ShadowMaskTexture = Shader.PropertyToID("_ShadowMaskTexture");
public static readonly int _LightLayersTexture = Shader.PropertyToID("_LightLayersTexture");
@@ -792,18 +747,11 @@ static class HDShaderIDs
public static readonly int _LowResDepthTexture = Shader.PropertyToID("_LowResDepthTexture");
public static readonly int _LowResTransparent = Shader.PropertyToID("_LowResTransparent");
- public static readonly int _AOBufferSize = Shader.PropertyToID("_AOBufferSize");
- public static readonly int _AOParams0 = Shader.PropertyToID("_AOParams0");
- public static readonly int _AOParams1 = Shader.PropertyToID("_AOParams1");
- public static readonly int _AOParams2 = Shader.PropertyToID("_AOParams2");
- public static readonly int _AOParams3 = Shader.PropertyToID("_AOParams3");
- public static readonly int _AOParams4 = Shader.PropertyToID("_AOParams4");
- public static readonly int _FirstTwoDepthMipOffsets = Shader.PropertyToID("_FirstTwoDepthMipOffsets");
+ public static readonly int _ShaderVariablesAmbientOcclusion = Shader.PropertyToID("ShaderVariablesAmbientOcclusion");
public static readonly int _OcclusionTexture = Shader.PropertyToID("_OcclusionTexture");
public static readonly int _BentNormalsTexture = Shader.PropertyToID("_BentNormalsTexture");
public static readonly int _AOPackedData = Shader.PropertyToID("_AOPackedData");
public static readonly int _AOPackedHistory = Shader.PropertyToID("_AOPackedHistory");
- public static readonly int _AODepthToViewParams = Shader.PropertyToID("_AODepthToViewParams");
public static readonly int _AOPackedBlurred = Shader.PropertyToID("_AOPackedBlurred");
public static readonly int _AOOutputHistory = Shader.PropertyToID("_AOOutputHistory");
@@ -819,6 +767,8 @@ static class HDShaderIDs
// Probe Volumes
public static readonly int _ProbeVolumeAtlasSH = Shader.PropertyToID("_ProbeVolumeAtlasSH");
+ public static readonly int _ProbeVolumeAtlasResolutionAndSliceCount = Shader.PropertyToID("_ProbeVolumeAtlasResolutionAndSliceCount");
+ public static readonly int _ProbeVolumeAtlasResolutionAndSliceCountInverse = Shader.PropertyToID("_ProbeVolumeAtlasResolutionAndSliceCountInverse");
public static readonly int _ProbeVolumeAtlasOctahedralDepth = Shader.PropertyToID("_ProbeVolumeAtlasOctahedralDepth");
public static readonly int _ProbeVolumeResolution = Shader.PropertyToID("_ProbeVolumeResolution");
public static readonly int _ProbeVolumeResolutionInverse = Shader.PropertyToID("_ProbeVolumeResolutionInverse");
@@ -829,6 +779,7 @@ static class HDShaderIDs
public static readonly int _ProbeVolumeAtlasReadValidityBuffer = Shader.PropertyToID("_ProbeVolumeAtlasReadValidityBuffer");
public static readonly int _ProbeVolumeAtlasWriteTextureSH = Shader.PropertyToID("_ProbeVolumeAtlasWriteTextureSH");
public static readonly int _ProbeVolumeAtlasOctahedralDepthScaleBias = Shader.PropertyToID("_ProbeVolumeAtlasOctahedralDepthScaleBias");
+ public static readonly int _ProbeVolumeAtlasOctahedralDepthResolutionAndInverse = Shader.PropertyToID("_ProbeVolumeAtlasOctahedralDepthResolutionAndInverse");
public static readonly int _ProbeVolumeAtlasOctahedralDepthReadBufferCount = Shader.PropertyToID("_ProbeVolumeAtlasOctahedralDepthReadBufferCount");
public static readonly int _ProbeVolumeAtlasOctahedralDepthReadBuffer = Shader.PropertyToID("_ProbeVolumeAtlasOctahedralDepthReadBuffer");
public static readonly int _ProbeVolumeAtlasOctahedralDepthWriteTexture = Shader.PropertyToID("_ProbeVolumeAtlasOctahedralDepthWriteTexture");
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl
index daad559f332..ad576d1c074 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl
@@ -119,7 +119,7 @@ void Frag(PackedVaryingsToPS packedInput,
ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer);
#endif
-
+
// Same code in ShaderPassForwardUnlit.shader
// Reminder: _DebugViewMaterialArray[i]
@@ -129,7 +129,7 @@ void Frag(PackedVaryingsToPS packedInput,
// - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported)
// - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty)
bool viewMaterial = false;
- int bufferSize = int(_DebugViewMaterialArray[0]);
+ int bufferSize = _DebugViewMaterialArray[0].x;
if (bufferSize != 0)
{
bool needLinearToSRGB = false;
@@ -139,7 +139,7 @@ void Frag(PackedVaryingsToPS packedInput,
// Works because GetSurfaceDataDebug will do nothing if the index is not a known one
for (int index = 1; index <= bufferSize; index++)
{
- int indexMaterialProperty = int(_DebugViewMaterialArray[index]);
+ int indexMaterialProperty = _DebugViewMaterialArray[index].x;
// skip if not really in use
if (indexMaterialProperty != 0)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
index 43d8222d98e..8ceb9ecfaa5 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
@@ -58,12 +58,12 @@ float4 Frag(PackedVaryingsToPS packedInput) : SV_Target
// The index stored in this buffer could either be
// - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported)
// - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty)
- int bufferSize = int(_DebugViewMaterialArray[0]);
+ int bufferSize = _DebugViewMaterialArray[0].x;
// Loop through the whole buffer
// Works because GetSurfaceDataDebug will do nothing if the index is not a known one
for (int index = 1; index <= bufferSize; index++)
{
- int indexMaterialProperty = int(_DebugViewMaterialArray[index]);
+ int indexMaterialProperty = _DebugViewMaterialArray[index].x;
if (indexMaterialProperty != 0)
{
float3 result = float3(1.0, 0.0, 1.0);
@@ -74,7 +74,7 @@ float4 Frag(PackedVaryingsToPS packedInput) : SV_Target
GetBuiltinDataDebug(indexMaterialProperty, builtinData, posInput, result, needLinearToSRGB);
GetSurfaceDataDebug(indexMaterialProperty, surfaceData, result, needLinearToSRGB);
GetBSDFDataDebug(indexMaterialProperty, bsdfData, result, needLinearToSRGB);
-
+
// TEMP!
// For now, the final blit in the backbuffer performs an sRGB write
// So in the meantime we apply the inverse transform to linear data to compensate.
@@ -92,6 +92,6 @@ float4 Frag(PackedVaryingsToPS packedInput) : SV_Target
}
#endif
-
+
return outColor;
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
index b4dbadc6271..d8b7a0afe93 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl
@@ -149,26 +149,7 @@ SAMPLER(samplerunity_ProbeVolumeSH);
TEXTURE2D(_ExposureTexture);
TEXTURE2D(_PrevExposureTexture);
-// Custom generated by HDRP, not from Unity Engine (passed in via HDCamera)
-#if defined(USING_STEREO_MATRICES)
-GLOBAL_CBUFFER_START(UnityXRViewConstants, UNITY_XR_VIEW_CONSTANTS_CBUFFER_REGISTER)
- float4x4 _XRViewMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRInvViewMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRInvProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRViewProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRInvViewProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRNonJitteredViewProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRPrevViewProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRPrevInvViewProjMatrix[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRPrevViewProjMatrixNoCameraTrans[SHADEROPTIONS_XR_MAX_VIEWS];
- float4x4 _XRPixelCoordToViewDirWS[SHADEROPTIONS_XR_MAX_VIEWS];
-
- float4 _XRWorldSpaceCameraPos[SHADEROPTIONS_XR_MAX_VIEWS];
- float4 _XRWorldSpaceCameraPosViewOffset[SHADEROPTIONS_XR_MAX_VIEWS];
- float4 _XRPrevWorldSpaceCameraPos[SHADEROPTIONS_XR_MAX_VIEWS];
-CBUFFER_END
-#endif
+#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl"
// Note: To sample camera depth in HDRP we provide these utils functions because the way we store the depth mips can change
// Currently it's an atlas and it's layout can be found at ComputePackedMipChainInfo in HDUtils.cs
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs
index 294faf951ec..66f7b13cacd 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs
@@ -4,6 +4,8 @@ namespace UnityEngine.Rendering.HighDefinition
enum ConstantRegister
{
Global = 0,
+ XR = 1,
+ PBRSky = 2,
}
// We need to keep the number of different constant buffers low.
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl.meta
index b7628864641..31657d176f7 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl.meta
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl.meta
@@ -1,5 +1,9 @@
fileFormatVersion: 2
+<<<<<<< HEAD:com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ShaderVariablesAmbientOcclusion.cs.hlsl.meta
+guid: 76eeb935e3f2f6341a2ade96fccecc6c
+=======
guid: 6e0fdcd3c439283408fa825c454499a2
+>>>>>>> 8f57f3a16bc29eb6b6995b083fc3fc9a89e9ea88:com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl.meta
ShaderImporter:
externalObjects: {}
defaultTextures: []
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.hlsl
index 1571c0c7d0d..00c9dd5a040 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.hlsl
@@ -13,9 +13,6 @@
#endif
// Global Constant Buffers - b registers. Unity supports a maximum of 16 global constant buffers.
- // Common constant buffers
-#define UNITY_XR_VIEW_CONSTANTS_CBUFFER_REGISTER b1
-#define UNITY_PHYSICALLY_BASED_SKY_CBUFFER_REGISTER b2
// Ray tracing specific constant buffers
#define UNITY_RAY_TRACING_GLOBAL_CBUFFER_REGISTER b3
#define UNITY_RAY_TRACING_LIGHT_LOOP_CBUFFER_REGISTER b4
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs
new file mode 100644
index 00000000000..6898a2fbcc3
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs
@@ -0,0 +1,38 @@
+namespace UnityEngine.Rendering.HighDefinition
+{
+ // Custom generated by HDRP, not from Unity Engine (passed in via HDCamera)
+ [GenerateHLSL(needAccessors = false, generateCBuffer = true, constantRegister = (int)ConstantRegister.XR)]
+ unsafe struct ShaderVariablesXR
+ {
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRViewMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRInvViewMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRInvProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRInvViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRNonJitteredViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRPrevViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRPrevInvViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRPrevViewProjMatrixNoCameraTrans[(int)ShaderOptions.XrMaxViews * 16];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
+ public fixed float _XRPixelCoordToViewDirWS[(int)ShaderOptions.XrMaxViews * 16];
+
+
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Vector4))]
+ public fixed float _XRWorldSpaceCameraPos[(int)ShaderOptions.XrMaxViews * 4];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Vector4))]
+ public fixed float _XRWorldSpaceCameraPosViewOffset[(int)ShaderOptions.XrMaxViews * 4];
+ [HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Vector4))]
+ public fixed float _XRPrevWorldSpaceCameraPos[(int)ShaderOptions.XrMaxViews * 4];
+ }
+}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl
new file mode 100644
index 00000000000..7f27e8fe898
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl
@@ -0,0 +1,27 @@
+//
+// This file was automatically generated. Please don't edit by hand.
+//
+
+#ifndef SHADERVARIABLESXR_CS_HLSL
+#define SHADERVARIABLESXR_CS_HLSL
+// Generated from UnityEngine.Rendering.HighDefinition.ShaderVariablesXR
+// PackingRules = Exact
+GLOBAL_CBUFFER_START(ShaderVariablesXR, b1)
+ float4x4 _XRViewMatrix[2];
+ float4x4 _XRInvViewMatrix[2];
+ float4x4 _XRProjMatrix[2];
+ float4x4 _XRInvProjMatrix[2];
+ float4x4 _XRViewProjMatrix[2];
+ float4x4 _XRInvViewProjMatrix[2];
+ float4x4 _XRNonJitteredViewProjMatrix[2];
+ float4x4 _XRPrevViewProjMatrix[2];
+ float4x4 _XRPrevInvViewProjMatrix[2];
+ float4x4 _XRPrevViewProjMatrixNoCameraTrans[2];
+ float4x4 _XRPixelCoordToViewDirWS[2];
+ float4 _XRWorldSpaceCameraPos[2];
+ float4 _XRWorldSpaceCameraPosViewOffset[2];
+ float4 _XRPrevWorldSpaceCameraPos[2];
+CBUFFER_END
+
+
+#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl.meta
new file mode 100644
index 00000000000..88a2b30886b
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.hlsl.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: a70588104cdb44843bb61b8ad227c442
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ preprocessorOverride: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.meta
new file mode 100644
index 00000000000..b096f1df99e
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesXR.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 23ea53b0cd1fd7b4ab43203831612198
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl
index ce320e882c9..bdc2e64d12f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl
@@ -5,47 +5,8 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/VolumeRendering.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Sampling.hlsl"
-#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.hlsl"
-
-GLOBAL_CBUFFER_START(UnityPhysicallyBasedSky, UNITY_PHYSICALLY_BASED_SKY_CBUFFER_REGISTER)
- // All the distance-related entries use SI units (meter, 1/meter, etc).
- float _PlanetaryRadius;
- float _RcpPlanetaryRadius;
- float _AtmosphericDepth;
- float _RcpAtmosphericDepth;
-
- float _AtmosphericRadius;
- float _AerosolAnisotropy;
- float _AerosolPhasePartConstant;
- float _Unused;
-
- float _AirDensityFalloff;
- float _AirScaleHeight;
- float _AerosolDensityFalloff;
- float _AerosolScaleHeight;
-
- float3 _AirSeaLevelExtinction;
- float _AerosolSeaLevelExtinction;
-
- float3 _AirSeaLevelScattering;
- float _IntensityMultiplier;
-
- float3 _AerosolSeaLevelScattering;
- float _ColorSaturation;
-
- float3 _GroundAlbedo;
- float _AlphaSaturation;
-
- float3 _PlanetCenterPosition; // Not used during the precomputation, but needed to apply the atmospheric effect
- float _AlphaMultiplier;
-
- float3 _HorizonTint;
- float _HorizonZenithShiftPower;
-
- float3 _ZenithTint;
- float _HorizonZenithShiftScale;
-CBUFFER_END
+#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs.hlsl"
TEXTURE2D(_GroundIrradianceTexture);
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs
index a9f1a4b69e7..15cc2560985 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs
@@ -18,6 +18,47 @@ public enum PbrSkyConfig
InScatteredRadianceTableSizeW = 64, // ,
}
+ [GenerateHLSL(needAccessors = false, generateCBuffer = true, constantRegister = (int)ConstantRegister.PBRSky)]
+ unsafe struct ShaderVariablesPhysicallyBasedSky
+ {
+ // All the distance-related entries use SI units (meter, 1/meter, etc).
+ public float _PlanetaryRadius;
+ public float _RcpPlanetaryRadius;
+ public float _AtmosphericDepth;
+ public float _RcpAtmosphericDepth;
+
+ public float _AtmosphericRadius;
+ public float _AerosolAnisotropy;
+ public float _AerosolPhasePartConstant;
+ public float _Unused;
+
+ public float _AirDensityFalloff;
+ public float _AirScaleHeight;
+ public float _AerosolDensityFalloff;
+ public float _AerosolScaleHeight;
+
+ public Vector3 _AirSeaLevelExtinction;
+ public float _AerosolSeaLevelExtinction;
+
+ public Vector3 _AirSeaLevelScattering;
+ public float _IntensityMultiplier;
+
+ public Vector3 _AerosolSeaLevelScattering;
+ public float _ColorSaturation;
+
+ public Vector3 _GroundAlbedo;
+ public float _AlphaSaturation;
+
+ public Vector3 _PlanetCenterPosition; // Not used during the precomputation, but needed to apply the atmospheric effect
+ public float _AlphaMultiplier;
+
+ public Vector3 _HorizonTint;
+ public float _HorizonZenithShiftPower;
+
+ public Vector3 _ZenithTint;
+ public float _HorizonZenithShiftScale;
+ }
+
// Store the hash of the parameters each time precomputation is done.
// If the hash does not match, we must recompute our data.
int m_LastPrecomputationParamHash;
@@ -35,6 +76,9 @@ public enum PbrSkyConfig
static Material s_PbrSkyMaterial;
static MaterialPropertyBlock s_PbrSkyMaterialProperties;
+ ShaderVariablesPhysicallyBasedSky m_ConstantBuffer;
+ int m_ShaderVariablesPhysicallyBasedSkyID = Shader.PropertyToID("ShaderVariablesPhysicallyBasedSky");
+
static GraphicsFormat s_ColorFormat = GraphicsFormat.R16G16B16A16_SFloat;
RTHandle AllocateGroundIrradianceTable(int index)
@@ -160,40 +204,46 @@ void UpdateGlobalConstantBuffer(CommandBuffer cmd, BuiltinSkyParameters builtinP
Vector2 expParams = ComputeExponentialInterpolationParams(pbrSky.horizonZenithShift.value);
- cmd.SetGlobalFloat( HDShaderIDs._PlanetaryRadius, R);
- cmd.SetGlobalFloat( HDShaderIDs._RcpPlanetaryRadius, 1.0f / R);
- cmd.SetGlobalFloat( HDShaderIDs._AtmosphericDepth, D);
- cmd.SetGlobalFloat( HDShaderIDs._RcpAtmosphericDepth, 1.0f / D);
+ m_ConstantBuffer._PlanetaryRadius = R;
+ m_ConstantBuffer._RcpPlanetaryRadius = 1.0f / R;
+ m_ConstantBuffer._AtmosphericDepth = D;
+ m_ConstantBuffer._RcpAtmosphericDepth = 1.0f / D;
+
+ m_ConstantBuffer._AtmosphericRadius = R + D;
+ m_ConstantBuffer._AerosolAnisotropy = pbrSky.aerosolAnisotropy.value;
+ m_ConstantBuffer._AerosolPhasePartConstant = CornetteShanksPhasePartConstant(pbrSky.aerosolAnisotropy.value);
+ m_ConstantBuffer._Unused = 0.0f; // Warning fix
- cmd.SetGlobalFloat( HDShaderIDs._AtmosphericRadius, R + D);
- cmd.SetGlobalFloat( HDShaderIDs._AerosolAnisotropy, pbrSky.aerosolAnisotropy.value);
- cmd.SetGlobalFloat( HDShaderIDs._AerosolPhasePartConstant, CornetteShanksPhasePartConstant(pbrSky.aerosolAnisotropy.value));
+ m_ConstantBuffer._AirDensityFalloff = 1.0f / airH;
+ m_ConstantBuffer._AirScaleHeight = airH;
+ m_ConstantBuffer._AerosolDensityFalloff = 1.0f / aerH;
+ m_ConstantBuffer._AerosolScaleHeight = aerH;
- cmd.SetGlobalFloat( HDShaderIDs._AirDensityFalloff, 1.0f / airH);
- cmd.SetGlobalFloat( HDShaderIDs._AirScaleHeight, airH);
- cmd.SetGlobalFloat( HDShaderIDs._AerosolDensityFalloff, 1.0f / aerH);
- cmd.SetGlobalFloat( HDShaderIDs._AerosolScaleHeight, aerH);
+ m_ConstantBuffer._AirSeaLevelExtinction = pbrSky.GetAirExtinctionCoefficient();
+ m_ConstantBuffer._AerosolSeaLevelExtinction = pbrSky.GetAerosolExtinctionCoefficient();
- cmd.SetGlobalVector(HDShaderIDs._AirSeaLevelExtinction, pbrSky.GetAirExtinctionCoefficient());
- cmd.SetGlobalFloat( HDShaderIDs._AerosolSeaLevelExtinction, pbrSky.GetAerosolExtinctionCoefficient());
+ m_ConstantBuffer._AirSeaLevelScattering = pbrSky.GetAirScatteringCoefficient();
+ m_ConstantBuffer._IntensityMultiplier = iMul;
- cmd.SetGlobalVector(HDShaderIDs._AirSeaLevelScattering, pbrSky.GetAirScatteringCoefficient());
- cmd.SetGlobalFloat( HDShaderIDs._IntensityMultiplier, iMul);
+ m_ConstantBuffer._AerosolSeaLevelScattering = pbrSky.GetAerosolScatteringCoefficient();
+ m_ConstantBuffer._ColorSaturation = pbrSky.colorSaturation.value;
- cmd.SetGlobalVector(HDShaderIDs._AerosolSeaLevelScattering, pbrSky.GetAerosolScatteringCoefficient());
- cmd.SetGlobalFloat( HDShaderIDs._ColorSaturation, pbrSky.colorSaturation.value);
+ Vector3 groundAlbedo = new Vector3(pbrSky.groundTint.value.r, pbrSky.groundTint.value.g, pbrSky.groundTint.value.b);
+ m_ConstantBuffer._GroundAlbedo = groundAlbedo;
+ m_ConstantBuffer._AlphaSaturation = pbrSky.alphaSaturation.value;
- cmd.SetGlobalVector(HDShaderIDs._GroundAlbedo, pbrSky.groundTint.value);
- cmd.SetGlobalFloat( HDShaderIDs._AlphaSaturation, pbrSky.alphaSaturation.value);
+ m_ConstantBuffer._PlanetCenterPosition = pbrSky.GetPlanetCenterPosition(builtinParams.worldSpaceCameraPos);
+ m_ConstantBuffer._AlphaMultiplier = pbrSky.alphaMultiplier.value;
- cmd.SetGlobalVector(HDShaderIDs._PlanetCenterPosition, pbrSky.GetPlanetCenterPosition(builtinParams.worldSpaceCameraPos));
- cmd.SetGlobalFloat( HDShaderIDs._AlphaMultiplier, pbrSky.alphaMultiplier.value);
+ Vector3 horizonTint = new Vector3(pbrSky.horizonTint.value.r, pbrSky.horizonTint.value.g, pbrSky.horizonTint.value.b);
+ m_ConstantBuffer._HorizonTint = horizonTint;
+ m_ConstantBuffer._HorizonZenithShiftPower = expParams.x;
- cmd.SetGlobalVector(HDShaderIDs._HorizonTint, pbrSky.horizonTint.value);
- cmd.SetGlobalFloat( HDShaderIDs._HorizonZenithShiftPower, expParams.x);
+ Vector3 zenithTint = new Vector3(pbrSky.zenithTint.value.r, pbrSky.zenithTint.value.g, pbrSky.zenithTint.value.b);
+ m_ConstantBuffer._ZenithTint = zenithTint;
+ m_ConstantBuffer._HorizonZenithShiftScale = expParams.y;
- cmd.SetGlobalVector(HDShaderIDs._ZenithTint, pbrSky.zenithTint.value);
- cmd.SetGlobalFloat( HDShaderIDs._HorizonZenithShiftScale, expParams.y);
+ ConstantBuffer.PushGlobal(cmd, m_ConstantBuffer, m_ShaderVariablesPhysicallyBasedSkyID);
}
void PrecomputeTables(CommandBuffer cmd)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs.hlsl
index bc68e702d48..69644bc7a6a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs.hlsl
@@ -13,5 +13,36 @@
#define PBRSKYCONFIG_IN_SCATTERED_RADIANCE_TABLE_SIZE_Z (16)
#define PBRSKYCONFIG_IN_SCATTERED_RADIANCE_TABLE_SIZE_W (64)
+// Generated from UnityEngine.Rendering.HighDefinition.PhysicallyBasedSkyRenderer+ShaderVariablesPhysicallyBasedSky
+// PackingRules = Exact
+GLOBAL_CBUFFER_START(ShaderVariablesPhysicallyBasedSky, b2)
+ float _PlanetaryRadius;
+ float _RcpPlanetaryRadius;
+ float _AtmosphericDepth;
+ float _RcpAtmosphericDepth;
+ float _AtmosphericRadius;
+ float _AerosolAnisotropy;
+ float _AerosolPhasePartConstant;
+ float _Unused;
+ float _AirDensityFalloff;
+ float _AirScaleHeight;
+ float _AerosolDensityFalloff;
+ float _AerosolScaleHeight;
+ float3 _AirSeaLevelExtinction;
+ float _AerosolSeaLevelExtinction;
+ float3 _AirSeaLevelScattering;
+ float _IntensityMultiplier;
+ float3 _AerosolSeaLevelScattering;
+ float _ColorSaturation;
+ float3 _GroundAlbedo;
+ float _AlphaSaturation;
+ float3 _PlanetCenterPosition;
+ float _AlphaMultiplier;
+ float3 _HorizonTint;
+ float _HorizonZenithShiftPower;
+ float3 _ZenithTint;
+ float _HorizonZenithShiftScale;
+CBUFFER_END
+
#endif
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 7e780d317e2..de6b404b536 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs
@@ -230,7 +230,7 @@ public void UpdateCurrentSkySettings(HDCamera hdCamera)
hdCamera.UpdateCurrentSky(this);
}
- public void SetGlobalSkyData(CommandBuffer cmd, HDCamera hdCamera)
+ void SetGlobalSkyData(CommandBuffer cmd, HDCamera hdCamera)
{
if (IsCachedContextValid(hdCamera.lightingSky))
{
@@ -811,6 +811,8 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC
m_UpdateRequired = false;
+ SetGlobalSkyData(cmd, hdCamera);
+
var reflectionTexture = GetReflectionTexture(hdCamera.lightingSky);
cmd.SetGlobalTexture(HDShaderIDs._SkyTexture, reflectionTexture);
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl
index 1800f255452..fe43e6555a6 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl
@@ -41,12 +41,12 @@ float4 VFXCalcPixelOutputForward(const SurfaceData surfaceData, const BuiltinDat
// The index stored in this buffer could either be
// - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported)
// - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty)
- int bufferSize = int(_DebugViewMaterialArray[0]);
+ int bufferSize = _DebugViewMaterialArray[0].x;
// Loop through the whole buffer
// Works because GetSurfaceDataDebug will do nothing if the index is not a known one
for (int index = 1; index <= bufferSize; index++)
{
- int indexMaterialProperty = int(_DebugViewMaterialArray[index]);
+ int indexMaterialProperty = _DebugViewMaterialArray[index].x;
if (indexMaterialProperty != 0)
{
float3 result = float3(1.0, 0.0, 1.0);
@@ -89,14 +89,14 @@ float4 VFXGetPixelOutputForward(const VFX_VARYING_PS_INPUTS i, float3 normalWS,
uint2 tileIndex = uint2(i.VFX_VARYING_POSCS.xy) / GetTileSize();
VFXGetHDRPLitData(surfaceData,builtinData,bsdfData,preLightData,i,normalWS,uvData,tileIndex);
-
+
float3 posRWS = VFXGetPositionRWS(i);
PositionInputs posInput = GetPositionInput(i.VFX_VARYING_POSCS.xy, _ScreenSize.zw, i.VFX_VARYING_POSCS.z, i.VFX_VARYING_POSCS.w, posRWS, tileIndex);
-
+
return VFXCalcPixelOutputForward(surfaceData,builtinData,preLightData, bsdfData, posInput, posRWS);
}
-
+
#else
@@ -108,19 +108,19 @@ float4 VFXGetPixelOutputForwardShaderGraph(SurfaceData surfaceData, BuiltinData
float3 posRWS = VFXGetPositionRWS(i);
float4 posSS = i.VFX_VARYING_POSCS;
PositionInputs posInput = GetPositionInput(posSS.xy, _ScreenSize.zw, posSS.z, posSS.w, posRWS, tileIndex);
-
+
PreLightData preLightData = (PreLightData)0;
BSDFData bsdfData = (BSDFData)0;
bsdfData = ConvertSurfaceDataToBSDFData(posSS.xy, surfaceData);
-
+
preLightData = GetPreLightData(GetWorldSpaceNormalizeViewDir(posRWS),posInput,bsdfData);
preLightData.diffuseFGD = 1.0f;
-
+
float3 emissive = builtinData.emissiveColor;
InitBuiltinData(posInput, builtinData.opacity, surfaceData.normalWS, -surfaceData.normalWS, (float4)0, (float4)0, builtinData);
builtinData.emissiveColor = emissive;
PostInitBuiltinData(GetWorldSpaceNormalizeViewDir(posInput.positionWS), posInput,surfaceData, builtinData);
-
+
return VFXCalcPixelOutputForward(surfaceData,builtinData,preLightData, bsdfData, posInput, posRWS);
}
#endif
@@ -157,4 +157,4 @@ void VFXSetupBuiltin(inout BuiltinData builtin,SurfaceData surface,float3 emissi
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), i.VFX_VARYING_POSCS, outNormalBuffer); \
}
-#endif
\ No newline at end of file
+#endif