Example #1
0
        public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary <string, object> parameters)
        {
            // TODO: implement
            throw new NotImplementedException();

            // set projection to orthographic
            Dictionary <string, IUniformValue> uniforms = stage.GetShaderUniforms(parameters["material"] as string);

            uniforms["projection"] = UniformValue.Create(Matrix4.CreateOrthographic(1f, 1f, -1f, 1f));
            uniforms["modelView"]  = UniformValue.Create(Matrix4.CreateTranslation(0, 0, 0));

            // draw a full screen quad.
            if (_fsQuad == null)
            {
                // create the quad VertexArray.
                VertexBuffer vbo = VertexBuffer.Create(VertexFormat.PositionTexture, new VertexPositionTexture[] {
                    new VertexPositionTexture(new Vector3(0f, 0f, 0f), new Vector2(0.0f, 1.0f)),
                    new VertexPositionTexture(new Vector3(1.0f, 0f, 0f), new Vector2(1.0f, 1.0f)),
                    new VertexPositionTexture(new Vector3(1.0f, 0f, 0f), new Vector2(1.0f, 0.0f)),
                    new VertexPositionTexture(new Vector3(0f, 1.0f, 0f), new Vector2(0.0f, 0.0f))
                });
                IndexBuffer ibo = IndexBuffer.Create(new byte[] { 0, 1, 2, 2, 3, 0 });
                _fsQuad = new VertexArray(vbo, ibo);
            }

            // get material from pipeline cache

            // set materials uniforms

            // draw full screen quad with material
        }
Example #2
0
        public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary <string, object> parameters)
        {
            Color4 color = (Color4)parameters["color"];

            if ((bool)parameters["depth"] == true)
            {
                GL.ClearDepth(1.0);
            }
            DrawBuffersEnum[] buffers = ((int[])parameters["buffers"]).Select(i => DrawBuffersEnum.ColorAttachment0 + i).ToArray();
            if (buffers.Length != 0)
            {
                GL.DrawBuffers(buffers.Length, buffers);
                GL.ClearColor(color);
                GL.DrawBuffers(stage.Pipeline.CurrentRenderTarget.DrawBuffers.Length, stage.Pipeline.CurrentRenderTarget.DrawBuffers);
            }
        }
Example #3
0
 public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary<string, object> parameters)
 {
     float[] values = parameters["value"].ToString().Split(new char[] { ',' }).Select(f => float.Parse(f)).ToArray();
       IUniformValue value;
       if(values.Length == 1)
     value = UniformValue.Create(values[0]);
       else if(values.Length == 2)
     value = UniformValue.Create(values[0], values[1]);
       else if(values.Length == 3)
     value = UniformValue.Create(values[0], values[1], values[2]);
       else if(values.Length == 4)
     value = UniformValue.Create(values[0], values[1], values[2], values[3]);
       else
     throw new ArgumentException("value parameter must contain 1 - 4 float values.");
       stage.AddShaderUniform(parameters["material"].ToString(), parameters["uniform"].ToString(), value);
 }
Example #4
0
        public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary <string, object> parameters)
        {
            FrameBuffer fb = stage.Pipeline.GetRenderTarget(parameters["id"] as String);

            if (fb != null)
            {
                device.SetViewport(0, 0, fb.Width, fb.Height);
                fb.Bind();
                stage.Pipeline.CurrentRenderTarget = fb;
            }
            else
            {
                device.ViewPort = stage.Pipeline.Camera.Viewport;
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                stage.Pipeline.CurrentRenderTarget = null;
            }
        }
Example #5
0
        public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary <string, object> parameters)
        {
            FrameBuffer fb = stage.Pipeline.GetRenderTarget(parameters["source"] as String);

            if (fb != null)
            {
                Texture2D texture;
                if ((int)(parameters["index"]) == -1) // depth texture
                {
                    texture = fb.DepthTexture;
                }
                else
                {
                    texture = fb.Textures[(int)(parameters["index"])];
                }

                string sampler = parameters["sampler"] as string;

                stage.Pipeline.AddSamplerBinding(sampler, texture);
            }
        }
Example #6
0
 public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary <string, object> parameters)
 {
     // TODO: implement
     throw new NotImplementedException();
 }
Example #7
0
 public void Execute(GraphicsDevice device, RenderPipelineStage stage, Dictionary <string, object> parameters)
 {
     stage.Pipeline.ClearSamplerBindings();
 }