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 override void Process(int width, int height, GLTextuer2D tex, 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("width", (float)width); shader.SetUniform("height", (float)height); shader.SetUniform("radius", Radius); shader.SetUniform("outline", Outline); if (renderQuad != null) { renderQuad.Draw(); } //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); } }
public void Blend(GLTextuer2D piece, GLTextuer2D whole) { IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit | (int)ClearBufferMask.DepthBufferBit); if (shader != null) { shader.Use(); shader.SetUniform("blendMode", (int)Blending); shader.SetUniform("MainTex", 0); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); piece.Bind(); shader.SetUniform("Background", 1); IGL.Primary.ActiveTexture((int)TextureUnit.Texture1); whole.Bind(); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); Blit(whole, whole.Width, whole.Height); } }
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.SetUniform2("tiling", ref tiling); shader.SetUniform("MainTex", 0); shader.SetUniform("gamma", Gamma); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); tex.Bind(); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); } }
public virtual void DrawAsLight() { if (Mat != null && Mat.Shader != null) { IGLProgram shader = Mat.Shader; shader.Use(); Matrix4 proj = Projection; Matrix4 view = View; Matrix4 m = Model; Matrix4 norm = Matrix4.Invert(m); norm.Transpose(); shader.SetUniformMatrix4("projectionMatrix", ref proj); shader.SetUniformMatrix4("viewMatrix", ref view); shader.SetUniformMatrix4("modelMatrix", ref m); shader.SetUniformMatrix4("normalMatrix", ref norm); Vector2 tiling = Tiling; Vector4 lightColor = new Vector4(LightColor * LightPower, 1); shader.SetUniform2("tiling", ref tiling); shader.SetUniform4F("color", ref lightColor); ///draw vao.Bind(); IGL.Primary.DrawElements((int)BeginMode.Triangles, indicesCount, (int)DrawElementsType.UnsignedInt, 0); GLVertexArray.Unbind(); } }
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(); } }
/// <summary> /// This is used to simply render to frame buffer /// at the specified width and height /// it is used primarily to pull preview images /// from the stored textures /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <param name="tex"></param> public void Process(int width, int height, GLTextuer2D tex) { base.Process(width, height, tex, null); 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); tex.Bind(); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); } }
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); } }
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); } }
public override void Render(GLTextuer2D[] inputs, out GLTextuer2D[] outputs) { outputs = null; if (shader == null) { return; } if (inputs == null) { return; } if (inputs.Length < 2) { return; } blur.Intensity = Intensity; blur.Process(width, height, inputs[1], inputs[1]); blur.Complete(); Vector2 tiling = new Vector2(1); shader.Use(); shader.SetUniform("MainTex", 0); shader.SetUniform("Bloom", 1); shader.SetUniform2("tiling", ref tiling); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); inputs[0].Bind(); IGL.Primary.ActiveTexture((int)TextureUnit.Texture1); inputs[1].Bind(); //ensure polygon is actually rendered instead of wireframe during this step IGL.Primary.PolygonMode((int)MaterialFace.FrontAndBack, (int)PolygonMode.Fill); IGL.Primary.Disable((int)EnableCap.CullFace); quad.Draw(); IGL.Primary.Enable((int)EnableCap.CullFace); GLTextuer2D.Unbind(); }
public override void Render(GLTextuer2D[] inputs, out GLTextuer2D[] outputs) { outputs = null; if (shader == null) { return; } if (inputs == null) { return; } if (inputs.Length < 2) { return; } blur.Intensity = Intensity; blur.Process(width, height, inputs[1], inputs[1]); blur.Complete(); Vector2 tiling = new Vector2(1); shader.Use(); shader.SetUniform("MainTex", 0); shader.SetUniform("Bloom", 1); shader.SetUniform2("tiling", ref tiling); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); inputs[0].Bind(); IGL.Primary.ActiveTexture((int)TextureUnit.Texture1); inputs[1].Bind(); IGL.Primary.Disable((int)EnableCap.CullFace); quad.Draw(); IGL.Primary.Enable((int)EnableCap.CullFace); GLTextuer2D.Unbind(); }
public override void Draw() { if (shader != null && renderer != null) { shader.Use(); Matrix4 view = View; Matrix4 proj = Projection; Matrix4 model = Model; shader.SetUniformMatrix4("modelMatrix", ref model); shader.SetUniformMatrix4("viewMatrix", ref view); shader.SetUniformMatrix4("projectionMatrix", ref proj); IGL.Primary.PolygonMode((int)MaterialFace.FrontAndBack, (int)PolygonMode.Line); renderer.Bind(); IGL.Primary.DrawElements((int)BeginMode.Triangles, indicesCount, (int)DrawElementsType.UnsignedInt, 0); GLVertexArray.Unbind(); IGL.Primary.PolygonMode((int)MaterialFace.FrontAndBack, (int)PolygonMode.Fill); } }
public void Bind(GLTextuer2D tex) { if (shader != null) { Matrix4 model = Model; Matrix4 view = View; Matrix4 proj = Projection; shader.Use(); shader.SetUniformMatrix4("modelMatrix", ref model); shader.SetUniformMatrix4("viewMatrix", ref view); shader.SetUniformMatrix4("projectionMatrix", ref proj); shader.SetUniform("MainTex", 0); shader.SetUniform("luminosity", Luminosity); shader.SetUniform("flipY", FlipY); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); if (tex != null) { tex.Bind(); } } }
public override void Process(int width, int height, GLTextuer2D tex, GLTextuer2D output) { base.Process(width, height, tex, output); if (shader != null) { Vector2 tiling = new Vector2(TileX, TileY); Vector4 color = Color; shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform4F("color", ref color); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); } }
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); //by using the boxes for gaussian we can produce a more realisitc motion blur //then simply using a standard box blur alone (aka a non linear motion blur) float[] boxes = Materia.Nodes.Helpers.Blur.BoxesForGaussian(Magnitude, 3); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("width", (float)width); shader.SetUniform("height", (float)height); //the direction to blur in shader.SetUniform("tx", (float)Math.Cos(Direction)); shader.SetUniform("ty", -(float)Math.Sin(Direction)); //intensity / magnitude of motion blur shader.SetUniform("magnitude", (boxes[0] - 1.0f) / 2.0f); shader.SetUniform("MainTex", 0); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); tex.Bind(); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); for (int i = 1; i < 3; ++i) { shader.SetUniform("magnitude", (boxes[i] - 1.0f) / 2.0f); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); output.Bind(); IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit); IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); //output.Bind(); //output.CopyFromFrameBuffer(width, height); //GLTextuer2D.Unbind(); Blit(output, width, height); } } }
/// <summary> /// This would be too slow for real time performance at 60fps /// but since we are not doing 60fps it is fine /// it is a fast box gaussian blur /// produces results better than adobes gaussian blur /// and faster than theirs! /// can easily blur 4kx4k textures in low ms on a 1080 gtx gpu with 64+ intensity /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <param name="tex"></param> /// <param name="output"></param> public override void Process(int width, int height, GLTextuer2D tex, GLTextuer2D output) { base.Process(width, height, tex, output); colorBuff.Bind(); colorBuff.ClampToEdge(); GLTextuer2D.Unbind(); 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); float[] boxes = Materia.Nodes.Helpers.Blur.BoxesForGaussian(Intensity, 3); shader.Use(); shader.SetUniform2("tiling", ref tiling); shader.SetUniform("MainTex", 0); shader.SetUniform("horizontal", true); shader.SetUniform("intensity", (boxes[0] - 1.0f) / 2.0f); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); tex.Bind(); //clamp to prevent blur wrap tex.ClampToEdge(); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); /*output.Bind(); * output.CopyFromFrameBuffer(width, height); * GLTextuer2D.Unbind();*/ Blit(output, width, height); tex.Bind(); tex.Repeat(); GLTextuer2D.Unbind(); shader.SetUniform("horizontal", false); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); output.Bind(); //clamp to prevent blur wrap output.ClampToEdge(); IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit); IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); /*output.Bind(); * output.CopyFromFrameBuffer(width, height); * GLTextuer2D.Unbind();*/ Blit(output, width, height); //begin second box shader.SetUniform("horizontal", true); shader.SetUniform("intensity", (boxes[1] - 1.0f) / 2.0f); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); output.Bind(); IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit); IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); output.Bind(); output.CopyFromFrameBuffer(width, height); GLTextuer2D.Unbind(); shader.SetUniform("horizontal", false); shader.SetUniform("intensity", (boxes[1] - 1.0f) / 2.0f); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); output.Bind(); IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit); IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); /*output.Bind(); * output.CopyFromFrameBuffer(width, height); * GLTextuer2D.Unbind(); */ Blit(output, width, height); //begin third box shader.SetUniform("horizontal", true); shader.SetUniform("intensity", (boxes[2] - 1.0f) / 2.0f); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); output.Bind(); IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit); IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); /*output.Bind(); * output.CopyFromFrameBuffer(width, height); * GLTextuer2D.Unbind(); */ Blit(output, width, height); shader.SetUniform("horizontal", false); shader.SetUniform("intensity", (boxes[2] - 1.0f) / 2.0f); IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); output.Bind(); IGL.Primary.Clear((int)ClearBufferMask.ColorBufferBit); IGL.Primary.Clear((int)ClearBufferMask.DepthBufferBit); if (renderQuad != null) { renderQuad.Draw(); } GLTextuer2D.Unbind(); /*output.Bind(); * output.CopyFromFrameBuffer(width, height); * GLTextuer2D.Unbind();*/ Blit(output, width, height); } output.Bind(); output.Repeat(); GLTextuer2D.Unbind(); colorBuff.Bind(); colorBuff.Repeat(); GLTextuer2D.Unbind(); }
public virtual void DrawFull() { if (Mat != null && Mat.Shader != null) { IGLProgram shader = Mat.Shader; IGL.Primary.ActiveTexture((int)TextureUnit.Texture0); if (Mat.Albedo != null) { Mat.Albedo.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture1); if (Mat.Metallic != null) { Mat.Metallic.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture2); if (Mat.Roughness != null) { Mat.Roughness.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture3); if (Mat.Occlusion != null) { Mat.Occlusion.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture4); if (Mat.Normal != null) { Mat.Normal.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture5); if (Mat.Height != null) { Mat.Height.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture6); PBRMaterial.BRDFLut.Bind(); IGL.Primary.ActiveTexture((int)TextureUnit.Texture7); if (IrradianceMap != null) { IrradianceMap.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture8); if (PrefilterMap != null) { PrefilterMap.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture9); if (Mat.Thickness != null) { Mat.Thickness.Bind(); } IGL.Primary.ActiveTexture((int)TextureUnit.Texture10); if (Mat.Emission != null) { Mat.Emission.Bind(); } //use shader shader.Use(); //set texture bind points shader.SetUniform("albedo", 0); shader.SetUniform("metallicMap", 1); shader.SetUniform("roughnessMap", 2); shader.SetUniform("occlusionMap", 3); shader.SetUniform("normalMap", 4); shader.SetUniform("heightMap", 5); shader.SetUniform("brdfLUT", 6); shader.SetUniform("irradianceMap", 7); shader.SetUniform("prefilterMap", 8); shader.SetUniform("thicknessMap", 9); shader.SetUniform("emissionMap", 10); Vector3 lpos = LightPosition; Vector3 lc = LightColor; Vector3 cam = CameraPosition; //set camera and light stuff shader.SetUniform3("cameraPosition", ref cam); shader.SetUniform3("lightPosition", ref lpos); shader.SetUniform3("lightColor", ref lc); shader.SetUniform("lightPower", LightPower); //setup MVP and N matrices Matrix4 proj = Projection; Matrix4 view = View; Matrix4 m = Model; Matrix4 norm = Matrix4.Invert(m); norm.Transpose(); shader.SetUniformMatrix4("projectionMatrix", ref proj); shader.SetUniformMatrix4("viewMatrix", ref view); shader.SetUniformMatrix4("modelMatrix", ref m); shader.SetUniformMatrix4("normalMatrix", ref norm); shader.SetUniform("far", Far); shader.SetUniform("near", Near); shader.SetUniform("heightScale", Mat.HeightScale); shader.SetUniform("refraction", Mat.IOR); ///SSS Related shader.SetUniform("SSS_Distortion", Mat.SSSDistortion); shader.SetUniform("SSS_Ambient", Mat.SSSAmbient); shader.SetUniform("SSS_Power", Mat.SSSPower); if (Mat.ClipHeight) { shader.SetUniform("occlusionClipBias", Mat.ClipHeightBias); } else { shader.SetUniform("occlusionClipBias", -1.0f); } shader.SetUniform("displace", Mat.UseDisplacement); Vector2 tiling = Tiling; shader.SetUniform2("tiling", ref tiling); ///draw vao.Bind(); if (Mat.UseDisplacement) { IGL.Primary.DrawElements((int)BeginMode.Patches, indicesCount, (int)DrawElementsType.UnsignedInt, 0); } else { IGL.Primary.DrawElements((int)BeginMode.Triangles, indicesCount, (int)DrawElementsType.UnsignedInt, 0); } GLVertexArray.Unbind(); 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(); } }