From adca5e04b7162f50e233c1cc579a91b47511470f Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 5 Jun 2020 16:58:21 +0200 Subject: [PATCH 01/10] Add support for reflection controller. --- .../Lighting/IndirectLightingController.cs | 15 +++++++++++---- .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 9 +++++++-- .../Runtime/Material/BuiltinGIUtilities.hlsl | 13 +++++++++++++ .../Runtime/Material/BuiltinUtilities.hlsl | 5 +++-- .../RaytracingIndirectDiffuse.compute | 3 ++- .../ShaderLibrary/ShaderVariablesGlobal.cs | 3 ++- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs index 6ea09df9fd1..91f41c3014b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs @@ -8,9 +8,16 @@ namespace UnityEngine.Rendering.HighDefinition [Serializable, VolumeComponentMenu("Lighting/Indirect Lighting Controller")] public class IndirectLightingController : VolumeComponent { - /// Indirect specular intensity multiplier, between 0 and 1 - public MinFloatParameter indirectSpecularIntensity = new MinFloatParameter(1.0f, 0.0f); - /// Indirect diffuse intensity multiplier, between 0 and 1 - public MinFloatParameter indirectDiffuseIntensity = new MinFloatParameter(1.0f, 0.0f); + [FormerlySerializedAs("indirectSpecularIntensity")] + /// Reflection probe intensity multiplier, between 0 and 1 + public MinFloatParameter reflectionProbeIntensityMultiplier = new MinFloatParameter(1.0f, 0.0f); + /// Reflection lighting multiplier, between 0 and 1 + public MinFloatParameter reflectionLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); + /// Controls which layer will be affected by the reflection lighting multiplier + public LightLayerEnum reflectionLightinglayersMask = LightLayerEnum.LightLayerDefault; + /// Indirect diffuse lighting multiplier, between 0 and 1 + public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); + /// Controls which layer will be affected by the indirect diffuse lighting multiplier + public LightLayerEnum indirectDiffuseLightinglayersMask = LightLayerEnum.LightLayerDefault; } } 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 242a44f0fa4..1aeea322cb6 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 @@ -502,8 +502,9 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS // TODO: clean this case later to share more code, for now just reproduce the same behavior that is happening in PostInitBuiltinData() // Apply control from the indirect lighting volume settings (Remember there is no emissive here at this step) - builtinDataProbeVolumes.bakeDiffuseLighting *= _IndirectLightingMultiplier.x; - builtinDataProbeVolumes.backBakeDiffuseLighting *= _IndirectLightingMultiplier.x; + float indirectDiffuseMultiplier = GetIndirectDiffuseMultiplier(builtinData.renderingLayers); + builtinDataProbeVolumes.bakeDiffuseLighting *= indirectDiffuseMultiplier; + builtinDataProbeVolumes.backBakeDiffuseLighting *= indirectDiffuseMultiplier; #ifdef MODIFY_BAKED_DIFFUSE_LIGHTING #ifdef DEBUG_DISPLAY @@ -539,6 +540,10 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS ApplyDebugToLighting(context, builtinData, aggregateLighting); + // Note: We can't apply the IndirectDiffuseMultiplier here as with GBuffer, Emissive is part of the bakeDiffuseLighting. + // so IndirectDiffuseMultiplier is apply in PostInitBuiltinData or related location (like for probe volume) + aggregateLighting.indirect.specularReflected *= GetIndirectSpecularMultiplier(builtinData.renderingLayers); + // 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, diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl index f5ad182e0de..b8f5ddcd39d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl @@ -1,6 +1,19 @@ #ifndef __BUILTINGIUTILITIES_HLSL__ #define __BUILTINGIUTILITIES_HLSL__ +// Helper function for indirect control volume +float GetIndirectDiffuseMultiplier(uint renderingLayers) +{ + uint indirectDiffuseLayers = uint(_IndirectLightingMultiplier.y * 255.5); + return indirectDiffuseLayers & renderingLayers ? _IndirectLightingMultiplier.x : 1.0f; +} + +float GetIndirectSpecularMultiplier(uint renderingLayers) +{ + uint indirectSpecularLayers = uint(_IndirectLightingMultiplier.w * 255.5); + return indirectSpecularLayers & renderingLayers ? _IndirectLightingMultiplier.z : 1.0f; +} + #ifdef SHADERPASS #if ((SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_MATERIAL_PASS) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD)) || \ ((SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_LIGHT_LOOP) && (SHADERPASS == SHADERPASS_DEFERRED_LIGHTING || SHADERPASS == SHADERPASS_FORWARD)) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl index efd7a3a5096..3fc47dc3708 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl @@ -124,8 +124,9 @@ void PostInitBuiltinData( float3 V, PositionInputs posInput, SurfaceData surfa // color in case of lit deferred for example and avoid material to have to deal with it // Note: We only apply indirect multiplier for Material pass mode, for lightloop mode, the multiplier will be apply in lightloop - builtinData.bakeDiffuseLighting *= _IndirectLightingMultiplier.x; - builtinData.backBakeDiffuseLighting *= _IndirectLightingMultiplier.x; + float multiplier = GetIndirectDiffuseMultiplier(builtinData.renderingLayers); + builtinData.bakeDiffuseLighting *= multiplier; + builtinData.backBakeDiffuseLighting *= multiplier; #endif #ifdef MODIFY_BAKED_DIFFUSE_LIGHTING diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute index ad2d408fd25..5ed2a58c463 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute @@ -255,6 +255,7 @@ void IndirectDiffuseAccumulation(uint3 dispatchThreadId : SV_DispatchThreadID, u uint2 currentPixelCoordinate = groupId * RAYTRACING_INDIRECT_DIFFUSE_TILE_SIZE + groupThreadId; // Add the indirect diffuse to the buffer (while pre-multiplying by the base color) - _GBufferTexture3[COORD_TEXTURE2D_X(currentPixelCoordinate)] += LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, currentPixelCoordinate) * LOAD_TEXTURE2D_X(_GBufferTexture0, currentPixelCoordinate) * _IndirectLightingMultiplier.x; + float multiplier = GetIndirectDiffuseMultiplier(DEFAULT_LIGHT_LAYERS); // TODO: Handle light layers + _GBufferTexture3[COORD_TEXTURE2D_X(currentPixelCoordinate)] += LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, currentPixelCoordinate) * LOAD_TEXTURE2D_X(_GBufferTexture0, currentPixelCoordinate) * multiplier; #endif } 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 ca44206beb9..671ad0e533c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs @@ -177,7 +177,8 @@ unsafe struct ShaderVariablesGlobal public float _ReplaceDiffuseForIndirect; public Vector4 _AmbientOcclusionParam; // xyz occlusion color, w directLightStrenght - public Vector4 _IndirectLightingMultiplier; // .x indirect diffuse multiplier (use with indirect lighting volume controler) + public Vector4 _IndirectLightingMultiplier; // .x indirect diffuse multiplier, .y indirect diffuse layers mask (use with indirect lighting volume controler) + // .z indirect specular multiplier, .w indirect specular layers mask public float _MicroShadowOpacity; public uint _EnableProbeVolumes; From ac3df3810e937cac4e15bba8b365994fd24b40df Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 5 Jun 2020 22:23:46 +0200 Subject: [PATCH 02/10] Fix compilation --- .../IndirectLightingControllerEditor.cs | 21 +++++++++++----- .../Lighting/IndirectLightingController.cs | 25 ++++++++++++++++++- .../Runtime/Lighting/LightLoop/LightLoop.cs | 2 +- .../Runtime/Material/BuiltinGIUtilities.hlsl | 13 ---------- .../RenderPipeline/HDRenderPipeline.cs | 6 ++++- .../ShaderLibrary/ShaderVariables.hlsl | 13 ++++++++++ 6 files changed, 58 insertions(+), 22 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs index b0319d491fa..7b04bfb1a66 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs @@ -6,21 +6,30 @@ namespace UnityEditor.Rendering.HighDefinition [VolumeComponentEditor(typeof(IndirectLightingController))] class IndirectLightingControllerEditor : VolumeComponentEditor { - SerializedDataParameter m_IndirectDiffuseIntensity; - SerializedDataParameter m_IndirectSpecularIntensity; + SerializedDataParameter m_ReflectionProbeIntensityMultiplier; + SerializedDataParameter m_ReflectionLightingMultiplier; + SerializedDataParameter m_ReflectionLightinglayersMask; + SerializedDataParameter m_IndirectDiffuseLightingMultiplier; + SerializedDataParameter m_IndirectDiffuseLightinglayersMask; public override void OnEnable() { var o = new PropertyFetcher(serializedObject); - m_IndirectSpecularIntensity = Unpack(o.Find(x => x.indirectSpecularIntensity)); - m_IndirectDiffuseIntensity = Unpack(o.Find(x => x.indirectDiffuseIntensity)); + m_ReflectionProbeIntensityMultiplier = Unpack(o.Find(x => x.reflectionProbeIntensityMultiplier)); + m_ReflectionLightingMultiplier = Unpack(o.Find(x => x.reflectionLightingMultiplier)); + m_ReflectionLightinglayersMask = Unpack(o.Find(x => x.reflectionLightinglayersMask)); + m_IndirectDiffuseLightingMultiplier = Unpack(o.Find(x => x.indirectDiffuseLightingMultiplier)); + m_IndirectDiffuseLightinglayersMask = Unpack(o.Find(x => x.indirectDiffuseLightinglayersMask)); } public override void OnInspectorGUI() { - PropertyField(m_IndirectDiffuseIntensity, EditorGUIUtility.TrTextContent("Indirect Diffuse Intensity", "Sets the multiplier for baked diffuse lighting.")); - PropertyField(m_IndirectSpecularIntensity, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Intensity", "Sets the multiplier for baked diffuse lighting.")); + PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_ReflectionLightinglayersMask, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_IndirectDiffuseLightinglayersMask, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs index 91f41c3014b..6628022ed1a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs @@ -8,16 +8,39 @@ namespace UnityEngine.Rendering.HighDefinition [Serializable, VolumeComponentMenu("Lighting/Indirect Lighting Controller")] public class IndirectLightingController : VolumeComponent { - [FormerlySerializedAs("indirectSpecularIntensity")] + [UnityEngine.Serialization.FormerlySerializedAs("indirectSpecularIntensity")] /// Reflection probe intensity multiplier, between 0 and 1 public MinFloatParameter reflectionProbeIntensityMultiplier = new MinFloatParameter(1.0f, 0.0f); + /// Reflection lighting multiplier, between 0 and 1 public MinFloatParameter reflectionLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); /// Controls which layer will be affected by the reflection lighting multiplier public LightLayerEnum reflectionLightinglayersMask = LightLayerEnum.LightLayerDefault; + + [UnityEngine.Serialization.FormerlySerializedAs("indirectDiffuseIntensity")] /// Indirect diffuse lighting multiplier, between 0 and 1 public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); /// Controls which layer will be affected by the indirect diffuse lighting multiplier public LightLayerEnum indirectDiffuseLightinglayersMask = LightLayerEnum.LightLayerDefault; + + /// + /// Returns a mask of reflection lighting layers as uint and handle the case of Everything as being 0xFF and not -1 + /// + /// + public uint GetReflectionLightingLayers() + { + int value = (int)reflectionLightinglayersMask; + return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value; + } + + /// + /// Returns a mask of indirect diffuse lighting layers as uint and handle the case of Everything as being 0xFF and not -1 + /// + /// + public uint GetIndirectDiffuseLightingLayers() + { + int value = (int)indirectDiffuseLightinglayersMask; + return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value; + } } } 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 84890509e9f..352eb2b1ea0 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 @@ -1846,7 +1846,7 @@ internal bool GetEnvLightData(CommandBuffer cmd, HDCamera hdCamera, in Processed envLightData.lightLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? probe.lightLayersAsUInt : uint.MaxValue; envLightData.influenceShapeType = influence.envShape; envLightData.weight = processedProbe.weight; - envLightData.multiplier = probe.multiplier * m_indirectLightingController.indirectSpecularIntensity.value; + envLightData.multiplier = probe.multiplier * m_indirectLightingController.reflectionProbeIntensityMultiplier.value; envLightData.rangeCompressionFactorCompensation = Mathf.Max(probe.rangeCompressionFactor, 1e-6f); envLightData.influenceExtents = influence.extents; switch (influence.envShape) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl index b8f5ddcd39d..f5ad182e0de 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl @@ -1,19 +1,6 @@ #ifndef __BUILTINGIUTILITIES_HLSL__ #define __BUILTINGIUTILITIES_HLSL__ -// Helper function for indirect control volume -float GetIndirectDiffuseMultiplier(uint renderingLayers) -{ - uint indirectDiffuseLayers = uint(_IndirectLightingMultiplier.y * 255.5); - return indirectDiffuseLayers & renderingLayers ? _IndirectLightingMultiplier.x : 1.0f; -} - -float GetIndirectSpecularMultiplier(uint renderingLayers) -{ - uint indirectSpecularLayers = uint(_IndirectLightingMultiplier.w * 255.5); - return indirectSpecularLayers & renderingLayers ? _IndirectLightingMultiplier.z : 1.0f; -} - #ifdef SHADERPASS #if ((SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_MATERIAL_PASS) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD)) || \ ((SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_LIGHT_LOOP) && (SHADERPASS == SHADERPASS_DEFERRED_LIGHTING || SHADERPASS == SHADERPASS_FORWARD)) 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 fe7ce3c23f1..1d5ad222651 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1191,7 +1191,11 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd) ScreenSpaceRefraction ssRefraction = hdCamera.volumeStack.GetComponent(); m_ShaderVariablesGlobalCB._SSRefractionInvScreenWeightDistance = 1.0f / ssRefraction.screenFadeDistance.value; - m_ShaderVariablesGlobalCB._IndirectLightingMultiplier = new Vector4(hdCamera.volumeStack.GetComponent().indirectDiffuseIntensity.value, 0, 0, 0); + IndirectLightingController indirectLightingController = hdCamera.volumeStack.GetComponent(); + m_ShaderVariablesGlobalCB._IndirectLightingMultiplier = new Vector4(indirectLightingController.indirectDiffuseLightingMultiplier.value, + indirectLightingController.GetReflectionLightingLayers(), + indirectLightingController.reflectionLightingMultiplier.value, + indirectLightingController.GetIndirectDiffuseLightingLayers()); m_ShaderVariablesGlobalCB._OffScreenRendering = 0; m_ShaderVariablesGlobalCB._OffScreenDownsampleFactor = 1; m_ShaderVariablesGlobalCB._ReplaceDiffuseForIndirect = hdCamera.frameSettings.IsEnabled(FrameSettingsField.ReplaceDiffuseForIndirect) ? 1.0f : 0.0f; 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 fc896274584..ad138a81557 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -279,6 +279,19 @@ float GetInversePreviousExposureMultiplier() return rcp(exposure + (exposure == 0.0)); // zero-div guard } +// Helper function for indirect control volume +float GetIndirectDiffuseMultiplier(uint renderingLayers) +{ + uint indirectDiffuseLayers = uint(_IndirectLightingMultiplier.y * 255.5); + return indirectDiffuseLayers & renderingLayers ? _IndirectLightingMultiplier.x : 1.0f; +} + +float GetIndirectSpecularMultiplier(uint renderingLayers) +{ + uint indirectSpecularLayers = uint(_IndirectLightingMultiplier.w * 255.5); + return indirectSpecularLayers & renderingLayers ? _IndirectLightingMultiplier.z : 1.0f; +} + // Functions to clamp UVs to use when RTHandle system is used. float2 ClampAndScaleUV(float2 UV, float2 texelSize, float numberOfTexels) From 9083b2aae8a1e44fc4bbaa1d44c18293d73bc493 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 15 Jun 2020 15:33:58 +0200 Subject: [PATCH 03/10] Fixed compilation issue and naming --- .../IndirectLightingControllerEditor.cs | 10 ++++---- .../Lighting/IndirectLightingController.cs | 24 +++++++++++++++---- .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 3 ++- .../ShaderLibrary/ShaderVariables.hlsl | 4 ++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs index 7b04bfb1a66..87578c7d2e0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs @@ -25,11 +25,11 @@ public override void OnEnable() public override void OnInspectorGUI() { - PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Intensity", "Sets the multiplier for baked diffuse lighting.")); - PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); - PropertyField(m_ReflectionLightinglayersMask, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); - PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); - PropertyField(m_IndirectDiffuseLightinglayersMask, EditorGUIUtility.TrTextContent("Indirect Specular Intensity", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_ReflectionLightinglayersMask, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier Mask", "Sets the light layer mask for reflected specular lighting.")); + PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier", "Sets the multiplier for indirect diffuse lighting.")); + PropertyField(m_IndirectDiffuseLightinglayersMask, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier Mask", "Sets the light layer mask for indirect diffuse lighting.")); + PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection Probe Intensity Multiplier", "Sets the intensity multiplier for reflection probes.")); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs index 6628022ed1a..07c1cbf954b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; namespace UnityEngine.Rendering.HighDefinition { @@ -15,13 +16,13 @@ public class IndirectLightingController : VolumeComponent /// Reflection lighting multiplier, between 0 and 1 public MinFloatParameter reflectionLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); /// Controls which layer will be affected by the reflection lighting multiplier - public LightLayerEnum reflectionLightinglayersMask = LightLayerEnum.LightLayerDefault; + public LightLayerEnumParameter reflectionLightinglayersMask = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault); [UnityEngine.Serialization.FormerlySerializedAs("indirectDiffuseIntensity")] /// Indirect diffuse lighting multiplier, between 0 and 1 public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); /// Controls which layer will be affected by the indirect diffuse lighting multiplier - public LightLayerEnum indirectDiffuseLightinglayersMask = LightLayerEnum.LightLayerDefault; + public LightLayerEnumParameter indirectDiffuseLightinglayersMask = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault); /// /// Returns a mask of reflection lighting layers as uint and handle the case of Everything as being 0xFF and not -1 @@ -29,7 +30,7 @@ public class IndirectLightingController : VolumeComponent /// public uint GetReflectionLightingLayers() { - int value = (int)reflectionLightinglayersMask; + int value = (int)reflectionLightinglayersMask.GetValue(); return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value; } @@ -39,8 +40,23 @@ public uint GetReflectionLightingLayers() /// public uint GetIndirectDiffuseLightingLayers() { - int value = (int)indirectDiffuseLightinglayersMask; + int value = (int)indirectDiffuseLightinglayersMask.GetValue(); return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value; } + + /// + /// Sky Ambient Mode volume parameter. + /// + [Serializable, DebuggerDisplay(k_DebuggerDisplay)] + public sealed class LightLayerEnumParameter : VolumeParameter + { + /// + /// Light Layer Enum parameterconstructor. + /// + /// Light Layer Enum parameter. + /// Initial override value. + public LightLayerEnumParameter(LightLayerEnum value, bool overrideState = false) + : base(value, overrideState) { } + } } } 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 8e87ebd2932..a182d07ec53 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 @@ -539,7 +539,8 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS BuiltinData builtInDataSSGI; ZERO_INITIALIZE(BuiltinData, builtInDataSSGI); builtInDataSSGI.bakeDiffuseLighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, posInput.positionSS).xyz * GetInverseCurrentExposureMultiplier(); - builtInDataSSGI.bakeDiffuseLighting *= _IndirectLightingMultiplier.x; + float indirectDiffuseMultiplier = GetIndirectDiffuseMultiplier(builtinData.renderingLayers); + builtInDataSSGI.bakeDiffuseLighting *= indirectDiffuseMultiplier; ModifyBakedDiffuseLighting(V, posInput, preLightData, bsdfData, builtInDataSSGI); builtinData.bakeDiffuseLighting += builtInDataSSGI.bakeDiffuseLighting; } 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 8bdfe07f7f4..e5c455d3cae 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -283,13 +283,13 @@ float GetInversePreviousExposureMultiplier() float GetIndirectDiffuseMultiplier(uint renderingLayers) { uint indirectDiffuseLayers = uint(_IndirectLightingMultiplier.y * 255.5); - return indirectDiffuseLayers & renderingLayers ? _IndirectLightingMultiplier.x : 1.0f; + return (indirectDiffuseLayers & renderingLayers) ? _IndirectLightingMultiplier.x : 1.0f; } float GetIndirectSpecularMultiplier(uint renderingLayers) { uint indirectSpecularLayers = uint(_IndirectLightingMultiplier.w * 255.5); - return indirectSpecularLayers & renderingLayers ? _IndirectLightingMultiplier.z : 1.0f; + return (indirectSpecularLayers & renderingLayers) ? _IndirectLightingMultiplier.z : 1.0f; } // Functions to clamp UVs to use when RTHandle system is used. From 21d5558a86723371c9b57897f0d6b409adb0d145 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 15 Jun 2020 18:35:09 +0200 Subject: [PATCH 04/10] Fixed compilation issue and naming --- .../IndirectLightingControllerEditor.cs | 34 +++++++++++++------ .../Lighting/IndirectLightingController.cs | 22 ++++++------ .../RenderPipeline/HDRenderPipeline.cs | 9 ++--- .../ShaderLibrary/ShaderVariables.hlsl | 6 ++-- .../ShaderLibrary/ShaderVariablesGlobal.cs | 7 ++-- .../ShaderVariablesGlobal.cs.hlsl | 5 ++- 6 files changed, 50 insertions(+), 33 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs index 87578c7d2e0..7c6ae0672cb 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs @@ -1,4 +1,6 @@ +using UnityEngine; using UnityEngine.Rendering.HighDefinition; +using UnityEngine.Rendering; namespace UnityEditor.Rendering.HighDefinition { @@ -6,29 +8,39 @@ namespace UnityEditor.Rendering.HighDefinition [VolumeComponentEditor(typeof(IndirectLightingController))] class IndirectLightingControllerEditor : VolumeComponentEditor { - SerializedDataParameter m_ReflectionProbeIntensityMultiplier; - SerializedDataParameter m_ReflectionLightingMultiplier; - SerializedDataParameter m_ReflectionLightinglayersMask; SerializedDataParameter m_IndirectDiffuseLightingMultiplier; - SerializedDataParameter m_IndirectDiffuseLightinglayersMask; + SerializedDataParameter m_IndirectDiffuseLightingLayers; + + SerializedDataParameter m_ReflectionLightingMultiplier; + SerializedDataParameter m_ReflectionLightingLayers; + + SerializedDataParameter m_ReflectionProbeIntensityMultiplier; public override void OnEnable() { var o = new PropertyFetcher(serializedObject); - m_ReflectionProbeIntensityMultiplier = Unpack(o.Find(x => x.reflectionProbeIntensityMultiplier)); - m_ReflectionLightingMultiplier = Unpack(o.Find(x => x.reflectionLightingMultiplier)); - m_ReflectionLightinglayersMask = Unpack(o.Find(x => x.reflectionLightinglayersMask)); m_IndirectDiffuseLightingMultiplier = Unpack(o.Find(x => x.indirectDiffuseLightingMultiplier)); - m_IndirectDiffuseLightinglayersMask = Unpack(o.Find(x => x.indirectDiffuseLightinglayersMask)); + m_IndirectDiffuseLightingLayers = Unpack(o.Find(x => x.indirectDiffuseLightingLayers)); + + m_ReflectionLightingMultiplier = Unpack(o.Find(x => x.reflectionLightingMultiplier)); + m_ReflectionLightingLayers = Unpack(o.Find(x => x.reflectionLightingLayers)); + + m_ReflectionProbeIntensityMultiplier = Unpack(o.Find(x => x.reflectionProbeIntensityMultiplier)); } public override void OnInspectorGUI() { - PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier", "Sets the multiplier for reflected specular lighting.")); - PropertyField(m_ReflectionLightinglayersMask, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier Mask", "Sets the light layer mask for reflected specular lighting.")); PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier", "Sets the multiplier for indirect diffuse lighting.")); - PropertyField(m_IndirectDiffuseLightinglayersMask, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier Mask", "Sets the light layer mask for indirect diffuse lighting.")); + GUI.enabled = HDUtils.hdrpSettings.supportLightLayers; + PropertyField(m_IndirectDiffuseLightingLayers, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Layers", "Sets the light layer mask for indirect diffuse lighting.")); + GUI.enabled = true; + + PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier", "Sets the multiplier for reflected specular lighting.")); + GUI.enabled = HDUtils.hdrpSettings.supportLightLayers; + PropertyField(m_ReflectionLightingLayers, EditorGUIUtility.TrTextContent("Reflection Lighting Layers", "Sets the light layer mask for reflected specular lighting.")); + GUI.enabled = true; + PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection Probe Intensity Multiplier", "Sets the intensity multiplier for reflection probes.")); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs index 07c1cbf954b..b982b9e71dd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/IndirectLightingController.cs @@ -9,20 +9,20 @@ namespace UnityEngine.Rendering.HighDefinition [Serializable, VolumeComponentMenu("Lighting/Indirect Lighting Controller")] public class IndirectLightingController : VolumeComponent { - [UnityEngine.Serialization.FormerlySerializedAs("indirectSpecularIntensity")] - /// Reflection probe intensity multiplier, between 0 and 1 - public MinFloatParameter reflectionProbeIntensityMultiplier = new MinFloatParameter(1.0f, 0.0f); + [UnityEngine.Serialization.FormerlySerializedAs("indirectDiffuseIntensity")] + /// Indirect diffuse lighting multiplier, between 0 and 1 + public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); + /// Controls which layer will be affected by the indirect diffuse lighting multiplier + public LightLayerEnumParameter indirectDiffuseLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault); /// Reflection lighting multiplier, between 0 and 1 public MinFloatParameter reflectionLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); /// Controls which layer will be affected by the reflection lighting multiplier - public LightLayerEnumParameter reflectionLightinglayersMask = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault); + public LightLayerEnumParameter reflectionLightingLayers = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault); - [UnityEngine.Serialization.FormerlySerializedAs("indirectDiffuseIntensity")] - /// Indirect diffuse lighting multiplier, between 0 and 1 - public MinFloatParameter indirectDiffuseLightingMultiplier = new MinFloatParameter(1.0f, 0.0f); - /// Controls which layer will be affected by the indirect diffuse lighting multiplier - public LightLayerEnumParameter indirectDiffuseLightinglayersMask = new LightLayerEnumParameter(LightLayerEnum.LightLayerDefault); + [UnityEngine.Serialization.FormerlySerializedAs("indirectSpecularIntensity")] + /// Reflection probe intensity multiplier, between 0 and 1 + public MinFloatParameter reflectionProbeIntensityMultiplier = new MinFloatParameter(1.0f, 0.0f); /// /// Returns a mask of reflection lighting layers as uint and handle the case of Everything as being 0xFF and not -1 @@ -30,7 +30,7 @@ public class IndirectLightingController : VolumeComponent /// public uint GetReflectionLightingLayers() { - int value = (int)reflectionLightinglayersMask.GetValue(); + int value = (int)reflectionLightingLayers.GetValue(); return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value; } @@ -40,7 +40,7 @@ public uint GetReflectionLightingLayers() /// public uint GetIndirectDiffuseLightingLayers() { - int value = (int)indirectDiffuseLightinglayersMask.GetValue(); + int value = (int)indirectDiffuseLightingLayers.GetValue(); return value < 0 ? (uint)LightLayerEnum.Everything : (uint)value; } 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 8398641e532..02b7557d62e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1247,10 +1247,11 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd) m_ShaderVariablesGlobalCB._SSRefractionInvScreenWeightDistance = 1.0f / ssRefraction.screenFadeDistance.value; IndirectLightingController indirectLightingController = hdCamera.volumeStack.GetComponent(); - m_ShaderVariablesGlobalCB._IndirectLightingMultiplier = new Vector4(indirectLightingController.indirectDiffuseLightingMultiplier.value, - indirectLightingController.GetReflectionLightingLayers(), - indirectLightingController.reflectionLightingMultiplier.value, - indirectLightingController.GetIndirectDiffuseLightingLayers()); + m_ShaderVariablesGlobalCB._IndirectDiffuseLightingMultiplier = indirectLightingController.indirectDiffuseLightingMultiplier.value; + m_ShaderVariablesGlobalCB._IndirectDiffuseLightingLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? indirectLightingController.GetIndirectDiffuseLightingLayers() : uint.MaxValue; + m_ShaderVariablesGlobalCB._ReflectionLightingMultiplier = indirectLightingController.reflectionLightingMultiplier.value; + m_ShaderVariablesGlobalCB._ReflectionLightingLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? indirectLightingController.GetReflectionLightingLayers() : uint.MaxValue; + m_ShaderVariablesGlobalCB._OffScreenRendering = 0; m_ShaderVariablesGlobalCB._OffScreenDownsampleFactor = 1; m_ShaderVariablesGlobalCB._ReplaceDiffuseForIndirect = hdCamera.frameSettings.IsEnabled(FrameSettingsField.ReplaceDiffuseForIndirect) ? 1.0f : 0.0f; 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 e5c455d3cae..373797bb73d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -282,14 +282,12 @@ float GetInversePreviousExposureMultiplier() // Helper function for indirect control volume float GetIndirectDiffuseMultiplier(uint renderingLayers) { - uint indirectDiffuseLayers = uint(_IndirectLightingMultiplier.y * 255.5); - return (indirectDiffuseLayers & renderingLayers) ? _IndirectLightingMultiplier.x : 1.0f; + return (_IndirectDiffuseLightingLayers & renderingLayers) ? _IndirectDiffuseLightingMultiplier : 1.0f; } float GetIndirectSpecularMultiplier(uint renderingLayers) { - uint indirectSpecularLayers = uint(_IndirectLightingMultiplier.w * 255.5); - return (indirectSpecularLayers & renderingLayers) ? _IndirectLightingMultiplier.z : 1.0f; + return (_ReflectionLightingLayers & renderingLayers) ? _ReflectionLightingMultiplier : 1.0f; } // Functions to clamp UVs to use when RTHandle system is used. 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 d5207d3ae47..bb31626d12e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs @@ -177,8 +177,11 @@ unsafe struct ShaderVariablesGlobal public float _ReplaceDiffuseForIndirect; public Vector4 _AmbientOcclusionParam; // xyz occlusion color, w directLightStrenght - public Vector4 _IndirectLightingMultiplier; // .x indirect diffuse multiplier, .y indirect diffuse layers mask (use with indirect lighting volume controler) - // .z indirect specular multiplier, .w indirect specular layers mask + + public float _IndirectDiffuseLightingMultiplier; + public uint _IndirectDiffuseLightingLayers; + public float _ReflectionLightingMultiplier; + public uint _ReflectionLightingLayers; public float _MicroShadowOpacity; public uint _EnableProbeVolumes; diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl index 9cb82542b2d..ebe3ecad8b0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl @@ -94,7 +94,10 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0) float _ContactShadowOpacity; float _ReplaceDiffuseForIndirect; float4 _AmbientOcclusionParam; - float4 _IndirectLightingMultiplier; + float _IndirectDiffuseLightingMultiplier; + uint _IndirectDiffuseLightingLayers; + float _ReflectionLightingMultiplier; + uint _ReflectionLightingLayers; float _MicroShadowOpacity; uint _EnableProbeVolumes; uint _ProbeVolumeCount; From 82dc77b854c6445993a5a6a4e979667160be3554 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 15 Jun 2020 18:41:12 +0200 Subject: [PATCH 05/10] Update IndirectLightingControllerEditor.cs --- .../Lighting/IndirectLightingControllerEditor.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs index 7c6ae0672cb..8e5ba7eb59a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs @@ -31,17 +31,17 @@ public override void OnEnable() public override void OnInspectorGUI() { - PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier", "Sets the multiplier for indirect diffuse lighting.")); + PropertyField(m_IndirectDiffuseLightingMultiplier, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Multiplier", "Sets the multiplier for indirect diffuse lighting.\nIt affect Ambient Probe, Light Probes, Lightmaps, Light Probe Volumes, Screen Space Global Illumination, Raytrace Global Illumination.")); GUI.enabled = HDUtils.hdrpSettings.supportLightLayers; - PropertyField(m_IndirectDiffuseLightingLayers, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Layers", "Sets the light layer mask for indirect diffuse lighting.")); + PropertyField(m_IndirectDiffuseLightingLayers, EditorGUIUtility.TrTextContent("Indirect Diffuse Lighting Layers", "Sets the light layer mask for indirect diffuse lighting. Only matching RenderingLayers on Mesh will get affected by the multiplier.")); GUI.enabled = true; - PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier", "Sets the multiplier for reflected specular lighting.")); + PropertyField(m_ReflectionLightingMultiplier, EditorGUIUtility.TrTextContent("Reflection Lighting Multiplier", "Sets the multiplier for reflected specular lighting.\nIt affect Sky Reflection, Reflection Probes, Planar Probes, Screen Space Reflection, Raytrace Reflection.")); GUI.enabled = HDUtils.hdrpSettings.supportLightLayers; - PropertyField(m_ReflectionLightingLayers, EditorGUIUtility.TrTextContent("Reflection Lighting Layers", "Sets the light layer mask for reflected specular lighting.")); + PropertyField(m_ReflectionLightingLayers, EditorGUIUtility.TrTextContent("Reflection Lighting Layers", "Sets the light layer mask for reflected specular lighting. Only matching RenderingLayers on Mesh will get affected by the multiplier.")); GUI.enabled = true; - PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection Probe Intensity Multiplier", "Sets the intensity multiplier for reflection probes.")); + PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection Probe Intensity Multiplier", "Sets the intensity multiplier for Reflection Probes.")); } } } From 4e1f5ce20e686d2e3af69eda67f58d55d923fff8 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 15 Jun 2020 18:41:51 +0200 Subject: [PATCH 06/10] Update CHANGELOG.md --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6e5014a17a9..f8e51351a66 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -148,6 +148,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added support to combine RTSSS and RTGI (1248733). - Added IES Profile support for Point, Spot and Rectangular-Area lights - Added support for multiple mapping modes in AxF. +- Add support of lightlayers on indirect lighting controller ### Fixed - Fix when rescale probe all direction below zero (1219246) From 3544d230c0dd42782b8d01b19e889be248e19141 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 15 Jun 2020 18:52:06 +0200 Subject: [PATCH 07/10] Update Override-Indirect-Lighting-Controller.md --- .../Override-Indirect-Lighting-Controller.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md index fe2646f9438..f30252a36ef 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md @@ -11,16 +11,29 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework, 1. In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector. 2. In the Inspector, navigate to **Add Override > Lighting** and click on **Indirect Lighting Controller**. You can now use the **Indirect Lighting Controller** to control baked or precomputed indirect lighting. + + ## Properties ![](Images/Override-IndirectLightingController1.png) | Property | Description | | ------------------------------- | ------------------------------------------------------------ | -| **Indirect Diffuse Intensity** | A multiplier for baked and realtime Global Illumination lightmaps and Light Probes. HDRP multiplies the lightmap and Light Probe data by this value. | -| **Indirect Specular Intensity** | A multiplier for baked, realtime, and custom Reflection Probes. HDRP multiplies the Reflection Probe data by this value. | +| **Indirect Diffuse Lighting Multiplier** | A multiplier for lightmaps, Light Probes, Light Probe Volumes, Screen Space Global Illumination and Raytrace Global Illumination. HDRP multiplies all those data by this value. | +| **Indirect Diffuse Lighting Layers** | Light layers for indirect diffuse lighting. See [LightLayers](Light-Layers.md). After you enable Light Layers, you can then use them to decouple Meshes from the this multiplier in your Scene. | +| **Reflection Lighting Multiplier** | A multiplier for baked, realtime, custom Reflection Probes and Planar Probes, Screen Space Reflection, Raytrace Reflection and Sky Reflection. HDRP multiplies all those data by this value. | +| **Reflection Lighting Layers** | Light layers for reflection lighting. See [LightLayers](Light-Layers.md). After you enable Light Layers, you can then use them to decouple Meshes from the this multiplier in your Scene. | +| **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom Reflection Probes. HDRP multiplies the Reflection Probe data by this value. | + +## Using Light Layers +After you enable Light Layers, you can then use them to decouple Meshes from certain Lights in your Scene. To do this: +1. Click on a Light in the Hierarchy or the Scene view to view it in the Inspector. +2. Expose [more options](More-Options.html) in the **General** section to expose the **Light Layer** property. +3. Use the **Light Layer** property drop-down to select which Light Layers this Light affects. +4. Click on a Mesh Renderer in the Hierarchy or the Scene view to view it in the Inspector. +5. Use the **Rendering Layer Mask** drop-down to select which Light Layers affect this Mesh Renderer. When you enable Light Layers, a Light only affects a Mesh Renderer if they both use a matching Light Layer. ## Details From 9be2e82b58ac7ed3b53f73db5023d2bbe827d6d2 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 15 Jun 2020 18:57:24 +0200 Subject: [PATCH 08/10] Update Override-Indirect-Lighting-Controller.md --- .../Override-Indirect-Lighting-Controller.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md index f30252a36ef..ba4fe184cb0 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md @@ -11,8 +11,6 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework, 1. In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector. 2. In the Inspector, navigate to **Add Override > Lighting** and click on **Indirect Lighting Controller**. You can now use the **Indirect Lighting Controller** to control baked or precomputed indirect lighting. - - ## Properties ![](Images/Override-IndirectLightingController1.png) @@ -25,16 +23,6 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework, | **Reflection Lighting Layers** | Light layers for reflection lighting. See [LightLayers](Light-Layers.md). After you enable Light Layers, you can then use them to decouple Meshes from the this multiplier in your Scene. | | **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom Reflection Probes. HDRP multiplies the Reflection Probe data by this value. | -## Using Light Layers - -After you enable Light Layers, you can then use them to decouple Meshes from certain Lights in your Scene. To do this: - -1. Click on a Light in the Hierarchy or the Scene view to view it in the Inspector. -2. Expose [more options](More-Options.html) in the **General** section to expose the **Light Layer** property. -3. Use the **Light Layer** property drop-down to select which Light Layers this Light affects. -4. Click on a Mesh Renderer in the Hierarchy or the Scene view to view it in the Inspector. -5. Use the **Rendering Layer Mask** drop-down to select which Light Layers affect this Mesh Renderer. When you enable Light Layers, a Light only affects a Mesh Renderer if they both use a matching Light Layer. - ## Details An example of a situation where an **Indirect Lighting Controller** would be useful is when your Camera is in a dark area and you want to light the area suddenly. To create this effect: From 0107aaffb9756015a5865f9970cb6151b11ee112 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Tue, 16 Jun 2020 12:40:21 +0200 Subject: [PATCH 09/10] Update Override-Indirect-Lighting-Controller.md --- .../Override-Indirect-Lighting-Controller.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md index ba4fe184cb0..2eecccd730e 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md @@ -17,11 +17,11 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework, | Property | Description | | ------------------------------- | ------------------------------------------------------------ | -| **Indirect Diffuse Lighting Multiplier** | A multiplier for lightmaps, Light Probes, Light Probe Volumes, Screen Space Global Illumination and Raytrace Global Illumination. HDRP multiplies all those data by this value. | -| **Indirect Diffuse Lighting Layers** | Light layers for indirect diffuse lighting. See [LightLayers](Light-Layers.md). After you enable Light Layers, you can then use them to decouple Meshes from the this multiplier in your Scene. | -| **Reflection Lighting Multiplier** | A multiplier for baked, realtime, custom Reflection Probes and Planar Probes, Screen Space Reflection, Raytrace Reflection and Sky Reflection. HDRP multiplies all those data by this value. | -| **Reflection Lighting Layers** | Light layers for reflection lighting. See [LightLayers](Light-Layers.md). After you enable Light Layers, you can then use them to decouple Meshes from the this multiplier in your Scene. | -| **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom Reflection Probes. HDRP multiplies the Reflection Probe data by this value. | +| **Indirect Diffuse Lighting Multiplier** | A multiplier for lightmaps, Light Probes, Light Probe Volumes, Screen-Space Global Illumination, and [Ray-Traced Global Illumination](Ray-Traced-Global-Illumination.md). HDRP multiplies the light data from all of these by this value. | +| **Indirect Diffuse Lighting Layers** | Specifies the [Light Layers](Light-Layers.md) for indirect diffuse lighting. If you enable Light Layers, you can use them to decouple Meshes in your Scene from the above multiplier. | +| **Reflection Lighting Multiplier** | A multiplier for baked, realtime, custom [Reflection Probes](Reflection-Probe.md) and [Planar Probes](Planar-Reflection-Probe.md), [Screen-Space Reflection](Override-Screen-Space-Reflection.md), [Ray-Traced Reflection](Ray-Traced-Reflections.md), and Sky Reflection. HDRP multiplies the light data from all of these by this value. | +| **Reflection Lighting Layers** | LSpecifies the [Light Layers](Light-Layers.md) for reflection lighting. If you enable Light Layers, you can use them to decouple Meshes in your Scene from the above multiplier. | +| **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom [Reflection Probes](Reflection-Probe.md). HDRP multiplies the Reflection Probe data by this value. | ## Details From 61c3d24fb6aaa9a000d8a63c8b47c9c1730c840a Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Tue, 16 Jun 2020 14:33:28 +0200 Subject: [PATCH 10/10] Update. Indirect controller also affect planar --- .../Documentation~/Override-Indirect-Lighting-Controller.md | 2 +- .../Editor/Lighting/IndirectLightingControllerEditor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md index 2eecccd730e..0688b528c12 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md @@ -21,7 +21,7 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework, | **Indirect Diffuse Lighting Layers** | Specifies the [Light Layers](Light-Layers.md) for indirect diffuse lighting. If you enable Light Layers, you can use them to decouple Meshes in your Scene from the above multiplier. | | **Reflection Lighting Multiplier** | A multiplier for baked, realtime, custom [Reflection Probes](Reflection-Probe.md) and [Planar Probes](Planar-Reflection-Probe.md), [Screen-Space Reflection](Override-Screen-Space-Reflection.md), [Ray-Traced Reflection](Ray-Traced-Reflections.md), and Sky Reflection. HDRP multiplies the light data from all of these by this value. | | **Reflection Lighting Layers** | LSpecifies the [Light Layers](Light-Layers.md) for reflection lighting. If you enable Light Layers, you can use them to decouple Meshes in your Scene from the above multiplier. | -| **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom [Reflection Probes](Reflection-Probe.md). HDRP multiplies the Reflection Probe data by this value. | +| **Reflection Probe Intensity Multiplier** | A multiplier for baked, realtime, and custom [Reflection Probes](Reflection-Probe.md) and [Planar Probes](Planar-Reflection-Probe.md). HDRP multiplies the Reflection Probe data by this value. | ## Details diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs index 8e5ba7eb59a..d2a61a5e247 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/IndirectLightingControllerEditor.cs @@ -41,7 +41,7 @@ public override void OnInspectorGUI() PropertyField(m_ReflectionLightingLayers, EditorGUIUtility.TrTextContent("Reflection Lighting Layers", "Sets the light layer mask for reflected specular lighting. Only matching RenderingLayers on Mesh will get affected by the multiplier.")); GUI.enabled = true; - PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection Probe Intensity Multiplier", "Sets the intensity multiplier for Reflection Probes.")); + PropertyField(m_ReflectionProbeIntensityMultiplier, EditorGUIUtility.TrTextContent("Reflection/Planar Probe Intensity Multiplier", "Sets the intensity multiplier for Reflection/Planar Probes.")); } } }