Exemple #1
0
        private void RenderPass2(RenderContext context, Camera camera)
        {
            Pass = DeferredPass.Pass2;
            ObjectManager.PushDebugGroup("OnRender LightShader", this);

            _DefLightShader.Bind();

            GPosition.Bind(TextureUnit.Texture0);
            GNormal.Bind(TextureUnit.Texture1);
            GAlbedoSpec.Bind(TextureUnit.Texture2);
            GMaterial.Bind(TextureUnit.Texture3);

            if (Renderer.Current.UseShadows)
            {
                context.GetPipeline <DirectionalShadowRenderPipeline>().FrameBuffer.GetDestinationTexture().Bind(TextureUnit.Texture4);
                _DefLightShader.SetInt("DirectionalShadowMap", 4);
                context.GetPipeline <PointShadowRenderPipeline>().FrameBuffer.GetDestinationTexture().Bind(TextureUnit.Texture5);
                _DefLightShader.SetInt("PointShadowMap", 5);
            }

            _DefLightShader.SetVector3("ViewPos", camera.Position);
            _DefLightShader.SetFloat("FarPlane", camera.FarPlane);

            // TODO: Move to Pass1
            //_DefLightShader.SetMaterial("material", Material.Default);

            _DefLightShader.BindBlock("LightsArray", context.LightBinding);
            _DefLightShader.SetInt("LightCount", context.LightObjects.Count);

            context.GetPipeline <ForwardRenderPipeline>().FrameBuffer.Bind();
            vao.Bind();
            GL.Disable(EnableCap.DepthTest);
            vao.Draw();
            GL.Enable(EnableCap.DepthTest);

            ObjectManager.PopDebugGroup();
        }