public void ApplyCustomSettingsChanges(bool saveConfig) { HDRenderPipeline hdrp = RenderPipelineManager.currentPipeline as HDRenderPipeline; if (hdrp != null) { ref FrameSettings fs = ref hdrp.GetDefaultCameraFrameSettings(); fs.SetEnabled(FrameSettingsField.ShadowMaps, Cfg.Shadows); fs.SetEnabled(FrameSettingsField.Antialiasing, Cfg.Antialiasing); fs.SetEnabled(FrameSettingsField.SSAO, Cfg.AmbientOcclusion); fs.SetEnabled(FrameSettingsField.SubsurfaceScattering, Cfg.Scattering); fs.SetEnabled(FrameSettingsField.Volumetrics, Cfg.Volumetrics); fs.SetEnabled(FrameSettingsField.MotionVectors, Cfg.MotionBlur); }
// deactivate this test for template package making issue //[Test] public void FrameSettingsAggregation() { for (int i = 0; i < 10; ++i) { //init FrameSettings fs = default; FrameSettingsOverrideMask fso = default; FrameSettingsRenderType defaultFSType = RandomUtilities.RandomEnumValue <FrameSettingsRenderType>(i); FrameSettings defaultFS; FrameSettings result = FrameSettings.NewDefaultCamera(); FrameSettings tester = default; RenderPipelineSettings supportedFeatures = new RenderPipelineSettings(); switch (defaultFSType) { case FrameSettingsRenderType.Camera: defaultFS = FrameSettings.NewDefaultCamera(); break; case FrameSettingsRenderType.CustomOrBakedReflection: defaultFS = FrameSettings.NewDefaultCustomOrBakeReflectionProbe(); break; case FrameSettingsRenderType.RealtimeReflection: defaultFS = FrameSettings.NewDefaultRealtimeReflectionProbe(); break; default: throw new ArgumentException("Unknown FrameSettingsRenderType"); } //change randomly override values for (int j = 0; j < 10; ++j) { FrameSettingsField field = RandomUtilities.RandomEnumValue <FrameSettingsField>((i + 0.5f) * (j + 0.3f)); fs.SetEnabled(field, RandomUtilities.RandomBool((i + 1) * j)); fso.mask[(uint)field] = true; } //create and init gameobjects var go = new GameObject("TestObject"); m_ToClean = go; var cam = go.AddComponent <Camera>(); var add = cam.GetComponent <HDAdditionalCameraData>() ?? cam.gameObject.AddComponent <HDAdditionalCameraData>(); Assert.True(add != null && !add.Equals(null)); add.renderingPathCustomFrameSettings = fs; add.renderingPathCustomFrameSettingsOverrideMask = fso; add.defaultFrameSettings = defaultFSType; add.customRenderingSettings = true; //gather data two different ways FrameSettings.AggregateFrameSettings(ref result, cam, add, ref defaultFS, supportedFeatures); foreach (FrameSettingsField field in Enum.GetValues(typeof(FrameSettingsField))) { tester.SetEnabled(field, fso.mask[(uint)field] ? fs.IsEnabled(field) : defaultFS.IsEnabled(field)); } tester.lodBias = result.lodBias; tester.lodBiasMode = result.lodBiasMode; tester.maximumLODLevel = result.maximumLODLevel; tester.maximumLODLevelMode = result.maximumLODLevelMode; FrameSettings.Sanitize(ref tester, cam, supportedFeatures); //test Assert.AreEqual(result, tester); Object.DestroyImmediate(go); } }
public void EnablePostProcessing(Camera camera, bool value) { HDAdditionalCameraData cameraData = camera.GetComponent <HDAdditionalCameraData>(); if (cameraData == null) { cameraData = camera.gameObject.AddComponent <HDAdditionalCameraData>(); } cameraData.customRenderingSettings = true; FrameSettingsOverrideMask settingsOverride = cameraData.renderingPathCustomFrameSettingsOverrideMask; FrameSettings settings = cameraData.renderingPathCustomFrameSettings; settings.SetEnabled(FrameSettingsField.Postprocess, value); settings.SetEnabled(FrameSettingsField.AfterPostprocess, value); settings.SetEnabled(FrameSettingsField.TransparentPostpass, value); settings.SetEnabled(FrameSettingsField.TransparentPostpass, value); settings.SetEnabled(FrameSettingsField.LowResTransparent, value); settings.SetEnabled(FrameSettingsField.ShadowMaps, value); settings.SetEnabled(FrameSettingsField.ContactShadows, value); settings.SetEnabled(FrameSettingsField.ScreenSpaceShadows, value); settings.SetEnabled(FrameSettingsField.Transmission, value); settings.SetEnabled(FrameSettingsField.ExposureControl, value); settings.SetEnabled(FrameSettingsField.ReflectionProbe, value); settings.SetEnabled(FrameSettingsField.PlanarProbe, value); settings.SetEnabled(FrameSettingsField.ReplaceDiffuseForIndirect, value); settings.SetEnabled(FrameSettingsField.SkyReflection, value); settings.SetEnabled(FrameSettingsField.DirectSpecularLighting, value); settings.SetEnabled(FrameSettingsField.Volumetrics, value); settings.SetEnabled(FrameSettingsField.ReprojectionForVolumetrics, value); settings.SetEnabled(FrameSettingsField.CustomPostProcess, value); settingsOverride.mask[(uint)FrameSettingsField.Postprocess] = true; settingsOverride.mask[(uint)FrameSettingsField.AfterPostprocess] = true; settingsOverride.mask[(uint)FrameSettingsField.TransparentPostpass] = true; settingsOverride.mask[(uint)FrameSettingsField.TransparentPostpass] = true; settingsOverride.mask[(uint)FrameSettingsField.LowResTransparent] = true; settingsOverride.mask[(uint)FrameSettingsField.ShadowMaps] = true; settingsOverride.mask[(uint)FrameSettingsField.ContactShadows] = true; settingsOverride.mask[(uint)FrameSettingsField.ScreenSpaceShadows] = true; settingsOverride.mask[(uint)FrameSettingsField.SubsurfaceScattering] = true; settingsOverride.mask[(uint)FrameSettingsField.Transmission] = true; settingsOverride.mask[(uint)FrameSettingsField.ExposureControl] = true; settingsOverride.mask[(uint)FrameSettingsField.ReflectionProbe] = true; settingsOverride.mask[(uint)FrameSettingsField.PlanarProbe] = true; settingsOverride.mask[(uint)FrameSettingsField.ReplaceDiffuseForIndirect] = true; settingsOverride.mask[(uint)FrameSettingsField.SkyReflection] = true; settingsOverride.mask[(uint)FrameSettingsField.DirectSpecularLighting] = true; settingsOverride.mask[(uint)FrameSettingsField.Volumetrics] = true; settingsOverride.mask[(uint)FrameSettingsField.ReprojectionForVolumetrics] = true; settingsOverride.mask[(uint)FrameSettingsField.CustomPostProcess] = true; cameraData.renderingPathCustomFrameSettingsOverrideMask = settingsOverride; cameraData.renderingPathCustomFrameSettings = settings; if (PostProcessingEnabled != null) { PostProcessingEnabled(camera, value); } }