diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 3f579ce945d..f289ff230cf 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -736,6 +736,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with duplicate names in newly created sub-layers in the graphics compositor (case 1263093).
- Remove MSAA debug mode when renderpipeline asset has no MSAA
- Fixed some post processing using motion vectors when they are disabled
+- Fixed the multiplier of the environement lights being overriden with a wrong value for ray tracing (1260311).
### Changed
- Improve MIP selection for decals on Transparents
@@ -898,6 +899,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Shutter speed can now be changed by dragging the mouse over the UI label (case 1245007).
- Remove the 'Point Cube Size' for cookie, use the Cubemap size directly.
- Only building the RTAS if there is an effect that will require it (1262217).
+- Fixed the first ray tracing frame not having the light cluster being set up properly (1260311).
## [7.1.1] - 2019-09-05
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md
index 312dcabc21f..4363782dd08 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md
@@ -183,11 +183,12 @@ The PCF algorithm applies a fixed size blur. PCSS applies a different blur size
Use these settings to enable or disable settings relating to lighting in HDRP.
-| **Property** | **Description** |
-| --------------------------------- | ------------------------------------------------------------ |
-| **Maximum Directional On Screen** | The maximum number of Directional Lights HDRP can manage on screen at once. |
-| **Maximum Punctual On Screen** | The maximum number of [Point and Spot Lights](Glossary.html#PunctualLight) HDRP can manage on screen at once. |
-| **Maximum Area On Screen** | The maximum number of area Lights HDRP can manage on screen at once. |
+| **Property** | **Description** |
+| ----------------------------------------- | ------------------------------------------------------------ |
+| **Maximum Directional On Screen** | The maximum number of Directional Lights HDRP can manage on screen at once. |
+| **Maximum Punctual On Screen** | The maximum number of [Point and Spot Lights](Glossary.html#PunctualLight) HDRP can manage on screen at once. |
+| **Maximum Area On Screen** | The maximum number of area Lights HDRP can manage on screen at once. |
+| **Maximum Lights Per Cell (Ray Tracing)** | The maximum number of Lights that an individual grid cell in a [Light Cluster](Ray-Tracing-Light-Cluster.md) can store. |
## Material
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Light-Cluster.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Light-Cluster.md
index dcccec16d01..8d66d99172f 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Light-Cluster.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Light-Cluster.md
@@ -16,8 +16,7 @@ For ray tracing, HDRP builds an axis-aligned grid which, in each cell, stores th
## Properties
-| **Property** | **Description** |
-| --------------------------- | ------------------------------------------------------------ |
-| **Maximum Lights Per Cell** | Sets the maximum number of Lights that an individual cell can store. |
-| **Camera Cluster Range** | Sets the range of the cluster grid. The cluster grid itself has its center on the Camera's position and extends in all directions because an intersection may occur outside of the Camera frustum. |
+| **Property** | **Description** |
+| ------------------------ | ------------------------------------------------------------ |
+| **Camera Cluster Range** | The range of the cluster grid. The cluster grid itself has its center on the Camera's position and extends in all directions because an intersection may occur outside of the Camera frustum. |
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
index fbe26589dc7..4591cd5cf67 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
@@ -170,6 +170,7 @@ public class GeneralSection
public static readonly GUIContent maxAreaContent = EditorGUIUtility.TrTextContent("Maximum Area on Screen", "Sets the maximum number of area Lights HDRP can handle on screen at once.");
public static readonly GUIContent maxEnvContent = EditorGUIUtility.TrTextContent("Maximum Reflection Probes on Screen", "Sets the maximum number of Planar and Reflection Probes HDRP can handle on screen at once.");
public static readonly GUIContent maxDecalContent = EditorGUIUtility.TrTextContent("Maximum Clustered Decals on Screen", "Sets the maximum number of decals that can affect transparent GameObjects on screen.");
+ public static readonly GUIContent maxLightPerCellContent = EditorGUIUtility.TrTextContent("Maximum Lights per Cell (Ray Tracing)", "Sets the maximum number of lights HDRP can handle in each cell of the ray tracing light cluster.");
public static readonly GUIContent resolutionContent = EditorGUIUtility.TrTextContent("Resolution", "Specifies the resolution of the shadow Atlas.");
public static readonly GUIContent cachedShadowAtlasResolution = EditorGUIUtility.TrTextContent("Cached Shadow Atlas Resolution", "Specifies the resolution of the shadow Atlas that contains the cached shadow maps.");
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
index b9c0361d084..3fee70ab462 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
@@ -473,6 +473,11 @@ static void Drawer_SectionLightLoop(SerializedHDRenderPipelineAsset serialized,
EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.maxAreaLightsOnScreen, Styles.maxAreaContent);
if (EditorGUI.EndChangeCheck())
serialized.renderPipelineSettings.lightLoopSettings.maxAreaLightsOnScreen.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.maxAreaLightsOnScreen.intValue, 1, HDRenderPipeline.k_MaxAreaLightsOnScreen);
+
+ EditorGUI.BeginChangeCheck();
+ EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell, Styles.maxLightPerCellContent);
+ if (EditorGUI.EndChangeCheck())
+ serialized.renderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell.intValue, 1, HDRenderPipeline.k_MaxLightsPerClusterCell);
}
static void Drawer_SectionDynamicResolutionSettings(SerializedHDRenderPipelineAsset serialized, Editor owner)
diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs
index 28ac5734030..32694a101e0 100644
--- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedGlobalLightLoopSettings.cs
@@ -27,6 +27,7 @@ class SerializedGlobalLightLoopSettings
public SerializedProperty maxEnvLightsOnScreen;
public SerializedProperty maxDecalsOnScreen;
public SerializedProperty maxPlanarReflectionOnScreen;
+ public SerializedProperty maxLightsPerClusterCell;
public SerializedGlobalLightLoopSettings(SerializedProperty root)
{
@@ -56,6 +57,7 @@ public SerializedGlobalLightLoopSettings(SerializedProperty root)
maxEnvLightsOnScreen = root.Find((GlobalLightLoopSettings s) => s.maxEnvLightsOnScreen);
maxDecalsOnScreen = root.Find((GlobalLightLoopSettings s) => s.maxDecalsOnScreen);
maxPlanarReflectionOnScreen = root.Find((GlobalLightLoopSettings s) => s.maxPlanarReflectionOnScreen);
+ maxLightsPerClusterCell = root.Find((GlobalLightLoopSettings s) => s.maxLightsPerClusterCell);
}
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs
index a644fae0248..2324e7d6c3d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/GlobalLightLoopSettings.cs
@@ -134,6 +134,7 @@ public struct GlobalLightLoopSettings
maxEnvLightsOnScreen = 64,
maxDecalsOnScreen = 512,
maxPlanarReflectionOnScreen = 16,
+ maxLightsPerClusterCell = 8,
};
/// Cookie atlas resolution.
@@ -181,5 +182,7 @@ public struct GlobalLightLoopSettings
public int maxDecalsOnScreen;
/// Maximum number of planar reflections at the same time on screen.
public int maxPlanarReflectionOnScreen;
+ /// Maximum number of lights per ray tracing light cluster cell.
+ public int maxLightsPerClusterCell;
}
}
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 6704448b584..a2274068dd9 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
@@ -265,6 +265,7 @@ public partial class HDRenderPipeline
internal const int k_MaxDecalsOnScreen = 2048;
internal const int k_MaxLightsOnScreen = k_MaxDirectionalLightsOnScreen + k_MaxPunctualLightsOnScreen + k_MaxAreaLightsOnScreen + k_MaxEnvLightsOnScreen;
internal const int k_MaxEnvLightsOnScreen = 1024;
+ internal const int k_MaxLightsPerClusterCell = 24;
internal static readonly Vector3 k_BoxCullingExtentThreshold = Vector3.one * 0.01f;
#if UNITY_SWITCH
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs
index 3f2bf953156..1a85efe29e7 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs
@@ -58,7 +58,11 @@ internal class HDRaytracingLightCluster
public static readonly int _ClusterCenterPosition = Shader.PropertyToID("_ClusterCenterPosition");
public static readonly int _ClusterDimension = Shader.PropertyToID("_ClusterDimension");
- // Temporary variables
+ // Temporary variables
+ // This value is now fixed for every HDRP asset
+ int m_NumLightsPerCell = 0;
+
+ // These values are overriden for every light cluster that is built
Vector3 minClusterPos = new Vector3(0.0f, 0.0f, 0.0f);
Vector3 maxClusterPos = new Vector3(0.0f, 0.0f, 0.0f);
Vector3 clusterCellSize = new Vector3(0.0f, 0.0f, 0.0f);
@@ -68,7 +72,6 @@ internal class HDRaytracingLightCluster
int areaLightCount = 0;
int envLightCount = 0;
int totalLightCount = 0;
- int numLightsPerCell = 0;
Bounds bounds = new Bounds();
Vector3 minBounds = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
Vector3 maxBounds = new Vector3(-float.MaxValue, -float.MaxValue, -float.MaxValue);
@@ -98,6 +101,11 @@ public void Initialize(HDRenderPipeline renderPipeline)
m_LightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightData)));
m_EnvLightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));
+ // Allocate the light cluster buffer at the right size
+ m_NumLightsPerCell = renderPipeline.asset.currentPlatformRenderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell;
+ int bufferSize = 64 * 64 * 32 * (renderPipeline.asset.currentPlatformRenderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell + 4);
+ ResizeClusterBuffer(bufferSize);
+
// Create the material required for debug
m_DebugMaterial = CoreUtils.CreateEngineMaterial(m_RenderPipelineRayTracingResources.lightClusterDebugS);
}
@@ -434,16 +442,6 @@ void BuildLightCluster(HDCamera hdCamera, CommandBuffer cmd)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RaytracingBuildCluster)))
{
- var lightClusterSettings = hdCamera.volumeStack.GetComponent();
- numLightsPerCell = lightClusterSettings.maxNumLightsPercell.value;
-
- // Make sure the Cluster buffer has the right size
- int bufferSize = 64 * 64 * 32 * (numLightsPerCell + 4);
- if (m_LightCluster.count != bufferSize)
- {
- ResizeClusterBuffer(bufferSize);
- }
-
// Grab the kernel
ComputeShader lightClusterCS = m_RenderPipelineRayTracingResources.lightClusterBuildCS;
int lightClusterKernel = lightClusterCS.FindKernel(m_LightClusterKernelName);
@@ -691,7 +689,7 @@ public int GetEnvLightCount()
public int GetLightPerCellCount()
{
- return numLightsPerCell;
+ return m_NumLightsPerCell;
}
void InvalidateCluster()
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
index bd5c5bd63b6..81ec4d72ab2 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/LightCluster.cs
@@ -8,12 +8,6 @@ namespace UnityEngine.Rendering.HighDefinition
[Serializable, VolumeComponentMenu("Ray Tracing/Light Cluster (Preview)")]
public sealed class LightCluster : VolumeComponent
{
- ///
- /// Controls the maximal number lights in a cell.
- ///
- [Tooltip("Controls the maximal number lights in a cell.")]
- public ClampedIntParameter maxNumLightsPercell = new ClampedIntParameter(10, 0, 24);
-
///
/// Controls the range of the cluster around the camera.
///
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute
index 9e77ffee38b..d493f5a3758 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute
@@ -93,7 +93,7 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro
// Evaluate the complete lighting
LightLoopOutput lightLoopOutput;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), lightLoopOutput);
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, 0.0, 1.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), lightLoopOutput);
// Alias
float3 diffuseLighting = lightLoopOutput.diffuseLighting;
@@ -183,7 +183,7 @@ void RaytracingDiffuseDeferred(uint3 dispatchThreadId : SV_DispatchThreadID, uin
// Evaluate lighting
LightLoopOutput lightLoopOutput;
- LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), lightLoopOutput);
+ LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, 0.0, 1.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), lightLoopOutput);
// Alias
float3 diffuseLighting = lightLoopOutput.diffuseLighting;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl
index ee4571c145f..745d5075edc 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl
@@ -119,7 +119,6 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS
#else
EnvLightData envLightData = _EnvLightDatasRT[envLightIdx];
#endif
- envLightData.multiplier = _EnvLightDatas[envLightIdx].multiplier;
if (reflectionHierarchyWeight < 1.0)
{