-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomRenderFeature.cs
43 lines (37 loc) · 1.11 KB
/
CustomRenderFeature.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class CustomRenderFeature<T> : ScriptableRendererFeature where T : VolumeComponent, IPostProcessComponent
{
public enum BufferType
{
CameraColor,
Custom
}
[System.Serializable]
public class Settings
{
public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
public BufferType sourceType = BufferType.CameraColor;
public BufferType destinationType = BufferType.CameraColor;
public string sourceTexture = "_SourceTexture";
public string destinationTexture = "_DestinationTexture";
}
public Settings settings = new Settings();
CustomPass<T> pass;
public override void Create()
{
pass = CreatePass(settings.renderPassEvent);
pass.Init(pass.GetShaderPath());
}
protected override void Dispose(bool disposing)
{
pass?.Release();
}
protected virtual CustomPass<T> CreatePass(RenderPassEvent renderPassEvent) { return null; }
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
pass.Setup(settings);
renderer.EnqueuePass(pass);
}
}