@@ -1035,46 +1035,89 @@ ProbeVolumeList PrepareVisibleProbeVolumeList(HDCamera hdCamera, CommandBuffer i
1035
1035
return probeVolumes ;
1036
1036
}
1037
1037
1038
- void DispatchProbeVolumeDynamicGI ( ScriptableRenderContext renderContext , HDCamera hdCamera , CommandBuffer cmd )
1038
+ enum ProbeVolumeDynamicGIMode
1039
1039
{
1040
- if ( ! m_SupportProbeVolume ) { return ; }
1040
+ None ,
1041
+ Dispatch ,
1042
+ Clear
1043
+ }
1044
+
1045
+ struct ProbeVolumeDynamicGICommonData
1046
+ {
1047
+ public ProbeVolumeDynamicGIMode mode ;
1048
+ public List < ProbeVolumeHandle > volumes ;
1049
+ public ProbeDynamicGI giSettings ;
1050
+ public ShaderVariablesGlobal globalCB ;
1051
+ }
1052
+
1053
+ class ProbeVolumeDynamicGIPassData
1054
+ {
1055
+ public ProbeVolumeDynamicGICommonData commonData ;
1056
+ public TextureHandle probeVolumesAtlas ;
1057
+ }
1058
+
1059
+ ProbeVolumeDynamicGICommonData PrepareProbeVolumeDynamicGIData ( HDCamera hdCamera )
1060
+ {
1061
+ ProbeVolumeDynamicGICommonData data = new ProbeVolumeDynamicGICommonData ( ) { mode = ProbeVolumeDynamicGIMode . None } ;
1062
+
1063
+ if ( ShaderConfig . s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes . Disabled )
1064
+ return data ;
1065
+
1066
+ if ( hdCamera . camera . cameraType != CameraType . Game && hdCamera . camera . cameraType != CameraType . SceneView )
1067
+ return data ;
1068
+
1069
+ if ( ! hdCamera . frameSettings . IsEnabled ( FrameSettingsField . ProbeVolume ) )
1070
+ return data ;
1071
+
1072
+ if ( ! m_SupportProbeVolume )
1073
+ return data ;
1074
+
1075
+ data . volumes = ProbeVolumeManager . manager . GetVolumesToRender ( ) ;
1076
+ data . giSettings = hdCamera . volumeStack . GetComponent < ProbeDynamicGI > ( ) ;
1077
+ data . globalCB = m_ShaderVariablesGlobalCB ;
1041
1078
1042
- if ( hdCamera . frameSettings . IsEnabled ( FrameSettingsField . ProbeVolume ) )
1079
+ if ( hdCamera . frameSettings . IsEnabled ( FrameSettingsField . ProbeVolumeDynamicGI ) )
1043
1080
{
1044
- using ( new ProfilingScope ( cmd , ProfilingSampler . Get ( HDProfileId . ProbeVolumeDynamicGI ) ) )
1081
+ data . mode = ProbeVolumeDynamicGIMode . Dispatch ;
1082
+ m_WasProbeVolumeDynamicGIEnabled = true ;
1083
+ }
1084
+ else if ( m_WasProbeVolumeDynamicGIEnabled )
1085
+ {
1086
+ data . mode = ProbeVolumeDynamicGIMode . Clear ;
1087
+ m_WasProbeVolumeDynamicGIEnabled = false ;
1088
+ }
1089
+
1090
+ return data ;
1091
+ }
1092
+
1093
+ static void ExecuteProbeVolumeDynamicGI ( CommandBuffer cmd , ProbeVolumeDynamicGICommonData data , RenderTargetIdentifier probeVolumeAtlas )
1094
+ {
1095
+ using ( new ProfilingScope ( cmd , ProfilingSampler . Get ( HDProfileId . ProbeVolumeDynamicGI ) ) )
1096
+ {
1097
+ if ( data . mode == ProbeVolumeDynamicGIMode . Dispatch )
1045
1098
{
1046
- // Collect all visible finite volume data, and upload it to the GPU.
1047
- List < ProbeVolumeHandle > volumes = ProbeVolumeManager . manager . GetVolumesToRender ( ) ;
1048
- var giSettings = hdCamera . volumeStack . GetComponent < ProbeDynamicGI > ( ) ;
1049
- float maxRange = Mathf . Max ( giSettings . rangeBehindCamera . value , giSettings . rangeInFrontOfCamera . value ) ;
1099
+ float maxRange = Mathf . Max ( data . giSettings . rangeBehindCamera . value , data . giSettings . rangeInFrontOfCamera . value ) ;
1050
1100
1051
- if ( hdCamera . frameSettings . IsEnabled ( FrameSettingsField . ProbeVolumeDynamicGI ) )
1101
+ // Update Probe Volume Data via Dynamic GI Propagation
1102
+ for ( int probeVolumeIndex = 0 ; probeVolumeIndex < data . volumes . Count ; ++ probeVolumeIndex )
1052
1103
{
1053
- m_WasProbeVolumeDynamicGIEnabled = true ;
1104
+ ProbeVolumeHandle volume = data . volumes [ probeVolumeIndex ] ;
1054
1105
1055
- // Update Probe Volume Data via Dynamic GI Propagation
1056
- for ( int probeVolumeIndex = 0 ; probeVolumeIndex < volumes . Count ; ++ probeVolumeIndex )
1106
+ // basic distance check
1107
+ var obb = volume . GetProbeVolumeEngineDataBoundingBox ( ) ;
1108
+ float maxExtent = Mathf . Max ( obb . extentX , Mathf . Max ( obb . extentY , obb . extentZ ) ) ;
1109
+ if ( obb . center . magnitude < ( maxRange + maxExtent ) )
1057
1110
{
1058
- ProbeVolumeHandle volume = volumes [ probeVolumeIndex ] ;
1059
-
1060
- // basic distance check
1061
- var obb = volume . GetProbeVolumeEngineDataBoundingBox ( ) ;
1062
- float maxExtent = Mathf . Max ( obb . extentX , Mathf . Max ( obb . extentY , obb . extentZ ) ) ;
1063
- if ( obb . center . magnitude < ( maxRange + maxExtent ) )
1064
- {
1065
- ProbeVolumeDynamicGI . instance . DispatchProbePropagation ( renderContext , hdCamera , cmd , volume , giSettings , in m_ShaderVariablesGlobalCB , m_ProbeVolumeAtlasSHRTHandle ) ;
1066
- }
1111
+ ProbeVolumeDynamicGI . instance . DispatchProbePropagation ( cmd , volume , data . giSettings , in data . globalCB , probeVolumeAtlas ) ;
1067
1112
}
1068
1113
}
1069
- else if ( m_WasProbeVolumeDynamicGIEnabled )
1114
+ }
1115
+ else if ( data . mode == ProbeVolumeDynamicGIMode . Clear )
1116
+ {
1117
+ for ( int probeVolumeIndex = 0 ; probeVolumeIndex < data . volumes . Count ; ++ probeVolumeIndex )
1070
1118
{
1071
- for ( int probeVolumeIndex = 0 ; probeVolumeIndex < volumes . Count ; ++ probeVolumeIndex )
1072
- {
1073
- ProbeVolumeHandle volume = volumes [ probeVolumeIndex ] ;
1074
- ProbeVolumeDynamicGI . instance . ClearProbePropagation ( renderContext , hdCamera , cmd , volume , giSettings , in m_ShaderVariablesGlobalCB , m_ProbeVolumeAtlasSHRTHandle ) ;
1075
- }
1076
-
1077
- m_WasProbeVolumeDynamicGIEnabled = false ;
1119
+ ProbeVolumeHandle volume = data . volumes [ probeVolumeIndex ] ;
1120
+ ProbeVolumeDynamicGI . instance . ClearProbePropagation ( cmd , volume , data . giSettings , in data . globalCB , probeVolumeAtlas ) ;
1078
1121
}
1079
1122
}
1080
1123
}
0 commit comments