public static void ReleaseAll() { if (temp != null) { temp.Release(); temp = null; } if (colorBuff != null) { colorBuff.Release(); colorBuff = null; } if (renderQuad != null) { renderQuad.Release(); renderQuad = null; } if (renderBuff != null) { renderBuff.Release(); renderBuff = null; } if (frameBuff != null) { frameBuff.Release(); frameBuff = null; } }
public virtual void Dispose() { ParentGraph = null; if (buffer != null) { buffer.Release(); buffer = null; } if (previewProcessor != null) { previewProcessor.Release(); previewProcessor = null; } }
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(); } }
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(); } }
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(); } }
public override void Dispose() { base.Dispose(); if (temp != null) { temp.Release(); temp = null; } if (processor != null) { processor.Release(); processor = null; } }
public override void Dispose() { base.Dispose(); if (processor != null) { processor.Release(); processor = null; } if (curveLUT != null) { curveLUT.Release(); curveLUT = null; } }
public override void Dispose() { base.Dispose(); if (character != null) { character.Release(); character = null; } if (processor != null) { processor.Release(); processor = null; } }
public static void ReleaseAll() { if (colorBuff != null) { colorBuff.Release(); } if (renderQuad != null) { renderQuad.Release(); } if (renderBuff != null) { renderBuff.Release(); } if (frameBuff != null) { frameBuff.Release(); } }
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(PixelInternalFormat.Rgba); tempColor.Bind(); tempColor.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear); GLTextuer2D.Unbind(); ResizeViewTo(blur, tempColor, blur.Width, blur.Height, width, height); blur = tempColor; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); ResizeViewTo(orig, output, orig.Width, orig.Height, width, height); orig = output; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Vector2 tiling = new Vector2(TileX, TileY); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("MainTex", 0); GL.ActiveTexture(TextureUnit.Texture0); blur.Bind(); shader.SetUniform("Original", 1); GL.ActiveTexture(TextureUnit.Texture1); orig.Bind(); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); output.Bind(); output.CopyFromFrameBuffer(width, height); GLTextuer2D.Unbind(); tempColor.Release(); } }
public void Release() { if (blankTexture != null) { blankTexture.Release(); blankTexture = null; } if (quad != null) { quad.Release(); quad = null; } if (glview != null) { glview.Dispose(); glview = null; FHost.Child = null; } }
public void Process(int width, int height, GLTextuer2D tex, GLTextuer2D source, GLTextuer2D output) { base.Process(width, height, tex, output); if (Shader != null && PreShader != null) { GLTextuer2D temp = new GLTextuer2D(output.InternalFormat); temp.Bind(); temp.SetData(IntPtr.Zero, PixelFormat.Rgba, width, height); temp.Linear(); temp.Repeat(); GLTextuer2D.Unbind(); GLTextuer2D temp2 = new GLTextuer2D(output.InternalFormat); temp2.Bind(); temp2.SetData(IntPtr.Zero, PixelFormat.Rgba, width, height); temp2.Linear(); temp2.Repeat(); GLTextuer2D.Unbind(); GLTextuer2D temp3 = new GLTextuer2D(PixelInternalFormat.Rgba32f); temp3.Bind(); temp3.SetData(IntPtr.Zero, PixelFormat.Rgba, width + 1, height + 1); temp3.Nearest(); temp3.ClampToEdge(); GLTextuer2D.Unbind(); ResizeViewTo(tex, temp, tex.Width, tex.Height, width, height); IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit)); if (source != null) { ResizeViewTo(source, temp2, source.Width, source.Height, width, height); } IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit)); tex = temp; PreShader.Use(); output.Bind(); output.BindAsImage(0, true, true); tex.Bind(); tex.BindAsImage(1, true, true); temp2.Bind(); temp2.BindAsImage(2, true, true); temp3.Bind(); temp3.BindAsImage(3, true, true); PreShader.SetUniform("width", (float)width); PreShader.SetUniform("height", (float)height); PreShader.SetUniform("sourceOnly", SourceOnly); PreShader.SetUniform("maxDistance", Distance); //stage 1 convert temp input range //into proper format //for dt PreShader.SetUniform("stage", (int)0); IGL.Primary.DispatchCompute(width / 8, height / 8, 1); Shader.Use(); output.Bind(); output.BindAsImage(0, true, true); tex.Bind(); tex.BindAsImage(1, true, true); temp2.Bind(); temp2.BindAsImage(2, true, true); temp3.Bind(); temp3.BindAsImage(3, true, true); Shader.SetUniform("width", (float)width); Shader.SetUniform("height", (float)height); Shader.SetUniform("sourceOnly", SourceOnly); Shader.SetUniform("maxDistance", Distance); //stage 2 run column transform Shader.SetUniform("stage", (int)0); IGL.Primary.DispatchCompute(width / 8, 1, 1); //stage 3 run row transform Shader.SetUniform("stage", (int)1); IGL.Primary.DispatchCompute(height / 8, 1, 1); PreShader.Use(); output.Bind(); output.BindAsImage(0, true, true); tex.Bind(); tex.BindAsImage(1, true, true); temp2.Bind(); temp2.BindAsImage(2, true, true); temp3.Bind(); temp3.BindAsImage(3, true, true); PreShader.SetUniform("width", (float)width); PreShader.SetUniform("height", (float)height); PreShader.SetUniform("sourceOnly", SourceOnly); PreShader.SetUniform("maxDistance", Distance); //stage 4 finalize with sqrt() etc PreShader.SetUniform("stage", (int)1); IGL.Primary.DispatchCompute(width / 8, height / 8, 1); GLTextuer2D.UnbindAsImage(0); GLTextuer2D.UnbindAsImage(1); GLTextuer2D.UnbindAsImage(2); GLTextuer2D.UnbindAsImage(3); GLTextuer2D.Unbind(); temp.Release(); temp2.Release(); temp3.Release(); } }
public void Process(int width, int height, GLTextuer2D tex, GLTextuer2D tex2, GLTextuer2D mask, GLTextuer2D output) { base.Process(width, height, tex, output); if (shader != null) { GLTextuer2D tempColor = new GLTextuer2D(PixelInternalFormat.Rgba); GLTextuer2D tempColor2 = new GLTextuer2D(PixelInternalFormat.Rgba); tempColor.Bind(); tempColor.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear); GLTextuer2D.Unbind(); tempColor2.Bind(); tempColor2.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(tex2, tempColor2, tex2.Width, tex2.Height, width, height); tex2 = tempColor2; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); if (mask != null) { ResizeViewTo(mask, output, mask.Width, mask.Height, width, height); mask = output; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); } Vector2 tiling = new Vector2(TileX, TileY); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("Foreground", 0); GL.ActiveTexture(TextureUnit.Texture0); tex.Bind(); shader.SetUniform("Background", 1); GL.ActiveTexture(TextureUnit.Texture1); tex2.Bind(); shader.SetUniform("blendMode", BlendMode); shader.SetUniform("alpha", Alpha); if (mask != null) { shader.SetUniform("Mask", 2); GL.ActiveTexture(TextureUnit.Texture2); shader.SetUniform("hasMask", 1); mask.Bind(); } else { shader.SetUniform("hasMask", 0); } if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); output.Bind(); output.CopyFromFrameBuffer(width, height); GLTextuer2D.Unbind(); tempColor.Release(); tempColor2.Release(); } }
public void Process(int width, int height, GLTextuer2D tex, GLTextuer2D tex2, GLTextuer2D mask, GLTextuer2D output) { base.Process(width, height, tex, output); if (shader != null) { GLTextuer2D tempColor = new GLTextuer2D(tex.InternalFormat); GLTextuer2D tempColor2 = new GLTextuer2D(tex2.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(); tempColor2.Bind(); tempColor2.SetData(IntPtr.Zero, PixelFormat.Rgba, tex2.Width, tex2.Height); if (tex2.InternalFormat == PixelInternalFormat.R16f || tex2.InternalFormat == PixelInternalFormat.R32f) { tempColor2.SetSwizzleLuminance(); } else if (tex.IsRGBBased) { tempColor.SetSwizzleRGB(); } tempColor2.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(tex2, tempColor2, tex2.Width, tex2.Height, width, height); tex2 = tempColor2; IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit)); if (mask != null) { ResizeViewTo(mask, output, mask.Width, mask.Height, width, height); mask = output; IGL.Primary.Clear((int)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit)); } Vector2 tiling = new Vector2(TileX, TileY); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("Foreground", 0); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); tex.Bind(); shader.SetUniform("Background", 1); IGL.Primary.ActiveTexture((int)TextureUnit.Texture1); tex2.Bind(); shader.SetUniform("blendMode", BlendMode); shader.SetUniform("alpha", Alpha); shader.SetUniform("alphaMode", AlphaMode); if (mask != null) { shader.SetUniform("Mask", 2); IGL.Primary.ActiveTexture((int)TextureUnit.Texture2); shader.SetUniform("hasMask", 1); mask.Bind(); } else { shader.SetUniform("hasMask", 0); } if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); tempColor.Release(); tempColor2.Release(); } }