@@ -5,32 +5,29 @@ namespace UnityEngine.Rendering.HighDefinition
55{
66 public partial class HDRenderPipeline : IDataProvider
77 {
8- #if UNITY_EDITOR
9- int m_LookDevVolumeProfileHash = - 1 ;
10- #endif
11-
128 struct LookDevDataForHDRP
139 {
1410 public HDAdditionalCameraData additionalCameraData ;
1511 public HDAdditionalLightData additionalLightData ;
1612 public VisualEnvironment visualEnvironment ;
1713 public HDRISky sky ;
1814 public Volume volume ;
15+ public int currentVolumeProfileHash ;
1916 }
2017
2118#if UNITY_EDITOR
22- bool UpdateVolumeProfile ( Volume volume , out VisualEnvironment visualEnvironment , out HDRISky sky )
19+ bool UpdateVolumeProfile ( Volume volume , out VisualEnvironment visualEnvironment , out HDRISky sky , ref int volumeProfileHash )
2320 {
2421 HDRenderPipelineAsset hdrpAsset = GraphicsSettings . renderPipelineAsset as HDRenderPipelineAsset ;
2522 if ( hdrpAsset . defaultLookDevProfile == null )
2623 hdrpAsset . defaultLookDevProfile = hdrpAsset . renderPipelineEditorResources . lookDev . defaultLookDevVolumeProfile ;
2724
2825 int newHashCode = hdrpAsset . defaultLookDevProfile . GetHashCode ( ) ;
29- if ( newHashCode != m_LookDevVolumeProfileHash )
26+ if ( newHashCode != volumeProfileHash )
3027 {
3128 VolumeProfile oldProfile = volume . sharedProfile ;
3229
33- m_LookDevVolumeProfileHash = newHashCode ;
30+ volumeProfileHash = newHashCode ;
3431
3532 VolumeProfile profile = ScriptableObject . Instantiate ( hdrpAsset . defaultLookDevProfile ) ;
3633 profile . hideFlags = HideFlags . HideAndDontSave ;
@@ -118,16 +115,17 @@ void IDataProvider.FirstInitScene(StageRuntimeInterface SRI)
118115
119116#if UNITY_EDITOR
120117 // Make sure we invalidate the current volume when first loading a scene.
121- m_LookDevVolumeProfileHash = - 1 ;
122- UpdateVolumeProfile ( volume , out var visualEnvironment , out var sky ) ;
118+ int volumeProfileHash = - 1 ;
119+ UpdateVolumeProfile ( volume , out var visualEnvironment , out var sky , ref volumeProfileHash ) ;
123120
124121 SRI . SRPData = new LookDevDataForHDRP ( )
125122 {
126123 additionalCameraData = additionalCameraData ,
127124 additionalLightData = additionalLightData ,
128125 visualEnvironment = visualEnvironment ,
129126 sky = sky ,
130- volume = volume
127+ volume = volume ,
128+ currentVolumeProfileHash = volumeProfileHash
131129 } ;
132130#else
133131 //remove unassigned warnings when building
@@ -174,11 +172,13 @@ void IDataProvider.OnBeginRendering(StageRuntimeInterface SRI)
174172 {
175173 LookDevDataForHDRP data = ( LookDevDataForHDRP ) SRI . SRPData ;
176174#if UNITY_EDITOR
175+ int currentHash = data . currentVolumeProfileHash ;
177176 // The default volume can change in the HDRP asset so if it does we need to re-instantiate it.
178- if ( UpdateVolumeProfile ( data . volume , out var visualEnv , out var sky ) )
177+ if ( UpdateVolumeProfile ( data . volume , out var visualEnv , out var sky , ref currentHash ) )
179178 {
180179 data . sky = sky ;
181180 data . visualEnvironment = visualEnv ;
181+ data . currentVolumeProfileHash = currentHash ;
182182 SRI . SRPData = data ;
183183 }
184184#endif
0 commit comments