BsStandardPostProcessSettings.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPrerequisites.h"
  5. #include "BsPostProcessSettings.h"
  6. #include "BsVector3.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Renderer
  10. * @{
  11. */
  12. /** Settings that control automatic exposure (eye adaptation) post-process. */
  13. struct BS_EXPORT AutoExposureSettings : public IReflectable
  14. {
  15. AutoExposureSettings();
  16. /**
  17. * Determines minimum luminance value in the eye adaptation histogram. The histogram is used for calculating the
  18. * average brightness of the scene. Any luminance value below this value will not be included in the histogram and
  19. * ignored in scene brightness calculations. In log2 units (-8 = 1/256). In the range [-16, 0].
  20. */
  21. float histogramLog2Min;
  22. /**
  23. * Determines maximum luminance value in the eye adaptation histogram. The histogram is used for calculating the
  24. * average brightness of the scene. Any luminance value above this value will not be included in the histogram and
  25. * ignored in scene brightness calculations. In log2 units (4 = 16). In the range [0, 16].
  26. */
  27. float histogramLog2Max;
  28. /**
  29. * Percentage below which to ignore values in the eye adaptation histogram. The histogram is used for calculating
  30. * the average brightness of the scene. Total luminance in the histogram will be summed up and multiplied by this
  31. * value to calculate minimal luminance. Luminance values below the minimal luminance will be ignored and not used
  32. * in scene brightness calculations. This allows you to remove outliers on the lower end of the histogram (for
  33. * example a few very dark pixels in an otherwise bright image). In range [0.0f, 1.0f].
  34. */
  35. float histogramPctLow;
  36. /**
  37. * Percentage above which to ignore values in the eye adaptation histogram. The histogram is used for calculating
  38. * the average brightness of the scene. Total luminance in the histogram will be summed up and multiplied by this
  39. * value to calculate maximum luminance. Luminance values above the maximum luminance will be ignored and not used
  40. * in scene brightness calculations. This allows you to remove outliers on the high end of the histogram (for
  41. * example a few very bright pixels). In range [0.0f, 1.0f].
  42. */
  43. float histogramPctHigh;
  44. /**
  45. * Clamps the minimum eye adaptation scale to this value. This allows you to limit eye adaptation so that exposure
  46. * is never too high (for example when in a very dark room you probably do not want the exposure to be so high that
  47. * everything is still visible). In range [0.0f, 10.0f].
  48. */
  49. float minEyeAdaptation;
  50. /**
  51. * Clamps the maximum eye adaptation scale to this value. This allows you to limit eye adaptation so that exposure
  52. * is never too low (for example when looking at a very bright light source you probably don't want the exposure to
  53. * be so low that the rest of the scene is all white (overexposed). In range [0.0f, 10.0f].
  54. */
  55. float maxEyeAdaptation;
  56. /**
  57. * Determines how quickly does the eye adaptation adjust to larger values. This affects how quickly does the
  58. * automatic exposure changes when the scene brightness increases. In range [0.01f, 20.0f].
  59. */
  60. float eyeAdaptationSpeedUp;
  61. /**
  62. * Determines how quickly does the eye adaptation adjust to smaller values. This affects how quickly does the
  63. * automatic exposure changes when the scene brightness decreases. In range [0.01f, 20.0f].
  64. */
  65. float eyeAdaptationSpeedDown;
  66. /************************************************************************/
  67. /* RTTI */
  68. /************************************************************************/
  69. public:
  70. friend class AutoExposureSettingsRTTI;
  71. static RTTITypeBase* getRTTIStatic();
  72. RTTITypeBase* getRTTI() const override;
  73. };
  74. /** Settings that control tonemap post-process. */
  75. struct BS_EXPORT TonemappingSettings : public IReflectable
  76. {
  77. TonemappingSettings();
  78. /**
  79. * Controls the shoulder (upper non-linear) section of the filmic curve used for tonemapping. Mostly affects bright
  80. * areas of the image and allows you to reduce over-exposure.
  81. */
  82. float filmicCurveShoulderStrength;
  83. /**
  84. * Controls the linear (middle) section of the filmic curve used for tonemapping. Mostly affects mid-range areas of
  85. * the image.
  86. */
  87. float filmicCurveLinearStrength;
  88. /**
  89. * Controls the linear (middle) section of the filmic curve used for tonemapping. Mostly affects mid-range areas of
  90. * the image and allows you to control how quickly does the curve climb.
  91. */
  92. float filmicCurveLinearAngle;
  93. /**
  94. * Controls the toe (lower non-linear) section of the filmic curve used for tonemapping. Mostly affects dark areas
  95. * of the image and allows you to reduce under-exposure.
  96. */
  97. float filmicCurveToeStrength;
  98. /** Controls the toe (lower non-linear) section of the filmic curve. used for tonemapping. Affects low-range. */
  99. float filmicCurveToeNumerator;
  100. /** Controls the toe (lower non-linear) section of the filmic curve used for tonemapping. Affects low-range. */
  101. float filmicCurveToeDenominator;
  102. /** Controls the white point of the filmic curve used for tonemapping. Affects the entire curve. */
  103. float filmicCurveLinearWhitePoint;
  104. /************************************************************************/
  105. /* RTTI */
  106. /************************************************************************/
  107. public:
  108. friend class TonemappingSettingsRTTI;
  109. static RTTITypeBase* getRTTIStatic();
  110. RTTITypeBase* getRTTI() const override;
  111. };
  112. /** Settings that control white balance post-process. */
  113. struct BS_EXPORT WhiteBalanceSettings : public IReflectable
  114. {
  115. WhiteBalanceSettings();
  116. /**
  117. * Temperature used for white balancing, in Kelvins.
  118. *
  119. * Moves along the Planckian locus. In range [1500.0f, 15000.0f].
  120. */
  121. float temperature;
  122. /**
  123. * Additional tint to be applied during white balancing. Can be used to further tweak the white balancing effect by
  124. * modifying the tint of the light. The tint is chosen on the Planckian locus isothermal, depending on the light
  125. * temperature specified by #temperature.
  126. *
  127. * In range [-1.0f, 1.0f].
  128. */
  129. float tint;
  130. /************************************************************************/
  131. /* RTTI */
  132. /************************************************************************/
  133. public:
  134. friend class WhiteBalanceSettingsRTTI;
  135. static RTTITypeBase* getRTTIStatic();
  136. RTTITypeBase* getRTTI() const override;
  137. };
  138. /** Settings that control color grading post-process. */
  139. struct BS_EXPORT ColorGradingSettings : public IReflectable
  140. {
  141. ColorGradingSettings();
  142. /**
  143. * Saturation to be applied during color grading. Larger values increase vibrancy of the image.
  144. * In range [0.0f, 2.0f].
  145. */
  146. Vector3 saturation;
  147. /**
  148. * Contrast to be applied during color grading. Larger values increase difference between light and dark areas of
  149. * the image. In range [0.0f, 2.0f].
  150. */
  151. Vector3 contrast;
  152. /**
  153. * Gain to be applied during color grading. Simply increases all color values by an equal scale.
  154. * In range [0.0f, 2.0f].
  155. */
  156. Vector3 gain;
  157. /**
  158. * Gain to be applied during color grading. Simply offsets all color values by an equal amount.
  159. * In range [-1.0f, 1.0f].
  160. */
  161. Vector3 offset;
  162. /************************************************************************/
  163. /* RTTI */
  164. /************************************************************************/
  165. public:
  166. friend class ColorGradingSettingsRTTI;
  167. static RTTITypeBase* getRTTIStatic();
  168. RTTITypeBase* getRTTI() const override;
  169. };
  170. /** Settings that control screen space ambient occlusion. */
  171. struct BS_EXPORT AmbientOcclusionSettings : public IReflectable
  172. {
  173. AmbientOcclusionSettings();
  174. /** Enables or disabled the screen space ambient occlusion effect. */
  175. bool enabled;
  176. /**
  177. * Radius (in world space, in meters) over which occluders are searched for. Smaller radius ensures better sampling
  178. * precision but can miss occluders. Larger radius ensures far away occluders are considered but can yield lower
  179. * quality or noise because of low sampling precision. Usually best to keep at around a meter, valid range
  180. * is roughly [0.05, 5.0].
  181. */
  182. float radius;
  183. /**
  184. * Bias used to reduce false occlusion artifacts. Higher values reduce the amount of artifacts but will cause
  185. * details to be lost in areas where occlusion isn't high. Value is in millimeters. Usually best to keep at a few
  186. * dozen millimeters, valid range is roughly [0, 200].
  187. */
  188. float bias;
  189. /**
  190. * Distance (in view space, in meters) after which AO starts fading out. The fade process will happen over the
  191. * range as specified by @p fadeRange.
  192. */
  193. float fadeDistance;
  194. /**
  195. * Range (in view space, in meters) in which AO fades out from 100% to 0%. AO starts fading out after the distance
  196. * specified in @p fadeDistance.
  197. */
  198. float fadeRange;
  199. /**
  200. * Linearly scales the intensity of the AO effect. Values less than 1 make the AO effect less pronounced, and vice
  201. * versa. Valid range is roughly [0.2, 2].
  202. */
  203. float intensity;
  204. /**
  205. * Controls how quickly does the AO darkening effect increase with higher occlusion percent. This is a non-linear
  206. * control and will cause the darkening to ramp up exponentially. Valid range is roughly [1, 4], where 1 means no
  207. * extra darkening will occur.
  208. */
  209. float power;
  210. /**
  211. * Quality level of generated ambient occlusion. In range [0, 4]. Higher levels yield higher quality AO at the cost
  212. * of performance.
  213. */
  214. UINT32 quality;
  215. /************************************************************************/
  216. /* RTTI */
  217. /************************************************************************/
  218. public:
  219. friend class AmbientOcclusionSettingsRTTI;
  220. static RTTITypeBase* getRTTIStatic();
  221. RTTITypeBase* getRTTI() const override;
  222. };
  223. /** Settings that control the depth-of-field effect. */
  224. struct BS_EXPORT DepthOfFieldSettings : public IReflectable
  225. {
  226. DepthOfFieldSettings();
  227. /** Enables or disables the depth of field effect. */
  228. bool enabled;
  229. /**
  230. * Distance from the camera at which the focal plane is located in. Objects at this distance will be fully in focus.
  231. */
  232. float focalDistance;
  233. /**
  234. * Range within which the objects remain fully in focus. This range is applied relative to the focal distance.
  235. * Only relevant if Gaussian depth of field is used as other methods don't use a constant in-focus range.
  236. */
  237. float focalRange;
  238. /**
  239. * Determines the size of the range within which objects transition from focused to fully unfocused, at the near
  240. * plane. Only relevant for Gaussian depth of field.
  241. */
  242. float nearTransitionRange;
  243. /**
  244. * Determines the size of the range within which objects transition from focused to fully unfocused, at the far
  245. * plane. Only relevant for Gaussian depth of field.
  246. */
  247. float farTransitionRange;
  248. /**
  249. * Determines the amount of blur to apply to fully unfocused objects that are closer to camera than the in-focus
  250. * zone. Set to zero to disable near-field blur. Only relevant for Gaussian depth of field.
  251. */
  252. float nearBlurAmount;
  253. /**
  254. * Determines the amount of blur to apply to fully unfocused objects that are farther away from camera than the
  255. * in-focus zone. Set to zero to disable far-field blur. Only relevant for Gaussian depth of field.
  256. */
  257. float farBlurAmount;
  258. /************************************************************************/
  259. /* RTTI */
  260. /************************************************************************/
  261. public:
  262. friend class DepthOfFieldSettingsRTTI;
  263. static RTTITypeBase* getRTTIStatic();
  264. RTTITypeBase* getRTTI() const override;
  265. };
  266. /**
  267. * Settings that control the screen space reflections effect. Screen space reflections provide high quality mirror-like
  268. * reflections at low performance cost. They should be used together with reflection probes as the effects complement
  269. * each other. As the name implies, the reflections are only limited to geometry drawn on the screen and the system will
  270. * fall back to refl. probes when screen space data is unavailable. Similarly the system will fall back to refl. probes
  271. * for rougher (more glossy rather than mirror-like) surfaces. Those surfaces require a higher number of samples to
  272. * achieve the glossy look, so we instead fall back to refl. probes which are pre-filtered and can be quickly sampled.
  273. */
  274. struct BS_EXPORT ScreenSpaceReflectionsSettings : public IReflectable
  275. {
  276. ScreenSpaceReflectionsSettings();
  277. /** Enables or disables the SSR effect. */
  278. bool enabled;
  279. /**
  280. * Quality of the SSR effect. Higher values cast more sample rays, and march those rays are lower increments for
  281. * better precision. This results in higher quality, as well as a higher performance requirement. Valid range is
  282. * [0, 4], default is 2.
  283. */
  284. UINT32 quality;
  285. /** Intensity of the screen space reflections. Valid range is [0, 1]. Default is 1 (100%). */
  286. float intensity;
  287. /**
  288. * Roughness at which screen space reflections start fading out and become replaced with refl. probes. Valid range
  289. * is [0, 1]. Default is 0.8.
  290. */
  291. float maxRoughness;
  292. /************************************************************************/
  293. /* RTTI */
  294. /************************************************************************/
  295. public:
  296. friend class ScreenSpaceReflectionsRTTI;
  297. static RTTITypeBase* getRTTIStatic();
  298. RTTITypeBase* getRTTI() const override;
  299. };
  300. /** Settings that control the post-process operations. */
  301. struct BS_EXPORT StandardPostProcessSettings : public PostProcessSettings
  302. {
  303. StandardPostProcessSettings();
  304. /**
  305. * Determines should automatic exposure be applied to the HDR image. When turned on the average scene brightness
  306. * will be calculated and used to automatically expose the image to the optimal range. Use the parameters provided
  307. * by autoExposure to customize the automatic exposure effect. You may also use exposureScale to
  308. * manually adjust the automatic exposure. When automatic exposure is turned off you can use exposureScale to
  309. * manually set the exposure.
  310. */
  311. bool enableAutoExposure;
  312. /**
  313. * Parameters used for customizing automatic scene exposure.
  314. *
  315. * @see enableAutoExposure
  316. */
  317. AutoExposureSettings autoExposure;
  318. /**
  319. * Determines should the image be tonemapped. Tonemapping converts an HDR image into LDR image by applying
  320. * a filmic curve to the image, simulating the effect of film cameras. Filmic curve improves image quality by
  321. * tapering off lows and highs, preventing under- and over-exposure. This is useful if an image contains both
  322. * very dark and very bright areas, in which case the global exposure parameter would leave some areas either over-
  323. * or under-exposed. Use #tonemapping to customize how tonemapping performed.
  324. *
  325. * If this is disabled, then color grading and white balancing will not be enabled either. Only relevant for HDR
  326. * images.
  327. */
  328. bool enableTonemapping;
  329. /**
  330. * Parameters used for customizing tonemapping.
  331. *
  332. * @see enableTonemapping
  333. */
  334. TonemappingSettings tonemapping;
  335. /**
  336. * Parameters used for customizing white balancing. White balancing converts a scene illuminated by a light of the
  337. * specified temperature into a scene illuminated by a standard D65 illuminant (average midday light) in order to
  338. * simulate the effects of chromatic adaptation of the human visual system.
  339. */
  340. WhiteBalanceSettings whiteBalance;
  341. /** Parameters used for customizing color grading. */
  342. ColorGradingSettings colorGrading;
  343. /** Parameters used for customizing the depth of field effect. */
  344. DepthOfFieldSettings depthOfField;
  345. /** Parameters used for customizing screen space ambient occlusion. */
  346. AmbientOcclusionSettings ambientOcclusion;
  347. /** Parameters used for customizing screen space reflections. */
  348. ScreenSpaceReflectionsSettings screenSpaceReflections;
  349. /** Enables the fast approximate anti-aliasing effect. */
  350. bool enableFXAA;
  351. /**
  352. * Log2 value to scale the eye adaptation by (for example 2^0 = 1). Smaller values yield darker image, while larger
  353. * yield brighter image. Allows you to customize exposure manually, applied on top of eye adaptation exposure (if
  354. * enabled). In range [-8, 8].
  355. */
  356. float exposureScale;
  357. /**
  358. * Gamma value to adjust the image for. Larger values result in a brighter image. When tonemapping is turned
  359. * on the best gamma curve for the output device is chosen automatically and this value can by used to merely tweak
  360. * that curve. If tonemapping is turned off this is the exact value of the gamma curve that will be applied.
  361. */
  362. float gamma;
  363. /** @copydoc PostProcessSettings::_getSyncData */
  364. void _getSyncData(UINT8* buffer, UINT32& size) override;
  365. /** @copydoc PostProcessSettings::_setSyncData */
  366. void _setSyncData(UINT8* buffer, UINT32 size) override;
  367. /************************************************************************/
  368. /* RTTI */
  369. /************************************************************************/
  370. public:
  371. friend class StandardPostProcessSettingsRTTI;
  372. static RTTITypeBase* getRTTIStatic();
  373. RTTITypeBase* getRTTI() const override;
  374. };
  375. /** @} */
  376. }