| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | | using System.Linq; |
| | 5 | | using UnityEngine.Rendering; |
| | 6 | | using UnityEngine.Rendering.Universal; |
| | 7 | |
|
| | 8 | | public class BlurController : MonoBehaviour |
| | 9 | | { |
| | 10 | | [SerializeField]private ForwardRendererData rendererData = null; |
| | 11 | | [SerializeField] private string featureName = null; |
| | 12 | | private ScriptableRendererFeature feature; |
| | 13 | |
|
| | 14 | | [Range(1, 25)] |
| 0 | 15 | | public int passes = 1; |
| | 16 | | [Range(1, 10)] |
| 0 | 17 | | public int downsampling = 1; |
| | 18 | |
|
| | 19 | | public Color color; |
| | 20 | |
|
| | 21 | | private void Awake() |
| | 22 | | { |
| 0 | 23 | | feature = rendererData.rendererFeatures.Where((f) => f.name == featureName).FirstOrDefault(); |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | void Update() |
| | 27 | | { |
| 0 | 28 | | if(feature) |
| | 29 | | { |
| 0 | 30 | | var blurFeature = feature as GaussianBlurHandler; |
| 0 | 31 | | blurFeature.settings.blurPasses = passes; |
| 0 | 32 | | blurFeature.settings.downsample = downsampling; |
| 0 | 33 | | blurFeature.settings.blurMaterial.SetColor("_color", color); |
| 0 | 34 | | rendererData.SetDirty(); |
| 0 | 35 | | } |
| | 36 | | else |
| | 37 | | { |
| 0 | 38 | | feature = rendererData.rendererFeatures.Where((f) => f.name == featureName).FirstOrDefault(); |
| | 39 | | } |
| 0 | 40 | | } |
| | 41 | | } |