diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index f6b67b27719..984c1782d0a 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -88,6 +88,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added support for fog attenuation in path tracing.
- Added a new debug panel for volumes
- Added XR setting to control camera jitter for temporal effects
+- Added Light decomposition lighting debugging modes
- Added an error message in the DrawRenderers custom pass when rendering opaque objects with an HDRP asset in DeferredOnly mode.
- Added API to enable proper recording of path traced scenes (with the Unity recorder or other tools).
- Added support for fog in Recursive rendering, ray traced reflections and ray traced indirect diffuse.
@@ -103,6 +104,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added a frame setting for alpha to mask.
- Added support for custom passes in the AOV API
+
### Fixed
- Fix when rescale probe all direction below zero (1219246)
- Update documentation of HDRISky-Backplate, precise how to have Ambient Occlusion on the Backplate
diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md b/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md
index 0c096b682d9..87ca0cde012 100644
--- a/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md
+++ b/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md
@@ -115,7 +115,7 @@ The **Lighting** panel has tools that you can use to visualize various component
| **- Punctual Lights** | Enable the checkbox to see [Punctual Lights](Glossary.html#PunctualLight) in your Scene. Disable this checkbox to remove Punctual Lights from your Scene's lighting. |
| **- Area Lights** | Enable the checkbox to see Area Lights in your Scene. Disable this checkbox to remove Aera Lights from your Scene's lighting. |
| **- Reflection Probes** | Enable the checkbox to see Reflection Probes in your Scene. Disable this checkbox to remove Reflection Probes from your Scene's lighting. |
-| **Debug Mode** | Use the drop-down to select a lighting mode to debug. For example, you can visualize diffuse lighting, specular lighting, and Directional Light shadow cascades. |
+| **Debug Mode** | Use the drop-down to select a lighting mode to debug. For example, you can visualize diffuse lighting, specular lighting, direct diffuse lighting, direct specular lighting, indirect diffuse lighting, reflection, refraction, transmittance, emissive and Directional Light shadow cascades. |
| **Hierarchy Debug Mode** | Use the drop-down to select a light type to show the direct lighting for or a Reflection Probe type to show the indirect lighting for. |
| **Light Layers Visualization** | Enable the checkbox to visualize light layers of objects in your Scene. |
| **- Use Selected Light** | Enable the checkbox to visualize objects affected by the selected light. |
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..1148fbf876c 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
@@ -567,6 +567,24 @@ public void SetDebugLightingMode(DebugLightingMode value)
data.mipMapDebugSettings.debugMipMapMode = DebugMipMapMode.None;
data.lightingDebugSettings.debugLightLayers = false;
}
+ if (value == DebugLightingMode.Emissive || value == DebugLightingMode.IndirectDiffuse)
+ {
+ HDRenderPipelineAsset hdrpAsset = (HDRenderPipelineAsset)GraphicsSettings.renderPipelineAsset;
+ if (hdrpAsset.currentPlatformRenderPipelineSettings.supportedLitShaderMode != RenderPipelineSettings.SupportedLitShaderMode.ForwardOnly)
+ {
+ Debug.LogWarning("Beware DebugLightingMode.Emissive/DebugLightingMode.IndirectDiffuse is only correct when in forward-only mode");
+ }
+ }
+
+ if (value == DebugLightingMode.Refraction || value == DebugLightingMode.Transmittance)
+ {
+ HDRenderPipelineAsset hdrpAsset = (HDRenderPipelineAsset)GraphicsSettings.renderPipelineAsset;
+ if (hdrpAsset.currentPlatformRenderPipelineSettings.supportedLitShaderMode != RenderPipelineSettings.SupportedLitShaderMode.ForwardOnly)
+ {
+ Debug.LogWarning("Beware DebugLightingMode.Refraction/DebugLightingMode.Transmittance is only correct when in forward-only mode");
+ }
+ }
+
data.lightingDebugSettings.debugLightingMode = value;
}
@@ -1538,7 +1556,8 @@ internal bool DebugNeedsExposure()
DebugLightingMode debugLighting = data.lightingDebugSettings.debugLightingMode;
DebugViewGbuffer debugGBuffer = (DebugViewGbuffer)data.materialDebugSettings.debugViewGBuffer;
ProbeVolumeDebugMode debugProbeVolume = data.lightingDebugSettings.probeVolumeDebugMode;
- return (debugLighting == DebugLightingMode.DiffuseLighting || debugLighting == DebugLightingMode.SpecularLighting || debugLighting == DebugLightingMode.VisualizeCascade) ||
+
+ return (debugLighting == DebugLightingMode.DirectDiffuse || debugLighting == DebugLightingMode.DirectSpecular || debugLighting == DebugLightingMode.IndirectDiffuse || debugLighting == DebugLightingMode.Reflection || debugLighting == DebugLightingMode.Refraction ||debugLighting == DebugLightingMode.DiffuseLighting || debugLighting == DebugLightingMode.SpecularLighting || debugLighting == DebugLightingMode.VisualizeCascade) ||
(data.lightingDebugSettings.overrideAlbedo || data.lightingDebugSettings.overrideNormal || data.lightingDebugSettings.overrideSmoothness || data.lightingDebugSettings.overrideSpecularColor || data.lightingDebugSettings.overrideEmissiveColor || data.lightingDebugSettings.overrideAmbientOcclusion) ||
(debugGBuffer == DebugViewGbuffer.BakeDiffuseLightingWithAlbedoPlusEmissive) || (data.lightingDebugSettings.debugLightFilterMode != DebugLightFilterMode.None) ||
(data.fullScreenDebugMode == FullScreenDebugMode.PreRefractionColorPyramid || data.fullScreenDebugMode == FullScreenDebugMode.FinalColorPyramid || data.fullScreenDebugMode == FullScreenDebugMode.ScreenSpaceReflections || data.fullScreenDebugMode == FullScreenDebugMode.LightCluster || data.fullScreenDebugMode == FullScreenDebugMode.ScreenSpaceShadows || data.fullScreenDebugMode == FullScreenDebugMode.NanTracker || data.fullScreenDebugMode == FullScreenDebugMode.ColorLog) || data.fullScreenDebugMode == FullScreenDebugMode.RayTracedGlobalIllumination ||
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs
index 08aa41e819b..b4ea51f1c9f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs
@@ -29,7 +29,21 @@ public enum DebugLightingMode
/// Display indirect specular occlusion.
IndirectSpecularOcclusion,
/// Display Probe Volumes.
- ProbeVolume
+ ProbeVolume,
+ /// Display only direct diffuse lighting.
+ DirectDiffuse,
+ /// Display only direct specular lighting.
+ DirectSpecular,
+ /// Display only indirect diffuse lighting.
+ IndirectDiffuse,
+ /// Display only reflection lighting.
+ Reflection,
+ /// Display only refraction lighting.
+ Refraction,
+ /// Display only Transmittance lighting.
+ Transmittance,
+ /// Display only Emissive lighting.
+ Emissive
}
///
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl
index 264d00600ca..8241888af0d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl
@@ -18,6 +18,13 @@
#define DEBUGLIGHTINGMODE_INDIRECT_DIFFUSE_OCCLUSION (8)
#define DEBUGLIGHTINGMODE_INDIRECT_SPECULAR_OCCLUSION (9)
#define DEBUGLIGHTINGMODE_PROBE_VOLUME (10)
+#define DEBUGLIGHTINGMODE_DIRECT_DIFFUSE (11)
+#define DEBUGLIGHTINGMODE_DIRECT_SPECULAR (12)
+#define DEBUGLIGHTINGMODE_INDIRECT_DIFFUSE (13)
+#define DEBUGLIGHTINGMODE_REFLECTION (14)
+#define DEBUGLIGHTINGMODE_REFRACTION (15)
+#define DEBUGLIGHTINGMODE_TRANSMITTANCE (16)
+#define DEBUGLIGHTINGMODE_EMISSIVE (17)
//
// UnityEngine.Rendering.HighDefinition.DebugLightFilterMode: static fields
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader
index abe02eecc79..07f5de7ff76 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader
@@ -137,7 +137,13 @@ Shader "Hidden/HDRP/Deferred"
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, diffuseLighting, specularLighting, decomposedLighting);
+
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
diffuseLighting *= GetCurrentExposureMultiplier();
specularLighting *= GetCurrentExposureMultiplier();
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute
index 548dda5ee1c..b1a1ee62cb8 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute
@@ -165,7 +165,13 @@ void SHADE_OPAQUE_ENTRY(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 grou
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting, decomposedLighting);
+
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
diffuseLighting *= GetCurrentExposureMultiplier();
specularLighting *= GetCurrentExposureMultiplier();
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader
index bc68896e4f4..854e4538217 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader
@@ -244,7 +244,13 @@ Shader "Hidden/HDRP/DeferredTile"
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting, decomposedLighting);
+
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
diffuseLighting *= GetCurrentExposureMultiplier();
specularLighting *= GetCurrentExposureMultiplier();
@@ -405,7 +411,13 @@ Shader "Hidden/HDRP/DeferredTile"
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, diffuseLighting, specularLighting, decomposedLighting);
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
diffuseLighting *= GetCurrentExposureMultiplier();
specularLighting *= GetCurrentExposureMultiplier();
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl
index 8ac55c5c9ff..ad5915e10ce 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl
@@ -111,7 +111,8 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf
void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, uint featureFlags,
out float3 diffuseLighting,
- out float3 specularLighting)
+ out float3 specularLighting,
+ out DecomposedLighting decomposedLighting)
{
LightLoopContext context;
@@ -483,7 +484,7 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS
// Also Apply indiret diffuse (GI)
// PostEvaluateBSDF will perform any operation wanted by the material and sum everything into diffuseLighting and specularLighting
PostEvaluateBSDF( context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting,
- diffuseLighting, specularLighting);
+ diffuseLighting, specularLighting, decomposedLighting);
ApplyDebug(context, posInput, bsdfData, diffuseLighting, specularLighting);
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
index 1a42ba904eb..5dd8fc8f0d5 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl
@@ -2584,7 +2584,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
// There is no AmbientOcclusion from data with AxF, but let's apply our SSAO
AmbientOcclusionFactor aoFactor;
@@ -2603,6 +2603,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
diffuseLighting = 10 * float3(1, 0.3, 0.01);
#endif
+ decomposedLighting.directDiffuse = bsdfData.diffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular;
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting;
+ decomposedLighting.reflection = lighting.indirect.specularReflected;
+ decomposedLighting.refraction = 0;
+ decomposedLighting.transmittance = 0;
+ decomposedLighting.emissive = 0;
+
#ifdef DEBUG_DISPLAY
PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting);
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl
index a34ad165590..e57c816078d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl
@@ -820,7 +820,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
AmbientOcclusionFactor aoFactor;
GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor);
@@ -834,6 +834,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor;
specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;
+ decomposedLighting.directDiffuse = modifiedDiffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular;
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting;
+ decomposedLighting.reflection = lighting.indirect.specularReflected;
+ decomposedLighting.refraction = 0;
+ decomposedLighting.transmittance = 0;
+ decomposedLighting.emissive = builtinData.emissiveColor;
+
#ifdef DEBUG_DISPLAY
PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting);
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl
index 010c1a2f3db..cda0349201a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl
@@ -651,7 +651,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
AmbientOcclusionFactor aoFactor;
GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor);
@@ -667,6 +667,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
// TODO: Multiscattering for cloth?
+ decomposedLighting.directDiffuse = modifiedDiffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular;
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting;
+ decomposedLighting.reflection = lighting.indirect.specularReflected;
+ decomposedLighting.refraction = 0;
+ decomposedLighting.transmittance = 0;
+ decomposedLighting.emissive = builtinData.emissiveColor;
+
#ifdef DEBUG_DISPLAY
PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting);
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl
index ec96e98ab8c..909388a762a 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl
@@ -593,7 +593,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
AmbientOcclusionFactor aoFactor;
GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor);
@@ -604,6 +604,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
diffuseLighting = bsdfData.diffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor;
specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;
+ decomposedLighting.directDiffuse = modifiedDiffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular;
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting;
+ decomposedLighting.reflection = lighting.indirect.specularReflected;
+ decomposedLighting.refraction = 0;
+ decomposedLighting.transmittance = 0;
+ decomposedLighting.emissive = builtinData.emissiveColor;
+
#ifdef DEBUG_DISPLAY
PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting);
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl
index 60d55a52f9e..ead34110120 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl
@@ -1952,7 +1952,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
AmbientOcclusionFactor aoFactor;
// Use GTAOMultiBounce approximation for ambient occlusion (allow to get a tint from the baseColor)
@@ -1985,6 +1985,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
// Rescale the GGX to account for the multiple scattering.
specularLighting *= 1.0 + bsdfData.fresnel0 * preLightData.energyCompensation;
+ decomposedLighting.directDiffuse = modifiedDiffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular * (1.0 + bsdfData.fresnel0 * preLightData.energyCompensation);
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting;
+ decomposedLighting.reflection = lighting.indirect.specularReflected * (1.0 + bsdfData.fresnel0 * preLightData.energyCompensation);
+ decomposedLighting.refraction = lighting.indirect.specularTransmitted;
+ decomposedLighting.transmittance = bsdfData.transmittanceMask * _EnableSSRefraction;
+ decomposedLighting.emissive = builtinData.emissiveColor;
+
#ifdef DEBUG_DISPLAY
PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting);
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl
index 93ee8bb6450..76ffad773e2 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl
@@ -446,7 +446,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
AmbientOcclusionFactor aoFactor;
// Use GTAOMultiBounce approximation for ambient occlusion (allow to get a tint from the baseColor)
@@ -468,6 +468,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;
+ decomposedLighting.directDiffuse = modifiedDiffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular;
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting * GetDiffuseOrDefaultColor(bsdfData, _ReplaceDiffuseForIndirect).rgb;
+ decomposedLighting.reflection = lighting.indirect.specularReflected;
+ decomposedLighting.refraction = 0;
+ decomposedLighting.transmittance = 0;
+ decomposedLighting.emissive = builtinData.emissiveColor;
+
#ifdef DEBUG_DISPLAY
PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting);
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl
index 9bdbc03f0c8..4778361dde1 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl
@@ -116,6 +116,17 @@ void ApplyAmbientOcclusionFactor(AmbientOcclusionFactor aoFactor, inout BuiltinD
lighting.direct.specular *= aoFactor.directSpecularOcclusion;
}
+struct DecomposedLighting
+{
+ float3 directDiffuse;
+ float3 directSpecular;
+ float3 indirectDiffuse;
+ float3 reflection;
+ float3 refraction;
+ float transmittance;
+ float3 emissive;
+};
+
#ifdef DEBUG_DISPLAY
// mipmapColor is color use to store texture streaming information in XXXData.hlsl (look for DEBUGMIPMAPMODE_NONE)
void PostEvaluateBSDFDebugDisplay( AmbientOcclusionFactor aoFactor, BuiltinData builtinData, AggregateLighting lighting, float3 mipmapColor,
@@ -192,4 +203,81 @@ void PostEvaluateBSDFDebugDisplay( AmbientOcclusionFactor aoFactor, BuiltinData
}
}
}
+
+void PostLightLoopDebugDisplay(float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData,
+ DecomposedLighting decomposedLighting, inout float3 diffuseLightingOverride, inout float3 specularLightingOverride, inout float opacityOverride)
+{
+ if (_DebugLightingMode != 0)
+ {
+ // Caution: _DebugLightingMode is used in other part of the code, don't do anything outside of
+ // current cases
+ switch (_DebugLightingMode)
+ {
+ case DEBUGLIGHTINGMODE_DIRECT_DIFFUSE:
+ diffuseLightingOverride = decomposedLighting.directDiffuse;
+ specularLightingOverride = float3(0.0, 0.0, 0.0);
+ opacityOverride = 1;
+ break;
+
+ case DEBUGLIGHTINGMODE_DIRECT_SPECULAR:
+ diffuseLightingOverride = float3(0.0, 0.0, 0.0);
+ specularLightingOverride = decomposedLighting.directSpecular;
+ opacityOverride = 1;
+ break;
+
+ case DEBUGLIGHTINGMODE_INDIRECT_DIFFUSE:
+ diffuseLightingOverride = decomposedLighting.indirectDiffuse;
+ specularLightingOverride = float3(0.0, 0.0, 0.0);
+ opacityOverride = 1;
+ break;
+
+ case DEBUGLIGHTINGMODE_REFLECTION:
+ diffuseLightingOverride = float3(0.0, 0.0, 0.0);
+ specularLightingOverride = decomposedLighting.reflection;
+ opacityOverride = 1;
+ break;
+
+ case DEBUGLIGHTINGMODE_REFRACTION:
+ if (decomposedLighting.transmittance > 0.0)
+ {
+ // Transparent object with refraction - output refraction value
+ diffuseLightingOverride = decomposedLighting.refraction;
+ specularLightingOverride = float3(0.0, 0.0, 0.0);
+ opacityOverride = 1;
+ }
+ else if (builtinData.opacity < 1.0)
+ {
+ // Transparent object without refraction - just pass through
+ diffuseLightingOverride = float3(0.0, 0.0, 0.0);
+ specularLightingOverride = float3(0.0, 0.0, 0.0);
+ opacityOverride = 0;
+ }
+ else
+ {
+ // Opaque object behind transparent object should still be properly lighted
+ }
+
+ // TODO: This is not exactly correct when there is transparent object behind transparent object
+ // The non-refraction lighting of the transparent object behind another transparent object will be missing
+ // To fix this, we need some kind of transparent depth prepass on a separate depth buffer
+ // Then when a transparent is drawn we can sample that depth RT to see if it is behind other transparent objects
+ // However, adding another depth render target is quite a big change to HDRP, so let's keep it simple for now
+
+ break;
+
+ case DEBUGLIGHTINGMODE_TRANSMITTANCE:
+ // Consider both refraction (opacity == 1) and transparent without refraction case (transmittance == 0)
+ diffuseLightingOverride = max(decomposedLighting.transmittance, (1 - builtinData.opacity));
+ specularLightingOverride = float3(0.0, 0.0, 0.0);
+ opacityOverride = 1;
+ break;
+
+ case DEBUGLIGHTINGMODE_EMISSIVE:
+ diffuseLightingOverride = decomposedLighting.emissive;
+ specularLightingOverride = float3(0.0, 0.0, 0.0);
+ opacityOverride = 1;
+ break;
+ }
+ }
+}
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl
index 38802c9ed82..d5704a69253 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl
@@ -4382,7 +4382,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext,
void PostEvaluateBSDF( LightLoopContext lightLoopContext,
float3 V, PositionInputs posInput,
PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting,
- out float3 diffuseLighting, out float3 specularLighting)
+ out float3 diffuseLighting, out float3 specularLighting, out DecomposedLighting decomposedLighting)
{
// Specular occlusion has been pre-computed in GetPreLightData() and applied on indirect specular light
// while screenSpaceAmbientOcclusion has also been cached in preLightData.
@@ -4414,6 +4414,14 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext,
specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;
+ decomposedLighting.directDiffuse = modifiedDiffuseColor * lighting.direct.diffuse;
+ decomposedLighting.directSpecular = lighting.direct.specular;
+ decomposedLighting.indirectDiffuse = builtinData.bakeDiffuseLighting * diffuseOcclusion;
+ decomposedLighting.reflection = lighting.indirect.specularReflected;
+ decomposedLighting.refraction = 0;
+ decomposedLighting.transmittance = 0;
+ decomposedLighting.emissive = builtinData.emissiveColor;
+
#ifdef DEBUG_DISPLAY
// For specularOcclusion we display red to indicate there's not one value possible here.
AmbientOcclusionFactor aoFactor;
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..f3c21ef05fc 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -265,7 +265,7 @@ internal int GetMaxScreenSpaceShadows()
///
/// Debug display settings.
///
- public DebugDisplaySettings debugDisplaySettings { get { return m_DebugDisplaySettings; } }
+ public DebugDisplaySettings debugDisplaySettings { get { return m_CurrentDebugDisplaySettings; } }
static DebugDisplaySettings s_NeutralDebugDisplaySettings = new DebugDisplaySettings();
internal DebugDisplaySettings m_CurrentDebugDisplaySettings;
RTHandle m_DebugColorPickerBuffer;
@@ -1927,6 +1927,36 @@ AOVRequestData aovRequest
aovRequest.SetupDebugData(ref m_CurrentDebugDisplaySettings);
+ // Frame setting may have changed at this point
+ // Need to make sure the new frame setting is respected so AOV output is correct
+ FrameSettings originalFrameSettings = hdCamera.frameSettings;
+ {
+ FrameSettings newFrameSettings = originalFrameSettings;
+
+ if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled())
+ {
+ if (m_CurrentDebugDisplaySettings.IsDebugDisplayRemovePostprocess())
+ {
+ newFrameSettings.SetEnabled(FrameSettingsField.Postprocess, false);
+ }
+
+ // Disable exposure if required
+ if (!m_CurrentDebugDisplaySettings.DebugNeedsExposure())
+ {
+ newFrameSettings.SetEnabled(FrameSettingsField.ExposureControl, false);
+ }
+
+ // Disable SSS if luxmeter is enabled
+ if (m_CurrentDebugDisplaySettings.data.lightingDebugSettings.debugLightingMode == DebugLightingMode.LuxMeter)
+ {
+ newFrameSettings.SetEnabled(FrameSettingsField.SubsurfaceScattering, false);
+ }
+ }
+
+ hdCamera.Update(newFrameSettings, this, hdCamera.msaaSamples, hdCamera.xr);
+ }
+
+
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing))
{
// Must update after getting DebugDisplaySettings
@@ -2544,7 +2574,12 @@ void Callback(CommandBuffer c, HDCamera cam)
RenderGizmos(cmd, camera, renderContext, GizmoSubset.PostImageEffects);
#endif
+
aovRequest.Execute(cmd, aovBuffers, aovCustomPassBuffers, RenderOutputProperties.From(hdCamera));
+ {
+ hdCamera.Update(originalFrameSettings, this, hdCamera.msaaSamples, hdCamera.xr);
+ }
+
}
// This is required so that all commands up to here are executed before EndCameraRendering is called for the user.
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 431969d69bb..c05b38be559 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
@@ -94,7 +94,13 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro
// Evaluate the complete lighting
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting, decomposedLighting);
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
+
float3 finalColor = (diffuseLighting + specularLighting);
// Apply fog attenuation
ApplyFogAttenuation(positionWS, rayDirection, rayDistance, finalColor, true);
@@ -180,7 +186,13 @@ void RaytracingDiffuseDeferred(uint3 dispatchThreadId : SV_DispatchThreadID, uin
// Evaluate lighting
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+
+ LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting, decomposedLighting);
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
// Read the previous value and combine with the current lighting
float3 previousValue = _RaytracingLitBufferRW[COORD_TEXTURE2D_X(currentCoord)].xyz;
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 9f70599a0d9..4748b6303a2 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
@@ -2,10 +2,11 @@
#define USE_LIGHT_CLUSTER
-void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData,
+void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData,
float reflectionHierarchyWeight, float refractionHierarchyWeight, float3 reflection, float3 transmission,
out float3 diffuseLighting,
- out float3 specularLighting)
+ out float3 specularLighting,
+ out DecomposedLighting decomposedLighting)
{
LightLoopContext context;
context.contactShadow = 1.0;
@@ -219,5 +220,6 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS
}
}
- PostEvaluateBSDF(context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting, diffuseLighting, specularLighting);
+ PostEvaluateBSDF(context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting,
+ diffuseLighting, specularLighting, decomposedLighting);
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs
index 17640a125c9..b0103dbe2fb 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequest.cs
@@ -13,6 +13,20 @@ public enum LightingProperty
DiffuseOnly = 1 << 0,
/// Render only specular.
SpecularOnly = 1 << 1,
+ /// Render only direct diffuse.
+ DirectDiffuseOnly = 1 << 2,
+ /// Render only direct specular.
+ DirectSpecularOnly = 1 << 3,
+ /// Render only indirect diffuse.
+ IndirectDiffuseOnly = 1 << 4,
+ /// Render only reflection.
+ ReflectionOnly = 1 << 5,
+ /// Render only refraction.
+ RefractionOnly = 1 << 6,
+ /// Represent how much final diffuse is from refraction and how much from other diffuse lighting.
+ Transmittance = 1 << 7,
+ /// Render only emissive.
+ EmissiveOnly = 1 << 8
}
/// Output a specific debug mode.
@@ -120,6 +134,27 @@ public void FillDebugData(DebugDisplaySettings debug)
case LightingProperty.SpecularOnly:
debug.SetDebugLightingMode(DebugLightingMode.SpecularLighting);
break;
+ case LightingProperty.DirectDiffuseOnly:
+ debug.SetDebugLightingMode(DebugLightingMode.DirectDiffuse);
+ break;
+ case LightingProperty.DirectSpecularOnly:
+ debug.SetDebugLightingMode(DebugLightingMode.DirectSpecular);
+ break;
+ case LightingProperty.IndirectDiffuseOnly:
+ debug.SetDebugLightingMode(DebugLightingMode.IndirectDiffuse);
+ break;
+ case LightingProperty.ReflectionOnly:
+ debug.SetDebugLightingMode(DebugLightingMode.Reflection);
+ break;
+ case LightingProperty.RefractionOnly:
+ debug.SetDebugLightingMode(DebugLightingMode.Refraction);
+ break;
+ case LightingProperty.Transmittance:
+ debug.SetDebugLightingMode(DebugLightingMode.Transmittance);
+ break;
+ case LightingProperty.EmissiveOnly:
+ debug.SetDebugLightingMode(DebugLightingMode.Emissive);
+ break;
default:
{
debug.SetDebugLightingMode(DebugLightingMode.None);
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..4a1e66c4138 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
@@ -189,7 +189,14 @@ void Frag(PackedVaryingsToPS packedInput,
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+
+ LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting, decomposedLighting);
+
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(V, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
diffuseLighting *= GetCurrentExposureMultiplier();
specularLighting *= GetCurrentExposureMultiplier();
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl
index 2f46b9c938d..56e5a82e233 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl
@@ -183,7 +183,13 @@ void ClosestHitForward(inout RayIntersection rayIntersection : SV_RayPayload, At
// Run the lightloop
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, refractedWeight, reflected, transmitted, diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+ LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, refractedWeight, reflected, transmitted, diffuseLighting, specularLighting, decomposedLighting);
+
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(viewWS, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
// Color display for the moment
rayIntersection.color = diffuseLighting + specularLighting;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl
index 933c718c71a..757da0516e9 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl
@@ -132,7 +132,13 @@ void ClosestHitMain(inout RayIntersection rayIntersection : SV_RayPayload, Attri
// Run the lightloop
float3 diffuseLighting;
float3 specularLighting;
- LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, 0.0, reflected, float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting);
+ DecomposedLighting decomposedLighting;
+ LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, 0.0, reflected, float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting, decomposedLighting);
+
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(viewWS, posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
// Color display for the moment
rayIntersection.color = diffuseLighting + specularLighting;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineRayTracingResources.asset b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineRayTracingResources.asset
index 593504922e7..23fbb638171 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineRayTracingResources.asset
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineRayTracingResources.asset
@@ -26,7 +26,6 @@ MonoBehaviour:
shadowFilterCS: {fileID: 7200000, guid: f71fd853a538bf74e9e5a7228fc14dae, type: 3}
forwardRaytracing: {fileID: 4807578003741378534, guid: d3a89a2d3f73b3e4da6f191e844fe68c,
type: 3}
- raytracingFlagMask: {fileID: 4800000, guid: 7822c8a69a1f21144a20cf6d84e5e706, type: 3}
lightClusterBuildCS: {fileID: 7200000, guid: c0625ea908b52854bbf1d456e34026e4, type: 3}
lightClusterDebugS: {fileID: 4800000, guid: c4d81c6e573560444bb1ea11ae4acfcb, type: 3}
lightClusterDebugCS: {fileID: 7200000, guid: d48a3a5496d98a44c89f335934805d10, type: 3}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.shader
index 6c9f6999425..e5157fe36bd 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/GradientSky/GradientSky.shader
@@ -57,12 +57,24 @@ Shader "Hidden/HDRP/Sky/GradientSky"
return RenderSky(input);
}
+ #pragma multi_compile _ DEBUG_DISPLAY
+
+ #ifdef DEBUG_DISPLAY
+ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
+ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl"
+ #endif
+
float4 FragRender(Varyings input) : SV_Target
{
- UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
- float4 color = RenderSky(input);
- color.rgb *= GetCurrentExposureMultiplier();
- return color;
+ UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
+ float4 color = RenderSky(input);
+ color.rgb *= GetCurrentExposureMultiplier();
+
+ #ifdef DEBUG_DISPLAY
+ color = ModifySkyColorDebug(color);
+ #endif
+
+ return color;
}
ENDHLSL
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader
index 960e636caf4..5c41a6feeaa 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader
@@ -235,11 +235,6 @@ Shader "Hidden/HDRP/Sky/HDRISky"
return RenderSky(input, 1.0);
}
- float4 FragRender(Varyings input) : SV_Target
- {
- UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
- return RenderSky(input, GetCurrentExposureMultiplier());
- }
float4 RenderBackplate(Varyings input, float exposure)
{
@@ -350,6 +345,23 @@ Shader "Hidden/HDRP/Sky/HDRISky"
Cull Off
HLSLPROGRAM
+ #pragma multi_compile _ DEBUG_DISPLAY
+
+ #ifdef DEBUG_DISPLAY
+ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
+ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl"
+ #endif
+
+ float4 FragRender(Varyings input) : SV_Target
+ {
+ UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
+ float4 color = RenderSky(input, GetCurrentExposureMultiplier());
+
+ #ifdef DEBUG_DISPLAY
+ color = ModifySkyColorDebug(color);
+ #endif
+ return color;
+ }
#pragma fragment FragRender
ENDHLSL
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader
index 299b583f8c1..b99d3a67323 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader
@@ -17,6 +17,12 @@ Shader "Hidden/HDRP/Sky/PbrSky"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl"
+ #pragma multi_compile _ DEBUG_DISPLAY
+
+ #ifdef DEBUG_DISPLAY
+ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
+ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl"
+ #endif
int _HasGroundAlbedoTexture; // bool...
int _HasGroundEmissionTexture; // bool...
@@ -236,6 +242,10 @@ Shader "Hidden/HDRP/Sky/PbrSky"
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float4 value = RenderSky(input);
value.rgb *= GetCurrentExposureMultiplier(); // Only the full-screen pass is pre-exposed
+#ifdef DEBUG_DISPLAY
+ value = ModifySkyColorDebug(value);
+#endif
+
return value;
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl
new file mode 100644
index 00000000000..cb739743d9c
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl
@@ -0,0 +1,43 @@
+#ifndef __SKYDEBUGUTILS_H__
+#define __SKYDEBUGUTILS_H__
+
+#ifdef DEBUG_DISPLAY
+float4 ModifySkyColorDebug(float4 color)
+{
+ if (_DebugLightingMode != 0)
+ {
+ switch (_DebugLightingMode)
+ {
+ case DEBUGLIGHTINGMODE_DIRECT_DIFFUSE:
+ color.rgb = 0;
+ break;
+
+ case DEBUGLIGHTINGMODE_DIRECT_SPECULAR:
+ color.rgb = 0;
+ break;
+
+ case DEBUGLIGHTINGMODE_INDIRECT_DIFFUSE:
+ color.rgb = 0;
+ break;
+
+ case DEBUGLIGHTINGMODE_REFLECTION:
+ color.rgb = 0;
+ break;
+
+ case DEBUGLIGHTINGMODE_REFRACTION:
+ break;
+
+ case DEBUGLIGHTINGMODE_TRANSMITTANCE:
+ color.rgb = 0;
+ break;
+
+ case DEBUGLIGHTINGMODE_EMISSIVE:
+ break;
+ }
+ }
+
+ return color;
+}
+#endif
+
+#endif // __SKYDEBUGUTILS_H__
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl.meta
new file mode 100644
index 00000000000..d023d93f4a9
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyDebugUtils.hlsl.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 1416adfa6e4237e49a41428a14d2c99b
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ userData:
+ assetBundleName:
+ assetBundleVariant:
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..f0a427b647e 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
@@ -5,6 +5,7 @@ float4 VFXCalcPixelOutputForward(const SurfaceData surfaceData, const BuiltinDat
{
float3 diffuseLighting;
float3 specularLighting;
+ DecomposedLighting decomposedLighting;
#if IS_OPAQUE_PARTICLE
@@ -26,6 +27,10 @@ float4 VFXCalcPixelOutputForward(const SurfaceData surfaceData, const BuiltinDat
#endif
LightLoop(GetWorldSpaceNormalizeViewDir(posRWS), posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting);
+#ifdef DEBUG_DISPLAY
+ PostLightLoopDebugDisplay(GetWorldSpaceNormalizeViewDir(posRWS), posInput, preLightData, bsdfData, builtinData,
+ decomposedLighting, diffuseLighting, specularLighting, builtinData.opacity);
+#endif
diffuseLighting *= GetCurrentExposureMultiplier();
specularLighting *= GetCurrentExposureMultiplier();