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(); } }
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(); } }
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(); } }
protected override void CreateBufferIfNeeded() { base.CreateBufferIfNeeded(); if (temp == null || temp.Id == 0) { temp = new GLTextuer2D((GLInterfaces.PixelInternalFormat)((int)internalPixelType)); temp.Bind(); temp.SetData(IntPtr.Zero, GLInterfaces.PixelFormat.Rgba, width, height); temp.Linear(); temp.Repeat(); if (internalPixelType == GraphPixelType.Luminance16F || internalPixelType == GraphPixelType.Luminance32F) { temp.SetSwizzleLuminance(); } GLTextuer2D.Unbind(); } }
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(); } }