PostProcessEffectRenderer.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. namespace UnityEngine.Rendering.PostProcessing
  2. {
  3. /// <summary>
  4. /// The base abstract class for all effect renderer types. If you're writing your own effect you
  5. /// should rather use <see cref="PostProcessEffectRenderer{T}"/>.
  6. /// </summary>
  7. /// <seealso cref="PostProcessEffectRenderer{T}"/>
  8. public abstract class PostProcessEffectRenderer
  9. {
  10. /// <summary>
  11. /// This member is set to <c>true</c> when <see cref="PostProcessLayer.ResetHistory"/> is
  12. /// called by the user to reset temporal effects and other history-based effects.
  13. /// </summary>
  14. protected bool m_ResetHistory = true;
  15. /// <summary>
  16. /// Called when the renderer is created and its associated settings have been set.
  17. /// </summary>
  18. /// <seealso cref="PostProcessEffectRenderer{T}.settings"/>
  19. public virtual void Init()
  20. {
  21. }
  22. /// <summary>
  23. /// Override this method if your renderer needs access to any of the buffers defined in
  24. /// <see cref="DepthTextureMode"/>.
  25. /// </summary>
  26. /// <returns>The currently set depth texture modes</returns>
  27. /// <seealso cref="DepthTextureMode"/>
  28. public virtual DepthTextureMode GetCameraFlags()
  29. {
  30. return DepthTextureMode.None;
  31. }
  32. /// <summary>
  33. /// Resets the history state for this renderer. This is automatically called when
  34. /// <see cref="PostProcessLayer.ResetHistory"/> is called by the user.
  35. /// </summary>
  36. public virtual void ResetHistory()
  37. {
  38. m_ResetHistory = true;
  39. }
  40. /// <summary>
  41. /// Override this method to release any resource allocated by your renderer.
  42. /// </summary>
  43. public virtual void Release()
  44. {
  45. ResetHistory();
  46. }
  47. /// <summary>
  48. /// The render method called by <see cref="PostProcessLayer"/> when the effect is rendered.
  49. /// </summary>
  50. /// <param name="context">A context object</param>
  51. public abstract void Render(PostProcessRenderContext context);
  52. internal abstract void SetSettings(PostProcessEffectSettings settings);
  53. }
  54. /// <summary>
  55. /// The base abstract class for all effect renderer types.
  56. /// </summary>
  57. /// <typeparam name="T">The associated type of settings for this renderer</typeparam>
  58. public abstract class PostProcessEffectRenderer<T> : PostProcessEffectRenderer
  59. where T : PostProcessEffectSettings
  60. {
  61. /// <summary>
  62. /// The current state of the effect settings associated with this renderer.
  63. /// </summary>
  64. public T settings { get; internal set; }
  65. internal override void SetSettings(PostProcessEffectSettings settings)
  66. {
  67. this.settings = (T)settings;
  68. }
  69. }
  70. }