Пример #1
0
        public Form1()
        {
            InitializeComponent();
            renderer  = new Renderer();
            swapChain = new CargoEngine.SwapChain(this, renderer);

            scene = new Scene();

            var terrain = new Terrain();

            scene.RootNode.AddChild(terrain);
            terrain.Transform.Scale = new Vector3(3.0f, 1.0f, 3.0f);

            cam = new Camera();
            cam.Transform.Position = new Vector3(0, 50.0f, 0.0f);
            cam.SetProjection(0.1f, 1000.0f, (float)this.Width / (float)this.Height, (float)Math.PI / 4.0f);
            cam.RenderTask = new DeferredRenderTask(swapChain);
            cam.Scene      = scene;
            cam.AddComponent(new FreeLookComponent(eventManager));
            cam.AddComponent(new FreeMoveComponent(eventManager)
            {
                Speed = 40.0f
            });
            scene.RootNode.AddChild(cam);

            timer.Start();
            AddEvents();
        }
Пример #2
0
        public DeferredRenderTask(SwapChain swapChain)
        {
            this.swapChain = swapChain;
            renderTargets  = new RenderTargetGroup(swapChain, Format.R8G8B8A8_UNorm); // Albedo
            renderTargets.AddDepthStencil();
            renderTargets.AddRenderTarget(Format.R8G8B8A8_UNorm);                     //Normals
            renderTargets.AddRenderTarget(Format.R16G16B16A16_Float);                 //Position
            renderTargets.AddRenderTarget(Format.R8G8B8A8_UNorm);                     //Light
            renderTargets.AddRenderTarget(Format.R8G8B8A8_UNorm);                     //Combine

            swapChain.OnResize += (o, e) => {
                renderTargets.Resize(e.Size.Width, e.Size.Height);
            };
            Init();

            FXAA = true;
        }