ScreenSpaceReflectionModel.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. namespace UnityEngine.PostProcessing
  3. {
  4. [Serializable]
  5. public class ScreenSpaceReflectionModel : PostProcessingModel
  6. {
  7. public ScreenSpaceReflectionModel.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 = ScreenSpaceReflectionModel.Settings.defaultSettings;
  21. }
  22. [SerializeField]
  23. private ScreenSpaceReflectionModel.Settings m_Settings = ScreenSpaceReflectionModel.Settings.defaultSettings;
  24. public enum SSRResolution
  25. {
  26. High,
  27. Low = 2
  28. }
  29. public enum SSRReflectionBlendType
  30. {
  31. PhysicallyBased,
  32. Additive
  33. }
  34. [Serializable]
  35. public struct IntensitySettings
  36. {
  37. [Tooltip("Nonphysical multiplier for the SSR reflections. 1.0 is physically based.")]
  38. [Range(0f, 2f)]
  39. public float reflectionMultiplier;
  40. [Tooltip("How far away from the maxDistance to begin fading SSR.")]
  41. [Range(0f, 1000f)]
  42. public float fadeDistance;
  43. [Tooltip("Amplify Fresnel fade out. Increase if floor reflections look good close to the surface and bad farther 'under' the floor.")]
  44. [Range(0f, 1f)]
  45. public float fresnelFade;
  46. [Tooltip("Higher values correspond to a faster Fresnel fade as the reflection changes from the grazing angle.")]
  47. [Range(0.1f, 10f)]
  48. public float fresnelFadePower;
  49. }
  50. [Serializable]
  51. public struct ReflectionSettings
  52. {
  53. [Tooltip("How the reflections are blended into the render.")]
  54. public ScreenSpaceReflectionModel.SSRReflectionBlendType blendType;
  55. [Tooltip("Half resolution SSRR is much faster, but less accurate.")]
  56. public ScreenSpaceReflectionModel.SSRResolution reflectionQuality;
  57. [Tooltip("Maximum reflection distance in world units.")]
  58. [Range(0.1f, 300f)]
  59. public float maxDistance;
  60. [Tooltip("Max raytracing length.")]
  61. [Range(16f, 1024f)]
  62. public int iterationCount;
  63. [Tooltip("Log base 2 of ray tracing coarse step size. Higher traces farther, lower gives better quality silhouettes.")]
  64. [Range(1f, 16f)]
  65. public int stepSize;
  66. [Tooltip("Typical thickness of columns, walls, furniture, and other objects that reflection rays might pass behind.")]
  67. [Range(0.01f, 10f)]
  68. public float widthModifier;
  69. [Tooltip("Blurriness of reflections.")]
  70. [Range(0.1f, 8f)]
  71. public float reflectionBlur;
  72. [Tooltip("Disable for a performance gain in scenes where most glossy objects are horizontal, like floors, water, and tables. Leave on for scenes with glossy vertical objects.")]
  73. public bool reflectBackfaces;
  74. }
  75. [Serializable]
  76. public struct ScreenEdgeMask
  77. {
  78. [Tooltip("Higher = fade out SSRR near the edge of the screen so that reflections don't pop under camera motion.")]
  79. [Range(0f, 1f)]
  80. public float intensity;
  81. }
  82. [Serializable]
  83. public struct Settings
  84. {
  85. public static ScreenSpaceReflectionModel.Settings defaultSettings
  86. {
  87. get
  88. {
  89. return new ScreenSpaceReflectionModel.Settings
  90. {
  91. reflection = new ScreenSpaceReflectionModel.ReflectionSettings
  92. {
  93. blendType = ScreenSpaceReflectionModel.SSRReflectionBlendType.PhysicallyBased,
  94. reflectionQuality = ScreenSpaceReflectionModel.SSRResolution.Low,
  95. maxDistance = 100f,
  96. iterationCount = 256,
  97. stepSize = 3,
  98. widthModifier = 0.5f,
  99. reflectionBlur = 1f,
  100. reflectBackfaces = false
  101. },
  102. intensity = new ScreenSpaceReflectionModel.IntensitySettings
  103. {
  104. reflectionMultiplier = 1f,
  105. fadeDistance = 100f,
  106. fresnelFade = 1f,
  107. fresnelFadePower = 1f
  108. },
  109. screenEdgeMask = new ScreenSpaceReflectionModel.ScreenEdgeMask
  110. {
  111. intensity = 0.03f
  112. }
  113. };
  114. }
  115. }
  116. public ScreenSpaceReflectionModel.ReflectionSettings reflection;
  117. public ScreenSpaceReflectionModel.IntensitySettings intensity;
  118. public ScreenSpaceReflectionModel.ScreenEdgeMask screenEdgeMask;
  119. }
  120. }
  121. }