///<summary> /// Prepare a viewport, the camera and the scene for a rendering operation ///</summary> protected void PreTargetOperation(CompositeTargetOperation op, Viewport vp, Camera cam) { if (cam != null) { var sm = cam.SceneManager; // Set up render target listener this.listener.SetOperation(op, sm, sm.TargetRenderSystem); this.listener.Viewport = vp; // Register it sm.QueueStarted += this.listener.OnRenderQueueStarted; sm.QueueEnded += this.listener.OnRenderQueueEnded; // Set visiblity mask this.oldVisibilityMask = sm.VisibilityMask; sm.VisibilityMask = op.VisibilityMask; // Set whether we find visibles this.oldFindVisibleObjects = sm.FindVisibleObjectsBool; sm.FindVisibleObjectsBool = op.FindVisibleObjects; // Set LOD bias level this.oldLodBias = cam.LodBias; cam.LodBias = cam.LodBias * op.LodBias; } // Set material scheme this.oldMaterialScheme = vp.MaterialScheme; vp.MaterialScheme = op.MaterialScheme; // Set Shadows Enabled this.oldShowShadows = vp.ShowShadows; vp.ShowShadows = op.ShadowsEnabled; //vp.ClearEveryFrame = true; //vp.ShowOverlays = false; //vp.BackgroundColor = op.ClearColor; }
///<summary> /// Set current operation and target */ ///</summary> public void SetOperation(CompositeTargetOperation op, SceneManager sm, RenderSystem rs) { this.operation = op; this.sceneManager = sm; this.renderSystem = rs; this.currentOp = 0; this.lastOp = op.RenderSystemOperations.Count; }
///<summary> /// Restore a viewport, the camera and the scene after a rendering operation ///</summary> protected void PostTargetOperation(CompositeTargetOperation op, Viewport vp, Camera cam) { if (cam != null) { var sm = cam.SceneManager; // Unregister our listener sm.QueueStarted -= this.listener.OnRenderQueueStarted; sm.QueueEnded -= this.listener.OnRenderQueueEnded; // Restore default scene and camera settings sm.VisibilityMask = this.oldVisibilityMask; sm.FindVisibleObjectsBool = this.oldFindVisibleObjects; cam.LodBias = this.oldLodBias; } vp.MaterialScheme = this.oldMaterialScheme; vp.ShowShadows = this.oldShowShadows; }
public CompositorChain(Viewport vp) { this.viewport = vp; this.originalScene = null; this.instances = new List <CompositorInstance>(); this.dirty = true; this.anyCompositorsEnabled = false; this.compiledState = new List <CompositeTargetOperation>(); this.outputOperation = null; this.oldClearEveryFrameBuffers = this.viewport.ClearBuffers; this.renderSystemOperations = new List <CompositeRenderSystemOperation>(); CreateOriginalScene(); this.listener = new RQListener(); Debug.Assert(this.viewport != null); this.viewport.Target.BeforeUpdate += BeforeRenderTargetUpdate; this.viewport.Target.AfterUpdate += AfterRenderTargetUpdate; this.viewport.Target.BeforeViewportUpdate += BeforeViewportUpdate; this.viewport.Target.AfterViewportUpdate += AfterViewportUpdate; }
protected void ClearCompiledState() { this.renderSystemOperations.Clear(); this.compiledState.Clear(); this.outputOperation = new CompositeTargetOperation(null); }