AntialiasingModel.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using System;
  2. namespace UnityEngine.PostProcessing
  3. {
  4. [Serializable]
  5. public class AntialiasingModel : PostProcessingModel
  6. {
  7. public AntialiasingModel.Settings settings
  8. {
  9. get
  10. {
  11. return this.m_Settings;
  12. }
  13. set
  14. {
  15. this.m_Settings = value;
  16. }
  17. }
  18. public override void Reset()
  19. {
  20. this.m_Settings = AntialiasingModel.Settings.defaultSettings;
  21. }
  22. [SerializeField]
  23. private AntialiasingModel.Settings m_Settings = AntialiasingModel.Settings.defaultSettings;
  24. public enum Method
  25. {
  26. Fxaa,
  27. Taa
  28. }
  29. public enum FxaaPreset
  30. {
  31. ExtremePerformance,
  32. Performance,
  33. Default,
  34. Quality,
  35. ExtremeQuality
  36. }
  37. [Serializable]
  38. public struct FxaaQualitySettings
  39. {
  40. [Tooltip("The amount of desired sub-pixel aliasing removal. Effects the sharpeness of the output.")]
  41. [Range(0f, 1f)]
  42. public float subpixelAliasingRemovalAmount;
  43. [Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")]
  44. [Range(0.063f, 0.333f)]
  45. public float edgeDetectionThreshold;
  46. [Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")]
  47. [Range(0f, 0.0833f)]
  48. public float minimumRequiredLuminance;
  49. public static AntialiasingModel.FxaaQualitySettings[] presets = new AntialiasingModel.FxaaQualitySettings[]
  50. {
  51. new AntialiasingModel.FxaaQualitySettings
  52. {
  53. subpixelAliasingRemovalAmount = 0f,
  54. edgeDetectionThreshold = 0.333f,
  55. minimumRequiredLuminance = 0.0833f
  56. },
  57. new AntialiasingModel.FxaaQualitySettings
  58. {
  59. subpixelAliasingRemovalAmount = 0.25f,
  60. edgeDetectionThreshold = 0.25f,
  61. minimumRequiredLuminance = 0.0833f
  62. },
  63. new AntialiasingModel.FxaaQualitySettings
  64. {
  65. subpixelAliasingRemovalAmount = 0.75f,
  66. edgeDetectionThreshold = 0.166f,
  67. minimumRequiredLuminance = 0.0833f
  68. },
  69. new AntialiasingModel.FxaaQualitySettings
  70. {
  71. subpixelAliasingRemovalAmount = 1f,
  72. edgeDetectionThreshold = 0.125f,
  73. minimumRequiredLuminance = 0.0625f
  74. },
  75. new AntialiasingModel.FxaaQualitySettings
  76. {
  77. subpixelAliasingRemovalAmount = 1f,
  78. edgeDetectionThreshold = 0.063f,
  79. minimumRequiredLuminance = 0.0312f
  80. }
  81. };
  82. }
  83. [Serializable]
  84. public struct FxaaConsoleSettings
  85. {
  86. [Tooltip("The amount of spread applied to the sampling coordinates while sampling for subpixel information.")]
  87. [Range(0.33f, 0.5f)]
  88. public float subpixelSpreadAmount;
  89. [Tooltip("This value dictates how sharp the edges in the image are kept; a higher value implies sharper edges.")]
  90. [Range(2f, 8f)]
  91. public float edgeSharpnessAmount;
  92. [Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")]
  93. [Range(0.125f, 0.25f)]
  94. public float edgeDetectionThreshold;
  95. [Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")]
  96. [Range(0.04f, 0.06f)]
  97. public float minimumRequiredLuminance;
  98. public static AntialiasingModel.FxaaConsoleSettings[] presets = new AntialiasingModel.FxaaConsoleSettings[]
  99. {
  100. new AntialiasingModel.FxaaConsoleSettings
  101. {
  102. subpixelSpreadAmount = 0.33f,
  103. edgeSharpnessAmount = 8f,
  104. edgeDetectionThreshold = 0.25f,
  105. minimumRequiredLuminance = 0.06f
  106. },
  107. new AntialiasingModel.FxaaConsoleSettings
  108. {
  109. subpixelSpreadAmount = 0.33f,
  110. edgeSharpnessAmount = 8f,
  111. edgeDetectionThreshold = 0.125f,
  112. minimumRequiredLuminance = 0.06f
  113. },
  114. new AntialiasingModel.FxaaConsoleSettings
  115. {
  116. subpixelSpreadAmount = 0.5f,
  117. edgeSharpnessAmount = 8f,
  118. edgeDetectionThreshold = 0.125f,
  119. minimumRequiredLuminance = 0.05f
  120. },
  121. new AntialiasingModel.FxaaConsoleSettings
  122. {
  123. subpixelSpreadAmount = 0.5f,
  124. edgeSharpnessAmount = 4f,
  125. edgeDetectionThreshold = 0.125f,
  126. minimumRequiredLuminance = 0.04f
  127. },
  128. new AntialiasingModel.FxaaConsoleSettings
  129. {
  130. subpixelSpreadAmount = 0.5f,
  131. edgeSharpnessAmount = 2f,
  132. edgeDetectionThreshold = 0.125f,
  133. minimumRequiredLuminance = 0.04f
  134. }
  135. };
  136. }
  137. [Serializable]
  138. public struct FxaaSettings
  139. {
  140. public static AntialiasingModel.FxaaSettings defaultSettings
  141. {
  142. get
  143. {
  144. return new AntialiasingModel.FxaaSettings
  145. {
  146. preset = AntialiasingModel.FxaaPreset.Default
  147. };
  148. }
  149. }
  150. public AntialiasingModel.FxaaPreset preset;
  151. }
  152. [Serializable]
  153. public struct TaaSettings
  154. {
  155. public static AntialiasingModel.TaaSettings defaultSettings
  156. {
  157. get
  158. {
  159. return new AntialiasingModel.TaaSettings
  160. {
  161. jitterSpread = 0.75f,
  162. sharpen = 0.3f,
  163. stationaryBlending = 0.95f,
  164. motionBlending = 0.85f
  165. };
  166. }
  167. }
  168. [Tooltip("The diameter (in texels) inside which jitter samples are spread. Smaller values result in crisper but more aliased output, while larger values result in more stable but blurrier output.")]
  169. [Range(0.1f, 1f)]
  170. public float jitterSpread;
  171. [Tooltip("Controls the amount of sharpening applied to the color buffer.")]
  172. [Range(0f, 3f)]
  173. public float sharpen;
  174. [Tooltip("The blend coefficient for a stationary fragment. Controls the percentage of history sample blended into the final color.")]
  175. [Range(0f, 0.99f)]
  176. public float stationaryBlending;
  177. [Tooltip("The blend coefficient for a fragment with significant motion. Controls the percentage of history sample blended into the final color.")]
  178. [Range(0f, 0.99f)]
  179. public float motionBlending;
  180. }
  181. [Serializable]
  182. public struct Settings
  183. {
  184. public static AntialiasingModel.Settings defaultSettings
  185. {
  186. get
  187. {
  188. return new AntialiasingModel.Settings
  189. {
  190. method = AntialiasingModel.Method.Fxaa,
  191. fxaaSettings = AntialiasingModel.FxaaSettings.defaultSettings,
  192. taaSettings = AntialiasingModel.TaaSettings.defaultSettings
  193. };
  194. }
  195. }
  196. public AntialiasingModel.Method method;
  197. public AntialiasingModel.FxaaSettings fxaaSettings;
  198. public AntialiasingModel.TaaSettings taaSettings;
  199. }
  200. }
  201. }