Updated namespace;
Added UTSPass; Chnaged the RTHanlde _HairShadowMap to not reallocate when screen resolution decreased;
This commit is contained in:
82
Runtime/HDRP/UTS Renderer/UTSRenderPassRegistrar.cs
Normal file
82
Runtime/HDRP/UTS Renderer/UTSRenderPassRegistrar.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
|
||||
namespace Misaki.HdrpToon
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoad]
|
||||
#endif
|
||||
public static class UTSRenderPassRegistrar
|
||||
{
|
||||
private static UTSRenderPassSettings _renderSetting;
|
||||
|
||||
private static UTSPass _utsPass;
|
||||
private static UTSHairShadowPass _hairShadowPass;
|
||||
private static UTSOutlinePass _outlinePass;
|
||||
|
||||
static UTSRenderPassRegistrar() => RegisterCustomPasses();
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
public static void RegisterCustomPasses()
|
||||
{
|
||||
_renderSetting = UTSRenderPassSettings.GetOrCreateSettings();
|
||||
if (_renderSetting == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_utsPass = new UTSPass()
|
||||
{
|
||||
name = "UTS Pass",
|
||||
targetColorBuffer = CustomPass.TargetBuffer.None,
|
||||
targetDepthBuffer = CustomPass.TargetBuffer.None,
|
||||
};
|
||||
|
||||
_hairShadowPass = new()
|
||||
{
|
||||
name = "UTS Hair Shadow Map",
|
||||
layerMask = _renderSetting.hairShadowSetting.shadowCasterLayer,
|
||||
targetColorBuffer = CustomPass.TargetBuffer.None,
|
||||
targetDepthBuffer = CustomPass.TargetBuffer.None,
|
||||
};
|
||||
|
||||
_outlinePass = new()
|
||||
{
|
||||
name = "UTS Outline",
|
||||
targetColorBuffer = CustomPass.TargetBuffer.None,
|
||||
targetDepthBuffer = CustomPass.TargetBuffer.None,
|
||||
};
|
||||
|
||||
CustomPassVolume.RegisterGlobalCustomPass(CustomPassInjectionPoint.BeforeRendering, _utsPass);
|
||||
CustomPassVolume.RegisterGlobalCustomPass(CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, _hairShadowPass);
|
||||
CustomPassVolume.RegisterGlobalCustomPass(CustomPassInjectionPoint.BeforePostProcess, _outlinePass);
|
||||
|
||||
NotifyRendererSettingChanged();
|
||||
}
|
||||
|
||||
public static void UnregisterGlobalCustomPass()
|
||||
{
|
||||
CustomPassVolume.UnregisterGlobalCustomPass(_utsPass);
|
||||
CustomPassVolume.UnregisterGlobalCustomPass(_hairShadowPass);
|
||||
CustomPassVolume.UnregisterGlobalCustomPass(_outlinePass);
|
||||
}
|
||||
|
||||
public static void NotifyRendererSettingChanged()
|
||||
{
|
||||
if (_hairShadowPass == null || _outlinePass == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_hairShadowPass.layerMask = _renderSetting.hairShadowSetting.shadowCasterLayer;
|
||||
_hairShadowPass.enabled = _renderSetting.hairShadowSetting.enable;
|
||||
_hairShadowPass.CurrentShadowQuality = _renderSetting.hairShadowSetting.shadowQuality;
|
||||
if (!_renderSetting.hairShadowSetting.enable)
|
||||
{
|
||||
_hairShadowPass.Release();
|
||||
}
|
||||
|
||||
_outlinePass.enabled = _renderSetting.outlineSetting.enable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user