Exemplo n.º 1
0
 public virtual void ReleaseBuffer()
 {
     if (buffer != null)
     {
         buffer.Release();
         buffer = null;
     }
 }
Exemplo n.º 2
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)input.Input.Data;
            GLTextuer2D i2 = (GLTextuer2D)input2.Input.Data;

            if (i1 == null || i1.Id == 0)
            {
                return;
            }
            if (i2 == null || i2.Id == 0)
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = TileY;

            int predChannel   = redChannel;
            int pgreenChannel = greenChannel;
            int pblueChannel  = blueChannel;
            int palphaChannel = alphaChannel;

            if (ParentGraph != null)
            {
                if (ParentGraph.HasParameterValue(Id, "RedChannel"))
                {
                    predChannel = Convert.ToInt32(ParentGraph.GetParameterValue(Id, "RedChannel"));
                }

                if (ParentGraph.HasParameterValue(Id, "GreenChannel"))
                {
                    pgreenChannel = Convert.ToInt32(ParentGraph.GetParameterValue(Id, "GreenChannel"));
                }

                if (ParentGraph.HasParameterValue(Id, "BlueChannel"))
                {
                    pblueChannel = Convert.ToInt32(ParentGraph.GetParameterValue(Id, "BlueChannel"));
                }

                if (ParentGraph.HasParameterValue(Id, "AlphaChannel"))
                {
                    palphaChannel = Convert.ToInt32(ParentGraph.GetParameterValue(Id, "AlphaChannel"));
                }
            }

            processor.RedChannel   = predChannel;
            processor.GreenChannel = pgreenChannel;
            processor.BlueChannel  = pblueChannel;
            processor.AlphaChannel = palphaChannel;
            processor.Process(width, height, i1, i2, buffer);
            processor.Complete();

            output.Data = buffer;
            output.Changed();
            Updated();
        }
Exemplo n.º 3
0
        void LoadDefaultTextures()
        {
            lightMat = new Material.PBRLight();

            if (defaultBlack == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 0f, 0f, 0f, 1);
                defaultBlack = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultBlack.Bind();
                defaultBlack.SetData(black.Image, GLInterfaces.PixelFormat.Rgba, 128, 128);
                defaultBlack.GenerateMipMaps();
                defaultBlack.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultBlack.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
                Materia.Nodes.Atomic.MeshNode.DefaultBlack = defaultBlack;
            }
            if (defaultWhite == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 1f, 1f, 1f, 1);
                defaultWhite = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultWhite.Bind();
                defaultWhite.SetData(black.Image, GLInterfaces.PixelFormat.Rgba, 128, 128);
                defaultWhite.GenerateMipMaps();
                defaultWhite.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultWhite.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
                Materia.Nodes.Atomic.MeshNode.DefaultWhite = defaultWhite;
            }
            if (defaultGray == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 0.5f, 0.5f, 0.5f, 1);
                defaultGray = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultGray.Bind();
                defaultGray.SetData(black.Image, GLInterfaces.PixelFormat.Rgba, 128, 128);
                defaultGray.GenerateMipMaps();
                defaultGray.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultGray.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
            }

            if (defaultDarkGray == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 0.25f, 0.25f, 0.25f, 1);
                defaultDarkGray = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultDarkGray.Bind();
                defaultDarkGray.SetData(black.Image, GLInterfaces.PixelFormat.Rgba, 128, 128);
                defaultDarkGray.GenerateMipMaps();
                defaultDarkGray.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultDarkGray.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
                Materia.Nodes.Atomic.MeshNode.DefaultDarkGray = defaultDarkGray;
            }
        }
Exemplo n.º 4
0
        public PBRMaterial()
        {
            if (BRDFLut == null)
            {
                BRDFLut = new GLTextuer2D(PixelInternalFormat.Rgba8);
            }

            LoadShader();
        }
Exemplo n.º 5
0
        void Process()
        {
            if (!input.HasInput || !input2.HasInput)
            {
                return;
            }

            GLTextuer2D i1 = (GLTextuer2D)input.Reference.Data;
            GLTextuer2D i2 = (GLTextuer2D)input2.Reference.Data;
            GLTextuer2D i3 = null;

            if (input3.HasInput)
            {
                if (input3.Reference.Data != null)
                {
                    i3 = (GLTextuer2D)input3.Reference.Data;
                }
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }
            if (i2 == null)
            {
                return;
            }
            if (i2.Id == 0)
            {
                return;
            }

            if (processor == null)
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.Horizontal = horiz;

            processor.ColorLUT = i2;
            processor.Mask     = i3;
            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            TriggerTextureChange();
        }
Exemplo n.º 6
0
        void ProcessQuad(FXQuadData data, int quads)
        {
            GLTextuer2D i1 = null;

            if (data.quadrant == 0)
            {
                if (!q1.HasInput)
                {
                    return;
                }
                i1 = (GLTextuer2D)q1.Input.Data;
            }
            else if (data.quadrant == 1)
            {
                if (!q2.HasInput)
                {
                    return;
                }
                i1 = (GLTextuer2D)q2.Input.Data;
            }
            else if (data.quadrant == 2)
            {
                if (!q3.HasInput)
                {
                    return;
                }
                i1 = (GLTextuer2D)q3.Input.Data;
            }
            else if (data.quadrant == 3)
            {
                if (!q4.HasInput)
                {
                    return;
                }
                i1 = (GLTextuer2D)q4.Input.Data;
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            processor.Blending    = data.blending;
            processor.Scale       = data.scale;
            processor.Translation = data.translation;
            processor.Angle       = data.angle;
            processor.Pivot       = data.pivot;
            processor.Luminosity  = data.luminosity;

            processor.Process(data.quadrant, width, height, i1, temp, quads);
            processor.Blend(temp, buffer);
        }
Exemplo n.º 7
0
        void Process()
        {
            if (!input.HasInput)
            {
                return;
            }

            GLTextuer2D i1 = (GLTextuer2D)input.Reference.Data;
            GLTextuer2D i2 = null;

            if (input2.HasInput)
            {
                i2 = (GLTextuer2D)input2.Reference.Data;
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (processor == null)
            {
                return;
            }
            if (shader == null)
            {
                return;
            }
            if (preshader == null)
            {
                return;
            }

            CreateBufferIfNeeded();

            buffer.Bind();
            IGL.Primary.ClearTexImage(buffer.Id, (int)PixelFormat.Rgba, (int)PixelType.Float);
            GLTextuer2D.Unbind();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.Shader     = shader;
            processor.PreShader  = preshader;
            processor.SourceOnly = psourceonly;
            processor.Distance   = pmaxDistance;
            processor.Process(width, height, i1, i2, buffer);
            processor.Complete();

            Output.Data = buffer;
            TriggerTextureChange();
        }
Exemplo n.º 8
0
        public void Process(int width, int height, GLTextuer2D tex, GLTextuer2D other, GLTextuer2D output)
        {
            base.Process(width, height, tex, output);

            if (shader != null)
            {
                GLTextuer2D tempColor = new GLTextuer2D(tex.InternalFormat);
                tempColor.Bind();
                tempColor.SetData(IntPtr.Zero, PixelFormat.Rgba, tex.Width, tex.Height);
                if (tex.InternalFormat == PixelInternalFormat.R16f || tex.InternalFormat == PixelInternalFormat.R32f)
                {
                    tempColor.SetSwizzleLuminance();
                }
                else if (tex.IsRGBBased)
                {
                    tempColor.SetSwizzleRGB();
                }
                tempColor.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear);
                GLTextuer2D.Unbind();

                ResizeViewTo(tex, tempColor, tex.Width, tex.Height, width, height);
                tex = tempColor;
                IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                ResizeViewTo(other, output, other.Width, other.Height, width, height);
                other = output;
                IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));


                Vector2 tiling = new Vector2(TileX, TileY);

                shader.Use();
                shader.SetUniform2("tiling", ref tiling);

                shader.SetUniform("redChannel", RedChannel);
                shader.SetUniform("greenChannel", GreenChannel);
                shader.SetUniform("blueChannel", BlueChannel);
                shader.SetUniform("alphaChannel", AlphaChannel);

                shader.SetUniform("MainTex", 0);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture0);
                tex.Bind();
                shader.SetUniform("Other", 1);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture1);
                other.Bind();

                if (renderQuad != null)
                {
                    renderQuad.Draw();
                }

                GLTextuer2D.Unbind();
                Blit(output, width, height);
                tempColor.Release();
            }
        }
Exemplo n.º 9
0
        protected virtual void OnPixelFormatChange()
        {
            if (buffer != null)
            {
                buffer.Release();
                buffer = null;
            }

            TryAndProcess();
        }
Exemplo n.º 10
0
        public void Process(int width, int height, GLTextuer2D tex, GLTextuer2D tex2, GLTextuer2D tex3, GLTextuer2D tex4, GLTextuer2D output)
        {
            base.Process(width, height, tex, output);

            if (Shader != null)
            {
                Vector2 tiling = new Vector2(TileX, TileY);
                Shader.Use();
                Shader.SetUniform2("tiling", ref tiling);
                Shader.SetUniform("Input0", 0);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture0);

                if (tex != null)
                {
                    tex.Bind();
                }

                Shader.SetUniform("Input1", 1);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture1);

                if (tex2 != null)
                {
                    tex2.Bind();
                }


                Shader.SetUniform("Input2", 2);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture2);

                if (tex3 != null)
                {
                    tex3.Bind();
                }

                Shader.SetUniform("Input3", 3);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture3);

                if (tex4 != null)
                {
                    tex4.Bind();
                }

                if (renderQuad != null)
                {
                    renderQuad.Draw();
                }

                GLTextuer2D.Unbind();
                //output.Bind();
                //output.CopyFromFrameBuffer(width, height);
                //GLTextuer2D.Unbind();
                Blit(output, width, height);
            }
        }
Exemplo n.º 11
0
        public CurvesNode(int w, int h, GraphPixelType p = GraphPixelType.RGBA)
        {
            Name = "Curves";
            Id   = Guid.NewGuid().ToString();

            width  = w;
            height = h;

            minValue = 0;
            maxValue = 1;

            points = new Dictionary <int, List <Point> >();

            previewProcessor = new BasicImageRenderer();

            tileX = tileY = 1;

            lutBrush = new FloatBitmap(256, 2);

            internalPixelType = p;

            curveLUT = new GLTextuer2D(GLInterfaces.PixelInternalFormat.Rgba8);
            curveLUT.Bind();
            curveLUT.SetFilter((int)GLInterfaces.TextureMinFilter.Nearest, (int)GLInterfaces.TextureMagFilter.Nearest);
            curveLUT.SetWrap((int)GLInterfaces.TextureWrapMode.Repeat);
            GLTextuer2D.Unbind();

            processor = new CurvesProcessor(curveLUT);

            //set defaults
            List <Point> pts = new List <Point>();

            pts.Add(new Point(0, 1));
            pts.Add(new Point(1, 0));

            points[0] = pts;
            points[1] = pts;
            points[2] = pts;
            points[3] = pts;

            input  = new NodeInput(NodeType.Color | NodeType.Gray, this, "Image Input");
            Output = new NodeOutput(NodeType.Color | NodeType.Gray, this);

            input.OnInputAdded   += Input_OnInputAdded;
            input.OnInputChanged += Input_OnInputChanged;
            input.OnInputRemoved += Input_OnInputRemoved;

            Inputs = new List <NodeInput>();
            Inputs.Add(input);

            Outputs = new List <NodeOutput>();
            Outputs.Add(Output);
        }
Exemplo n.º 12
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)input.Input.Data;
            GLTextuer2D i2 = null;

            if (input2.HasInput)
            {
                if (input2.Input.Data != null)
                {
                    i2 = (GLTextuer2D)input2.Input.Data;
                }
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (colorLUT == null || colorLUT.Id == 0)
            {
                colorLUT = new GLTextuer2D(PixelInternalFormat.Rgba8);
            }
            if (LUT == null)
            {
                LUT = new FloatBitmap(256, 2);
            }

            //generate gradient
            Utils.CreateGradient(LUT, gradient.positions, gradient.colors);

            colorLUT.Bind();
            colorLUT.SetData(LUT.Image, PixelFormat.Rgba, 256, 2);
            colorLUT.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear);
            GLTextuer2D.Unbind();

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.ColorLUT = colorLUT;
            processor.Mask     = i2;
            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            Output.Changed();
            Updated();
        }
Exemplo n.º 13
0
        public void Process(int width, int height, GLTextuer2D blur, GLTextuer2D orig, GLTextuer2D output)
        {
            base.Process(width, height, blur, output);

            if (shader != null)
            {
                GLTextuer2D tempColor = new GLTextuer2D(blur.InternalFormat);
                tempColor.Bind();
                tempColor.SetData(IntPtr.Zero, PixelFormat.Rgba, blur.Width, blur.Height);
                if (blur.InternalFormat == PixelInternalFormat.R16f || blur.InternalFormat == PixelInternalFormat.R32f)
                {
                    tempColor.SetSwizzleLuminance();
                }
                else if (blur.IsRGBBased)
                {
                    tempColor.SetSwizzleRGB();
                }
                tempColor.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear);
                GLTextuer2D.Unbind();

                ResizeViewTo(blur, tempColor, blur.Width, blur.Height, width, height);
                blur = tempColor;
                IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                ResizeViewTo(orig, output, orig.Width, orig.Height, width, height);
                orig = output;
                IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                Vector2 tiling = new Vector2(TileX, TileY);

                shader.Use();
                shader.SetUniform2("tiling", ref tiling);
                shader.SetUniform("MainTex", 0);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture0);
                blur.Bind();
                shader.SetUniform("Original", 1);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture1);
                orig.Bind();

                if (renderQuad != null)
                {
                    renderQuad.Draw();
                }

                GLTextuer2D.Unbind();
                //output.Bind();
                //output.CopyFromFrameBuffer(width, height);
                //GLTextuer2D.Unbind();

                Blit(output, width, height);
                tempColor.Release();
            }
        }
Exemplo n.º 14
0
        void Process()
        {
            GLTextuer2D buff = GetActiveBuffer();

            if (buff == null || buff.Id == 0)
            {
                return;
            }

            Output.Data = buff;
            TriggerTextureChange();
        }
Exemplo n.º 15
0
        void Process()
        {
            if (!input.HasInput)
            {
                return;
            }

            GLTextuer2D i1 = (GLTextuer2D)input.Reference.Data;
            GLTextuer2D i2 = null;

            if (input2.HasInput)
            {
                i2 = (GLTextuer2D)input2.Reference.Data;
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (processor == null)
            {
                return;
            }

            if (colorLUT == null || colorLUT.Id == 0)
            {
                colorLUT = new GLTextuer2D(PixelInternalFormat.Rgba8);
            }

            colorLUT.Bind();
            colorLUT.SetData(LUT.Image, PixelFormat.Rgba, 256, 2);
            colorLUT.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear);
            GLTextuer2D.Unbind();

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.ColorLUT = colorLUT;
            processor.Mask     = i2;
            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            TriggerTextureChange();
        }
Exemplo n.º 16
0
        void LoadDefaultTextures()
        {
            if (defaultBlack == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 0f, 0f, 0f, 1);
                defaultBlack = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultBlack.Bind();
                defaultBlack.SetData(black.Image, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, 128, 128);
                defaultBlack.GenerateMipMaps();
                defaultBlack.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultBlack.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
            }
            if (defaultWhite == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 1f, 1f, 1f, 1);
                defaultWhite = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultWhite.Bind();
                defaultWhite.SetData(black.Image, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, 128, 128);
                defaultWhite.GenerateMipMaps();
                defaultWhite.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultWhite.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
            }
            if (defaultGray == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 0.5f, 0.5f, 0.5f, 1);
                defaultGray = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultGray.Bind();
                defaultGray.SetData(black.Image, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, 128, 128);
                defaultGray.GenerateMipMaps();
                defaultGray.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultGray.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
            }

            if (defaultDarkGray == null)
            {
                FloatBitmap black = new FloatBitmap(128, 128);
                Nodes.Helpers.Utils.Fill(black, 0, 0, 0.25f, 0.25f, 0.25f, 1);
                defaultDarkGray = new GLTextuer2D(PixelInternalFormat.Rgba8);
                defaultDarkGray.Bind();
                defaultDarkGray.SetData(black.Image, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, 128, 128);
                defaultDarkGray.GenerateMipMaps();
                defaultDarkGray.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
                defaultDarkGray.SetWrap((int)TextureWrapMode.Repeat);
                GLTextuer2D.Unbind();
            }
        }
Exemplo n.º 17
0
        public PBRMaterial()
        {
            SSSDistortion = 0.5f;
            SSSAmbient    = 0f;
            SSSPower      = 1f;

            if (BRDFLut == null)
            {
                BRDFLut = new GLTextuer2D(PixelInternalFormat.Rgba8);
            }

            LoadShader();
        }
Exemplo n.º 18
0
        void Process()
        {
            GLTextuer2D buff = GetActiveBuffer();

            if (buff == null || buff.Id == 0)
            {
                return;
            }

            Updated();
            Output.Data = buff;
            Output.Changed();
        }
Exemplo n.º 19
0
        public override void Process(int width, int height, GLTextuer2D tex, GLTextuer2D output)
        {
            base.Process(width, height, tex, output);

            if (shader != null)
            {
                ResizeViewTo(tex, output, tex.Width, tex.Height, width, height);
                tex = output;
                IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                Vector2 tiling = new Vector2(TileX, TileY);

                shader.Use();

                shader.SetUniform("MainTex", 0);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture0);
                tex.Bind();

                shader.SetUniform("ColorLUT", 1);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture1);
                ColorLUT.Bind();

                shader.SetUniform("horizontal", Horizontal);
                shader.SetUniform2("tiling", ref tiling);
                shader.SetUniform("Mask", 2);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture2);

                if (Mask != null)
                {
                    UseMask = true;
                    Mask.Bind();
                }
                else
                {
                    UseMask = false;
                }

                shader.SetUniform("useMask", UseMask);

                if (renderQuad != null)
                {
                    renderQuad.Draw();
                }

                GLTextuer2D.Unbind();
                //output.Bind();
                //output.CopyFromFrameBuffer(width, height);
                //GLTextuer2D.Unbind();
                Blit(output, width, height);
            }
        }
Exemplo n.º 20
0
        public void Process(int width, int height, GLTextuer2D output)
        {
            CreateBuffersIfNeeded();

            if (Mesh != null)
            {
                //bind our depth framebuffer
                frameBuff.Bind();
                IGL.Primary.Viewport(0, 0, width, height);
                IGL.Primary.ClearColor(0, 0, 0, 0);
                IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit);
                IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit);

                //draw in depth
                Mesh.DrawForDepth();

                //output.Bind();
                //output.CopyFromFrameBuffer(width, height);
                //GLTextuer2D.Unbind();

                Blit(output, width, height);

                GLFrameBuffer.Unbind();
            }

            base.Process(width, height, output, output);

            if (shader != null)
            {
                Vector2 tiling = new Vector2(TileX, TileY);

                shader.Use();
                shader.SetUniform2("tiling", ref tiling);

                shader.SetUniform("MainTex", 0);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture0);
                output.Bind();

                if (renderQuad != null)
                {
                    renderQuad.Draw();
                }

                GLTextuer2D.Unbind();

                //output.Bind();
                //output.CopyFromFrameBuffer(width, height);
                //GLTextuer2D.Unbind();
                Blit(output, width, height);
            }
        }
Exemplo n.º 21
0
        void Process()
        {
            if (!input.HasInput || !input1.HasInput)
            {
                return;
            }

            GLTextuer2D i1 = (GLTextuer2D)input.Reference.Data;
            GLTextuer2D i2 = (GLTextuer2D)input1.Reference.Data;

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (i2 == null)
            {
                return;
            }
            if (i2.Id == 0)
            {
                return;
            }

            CreateBufferIfNeeded();

            if (processor == null || blur == null)
            {
                return;
            }

            processor.TileX     = tileX;
            processor.TileY     = TileY;
            processor.Angle     = pangle * (float)(Math.PI / 180.0f);
            processor.Intensity = pintensity;
            processor.Process(width, height, i1, i2, buffer);
            processor.Complete();

            blur.Intensity = Math.Max(0, bintensity);
            blur.Process(width, height, buffer, buffer);
            blur.Complete();

            output.Data = buffer;
            TriggerTextureChange();
        }
Exemplo n.º 22
0
        public void Process(int width, int height, GLTextuer2D tex, GLTextuer2D other, GLTextuer2D output)
        {
            base.Process(width, height, tex, output);

            if (shader != null)
            {
                GLTextuer2D tempColor = new GLTextuer2D(PixelInternalFormat.Rgba);
                tempColor.Bind();
                tempColor.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear);
                GLTextuer2D.Unbind();

                ResizeViewTo(tex, tempColor, tex.Width, tex.Height, width, height);
                tex = tempColor;
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                ResizeViewTo(other, output, other.Width, other.Height, width, height);
                other = output;
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);


                Vector2 tiling = new Vector2(TileX, TileY);

                shader.Use();
                shader.SetUniform2("tiling", ref tiling);

                shader.SetUniform("redChannel", RedChannel);
                shader.SetUniform("greenChannel", GreenChannel);
                shader.SetUniform("blueChannel", BlueChannel);
                shader.SetUniform("alphaChannel", AlphaChannel);

                shader.SetUniform("MainTex", 0);
                GL.ActiveTexture(TextureUnit.Texture0);
                tex.Bind();
                shader.SetUniform("Other", 1);
                GL.ActiveTexture(TextureUnit.Texture1);
                other.Bind();

                if (renderQuad != null)
                {
                    renderQuad.Draw();
                }

                GLTextuer2D.Unbind();
                output.Bind();
                output.CopyFromFrameBuffer(width, height);
                GLTextuer2D.Unbind();
                tempColor.Release();
            }
        }
Exemplo n.º 23
0
        public void Process(FunctionGraph graph, int width, int height, GLTextuer2D tex, GLTextuer2D tex2, GLTextuer2D tex3, GLTextuer2D tex4, GLTextuer2D output)
        {
            base.Process(width, height, tex, output);

            if (Shader != null)
            {
                Shader.Use();
                if (output != null)
                {
                    output.Bind();
                    output.BindAsImage(0, false, true);
                }

                Shader.SetUniform("Input0", 1);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture1);
                if (tex != null)
                {
                    tex.Bind();
                }

                Shader.SetUniform("Input1", 2);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture2);
                if (tex2 != null)
                {
                    tex2.Bind();
                }

                Shader.SetUniform("Input2", 3);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture3);
                if (tex3 != null)
                {
                    tex3.Bind();
                }

                Shader.SetUniform("Input3", 4);
                IGL.Primary.ActiveTexture((int)TextureUnit.Texture4);
                if (tex4 != null)
                {
                    tex4.Bind();
                }

                graph.AssignUniforms();

                IGL.Primary.DispatchCompute(width / 8, height / 8, 1);

                GLTextuer2D.UnbindAsImage(0);
                GLTextuer2D.Unbind();
            }
        }
Exemplo n.º 24
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)first.Input.Data;
            GLTextuer2D i2 = (GLTextuer2D)second.Input.Data;
            GLTextuer2D i3 = null;

            if (mask.HasInput)
            {
                i3 = (GLTextuer2D)mask.Input.Data;
            }

            if (i1 == null || i2 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }
            if (i2.Id == 0)
            {
                return;
            }

            CreateBufferIfNeeded();

            int   pmode  = (int)mode;
            float palpha = alpha;

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Mode"))
            {
                pmode = Convert.ToInt32(ParentGraph.GetParameterValue(Id, "Mode"));
            }
            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Alpha"))
            {
                palpha = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "Alpha"));
            }

            processor.TileX     = tileX;
            processor.TileY     = tileY;
            processor.Alpha     = palpha;
            processor.BlendMode = pmode;
            processor.Process(width, height, i1, i2, i3, buffer);
            processor.Complete();

            Updated();
            Output.Data = buffer;
            Output.Changed();
        }
Exemplo n.º 25
0
 protected void CreateBufferIfNeeded()
 {
     if (buffer == null || buffer.Id == 0)
     {
         buffer = new GLTextuer2D((OpenTK.Graphics.OpenGL.PixelInternalFormat)((int)internalPixelType));
         buffer.Bind();
         buffer.SetFilter((int)OpenTK.Graphics.OpenGL.TextureMinFilter.Linear, (int)OpenTK.Graphics.OpenGL.TextureMagFilter.Linear);
         buffer.SetWrap((int)OpenTK.Graphics.OpenGL.TextureWrapMode.Repeat);
         if (internalPixelType == GraphPixelType.Luminance16F || internalPixelType == GraphPixelType.Luminance32F)
         {
             buffer.SetSwizzleLuminance();
         }
         GLTextuer2D.Unbind();
     }
 }
Exemplo n.º 26
0
        public override void Dispose()
        {
            base.Dispose();

            if (temp != null)
            {
                temp.Release();
                temp = null;
            }

            if (processor != null)
            {
                processor.Release();
                processor = null;
            }
        }
Exemplo n.º 27
0
        public virtual void Dispose()
        {
            ParentGraph = null;

            if (buffer != null)
            {
                buffer.Release();
                buffer = null;
            }

            if (previewProcessor != null)
            {
                previewProcessor.Release();
                previewProcessor = null;
            }
        }
Exemplo n.º 28
0
 protected virtual void CreateBufferIfNeeded()
 {
     if (buffer == null || buffer.Id == 0)
     {
         buffer = new GLTextuer2D((GLInterfaces.PixelInternalFormat)((int)internalPixelType));
         buffer.Bind();
         buffer.SetData(IntPtr.Zero, GLInterfaces.PixelFormat.Rgba, width, height);
         buffer.Linear();
         buffer.Repeat();
         if (internalPixelType == GraphPixelType.Luminance16F || internalPixelType == GraphPixelType.Luminance32F)
         {
             buffer.SetSwizzleLuminance();
         }
         GLTextuer2D.Unbind();
     }
 }
Exemplo n.º 29
0
        public override void Dispose()
        {
            base.Dispose();

            if (processor != null)
            {
                processor.Release();
                processor = null;
            }

            if (curveLUT != null)
            {
                curveLUT.Release();
                curveLUT = null;
            }
        }
Exemplo n.º 30
0
        public override void Dispose()
        {
            base.Dispose();

            if (character != null)
            {
                character.Release();
                character = null;
            }

            if (processor != null)
            {
                processor.Release();
                processor = null;
            }
        }