예제 #1
0
        public FrameBuffer Render(FrameBuffer renderFrameBuffer)
        {
            Texture renderTexture = renderFrameBuffer.BoundTexture;

            if (postProcessShaders.Count <= 0)
            {
                return(renderFrameBuffer);
            }


            var destination = texture2;
            var source      = renderTexture;

            for (int i = 0; i < postProcessShaders.Count; i++)
            {
                Shader shader     = postProcessShaders[i];
                bool   lastShader = i >= postProcessShaders.Count - 1;

                if (!lastShader)
                {
                    postProBuffer.Use();
                    postProBuffer.BindTexture(destination);
                }
                else
                {
                    renderFrameBuffer.Use();
                }

                //Util.GLClear();
                source.BindToUnit(0);
                QuadMesh.ScreenQuad.Draw(shader);

                if (lastShader)
                {
                    break;
                }

                if (i == 0)
                {
                    source = texture1;
                }

                var temp = destination;
                destination = source;
                source      = temp;
            }

            return(renderFrameBuffer);
        }
예제 #2
0
        public void RenderPipeline()
        {
            FrameBuffer buffer = RenderFrameBuffer;

            buffer.Use();
            GL.GetApi().ClearFramebuffer();

            for (int i = 0; i < Pipeline.Count; i++)
            {
                buffer = Pipeline[i].Render(buffer);
            }

            buffer.BoundTexture.BindToUnit(0);
            FrameBuffer.UseDefault();
            Util.GLClear();
            _finalShader.SetInt("screen", 0);
            QuadMesh.ScreenQuad.Draw(_finalShader);
        }
예제 #3
0
        public FrameBuffer Render(FrameBuffer renderFrameBuffer)
        {
            LightingPass();

            Program.Window.GetSize(out int windowWidth, out int windowHeight);
            Gl.Viewport(0, 0, (uint)windowWidth, (uint)windowHeight);

            renderFrameBuffer.Use();
            Gl.CullFace(CullFaceMode.Back);

            DefaultShader.Use();
            CurrentCamera.SetData(DefaultShader);
            SetLightingData();
            RenderScene(DefaultShader);
            RenderExtras(renderFrameBuffer);


            return(renderFrameBuffer);
        }
예제 #4
0
 protected virtual void RenderExtras(FrameBuffer frameBuffer)
 {
 }