public static void EnableNightVisionEffect(AbstractActor source) { // Skip if the green effect is disabled if (!Mod.Config.Toggles.ShowNightVision) { return; } ModState.IsNightVisionMode = true; MoodController mc = ModState.GetMoodController(); Traverse uppT = Traverse.Create(mc).Field("unityPostProcess"); PostProcessingBehaviour ppb = uppT.GetValue <PostProcessingBehaviour>(); // Enable grain and set the intensity Traverse grainT = Traverse.Create(ppb).Field("m_Grain"); GrainComponent gc = grainT.GetValue <GrainComponent>(); GrainModel.Settings gms = gc.model.settings; gms.intensity = 0.8f; gms.size = 1.0f; gc.model.settings = gms; Traverse sunlightBTT = Traverse.Create(mc).Field("sunlightBT"); BTSunlight sunlightBT = sunlightBTT.GetValue <BTSunlight>(); // Disable shadows from sunlight //BTSunlight.SunlightSettings sunlightS = sunlightBT.sunSettings; //sunlightS.castShadows = false; //sunlightBT.sunSettings = sunlightS; Traverse sunlightT = Traverse.Create(sunlightBT).Field("sunLight"); Light sunlight = sunlightT.GetValue <Light>(); sunlight.shadows = LightShadows.None; // Set the sunlight color Color lightVision = Color.green; lightVision.a = 0.8f; Shader.SetGlobalColor(Shader.PropertyToID("_BT_SunlightColor"), lightVision); // Disable opacity from the clouds Shader.SetGlobalFloat(Shader.PropertyToID("_BT_CloudOpacity"), 0f); // Make the sunlight point straight down Shader.SetGlobalVector(Shader.PropertyToID("_BT_SunlightDirection"), sunlightBT.transform.up); }
void OnEnable() { m_CommandBuffers = new Dictionary <Type, KeyValuePair <CameraEvent, CommandBuffer> >(); m_MaterialFactory = new MaterialFactory(); m_RenderTextureFactory = new RenderTextureFactory(); m_Context = new PostProcessingContext(); // Keep a list of all post-fx for automation purposes m_Components = new List <PostProcessingComponentBase>(); // Component list m_DebugViews = AddComponent(new BuiltinDebugViewsComponent()); m_AmbientOcclusion = AddComponent(new AmbientOcclusionComponent()); m_ScreenSpaceReflection = AddComponent(new ScreenSpaceReflectionComponent()); m_FogComponent = AddComponent(new FogComponent()); m_MotionBlur = AddComponent(new MotionBlurComponent()); m_Taa = AddComponent(new TaaComponent()); m_EyeAdaptation = AddComponent(new EyeAdaptationComponent()); m_DepthOfField = AddComponent(new DepthOfFieldComponent()); m_Bloom = AddComponent(new BloomComponent()); m_ChromaticAberration = AddComponent(new ChromaticAberrationComponent()); m_ColorGrading = AddComponent(new ColorGradingComponent()); m_UserLut = AddComponent(new UserLutComponent()); m_Grain = AddComponent(new GrainComponent()); m_Vignette = AddComponent(new VignetteComponent()); m_Dithering = AddComponent(new DitheringComponent()); m_Fxaa = AddComponent(new FxaaComponent()); // Prepare state observers m_ComponentStates = new Dictionary <PostProcessingComponentBase, bool>(); foreach (var component in m_Components) { m_ComponentStates.Add(component, false); } useGUILayout = false; }