private void OnDisable() { Logger.Log("Lighting system disabled.", Category.Lighting); //don't run lighting system on headless if (GameData.IsHeadlessServer) { return; } OnLightingSystemEnabled?.Invoke(false); // Set object occlusion white, so occlusion dependent shaders will show appropriately while system is off. Shader.SetGlobalTexture("_ObjectFovMask", Texture2D.whiteTexture); // Default parameters to force parameters update on enable. operationParameters = default(OperationParameters); HandlePPPositionRequest -= ProviderPPPosition; // We can enable background layers again if (mMainCamera) { mMainCamera.cullingMask |= renderSettings.backgroundLayers; } if (mTextureDataRequest != null) { mTextureDataRequest.Dispose(); mTextureDataRequest = null; } }
private void OnEnable() { Logger.Log("Lighting system enabled.", Category.Lighting); //don't run lighting system on headless if (GameData.IsHeadlessServer) { return; } OnLightingSystemEnabled?.Invoke(true); if (!SystemInfo.supportsAsyncGPUReadback) { Logger.LogWarning("LightingSystem: Async GPU Readback not supported on this machine, slower synchronous readback will" + " be used instead.", Category.Lighting); } HandlePPPositionRequest += ProviderPPPosition; // Initialize members. mMainCamera = gameObject.GetComponent <Camera>(); if (mMainCamera == null) { throw new Exception("FovSystemManager require Camera component to operate."); } // Let's force camera to cull background light mMainCamera.cullingMask &= ~renderSettings.backgroundLayers; // Now validate other settings ValidateMainCamera(mMainCamera, renderSettings); if (mOcclusionRenderer == null) { mOcclusionRenderer = OcclusionMaskRenderer.InitializeMaskRenderer(gameObject, renderSettings.occlusionLayers, materialContainer.OcclusionMaskShader); } if (mLightMaskRenderer == null) { mLightMaskRenderer = LightMaskRenderer.InitializeMaskRenderer(gameObject); } if (mBackgroundRenderer == null) { mBackgroundRenderer = BackgroundRenderer.InitializeMaskRenderer(gameObject); } if (mPostProcessingStack == null) { mPostProcessingStack = new PostProcessingStack(materialContainer); } if (!renderSettings.disableAsyncGPUReadback && SystemInfo.supportsAsyncGPUReadback) { mTextureDataRequest = new TextureDataRequest(); } operationParameters = new OperationParameters(mMainCamera, renderSettings, matrixRotationMode);; ResolveRenderingTextures(operationParameters); }