Exemplo n.º 1
0
        private void RenderSceneToFramebuffer()
        {
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, mainFramebuffer.Fbo);
            Gl.Viewport(0, 0, Constants.renderWidth, Constants.renderHeight);
            Gl.ClearDepth(0.0f);
            Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            Gl.ClipControl(ClipControlOrigin.LowerLeft, ClipControlDepth.ZeroToOne);
            Gl.DepthFunc(DepthFunction.Greater);

            camera.Render();
            DrawSkybox();
            testModel.Draw(camera, shader, light, (skybox, convolutedSkybox, prefilteredSkybox), brdfLut);

            Gl.DepthFunc(DepthFunction.Less);
            Gl.ClipControl(ClipControlOrigin.LowerLeft, ClipControlDepth.NegativeOneToOne);
        }
Exemplo n.º 2
0
        private void RenderSceneToFramebuffer()
        {
            var cameraComponent = MainCamera.GetComponent <CameraComponent>();

            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, cameraComponent.Framebuffer.Fbo);
            Gl.Viewport(0, 0, (int)cameraComponent.Resolution.X, (int)cameraComponent.Resolution.Y);
            Gl.ClearDepth(0.0f);
            Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            Gl.ClipControl(ClipControlOrigin.LowerLeft, ClipControlDepth.ZeroToOne);
            Gl.DepthFunc(DepthFunction.Greater);

            MainCamera.Render();
            var skyboxComponent = skyboxEntity.GetComponent <SkyboxComponent>();

            skyboxComponent.DrawSkybox(MainCamera);

            var templateDrawInfo = new Mesh.DrawInfo()
            {
                Camera      = MainCamera,
                Light       = Lights[0],
                PbrCubemaps = (skyboxComponent.skybox, skyboxComponent.convolutedSkybox, skyboxComponent.prefilteredSkybox),
                BrdfLut     = brdfLut,
                HoloTexture = holoTexture,
                ProjMatrix  = MainCamera.GetComponent <CameraComponent>().ProjMatrix,
                ViewMatrix  = MainCamera.GetComponent <CameraComponent>().ViewMatrix
            };

            foreach (var entity in Entities)
            {
                if (!entity.HasComponent <ModelComponent>())
                {
                    continue;
                }

                var modelComponent = entity.GetComponent <ModelComponent>();
                var newDrawInfo    = new Mesh.DrawInfo(templateDrawInfo);
                newDrawInfo.Shader      = entity.GetComponent <ShaderComponent>();
                newDrawInfo.ModelMatrix = entity.GetComponent <TransformComponent>().Matrix;

                modelComponent.Draw(newDrawInfo);
            }

            Gl.DepthFunc(DepthFunction.Less);
            Gl.ClipControl(ClipControlOrigin.LowerLeft, ClipControlDepth.NegativeOneToOne);
        }