protected override void OnRenderFrame(FrameEventArgs e) { if (IsLoadingDone) { GUI.NewFrame(); Renderer.ClippedCount = 0; Renderer.DrawCalls = 0; World.GetInstance()?.Render(); Renderer.DrawQueue(); PostProcessingEffects.RenderEffects(); World.GetInstance()?.RenderGUI(); ContainerRenderer.RenderGUI(); Menu.RenderGUI(); Input.Input.PostRenderUpdate(); GUI.EndFrame(); } Context.SwapBuffers(); base.OnRenderFrame(e); }
private void Initialize() { graphicsDevice = ScreenManager.GraphicsDevice; content = ScreenManager.Content; spriteBatch = ScreenManager.SpriteBatch; font = ScreenManager.Font; MeshManager.InitializeManager(graphicsDevice, content); screenWidth = graphicsDevice.Viewport.Width; screenHeight = graphicsDevice.Viewport.Height; clearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f); // Create Render Targets mainRT = new RenderTarget2D(graphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents); reflectionRT = new RenderTarget2D(graphicsDevice, screenWidth / 2, screenHeight / 2, true, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); occlusionRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color, DepthFormat.None); bloomRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color, DepthFormat.None); postEffects = new PostProcessingEffects(graphicsDevice, content.Load <Effect>(@"Effects\PostProcessingEffects")); // Create renderers lightRenderer = new LightRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Light")); terrainRenderer = new TerrainRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Terrain")); surfaceRenderer = new SurfaceRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Surface")); waterRenderer = new WaterRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Water")); billboardRenderer = new BillboardRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Billboard")); meshRenderer = new MeshRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Mesh")); // Create camera camera = new FirstPersonCamera(); camera.AspectRatio = graphicsDevice.Viewport.AspectRatio; camera.AABBSize = new Vector2(1.0f, 8.0f); camera.DrawDistance = 10000.0f; camera.MoveSpeed = 25.0f; camera.FreeFlyEnabled = false; camera.PitchMinDegrees = -75.0f; camera.PitchMaxDegrees = 60.0f; camera.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), camera.AspectRatio, 0.1f, 10000.0f); secretSFX = content.Load <SoundEffect>(@"SoundEffects\shotgun_pump"); // Load level data LoadLevel(@"Levels\" + levelFileName); }
protected override void OnUnload(EventArgs e) { World.GetInstance()?.Dispose(); AssetDatabase.Dispose(); UniformBuffers.Dispose(); PostProcessingEffects.Dispose(); base.OnUnload(e); }
protected override async Task LoadContent() { await base.LoadContent(); hdrTexture = await Asset.LoadAsync <Texture>("Atrium"); hdrRenderTexture = Texture.New2D(GraphicsDevice, hdrTexture.Width, hdrTexture.Height, 1, hdrTexture.Format, TextureFlags.ShaderResource | TextureFlags.RenderTarget); drawEffectContext = RenderContext.GetShared(Services); postProcessingEffects = new PostProcessingEffects(drawEffectContext); postProcessingEffects.BrightFilter.Threshold = 100.0f; postProcessingEffects.Bloom.DownScale = 2; }
protected override async Task LoadContent() { await base.LoadContent(); hdrTexture = Content.Load <Texture>("HdrTexture"); hdrRenderTexture = Texture.New2D(GraphicsDevice, hdrTexture.Width, hdrTexture.Height, 1, hdrTexture.Description.Format, TextureFlags.ShaderResource | TextureFlags.RenderTarget); drawEffectContext = RenderContext.GetShared(Services); postProcessingEffects = new PostProcessingEffects(drawEffectContext); postProcessingEffects.BrightFilter.Threshold = 20.0f; postProcessingEffects.Bloom.DownScale = 2; postProcessingEffects.Bloom.Enabled = true; postProcessingEffects.Bloom.ShowOnlyBloom = true; }
protected override void OnLoad(EventArgs e) { IsLoadingDone = false; AssetDatabase.SetPack(AssetDatabase.DEFAULTPACK); GameBlocks.Init(); GameItems.Init(); CraftingRecipeDatabase.Init(); VSync = VSyncMode.Off; GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.Enable(EnableCap.FramebufferSrgb); GL.Enable(EnableCap.DepthTest); GL.ClearColor(CLEAR_COLOUR.X, CLEAR_COLOUR.Y, CLEAR_COLOUR.Z, CLEAR_COLOUR.Z); AssetDatabase.GetAsset <Material>("Resources/Materials/Fallback.mat"); MainMenu = new MainMenu(); MainMenu.Show(); Program.Settings.UpdateAll(); //Load texture pack before generating icons AssetDatabase.GetAsset <TexturePack>(""); IconGenerator.GenerateBlockItemIcons(); WindowWidth = Program.Settings.WindowWidth; WindowHeight = Program.Settings.WindowHeight; PostProcessingEffects.RegisterEffect(new Bloom()); PostProcessingEffects.RegisterEffect(new ACESTonemapEffect()); IsLoadingDone = true; OnResize(null); base.OnLoad(e); }
/// <summary> /// Initializes a new instance of the <see cref="SceneEditorGraphicsModeHDRSettings"/> class. /// </summary> public SceneEditorGraphicsModeHDRSettings() { BackgroundColor = (Color3) new Color(120, 120, 120); PostProcessingEffects = new PostProcessingEffects(); }