@@ -16,12 +16,21 @@ enum Expandable
16
16
{
17
17
Volume = 1 << 0 ,
18
18
Probes = 1 << 1 ,
19
- Baking = 1 << 2
19
+ Baking = 1 << 2 ,
20
+ DynamicBaking = 1 << 3
21
+ }
22
+
23
+ enum DynamicGIBakingStage
24
+ {
25
+ Neighborhood ,
26
+ MixedLights ,
27
+ FallbackRadiance ,
20
28
}
21
29
22
30
readonly static ExpandedState < Expandable , ProbeVolume > k_ExpandedStateVolume = new ExpandedState < Expandable , ProbeVolume > ( Expandable . Volume , "HDRP" ) ;
23
31
readonly static ExpandedState < Expandable , ProbeVolume > k_ExpandedStateProbes = new ExpandedState < Expandable , ProbeVolume > ( Expandable . Probes , "HDRP" ) ;
24
32
readonly static ExpandedState < Expandable , ProbeVolume > k_ExpandedStateBaking = new ExpandedState < Expandable , ProbeVolume > ( Expandable . Baking , "HDRP" ) ;
33
+ readonly static ExpandedState < Expandable , ProbeVolume > k_ExpandedStateDynamicBaking = new ExpandedState < Expandable , ProbeVolume > ( Expandable . DynamicBaking , "HDRP" ) ;
25
34
26
35
internal static readonly CED . IDrawer Inspector = CED . Group (
27
36
CED . Group (
@@ -55,6 +64,13 @@ enum Expandable
55
64
Expandable . Baking ,
56
65
k_ExpandedStateBaking ,
57
66
Drawer_BakeToolBar
67
+ ) ,
68
+ CED . space ,
69
+ CED . FoldoutGroup (
70
+ Styles . k_DynamicBakingHeader ,
71
+ Expandable . DynamicBaking ,
72
+ k_ExpandedStateDynamicBaking ,
73
+ Drawer_DynamicBakeToolBar
58
74
)
59
75
)
60
76
)
@@ -101,38 +117,108 @@ static void Drawer_BakeToolBar(SerializedProbeVolume serialized, Editor owner)
101
117
EditorGUILayout . Slider ( serialized . backfaceTolerance , 0.0f , 1.0f , Styles . s_BackfaceToleranceLabel ) ;
102
118
EditorGUILayout . PropertyField ( serialized . dilationIterations , Styles . s_DilationIterationLabel ) ;
103
119
104
- GUILayout . BeginHorizontal ( ) ;
105
- if ( GUILayout . Button ( Styles . k_BakeSelectedText ) )
120
+ var bakeButtonRect = EditorGUI . IndentedRect ( EditorGUILayout . GetControlRect ( false ) ) ;
121
+ if ( GUI . Button ( bakeButtonRect , Styles . k_BakeSelectedText ) )
106
122
{
107
123
ProbeVolumeManager . BakeSelected ( ) ;
108
124
}
109
- if ( GUILayout . Button ( Styles . k_BakeDynamicGIOnlyText ) )
125
+ }
126
+
127
+ static void Drawer_DynamicBakeToolBar ( SerializedProbeVolume serialized , Editor owner )
128
+ {
129
+ DynamicGIBakingStage dynamicGIBakingStage ;
130
+ if ( ProbeVolume . preparingMixedLights )
131
+ dynamicGIBakingStage = DynamicGIBakingStage . MixedLights ;
132
+ else if ( ProbeVolume . preparingForBake )
133
+ dynamicGIBakingStage = DynamicGIBakingStage . FallbackRadiance ;
134
+ else
135
+ dynamicGIBakingStage = DynamicGIBakingStage . Neighborhood ;
136
+
137
+ EditorGUI . BeginChangeCheck ( ) ;
138
+ dynamicGIBakingStage = ( DynamicGIBakingStage ) EditorGUILayout . EnumPopup ( Styles . k_DynamicBakingStageLabel , dynamicGIBakingStage ) ;
139
+ if ( EditorGUI . EndChangeCheck ( ) )
140
+ {
141
+ ProbeVolume . preparingMixedLights = dynamicGIBakingStage == DynamicGIBakingStage . MixedLights ;
142
+ ProbeVolume . preparingForBake = dynamicGIBakingStage == DynamicGIBakingStage . FallbackRadiance ;
143
+ }
144
+
145
+ EditorGUILayout . Space ( ) ;
146
+
147
+ var targets = serialized . GetTargetObjects ( ) ;
148
+
149
+ if ( dynamicGIBakingStage == DynamicGIBakingStage . Neighborhood )
110
150
{
111
- var targets = serialized . GetTargetObjects ( ) ;
112
- for ( int i = 0 ; i < targets . Length ; i ++ )
151
+ var dynamicBakeButtonRect = EditorGUI . IndentedRect ( EditorGUILayout . GetControlRect ( false ) ) ;
152
+ if ( GUI . Button ( dynamicBakeButtonRect , Styles . k_DynamicBakeNeighborhoodLabel ) )
113
153
{
114
- var probeVolume = ( ProbeVolume ) targets [ i ] ;
115
- EditorUtility . DisplayProgressBar ( "Baking Dynamic GI" , $ "{ i + 1 } /{ targets . Length } { probeVolume . name } ", ( i + 0.5f ) / targets . Length ) ;
116
- probeVolume . BakeDynamicGIOnly ( ) ;
154
+ for ( int i = 0 ; i < targets . Length ; i ++ )
155
+ {
156
+ var probeVolume = ( ProbeVolume ) targets [ i ] ;
157
+ EditorUtility . DisplayProgressBar ( "Baking Dynamic GI" , $ "{ i + 1 } /{ targets . Length } { probeVolume . name } ", ( i + 0.5f ) / targets . Length ) ;
158
+ probeVolume . BakeDynamicGIOnly ( ) ;
159
+ }
160
+ EditorUtility . ClearProgressBar ( ) ;
117
161
}
118
- EditorUtility . ClearProgressBar ( ) ;
119
162
}
120
- GUILayout . EndHorizontal ( ) ;
121
-
122
- EditorGUILayout . Space ( ) ;
123
-
124
- ProbeVolume . preparingMixedLights = EditorGUILayout . Toggle ( Styles . k_PrepareMixedLightsText , ProbeVolume . preparingMixedLights ) ;
125
- GUI . enabled = ProbeVolume . preparingMixedLights ;
163
+ else
164
+ {
165
+ GUI . enabled = ! CheckAndWarnNoNeighborhoodBaked ( targets ) ;
166
+
167
+ var dynamicBakeButtonRect = EditorGUI . IndentedRect ( EditorGUILayout . GetControlRect ( false ) ) ;
168
+ if ( dynamicGIBakingStage == DynamicGIBakingStage . MixedLights )
169
+ {
170
+ if ( GUI . Button ( dynamicBakeButtonRect , Styles . k_DynamicBakeMixedLightsLabel ) )
171
+ {
172
+ foreach ( var target in targets )
173
+ {
174
+ var probeVolume = ( ProbeVolume ) target ;
175
+ probeVolume . CopyDirectLightingToMixed ( ) ;
176
+ }
177
+ }
178
+ }
179
+ else if ( dynamicGIBakingStage == DynamicGIBakingStage . FallbackRadiance )
180
+ {
181
+ if ( GUI . Button ( dynamicBakeButtonRect , Styles . k_DynamicBakeFallbackRadianceLabel ) )
182
+ {
183
+ foreach ( var target in targets )
184
+ {
185
+ var probeVolume = ( ProbeVolume ) target ;
186
+ probeVolume . CopyDynamicSHToAsset ( ) ;
187
+ }
188
+ }
189
+ }
126
190
127
- if ( GUILayout . Button ( Styles . k_BakeMixedLightsText ) )
191
+ GUI . enabled = true ;
192
+
193
+ EditorGUILayout . Space ( ) ;
194
+
195
+ EditorGUILayout . HelpBox ( Styles . k_DynamicPipelineOverridesWarning , MessageType . Warning ) ;
196
+ var resetButtonRect = EditorGUI . IndentedRect ( EditorGUILayout . GetControlRect ( false ) ) ;
197
+ if ( GUI . Button ( resetButtonRect , Styles . k_DynamicResetPipelineOverridesLabel ) )
198
+ {
199
+ ProbeVolume . preparingMixedLights = false ;
200
+ ProbeVolume . preparingForBake = false ;
201
+ }
202
+ }
203
+ }
204
+
205
+ static bool CheckAndWarnNoNeighborhoodBaked ( Object [ ] targets )
206
+ {
207
+ var noNeighborhoodBaked = false ;
208
+ foreach ( var target in targets )
128
209
{
129
- var targets = serialized . GetTargetObjects ( ) ;
130
- for ( int i = 0 ; i < targets . Length ; i ++ )
210
+ var probeVolume = ( ProbeVolume ) target ;
211
+ if ( probeVolume . probeVolumeAsset == null )
131
212
{
132
- var probeVolume = ( ProbeVolume ) targets [ i ] ;
133
- probeVolume . CopyDirectLightingToMixed ( ) ;
213
+ noNeighborhoodBaked = true ;
214
+ break ;
134
215
}
135
216
}
217
+
218
+ if ( noNeighborhoodBaked )
219
+ EditorGUILayout . HelpBox ( Styles . k_DynamicNoNeighborhoodWarning , MessageType . Error ) ;
220
+
221
+ return noNeighborhoodBaked ;
136
222
}
137
223
138
224
static void Drawer_ToolBar ( SerializedProbeVolume serialized , Editor owner )
0 commit comments