2
0

RenderSettings.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using System.Runtime.InteropServices;
  6. namespace BansheeEngine
  7. {
  8. /// <summary>
  9. /// Settings that control automatic exposure (eye adaptation) post-process.
  10. /// </summary>
  11. [SerializeObject]
  12. public class AutoExposureSettings
  13. {
  14. /// <summary>
  15. /// Determines minimum luminance value in the eye adaptation histogram. The histogram is used for calculating the
  16. /// average brightness of the scene.Any luminance value below this value will not be included in the histogram and
  17. /// ignored in scene brightness calculations. In log2 units (-8 = 1/256). In the range [-16, 0].
  18. /// </summary>
  19. public float HistogramLog2Min;
  20. /// <summary>
  21. /// Determines maximum luminance value in the eye adaptation histogram. The histogram is used for calculating the
  22. /// average brightness of the scene.Any luminance value above this value will not be included in the histogram and
  23. /// ignored in scene brightness calculations. In log2 units (4 = 16). In the range [0, 16].
  24. /// </summary>
  25. public float HistogramLog2Max;
  26. /// <summary>
  27. /// Percentage below which to ignore values in the eye adaptation histogram. The histogram is used for calculating
  28. /// the average brightness of the scene.Total luminance in the histogram will be summed up and multiplied by this
  29. /// value to calculate minimal luminance. Luminance values below the minimal luminance will be ignored and not used
  30. /// in scene brightness calculations.This allows you to remove outliers on the lower end of the histogram (for
  31. /// example a few very dark pixels in an otherwise bright image). In range [0.0f, 1.0f].
  32. /// </summary>
  33. public float HistogramPctLow;
  34. /// <summary>
  35. /// Percentage above which to ignore values in the eye adaptation histogram. The histogram is used for calculating
  36. /// the average brightness of the scene.Total luminance in the histogram will be summed up and multiplied by this
  37. /// value to calculate maximum luminance. Luminance values above the maximum luminance will be ignored and not used
  38. /// in scene brightness calculations.This allows you to remove outliers on the high end of the histogram (for
  39. /// example a few very bright pixels). In range [0.0f, 1.0f].
  40. /// </summary>
  41. public float HistogramPctHigh;
  42. /// <summary>
  43. /// Clamps the minimum eye adaptation scale to this value. This allows you to limit eye adaptation so that exposure
  44. /// is never too high (for example when in a very dark room you probably do not want the exposure to be so high that
  45. /// everything is still visible). In range [0.0f, 10.0f].
  46. /// </summary>
  47. public float MinEyeAdaptation;
  48. /// <summary>
  49. /// Clamps the maximum eye adaptation scale to this value. This allows you to limit eye adaptation so that exposure
  50. /// is never too low (for example when looking at a very bright light source you probably don't want the exposure to
  51. /// be so low that the rest of the scene is all white (overexposed). In range [0.0f, 10.0f].
  52. /// </summary>
  53. public float MaxEyeAdaptation;
  54. /// <summary>
  55. /// Determines how quickly does the eye adaptation adjust to larger values. This affects how quickly does the
  56. /// automatic exposure changes when the scene brightness increases. In range [0.01f, 20.0f].
  57. /// </summary>
  58. public float EyeAdaptationSpeedUp;
  59. /// <summary>
  60. /// Determines how quickly does the eye adaptation adjust to smaller values. This affects how quickly does the
  61. /// automatic exposure changes when the scene brightness decreases. In range [0.01f, 20.0f].
  62. /// </summary>
  63. public float EyeAdaptationSpeedDown;
  64. };
  65. /// <summary>
  66. /// Settings that control tonemap post-process.
  67. /// </summary>
  68. [SerializeObject]
  69. public class TonemappingSettings
  70. {
  71. /// <summary>
  72. /// Controls the shoulder (upper non-linear) section of the filmic curve used for tonemapping. Mostly affects bright
  73. /// areas of the image and allows you to reduce over-exposure.
  74. /// </summary>
  75. public float FilmicCurveShoulderStrength;
  76. /// <summary>
  77. /// Controls the linear (middle) section of the filmic curve used for tonemapping. Mostly affects mid-range areas of
  78. /// the image.
  79. /// </summary>
  80. public float FilmicCurveLinearStrength;
  81. /// <summary>
  82. /// Controls the linear (middle) section of the filmic curve used for tonemapping. Mostly affects mid-range areas of
  83. /// the image and allows you to control how quickly does the curve climb.
  84. /// </summary>
  85. public float FilmicCurveLinearAngle;
  86. /// <summary>
  87. /// Controls the toe (lower non-linear) section of the filmic curve used for tonemapping. Mostly affects dark areas
  88. /// of the image and allows you to reduce under-exposure.
  89. /// </summary>
  90. public float FilmicCurveToeStrength;
  91. /// <summary>
  92. /// Controls the toe (lower non-linear) section of the filmic curve. used for tonemapping. Affects low-range.
  93. /// </summary>
  94. public float FilmicCurveToeNumerator;
  95. /// <summary>
  96. /// Controls the toe (lower non-linear) section of the filmic curve used for tonemapping. Affects low-range.
  97. /// </summary>
  98. public float FilmicCurveToeDenominator;
  99. /// <summary>
  100. /// Controls the white point of the filmic curve used for tonemapping. Affects the entire curve.
  101. /// </summary>
  102. public float FilmicCurveLinearWhitePoint;
  103. };
  104. /// <summary>
  105. /// Settings that control white balance post-process.
  106. /// </summary>
  107. [SerializeObject]
  108. public class WhiteBalanceSettings
  109. {
  110. /// <summary>
  111. /// Temperature used for white balancing, in Kelvins.
  112. ///
  113. /// Moves along the Planckian locus. In range [1500.0f, 15000.0f].
  114. /// </summary>
  115. public float Temperature;
  116. /// <summary>
  117. /// Additional tint to be applied during white balancing. Can be used to further tweak the white balancing effect by
  118. /// modifying the tint of the light.The tint is chosen on the Planckian locus isothermal, depending on the light
  119. /// temperature specified by <see cref="Temperature"/>.
  120. ///
  121. /// In range [-1.0f, 1.0f].
  122. /// </summary>
  123. public float Tint;
  124. };
  125. /// <summary>
  126. /// Settings that control color grading post-process.
  127. /// </summary>
  128. [SerializeObject]
  129. public class ColorGradingSettings
  130. {
  131. /// <summary>
  132. /// Saturation to be applied during color grading. Larger values increase vibrancy of the image.
  133. /// In range [0.0f, 2.0f].
  134. /// </summary>
  135. public Vector3 Saturation;
  136. /// <summary>
  137. /// Contrast to be applied during color grading. Larger values increase difference between light and dark areas of
  138. /// the image. In range [0.0f, 2.0f].
  139. /// </summary>
  140. public Vector3 Contrast;
  141. /// <summary>
  142. /// Gain to be applied during color grading. Simply increases all color values by an equal scale.
  143. /// In range [0.0f, 2.0f].
  144. /// </summary>
  145. public Vector3 Gain;
  146. /// <summary>
  147. /// Gain to be applied during color grading. Simply offsets all color values by an equal amount.
  148. /// In range [-1.0f, 1.0f].
  149. /// </summary>
  150. public Vector3 Offset;
  151. };
  152. /// <summary>
  153. /// Settings that control rendering operations for a single camera.
  154. /// </summary>
  155. [SerializeObject]
  156. public class RenderSettings
  157. {
  158. /// <summary>
  159. /// Determines should automatic exposure be applied to the HDR image. When turned on the average scene brightness
  160. /// will be calculated and used to automatically expose the image to the optimal range. Use the parameters provided
  161. /// by <see cref="AutoExposure"/> to customize the automatic exposure effect.You may also use
  162. /// <see cref="ExposureScale"/> to manually adjust the automatic exposure. When automatic exposure is turned off you
  163. /// can use <see cref="ExposureScale"/> to manually set the exposure.
  164. /// </summary>
  165. public bool EnableAutoExposure;
  166. /// <summary>
  167. /// Parameters used for customizing automatic scene exposure. <see cref="EnableAutoExposure"/>
  168. /// </summary>
  169. public AutoExposureSettings AutoExposure;
  170. /// <summary>
  171. /// Determines should the image be tonemapped. Tonemapping converts an HDR image into LDR image by applying
  172. /// a filmic curve to the image, simulating the effect of film cameras.Filmic curve improves image quality by
  173. /// tapering off lows and highs, preventing under- and over-exposure.This is useful if an image contains both
  174. /// very dark and very bright areas, in which case the global exposure parameter would leave some areas either over-
  175. /// or under-exposed. Use <see cref="Tonemapping"/> to customize how tonemapping performed.
  176. ///
  177. /// If this is disabled, then color grading and white balancing will not be enabled either.Only relevant for HDR
  178. /// images.
  179. /// </summary>
  180. public bool EnableTonemapping;
  181. /// <summary>
  182. /// Parameters used for customizing tonemapping. <see cref="EnableTonemapping"/>
  183. /// </summary>
  184. public TonemappingSettings Tonemapping;
  185. /// <summary>
  186. /// Parameters used for customizing white balancing. White balancing converts a scene illuminated by a light of the
  187. /// specified temperature into a scene illuminated by a standard D65 illuminant (average midday light) in order to
  188. /// simulate the effects of chromatic adaptation of the human visual system.
  189. /// </summary>
  190. public WhiteBalanceSettings WhiteBalance;
  191. /// <summary>
  192. /// Parameters used for customizing color grading.
  193. /// </summary>
  194. public ColorGradingSettings ColorGrading;
  195. /// <summary>
  196. /// Log2 value to scale the eye adaptation by (for example 2^0 = 1). Smaller values yield darker image, while larger
  197. /// yield brighter image.Allows you to customize exposure manually, applied on top of eye adaptation exposure (if
  198. /// enabled). In range [-8, 8].
  199. /// </summary>
  200. public float ExposureScale;
  201. /// <summary>
  202. /// Gamma value to adjust the image for. Larger values result in a brighter image. When tonemapping is turned
  203. /// on the best gamma curve for the output device is chosen automatically and this value can by used to merely tweak
  204. /// that curve. If tonemapping is turned off this is the exact value of the gamma curve that will be applied.
  205. /// </summary>
  206. public float Gamma;
  207. /// <summary>
  208. /// High dynamic range allows light intensity to be more correctly recorded when rendering by allowing for a larger
  209. /// range of values. The stored light is then converted into visible color range using exposure and a tone mapping
  210. /// operator.
  211. /// </summary>
  212. public bool EnableHDR;
  213. /// <summary>
  214. /// Determines if scene objects will be lit by lights. If disabled everything will be rendered using their albedo
  215. /// texture with no lighting applied.
  216. /// </summary>
  217. public bool EnableLighting;
  218. /// <summary>
  219. /// Determines if shadows cast by lights should be rendered. Only relevant if lighting is turned on.
  220. /// </summary>
  221. public bool EnableShadows;
  222. /// <summary>
  223. /// Signals the renderer to only render overlays (like GUI), and not scene objects. Such rendering doesn't require
  224. /// depth buffer or multi-sampled render targets and will not render any scene objects. This can improve performance
  225. /// and memory usage for overlay-only views.
  226. /// </summary>
  227. public bool OverlayOnly;
  228. /// <summary>
  229. /// Creates a new instance of render settings with the optimal default values.
  230. /// </summary>
  231. /// <returns>New instance of render settings.</returns>
  232. public static RenderSettings CreateDefault()
  233. {
  234. return Internal_CreateDefault();
  235. }
  236. [MethodImpl(MethodImplOptions.InternalCall)]
  237. private static extern RenderSettings Internal_CreateDefault();
  238. }
  239. }