protected override void OnEnable() { instance = this; this.camera = Rendering.CreateCameraWorld(this.SceneObject, ClientAmbientOcclusion.RenderingTag, -1000); this.camera.ClearColor = ClientAmbientOcclusion.IsDisplayMask ? Color.FromArgb(0x99, 0xFF, 0xFF, 0xFF) : Color.FromArgb(0x00, 0x00, 0x00, 0x00); // transparent black this.camera.DrawMode = CameraDrawMode.Manual; this.blurPostEffect = new BlurPostEffect { RenderTextureDownsampling = 1, Passes = 2, IsEnabled = true }; this.layerRenderer = Client.Rendering.CreateLayerRenderer( this.SceneObject, TextureResource.NoTexture, drawOrder: ClientAmbientOcclusion.IsDisplayMask // display as overlay (over everything) ? DrawOrder.Overlay : DrawOrder.Occlusion); this.layerRenderer.CustomDraw += this.LayerRendererBeforeDrawHandler; this.effectInstanceCompose = EffectInstance.Create(EffectResourceAmbientOcclusionCompose); }
protected override void OnDisable() { if (instance == this) { instance = null; } this.camera = null; this.blurPostEffect.IsEnabled = false; this.layerRenderer.CustomDraw -= this.LayerRendererBeforeDrawHandler; this.layerRenderer.Destroy(); this.layerRenderer = null; this.effectInstanceCompose.Dispose(); this.effectInstanceCompose = null; }