void IDataProvider.FirstInitScene(StageRuntimeInterface SRI)
        {
            Camera camera = SRI.camera;

            camera.allowHDR = true;

            var additionalCameraData = camera.gameObject.AddComponent <HDAdditionalCameraData>();

            additionalCameraData.clearColorMode       = HDAdditionalCameraData.ClearColorMode.Color;
            additionalCameraData.clearDepth           = true;
            additionalCameraData.backgroundColorHDR   = camera.backgroundColor;
            additionalCameraData.volumeAnchorOverride = camera.transform;
            additionalCameraData.volumeLayerMask      = 1 << 31; //31 is the culling layer used in LookDev

            Light light = SRI.sunLight;
            HDAdditionalLightData additionalLightData = light.gameObject.AddComponent <HDAdditionalLightData>();

#if UNITY_EDITOR
            HDAdditionalLightData.InitDefaultHDAdditionalLightData(additionalLightData);
#endif
            additionalLightData.intensity = 0f;
            additionalLightData.SetShadowResolution(2048);

            GameObject volumeGO = SRI.AddGameObject(persistent: true);
            volumeGO.name = "SkyManagementVolume";
            Volume volume = volumeGO.AddComponent <Volume>();
            volume.isGlobal = true;
            volume.priority = float.MaxValue;
            VolumeProfile profile = ScriptableObject.CreateInstance <VolumeProfile>();
            volume.sharedProfile = profile;

            HDShadowSettings shadows = profile.Add <HDShadowSettings>();
            shadows.maxShadowDistance.Override(25f);
            shadows.cascadeShadowSplitCount.Override(2);

            VisualEnvironment visualEnvironment = profile.Add <VisualEnvironment>();
            visualEnvironment.fogType.Override(FogType.None);

            HDRISky sky = profile.Add <HDRISky>();

            SRI.SRPData = new LookDevDataForHDRP()
            {
                additionalCameraData = additionalCameraData,
                additionalLightData  = additionalLightData,
                visualEnvironment    = visualEnvironment,
                sky    = sky,
                volume = volume
            };

            //[TODO: remove]
            //temp for debug: show component in scene hierarchy
            //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(camera.gameObject, GameObject.Find("Main Camera").scene);
            //camera.gameObject.hideFlags = HideFlags.None;
            //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(volumeGO, GameObject.Find("Main Camera").scene);
            //volumeGO.hideFlags = HideFlags.None;
            //UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(light.gameObject, GameObject.Find("Main Camera").scene);
            //light.gameObject.hideFlags = HideFlags.None;
        }
        void IDataProvider.FirstInitScene(StageRuntimeInterface SRI)
        {
            Camera camera = SRI.camera;

            camera.allowHDR = true;

            var additionalCameraData = camera.gameObject.AddComponent <HDAdditionalCameraData>();

            additionalCameraData.clearColorMode       = HDAdditionalCameraData.ClearColorMode.Color;
            additionalCameraData.clearDepth           = true;
            additionalCameraData.backgroundColorHDR   = camera.backgroundColor;
            additionalCameraData.volumeAnchorOverride = camera.transform;
            additionalCameraData.volumeLayerMask      = 1 << 31; //31 is the culling layer used in LookDev

            additionalCameraData.customRenderingSettings = true;
            additionalCameraData.renderingPathCustomFrameSettings.SetEnabled(FrameSettingsField.SSR, false);
            // LookDev cameras are enabled/disabled all the time so history is destroyed each frame.
            // In this case we know we want to keep history alive as long as the camera is.
            additionalCameraData.hasPersistentHistory = true;

            Light light = SRI.sunLight;
            HDAdditionalLightData additionalLightData = light.gameObject.AddComponent <HDAdditionalLightData>();

#if UNITY_EDITOR
            HDAdditionalLightData.InitDefaultHDAdditionalLightData(additionalLightData);
#endif
            additionalLightData.intensity = 0f;
            additionalLightData.SetShadowResolution(2048);

            GameObject volumeGO = SRI.AddGameObject(persistent: true);
            volumeGO.name = "SkyManagementVolume";
            Volume volume = volumeGO.AddComponent <Volume>();
            volume.isGlobal = true;
            volume.priority = float.MaxValue;
            VolumeProfile profile = ScriptableObject.CreateInstance <VolumeProfile>();
            volume.sharedProfile = profile;

            HDShadowSettings shadows = profile.Add <HDShadowSettings>();
            shadows.maxShadowDistance.Override(25f);
            shadows.cascadeShadowSplitCount.Override(2);

            VisualEnvironment visualEnvironment = profile.Add <VisualEnvironment>();
            visualEnvironment.skyType.Override((int)SkyType.HDRI);
            visualEnvironment.skyAmbientMode.Override(SkyAmbientMode.Dynamic);
            HDRISky sky = profile.Add <HDRISky>();

            SRI.SRPData = new LookDevDataForHDRP()
            {
                additionalCameraData = additionalCameraData,
                additionalLightData  = additionalLightData,
                visualEnvironment    = visualEnvironment,
                sky    = sky,
                volume = volume
            };
        }
Exemplo n.º 3
0
 public static CreateGpuLightDataJobGlobalConfig Create(
     HDCamera hdCamera,
     HDShadowSettings hdShadowSettings)
 {
     return(new CreateGpuLightDataJobGlobalConfig()
     {
         lightLayersEnabled = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers),
         specularGlobalDimmer = hdCamera.frameSettings.specularGlobalDimmer,
         maxShadowFadeDistance = hdShadowSettings.maxShadowDistance.value,
         invalidScreenSpaceShadowIndex = (int)LightDefinitions.s_InvalidScreenSpaceShadow
     });
 }