ScreenSpaceReflectionModel.cs
4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System;
namespace UnityEngine.PostProcessing
{
[Serializable]
public class ScreenSpaceReflectionModel : PostProcessingModel
{
public enum SSRResolution
{
High = 0,
Low = 2
}
public enum SSRReflectionBlendType
{
PhysicallyBased,
Additive
}
[Serializable]
public struct IntensitySettings
{
[Tooltip("Nonphysical multiplier for the SSR reflections. 1.0 is physically based.")]
[Range(0.0f, 2.0f)]
public float reflectionMultiplier;
[Tooltip("How far away from the maxDistance to begin fading SSR.")]
[Range(0.0f, 1000.0f)]
public float fadeDistance;
[Tooltip("Amplify Fresnel fade out. Increase if floor reflections look good close to the surface and bad farther 'under' the floor.")]
[Range(0.0f, 1.0f)]
public float fresnelFade;
[Tooltip("Higher values correspond to a faster Fresnel fade as the reflection changes from the grazing angle.")]
[Range(0.1f, 10.0f)]
public float fresnelFadePower;
}
[Serializable]
public struct ReflectionSettings
{
// When enabled, we just add our reflections on top of the existing ones. This is physically incorrect, but several
// popular demos and games have taken this approach, and it does hide some artifacts.
[Tooltip("How the reflections are blended into the render.")]
public SSRReflectionBlendType blendType;
[Tooltip("Half resolution SSRR is much faster, but less accurate.")]
public SSRResolution reflectionQuality;
[Tooltip("Maximum reflection distance in world units.")]
[Range(0.1f, 300.0f)]
public float maxDistance;
/// REFLECTIONS
[Tooltip("Max raytracing length.")]
[Range(16, 1024)]
public int iterationCount;
[Tooltip("Log base 2 of ray tracing coarse step size. Higher traces farther, lower gives better quality silhouettes.")]
[Range(1, 16)]
public int stepSize;
[Tooltip("Typical thickness of columns, walls, furniture, and other objects that reflection rays might pass behind.")]
[Range(0.01f, 10.0f)]
public float widthModifier;
[Tooltip("Blurriness of reflections.")]
[Range(0.1f, 8.0f)]
public float reflectionBlur;
[Tooltip("Enable 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.")]
public bool reflectBackfaces;
}
[Serializable]
public struct ScreenEdgeMask
{
[Tooltip("Higher = fade out SSRR near the edge of the screen so that reflections don't pop under camera motion.")]
[Range(0.0f, 1.0f)]
public float intensity;
}
[Serializable]
public struct Settings
{
public ReflectionSettings reflection;
public IntensitySettings intensity;
public ScreenEdgeMask screenEdgeMask;
public static Settings defaultSettings
{
get
{
return new Settings
{
reflection = new ReflectionSettings
{
blendType = SSRReflectionBlendType.PhysicallyBased,
reflectionQuality = SSRResolution.Low,
maxDistance = 100f,
iterationCount = 256,
stepSize = 3,
widthModifier = 0.5f,
reflectionBlur = 1f,
reflectBackfaces = false
},
intensity = new IntensitySettings
{
reflectionMultiplier = 1f,
fadeDistance = 100f,
fresnelFade = 1f,
fresnelFadePower = 1f,
},
screenEdgeMask = new ScreenEdgeMask
{
intensity = 0.03f
}
};
}
}
}
[SerializeField]
Settings m_Settings = Settings.defaultSettings;
public Settings settings
{
get { return m_Settings; }
set { m_Settings = value; }
}
public override void Reset()
{
m_Settings = Settings.defaultSettings;
}
}
}