maint: added htrace ssgi
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39d33876f15f45c091746aa50bedf133
|
||||
timeCreated: 1745943075
|
||||
@@ -0,0 +1,180 @@
|
||||
//pipelinedefine
|
||||
#define H_URP
|
||||
|
||||
using System;
|
||||
using HTraceSSGI.Scripts.Data.Private;
|
||||
using HTraceSSGI.Scripts.Data.Public;
|
||||
using HTraceSSGI.Scripts.Globals;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace HTraceSSGI.Scripts.Infrastructure.URP
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class HAmbientOverrideVolume: MonoBehaviour
|
||||
{
|
||||
private Volume _volumeComponent;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
private ProbeVolumesOptions _probeVolumesOptionsOverrideComponent;
|
||||
#endif
|
||||
|
||||
private static HAmbientOverrideVolume s_instance;
|
||||
|
||||
public static HAmbientOverrideVolume Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_instance == null)
|
||||
{
|
||||
s_instance = FindObjectOfType<HAmbientOverrideVolume>();
|
||||
|
||||
if (s_instance == null)
|
||||
{
|
||||
GameObject singletonObject = new GameObject($"HTrace AmbientOverride");
|
||||
s_instance = singletonObject.AddComponent<HAmbientOverrideVolume>();
|
||||
|
||||
if (Application.isPlaying)
|
||||
DontDestroyOnLoad(singletonObject);
|
||||
}
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActiveVolume(bool isActive)
|
||||
{
|
||||
_volumeComponent.enabled = isActive;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
_probeVolumesOptionsOverrideComponent.active = isActive;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitializeSingleton();
|
||||
SetupVolumeURP();
|
||||
}
|
||||
|
||||
private void InitializeSingleton()
|
||||
{
|
||||
if (s_instance == null)
|
||||
{
|
||||
s_instance = this;
|
||||
if (Application.isPlaying)
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else if (s_instance != this)
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
Destroy(gameObject);
|
||||
else
|
||||
DestroyImmediate(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile;
|
||||
if (!EditorApplication.isPlayingOrWillChangePlaymode)
|
||||
SetupVolumeURP();
|
||||
|
||||
gameObject.hideFlags = HideFlags.HideAndDontSave;
|
||||
if (s_instance != null && profile != null && profile.DebugSettings != null)
|
||||
s_instance.gameObject.hideFlags = profile.DebugSettings.ShowBowels ? HideFlags.None : HideFlags.HideAndDontSave;
|
||||
}
|
||||
#endif
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (s_instance == this)
|
||||
{
|
||||
s_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupVolumeURP()
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
CreateSSGIOverrideComponent();
|
||||
ApplySSGIOverrideComponentSettings();
|
||||
ChangeObjectWithSerialization_ONLYEDITOR();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
private void CreateSSGIOverrideComponent()
|
||||
{
|
||||
HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile;
|
||||
if (profile != null && profile != null && profile.DebugSettings != null)
|
||||
gameObject.hideFlags = profile.DebugSettings.ShowBowels ? HideFlags.None : HideFlags.HideAndDontSave;
|
||||
|
||||
_volumeComponent = gameObject.GetComponent<Volume>();
|
||||
if (_volumeComponent == null)
|
||||
{
|
||||
_volumeComponent = gameObject.AddComponent<Volume>();
|
||||
_volumeComponent.enabled = false;
|
||||
}
|
||||
|
||||
if (_volumeComponent.sharedProfile == null)
|
||||
{
|
||||
//We can't crate it in runtime, because after build it will break.
|
||||
//it will call only in editor, but if someone changes it in runtime, we will override.
|
||||
_volumeComponent.sharedProfile = Resources.Load<VolumeProfile>($"{HNames.ASSET_NAME}/HTraceSSGI Volume Profile URP");
|
||||
}
|
||||
|
||||
if (_probeVolumesOptionsOverrideComponent == null)
|
||||
_volumeComponent.sharedProfile.TryGet(out _probeVolumesOptionsOverrideComponent);
|
||||
}
|
||||
|
||||
private void ApplySSGIOverrideComponentSettings()
|
||||
{
|
||||
_volumeComponent.weight = 1;
|
||||
_volumeComponent.priority = 100;
|
||||
#if UNITY_EDITOR
|
||||
_volumeComponent.runInEditMode = true;
|
||||
#endif
|
||||
if (_probeVolumesOptionsOverrideComponent != null)
|
||||
{
|
||||
_probeVolumesOptionsOverrideComponent.normalBias.overrideState = true;
|
||||
_probeVolumesOptionsOverrideComponent.viewBias.overrideState = true;
|
||||
_probeVolumesOptionsOverrideComponent.samplingNoise.overrideState = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeObjectWithSerialization_ONLYEDITOR()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (_probeVolumesOptionsOverrideComponent == null)
|
||||
return;
|
||||
|
||||
SerializedObject probeVolumesOptionsObject = new SerializedObject(_probeVolumesOptionsOverrideComponent);
|
||||
|
||||
var normalBias = probeVolumesOptionsObject.FindProperty("normalBias");
|
||||
var m_OverrideState_normalBias = normalBias.FindPropertyRelative("m_OverrideState");
|
||||
var m_Value_normalBias = normalBias.FindPropertyRelative("m_Value");
|
||||
m_OverrideState_normalBias.boolValue = true;
|
||||
m_Value_normalBias.floatValue = 0.0f;
|
||||
|
||||
var viewBias = probeVolumesOptionsObject.FindProperty("viewBias");
|
||||
var m_OverrideState_viewBias = viewBias.FindPropertyRelative("m_OverrideState");
|
||||
var m_Value_viewBias = viewBias.FindPropertyRelative("m_Value");
|
||||
m_OverrideState_viewBias.boolValue = true;
|
||||
m_Value_viewBias.floatValue = 0.0f;
|
||||
|
||||
var samplingNoise = probeVolumesOptionsObject.FindProperty("samplingNoise");
|
||||
var m_OverrideState_samplingNoise = samplingNoise.FindPropertyRelative("m_OverrideState");
|
||||
var m_Value_samplingNoise = samplingNoise.FindPropertyRelative("m_Value");
|
||||
m_OverrideState_samplingNoise.boolValue = true;
|
||||
m_Value_samplingNoise.floatValue = 0.0f;
|
||||
|
||||
probeVolumesOptionsObject.ApplyModifiedProperties();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 665d2080decf49c2b73ac4747dbde1df
|
||||
timeCreated: 1757588204
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 336896
|
||||
packageName: 'HTrace: Screen Space Global Illumination URP'
|
||||
packageVersion: 1.2.0
|
||||
assetPath: Assets/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs
|
||||
uploadId: 840002
|
||||
@@ -0,0 +1,229 @@
|
||||
//pipelinedefine
|
||||
#define H_URP
|
||||
|
||||
using System;
|
||||
using HTraceSSGI.Scripts.Data.Private;
|
||||
using HTraceSSGI.Scripts.Data.Public;
|
||||
using HTraceSSGI.Scripts.Editor;
|
||||
using HTraceSSGI.Scripts.Globals;
|
||||
using HTraceSSGI.Scripts.Passes.URP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
#if UNITY_EDITOR
|
||||
using HTraceSSGI.Scripts.PipelelinesConfigurator;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace HTraceSSGI.Scripts.Infrastructure.URP
|
||||
{
|
||||
[DisallowMultipleRendererFeature]
|
||||
[ExecuteAlways, ExecuteInEditMode]
|
||||
[HelpURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)]
|
||||
public class HTraceSSGIRendererFeature : ScriptableRendererFeature
|
||||
{
|
||||
public bool UseVolumes = true;
|
||||
internal static bool IsUseVolumes { get; private set; }
|
||||
|
||||
private PrePassURP _prePassURP;
|
||||
private MotionVectorsURP _motionVectors;
|
||||
private GBufferPassURP _gBufferPass;
|
||||
private SSGIPassURP _ssgiPassUrp;
|
||||
private FinalPassURP _finalPassURP;
|
||||
|
||||
private bool _initialized = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this feature's resources. This is called every time serialization happens.
|
||||
/// </summary>
|
||||
public override void Create()
|
||||
{
|
||||
name = HNames.ASSET_NAME_FULL;
|
||||
// ActiveProfile = Profile;
|
||||
IsUseVolumes = UseVolumes;
|
||||
Dispose();
|
||||
|
||||
if (UseVolumes)
|
||||
{
|
||||
var stack = VolumeManager.instance.stack;
|
||||
HTraceSSGIVolume hTraceVolume = stack?.GetComponent<HTraceSSGIVolume>();
|
||||
SettingsBuild(hTraceVolume);
|
||||
}
|
||||
|
||||
_prePassURP = new PrePassURP();
|
||||
_prePassURP.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
|
||||
_motionVectors = new MotionVectorsURP();
|
||||
_motionVectors.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
|
||||
_gBufferPass = new GBufferPassURP();
|
||||
_gBufferPass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
|
||||
_ssgiPassUrp = new SSGIPassURP();
|
||||
_ssgiPassUrp.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
|
||||
_finalPassURP = new FinalPassURP();
|
||||
_finalPassURP.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
HPipelinesConfigurator.AlwaysIncludedShaders();
|
||||
#endif
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when render targets are allocated and ready to be used.
|
||||
/// </summary>
|
||||
/// <param name="renderer"></param>
|
||||
/// <param name="renderingData"></param>
|
||||
/// <!--https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@13.1/manual/upgrade-guide-2022-1.html-->
|
||||
public override void SetupRenderPasses(ScriptableRenderer renderer, in RenderingData renderingData)
|
||||
{
|
||||
if (_initialized == false)
|
||||
return;
|
||||
|
||||
if (HRendererURP.RenderGraphEnabled == false)
|
||||
{
|
||||
_prePassURP.Initialize(renderer);
|
||||
_motionVectors.Initialize(renderer);
|
||||
_gBufferPass.Initialize(renderer);
|
||||
_ssgiPassUrp.Initialize(renderer);
|
||||
_finalPassURP.Initialize(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Injects one or multiple ScriptableRenderPass in the renderer.
|
||||
/// </summary>
|
||||
/// <param name="renderer"></param>
|
||||
/// <param name="renderingData"></param>
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
if (renderingData.cameraData.cameraType == CameraType.Reflection || renderingData.cameraData.cameraType == CameraType.Preview)
|
||||
return;
|
||||
|
||||
var isActive = HTraceSSGISettings.ActiveProfile != null;
|
||||
|
||||
IsUseVolumes = UseVolumes;
|
||||
if (UseVolumes)
|
||||
{
|
||||
var stack = VolumeManager.instance.stack;
|
||||
var hTraceVolume = stack.GetComponent<HTraceSSGIVolume>();
|
||||
isActive = hTraceVolume != null && hTraceVolume.IsActive();
|
||||
|
||||
SettingsBuild(hTraceVolume);
|
||||
}
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HAmbientOverrideVolume.Instance.SetActiveVolume(isActive && HTraceSSGISettings.ActiveProfile != null && HTraceSSGISettings.ActiveProfile.GeneralSettings != null && HTraceSSGISettings.ActiveProfile.GeneralSettings.AmbientOverride);
|
||||
#endif
|
||||
|
||||
if (!isActive)
|
||||
return;
|
||||
|
||||
#if !UNITY_2022_1_OR_NEWER
|
||||
_prePassURP.Initialize(renderer);
|
||||
_motionVectors.Initialize(renderer);
|
||||
_gBufferPass.Initialize(renderer);
|
||||
_ssgiPassUrp.Initialize(renderer);
|
||||
_finalPassURP.Initialize(renderer);
|
||||
#endif
|
||||
renderer.EnqueuePass(_prePassURP);
|
||||
renderer.EnqueuePass(_motionVectors);
|
||||
renderer.EnqueuePass(_gBufferPass);
|
||||
renderer.EnqueuePass(_ssgiPassUrp);
|
||||
renderer.EnqueuePass(_finalPassURP);
|
||||
}
|
||||
|
||||
private void SettingsBuild(HTraceSSGIVolume hTraceVolume)
|
||||
{
|
||||
if (hTraceVolume == null || UseVolumes == false)
|
||||
return;
|
||||
|
||||
if (HTraceSSGISettings.ActiveProfile == null)
|
||||
{
|
||||
HTraceSSGISettings.SetProfile(ScriptableObject.CreateInstance<HTraceSSGIProfile>());
|
||||
#if UNITY_EDITOR
|
||||
HTraceSSGISettings.ActiveProfile.ApplyPreset(HTraceSSGIPreset.Balanced);
|
||||
#endif
|
||||
HTraceSSGISettings.ActiveProfile.name = "New HTrace SSGI Profile";
|
||||
}
|
||||
|
||||
var activeProfile = HTraceSSGISettings.ActiveProfile;
|
||||
|
||||
// Global Settings
|
||||
activeProfile.GeneralSettings.DebugMode = hTraceVolume.DebugMode.value;
|
||||
activeProfile.GeneralSettings.HBuffer = hTraceVolume.HBuffer.value;
|
||||
|
||||
// Global - Pipeline Integration
|
||||
activeProfile.GeneralSettings.MetallicIndirectFallback = hTraceVolume.MetallicIndirectFallback.value;
|
||||
activeProfile.GeneralSettings.AmbientOverride = hTraceVolume.AmbientOverride.value;
|
||||
activeProfile.GeneralSettings.Multibounce = hTraceVolume.Multibounce.value;
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
activeProfile.GeneralSettings.ExcludeReceivingMask = hTraceVolume.ExcludeReceivingMask.value;
|
||||
activeProfile.GeneralSettings.ExcludeCastingMask = hTraceVolume.ExcludeCastingMask.value;
|
||||
#endif
|
||||
activeProfile.GeneralSettings.FallbackType = hTraceVolume.FallbackType.value;
|
||||
activeProfile.GeneralSettings.SkyIntensity = hTraceVolume.SkyIntensity.value;
|
||||
|
||||
// APV parameters
|
||||
activeProfile.GeneralSettings.ViewBias = hTraceVolume.ViewBias.value;
|
||||
activeProfile.GeneralSettings.NormalBias = hTraceVolume.NormalBias.value;
|
||||
activeProfile.GeneralSettings.SamplingNoise = hTraceVolume.SamplingNoise.value;
|
||||
activeProfile.GeneralSettings.IntensityMultiplier = hTraceVolume.IntensityMultiplier.value;
|
||||
activeProfile.GeneralSettings.DenoiseFallback = hTraceVolume.DenoiseFallback.value;
|
||||
|
||||
// Global - Visuals
|
||||
activeProfile.SSGISettings.BackfaceLighting = hTraceVolume.BackfaceLighting.value;
|
||||
activeProfile.SSGISettings.MaxRayLength = hTraceVolume.MaxRayLength.value;
|
||||
activeProfile.SSGISettings.ThicknessMode = hTraceVolume.ThicknessMode.value;
|
||||
activeProfile.SSGISettings.Thickness = hTraceVolume.Thickness.value;
|
||||
activeProfile.SSGISettings.Intensity = hTraceVolume.Intensity.value;
|
||||
activeProfile.SSGISettings.Falloff = hTraceVolume.Falloff.value;
|
||||
|
||||
// Quality - Tracing
|
||||
activeProfile.SSGISettings.RayCount = hTraceVolume.RayCount.value;
|
||||
activeProfile.SSGISettings.StepCount = hTraceVolume.StepCount.value;
|
||||
activeProfile.SSGISettings.RefineIntersection = hTraceVolume.RefineIntersection.value;
|
||||
activeProfile.SSGISettings.FullResolutionDepth = hTraceVolume.FullResolutionDepth.value;
|
||||
|
||||
// Quality - Rendering
|
||||
activeProfile.SSGISettings.Checkerboard = hTraceVolume.Checkerboard.value;
|
||||
activeProfile.SSGISettings.RenderScale = hTraceVolume.RenderScale.value;
|
||||
|
||||
// Denoising
|
||||
activeProfile.DenoisingSettings.BrightnessClamp = hTraceVolume.BrightnessClamp.value;
|
||||
activeProfile.DenoisingSettings.MaxValueBrightnessClamp = hTraceVolume.MaxValueBrightnessClamp.value;
|
||||
activeProfile.DenoisingSettings.MaxDeviationBrightnessClamp = hTraceVolume.MaxDeviationBrightnessClamp.value;
|
||||
|
||||
// Denoising - ReSTIR Validation
|
||||
activeProfile.DenoisingSettings.HalfStepValidation = hTraceVolume.HalfStepValidation.value;
|
||||
activeProfile.DenoisingSettings.SpatialOcclusionValidation = hTraceVolume.SpatialOcclusionValidation.value;
|
||||
activeProfile.DenoisingSettings.TemporalLightingValidation = hTraceVolume.TemporalLightingValidation.value;
|
||||
activeProfile.DenoisingSettings.TemporalOcclusionValidation = hTraceVolume.TemporalOcclusionValidation.value;
|
||||
|
||||
// Denoising - Spatial Filter
|
||||
activeProfile.DenoisingSettings.SpatialRadius = hTraceVolume.SpatialRadius.value;
|
||||
activeProfile.DenoisingSettings.Adaptivity = hTraceVolume.Adaptivity.value;
|
||||
activeProfile.DenoisingSettings.RecurrentBlur = hTraceVolume.RecurrentBlur.value;
|
||||
activeProfile.DenoisingSettings.FireflySuppression = hTraceVolume.FireflySuppression.value;
|
||||
|
||||
// Debug
|
||||
activeProfile.DebugSettings.ShowBowels = hTraceVolume.ShowBowels.value;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
_prePassURP?.Dispose();
|
||||
_motionVectors?.Dispose();
|
||||
_gBufferPass?.Dispose();
|
||||
_ssgiPassUrp?.Dispose();
|
||||
_finalPassURP?.Dispose();
|
||||
|
||||
_prePassURP = null;
|
||||
_motionVectors = null;
|
||||
_gBufferPass = null;
|
||||
_ssgiPassUrp = null;
|
||||
_finalPassURP = null;
|
||||
|
||||
_initialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43a84b065505d8f41b624b74c882ed4b
|
||||
timeCreated: 1729922427
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 336896
|
||||
packageName: 'HTrace: Screen Space Global Illumination URP'
|
||||
packageVersion: 1.2.0
|
||||
assetPath: Assets/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs
|
||||
uploadId: 840002
|
||||
@@ -0,0 +1,231 @@
|
||||
//pipelinedefine
|
||||
#define H_URP
|
||||
|
||||
|
||||
using System;
|
||||
using HTraceSSGI.Scripts.Globals;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace HTraceSSGI.Scripts.Infrastructure.URP
|
||||
{
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
[VolumeComponentMenu("Lighting/HTrace: Screen Space Global Illumination"), SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
|
||||
#else
|
||||
[VolumeComponentMenuForRenderPipeline("Lighting/HTrace: Screen Space Global Illumination", typeof(UniversalRenderPipeline))]
|
||||
#endif
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
[VolumeRequiresRendererFeatures(typeof(HTraceSSGIRendererFeature))]
|
||||
#endif
|
||||
[HelpURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)]
|
||||
public sealed class HTraceSSGIVolume : VolumeComponent, IPostProcessComponent
|
||||
{
|
||||
public HTraceSSGIVolume()
|
||||
{
|
||||
displayName = HNames.ASSET_NAME_FULL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable Screen Space Global Illumination.
|
||||
/// </summary>
|
||||
[Tooltip("Enable HTrace Screen Space Global Illumination")]
|
||||
public BoolParameter Enable = new BoolParameter(false, BoolParameter.DisplayType.EnumPopup);
|
||||
|
||||
// --------------------------------------- GLOBAL SETTINGS ---------------------------------------------
|
||||
|
||||
[InspectorName("Debug Mode"), Tooltip("")]
|
||||
public DebugModeParameter DebugMode = new(Globals.DebugMode.None, false);
|
||||
|
||||
[InspectorName("Buffer"), Tooltip("Visualizes data from different buffers for debugging")]
|
||||
public HBufferParameter HBuffer = new(Globals.HBuffer.Multi, false);
|
||||
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
[InspectorName("Exclude Casting Mask"), Tooltip("Prevents objects on the selected layers from contributing to GI")]
|
||||
public RenderingLayerMaskEnumParameter ExcludeCastingMask = new(0, false);
|
||||
|
||||
[InspectorName("Exclude Receiving Mask"), Tooltip("Prevents objects on the selected layers from receiving GI")]
|
||||
public RenderingLayerMaskEnumParameter ExcludeReceivingMask = new(0, false);
|
||||
#endif
|
||||
|
||||
[InspectorName("Fallback Type"), Tooltip("Fallback data for rays that failed to find a hit in screen space")]
|
||||
public FallbackTypeParameter FallbackType = new FallbackTypeParameter(Globals.FallbackType.None, false);
|
||||
|
||||
[InspectorName("Sky Intensity"), Tooltip("Brightness of the sky used for fallback")]
|
||||
public ClampedFloatParameter SkyIntensity = new ClampedFloatParameter(0.5f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("View Bias"), Tooltip("Offsets the APV sample position towards the camera")]
|
||||
public ClampedFloatParameter ViewBias = new ClampedFloatParameter(0.1f, 0.0f, 2.0f, false);
|
||||
|
||||
[InspectorName("Normal Bias"), Tooltip("Offsets the APV sample position along the pixel’s surface normal")]
|
||||
public ClampedFloatParameter NormalBias = new ClampedFloatParameter(0.25f, 0.0f, 2.0f, false);
|
||||
|
||||
[InspectorName("Sampling Noise"), Tooltip("Amount of jitter noise added to the APV sample position")]
|
||||
public ClampedFloatParameter SamplingNoise = new ClampedFloatParameter(0.1f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("Intensity Multiplier"), Tooltip("Strength of the light contribution from APV")]
|
||||
public ClampedFloatParameter IntensityMultiplier = new ClampedFloatParameter(1.0f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("Denoise Fallback"), Tooltip("Includes fallback lighting in denoising")]
|
||||
public BoolParameter DenoiseFallback = new BoolParameter(true, false);
|
||||
|
||||
// ------------------------------------- Pipeline Integration -----------------------------------------
|
||||
|
||||
[InspectorName("Metallic Indirect Fallback"), Tooltip("Renders metals as diffuse when no reflections exist, preventing them from going black")]
|
||||
public BoolParameter MetallicIndirectFallback = new BoolParameter(false, false);
|
||||
|
||||
[InspectorName("Ambient Override"), Tooltip("Removes Unity’s ambient lighting before HTrace SSGI runs to avoid double GI")]
|
||||
public BoolParameter AmbientOverride = new BoolParameter(true, false);
|
||||
|
||||
[InspectorName("Multibounce"), Tooltip("Uses previous frame GI to approximate additional light bounces")]
|
||||
public BoolParameter Multibounce = new BoolParameter(true, false);
|
||||
|
||||
// -------------------------------------------- Visuals -----------------------------------------------
|
||||
|
||||
[InspectorName("Backface Lighting"), Tooltip("Include lighting from back-facing surfaces")]
|
||||
public ClampedFloatParameter BackfaceLighting = new ClampedFloatParameter(0.25f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("Max Ray Length"), Tooltip("Maximum ray distance in meters")]
|
||||
public ClampedFloatParameter MaxRayLength = new ClampedFloatParameter(100.0f, 0.0f, float.MaxValue, false);
|
||||
|
||||
[InspectorName("Thickness Mode"), Tooltip("Method used for thickness estimation")]
|
||||
public ThicknessModeParameter ThicknessMode = new(Globals.ThicknessMode.Relative, false);
|
||||
|
||||
[InspectorName("Thickness"), Tooltip("Virtual object thickness for ray intersections")]
|
||||
public ClampedFloatParameter Thickness = new ClampedFloatParameter(0.35f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("Intensity"), Tooltip("Indirect lighting intensity multiplier")]
|
||||
public ClampedFloatParameter Intensity = new ClampedFloatParameter(1.0f, 0.1f, 5.0f, false);
|
||||
|
||||
[InspectorName("Falloff"), Tooltip("Softens indirect lighting over distance")]
|
||||
public ClampedFloatParameter Falloff = new ClampedFloatParameter(0.0f, 0.0f, 1.0f, false);
|
||||
|
||||
// -------------------------------------------- QUALITY -----------------------------------------------
|
||||
|
||||
// -------------------------------------------- Tracing -----------------------------------------------
|
||||
|
||||
[InspectorName("Ray Count"), Tooltip("Number of rays per pixel")]
|
||||
public ClampedIntParameter RayCount = new ClampedIntParameter(3, 2, 16, false);
|
||||
|
||||
[InspectorName("Step Count"), Tooltip("Number of steps per ray")]
|
||||
public ClampedIntParameter StepCount = new ClampedIntParameter(24, 8, 64, false);
|
||||
|
||||
[InspectorName("Refine Intersection"), Tooltip("Extra check to confirm intersection")]
|
||||
public BoolParameter RefineIntersection = new BoolParameter(true, false);
|
||||
|
||||
[InspectorName("Full Resolution Depth"), Tooltip("Uses full-res depth buffer for tracing")]
|
||||
public BoolParameter FullResolutionDepth = new BoolParameter(true, false);
|
||||
|
||||
// ------------------------------------------- Rendering -----------------------------------------------
|
||||
|
||||
[InspectorName("Checkerboard"), Tooltip("Enables checkerboard rendering, processing only half of the pixels per frame")]
|
||||
public BoolParameter Checkerboard = new BoolParameter(false, false);
|
||||
|
||||
[InspectorName("Render Scale"), Tooltip("Local render scale of SSGI pipeline")]
|
||||
public ClampedFloatParameter RenderScale = new ClampedFloatParameter(1.0f, 0.5f, 1.0f, false);
|
||||
|
||||
// ------------------------------------------- DENOISING -----------------------------------------------
|
||||
|
||||
[InspectorName("Brightness Clamp"), Tooltip("Defines the maximum brightness at the hit point")]
|
||||
public BrightnessClampParameter BrightnessClamp = new(Globals.BrightnessClamp.Manual, false);
|
||||
|
||||
[InspectorName("Max Value"), Tooltip("Maximum brightness allowed at hit points.")]
|
||||
public ClampedFloatParameter MaxValueBrightnessClamp = new ClampedFloatParameter(7.0f, 1.0f, 30.0f, false);
|
||||
|
||||
[InspectorName("Max Deviation"), Tooltip("Maximum standard deviation for brightness allowed at hit points")]
|
||||
public ClampedFloatParameter MaxDeviationBrightnessClamp = new ClampedFloatParameter(3.0f, 1.0f, 5.0f, false);
|
||||
|
||||
// ---------------------------------------- ReSTIR Validation ------------------------------------------
|
||||
|
||||
[InspectorName("Half Step"), Tooltip("Halves validation ray steps")]
|
||||
public BoolParameter HalfStepValidation = new BoolParameter(false, false);
|
||||
|
||||
[InspectorName("Spatial Occlusion"), Tooltip("Protects indirect shadows and details from overblurring")]
|
||||
public BoolParameter SpatialOcclusionValidation = new BoolParameter(true, false);
|
||||
|
||||
[InspectorName("Temporal Lighting"), Tooltip("Faster reaction to changing lighting conditions")]
|
||||
public BoolParameter TemporalLightingValidation = new BoolParameter(true, false);
|
||||
|
||||
[InspectorName("Temporal Occlusion"), Tooltip("Faster reaction to moving indirect shadows")]
|
||||
public BoolParameter TemporalOcclusionValidation = new BoolParameter(true, false);
|
||||
|
||||
|
||||
// ----------------------------------------- Spatial Filter ---------------------------------------------------
|
||||
|
||||
[InspectorName("Spatial"), Tooltip("Width of spatial filter")]
|
||||
public ClampedFloatParameter SpatialRadius = new ClampedFloatParameter(0.6f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("Adaptivity"), Tooltip("Shrinks the filter radius in geometry corners to preserve details")]
|
||||
public ClampedFloatParameter Adaptivity = new ClampedFloatParameter(0.9f, 0.0f, 1.0f, false);
|
||||
|
||||
[InspectorName("Recurrent Blur"), Tooltip("Makes blur stronger by using the spatial output as temporal history")]
|
||||
public BoolParameter RecurrentBlur = new BoolParameter(false, false);
|
||||
|
||||
[InspectorName("Firefly Suppression"), Tooltip("Removes bright outliers before denoising")]
|
||||
public BoolParameter FireflySuppression = new BoolParameter(false, false);
|
||||
|
||||
// ----------------------------------------------- Debug -----------------------------------------------------
|
||||
|
||||
public BoolParameter ShowBowels = new BoolParameter(false, true);
|
||||
|
||||
public bool IsActive()
|
||||
{
|
||||
return Enable.value;
|
||||
}
|
||||
|
||||
#if !UNITY_2023_2_OR_NEWER
|
||||
public bool IsTileCompatible() => false;
|
||||
#endif
|
||||
|
||||
[Serializable]
|
||||
public sealed class HBufferParameter : VolumeParameter<HBuffer>
|
||||
{
|
||||
/// <param name="value">The initial value to store in the parameter.</param>
|
||||
/// <param name="overrideState">The initial override state for the parameter.</param>
|
||||
public HBufferParameter(HBuffer value, bool overrideState = false) : base(value, overrideState) { }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class DebugModeParameter : VolumeParameter<DebugMode>
|
||||
{
|
||||
/// <param name="value">The initial value to store in the parameter.</param>
|
||||
/// <param name="overrideState">The initial override state for the parameter.</param>
|
||||
public DebugModeParameter(DebugMode value, bool overrideState = false) : base(value, overrideState) { }
|
||||
}
|
||||
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
[Serializable]
|
||||
public sealed class RenderingLayerMaskEnumParameter : VolumeParameter<RenderingLayerMask>
|
||||
{
|
||||
/// <param name="value">The initial value to store in the parameter.</param>
|
||||
/// <param name="overrideState">The initial override state for the parameter.</param>
|
||||
public RenderingLayerMaskEnumParameter(RenderingLayerMask value, bool overrideState = false) : base(value, overrideState) { }
|
||||
}
|
||||
#endif
|
||||
|
||||
[Serializable]
|
||||
public sealed class FallbackTypeParameter : VolumeParameter<FallbackType>
|
||||
{
|
||||
/// <param name="value">The initial value to store in the parameter.</param>
|
||||
/// <param name="overrideState">The initial override state for the parameter.</param>
|
||||
public FallbackTypeParameter(FallbackType value, bool overrideState = false) : base(value, overrideState) { }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ThicknessModeParameter : VolumeParameter<ThicknessMode>
|
||||
{
|
||||
/// <param name="value">The initial value to store in the parameter.</param>
|
||||
/// <param name="overrideState">The initial override state for the parameter.</param>
|
||||
public ThicknessModeParameter(ThicknessMode value, bool overrideState = false) : base(value, overrideState) { }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class BrightnessClampParameter : VolumeParameter<BrightnessClamp>
|
||||
{
|
||||
/// <param name="value">The initial value to store in the parameter.</param>
|
||||
/// <param name="overrideState">The initial override state for the parameter.</param>
|
||||
public BrightnessClampParameter(BrightnessClamp value, bool overrideState = false) : base(value, overrideState) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f17acff6deb4f089d110375635d4e37
|
||||
timeCreated: 1756743404
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 336896
|
||||
packageName: 'HTrace: Screen Space Global Illumination URP'
|
||||
packageVersion: 1.2.0
|
||||
assetPath: Assets/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs
|
||||
uploadId: 840002
|
||||
Reference in New Issue
Block a user