Exemplo n.º 1
0
        public void RenderAll(IReadOnlyList <Camera> cameras, IReadOnlyList <LightSource> lights, RendererCollection renderables)
        {
            Assert.True(cameras.Count > 0);

            _glContext.Viewport(0u, 0u, (uint)_screenSize.Width, (uint)_screenSize.Height);
            _graphics.DrawCalls = 0;

            for (int camNo = 0; camNo < cameras.Count; camNo++)
            {
                var camera = cameras[camNo];
                if (camera.IsEnabled == false)
                {
                    continue;
                }

                _graphics.SetupCameraAndLights(camera, lights);

                FirstPass(renderables, camera);
                SecondPass(camNo == 0, camera);

                _glContext.DepthMask(false);
                _glContext.Enable(EnableCap.Blend);
                var opaqueCount = renderables.Opaque.Count;
                var transparent = renderables.Transparent;
                for (int i = 0; i < transparent.Count; i++)
                {
                    _graphics.UpdateAndRender(camera, transparent[i], (uint)(i + 1 + opaqueCount));
                }
                _glContext.DepthMask(true);
            }

            DrawGBuffer();
        }
Exemplo n.º 2
0
        public void RenderAll(IReadOnlyList <Camera> cameras, IReadOnlyList <LightSource> lights, RendererCollection renderables)
        {
            Prepare();

            for (int i = 0; i < cameras.Count; i++)
            {
                var camera = cameras[i];
                if (camera.IsEnabled == false)
                {
                    continue;
                }

                if (i == 0)
                {
                    _glContext.ClearColor(camera.ClearColor);
                    _glContext.Clear(BufferMask.ColorBufferBit | BufferMask.DepthBufferBit | BufferMask.StencilBufferBit);
                }
                else
                {
                    _glContext.Clear(BufferMask.DepthBufferBit);
                }

                _graphics.SetupCameraAndLights(camera, lights);
                RenderCamera(camera, renderables);
            }
        }