FilmGrain.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. namespace UnityEngine.Rendering.Universal
  3. {
  4. public enum FilmGrainLookup
  5. {
  6. Thin1,
  7. Thin2,
  8. Medium1,
  9. Medium2,
  10. Medium3,
  11. Medium4,
  12. Medium5,
  13. Medium6,
  14. Large01,
  15. Large02,
  16. Custom
  17. }
  18. [Serializable, VolumeComponentMenu("Post-processing/FilmGrain")]
  19. public sealed class FilmGrain : VolumeComponent, IPostProcessComponent
  20. {
  21. [Tooltip("The type of grain to use. You can select a preset or provide your own texture by selecting Custom.")]
  22. public FilmGrainLookupParameter type = new FilmGrainLookupParameter(FilmGrainLookup.Thin1);
  23. [Tooltip("Amount of vignetting on screen.")]
  24. public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
  25. [Tooltip("Controls the noisiness response curve based on scene luminance. Higher values mean less noise in light areas.")]
  26. public ClampedFloatParameter response = new ClampedFloatParameter(0.8f, 0f, 1f);
  27. [Tooltip("A tileable texture to use for the grain. The neutral value is 0.5 where no grain is applied.")]
  28. public NoInterpTextureParameter texture = new NoInterpTextureParameter(null);
  29. public bool IsActive() => intensity.value > 0f && (type.value != FilmGrainLookup.Custom || texture.value != null);
  30. public bool IsTileCompatible() => true;
  31. }
  32. [Serializable]
  33. public sealed class FilmGrainLookupParameter : VolumeParameter<FilmGrainLookup> { public FilmGrainLookupParameter(FilmGrainLookup value, bool overrideState = false) : base(value, overrideState) { } }
  34. }