protected override void DrawCore(RenderDrawContext context) { // Get or create VisibilityGroup for this RenderSystem var sceneInstance = SceneInstance.GetCurrent(context.RenderContext); var visibilityGroup = sceneInstance.GetOrCreateVisibilityGroup(RenderSystem); using (context.RenderContext.PushTagAndRestore(SceneInstance.CurrentVisibilityGroup, visibilityGroup)) using (context.RenderContext.PushTagAndRestore(SceneInstance.CurrentRenderSystem, RenderSystem)) { // Collect visibilityGroup.Reset(); try { // Collect in layers. Setup features/stages, enumerate viewes and populates VisibilityGroup Layers.Collect(context.RenderContext); Master.Collect(context.RenderContext); // Collect in render features RenderSystem.Collect(context); // Extract RenderSystem.Extract(context); // Prepare RenderSystem.Prepare(context); // Draw the layers Layers.Draw(context); // Draw the master track Master.Draw(context); // Flush RenderSystem.Flush(context); } finally { // Reset render context data RenderSystem.Reset(); } context.RenderContext.Reset(); } }
/// <inheritdoc/> protected override void DrawCore(RenderDrawContext context) { if (Game != null) { // Get or create VisibilityGroup for this RenderSystem + SceneInstance var sceneInstance = SceneInstance.GetCurrent(context.RenderContext); VisibilityGroup visibilityGroup = null; if (sceneInstance != null) { // Find if VisibilityGroup foreach (var currentVisibilityGroup in sceneInstance.VisibilityGroups) { if (currentVisibilityGroup.RenderSystem == RenderSystem) { visibilityGroup = currentVisibilityGroup; break; } } // If first time, let's create and register it if (visibilityGroup == null) { sceneInstance.VisibilityGroups.Add(visibilityGroup = new VisibilityGroup(RenderSystem)); initializedSceneInstances.Add(sceneInstance); } // Reset & cleanup visibilityGroup.Reset(); } using (context.RenderContext.PushTagAndRestore(SceneInstance.CurrentVisibilityGroup, visibilityGroup)) using (context.RenderContext.PushTagAndRestore(SceneInstance.CurrentRenderSystem, RenderSystem)) using (context.RenderContext.PushTagAndRestore(SceneCameraSlotCollection.Current, Cameras)) { // Set render system context.RenderContext.RenderSystem = RenderSystem; context.RenderContext.VisibilityGroup = visibilityGroup; // Set start states for viewports and output (it will be used during the Collect phase) var renderOutputs = new RenderOutputDescription(); renderOutputs.CaptureState(context.CommandList); context.RenderContext.RenderOutput = renderOutputs; var viewports = new ViewportState(); viewports.CaptureState(context.CommandList); context.RenderContext.ViewportState = viewports; try { // Collect in the game graphics compositor: Setup features/stages, enumerate views and populates VisibilityGroup Game.Collect(context.RenderContext); // Collect in render features RenderSystem.Collect(context.RenderContext); // Collect visibile objects from each view (that were not properly collected previously) if (visibilityGroup != null) { foreach (var view in RenderSystem.Views) { visibilityGroup.TryCollect(view); } } // Extract RenderSystem.Extract(context.RenderContext); // Prepare RenderSystem.Prepare(context); // Draw using the game graphics compositor Game.Draw(context); // Flush RenderSystem.Flush(context); } finally { // Reset render context data RenderSystem.Reset(); } } } }