61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
// NiloToon Fur Renderer Feature
|
|
// Add this to your URP Renderer to enable fur shell rendering
|
|
// This allows single-material fur shaders to work properly
|
|
//
|
|
// Note: Fur mask rendering is now integrated into NiloToonPrepassBufferRTPass
|
|
// The fur mask is automatically rendered to G and B channels of _NiloToonPrepassBufferTex
|
|
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
namespace NiloToon.NiloToonURP
|
|
{
|
|
[Serializable]
|
|
public class NiloToonFurRendererFeatureSettings
|
|
{
|
|
[Header("Fur Shell Settings")]
|
|
public NiloToonFurShellPass.Settings furShellSettings = new NiloToonFurShellPass.Settings();
|
|
}
|
|
|
|
public class NiloToonFurRendererFeature : ScriptableRendererFeature
|
|
{
|
|
public NiloToonFurRendererFeatureSettings settings = new NiloToonFurRendererFeatureSettings();
|
|
|
|
NiloToonFurShellPass FurShellPass;
|
|
|
|
public override void Create()
|
|
{
|
|
ReInitPassesIfNeeded();
|
|
}
|
|
|
|
private void ReInitPassesIfNeeded()
|
|
{
|
|
if (FurShellPass == null)
|
|
FurShellPass = new NiloToonFurShellPass(settings.furShellSettings);
|
|
|
|
// Set render pass events
|
|
FurShellPass.renderPassEvent = settings.furShellSettings.renderTiming;
|
|
}
|
|
|
|
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
|
{
|
|
ReInitPassesIfNeeded();
|
|
|
|
// Update render timing in case it changed
|
|
FurShellPass.renderPassEvent = settings.furShellSettings.renderTiming;
|
|
|
|
// Enqueue fur shell pass for actual fur rendering
|
|
// Note: Fur mask is rendered via NiloToonPrepassBufferRTPass (NiloToonFurShellMask LightMode)
|
|
renderer.EnqueuePass(FurShellPass);
|
|
}
|
|
|
|
#if UNITY_2022_2_OR_NEWER
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
FurShellPass = null;
|
|
}
|
|
#endif
|
|
}
|
|
}
|