public GlowFilter(int screenw, int screenh) { Log.Assert(Util.IsPowerOf2(screenw)); Log.Assert(Util.IsPowerOf2(screenh)); width = screenw; height = screenh; hGlowShader = Resources.TheResources.GetShader("glow1"); vGlowShader = Resources.TheResources.GetShader("glow2"); combineShader = Resources.TheResources.GetShader("glow3"); // XXX: This could be more efficient somehow... matrix = Matrix4.CreateOrthographic(1, 1, 0, 10f); // Create back-buffer DestTexture1 = new Texture(width, height); DestTexture2 = new Texture(width, height); // Create framebuffer fbo1 = new FramebufferObject(DestTexture1); fbo2 = new FramebufferObject(DestTexture2); //this.bb = Starmaze.Content.Images.Billboard(); // Make a billboard to render to. // XXX: Aspect ratio... var aspectRatio = 4.0f / 3.0f; var bb = new VertexList(VertexLayout.TextureVertex); var halfHeight = 1.0f / 2; var halfWidth = 1.0f / 2; bb.AddTextureVertex( new Vector2(-halfWidth, -halfHeight), Color4.White, new Vector2(0, 0) ); bb.AddTextureVertex( new Vector2(-halfWidth, halfHeight), Color4.White, new Vector2(0, (1.0f / aspectRatio)) ); bb.AddTextureVertex( new Vector2(halfWidth, halfHeight), Color4.White, new Vector2(1, (1.0f / aspectRatio)) ); bb.AddTextureVertex( new Vector2(halfWidth, -halfHeight), Color4.White, new Vector2(1, 0) ); var indices = new uint[] { 0, 1, 2, 0, 2, 3, }; bb1 = new VertexArray(hGlowShader, bb, idxs: indices); bb2 = new VertexArray(vGlowShader, bb, idxs: indices); bb3 = new VertexArray(combineShader, bb, idxs: indices); }
public PostprocStep(Shader shader, int screenw, int screenh) { Log.Assert(Util.IsPowerOf2(screenw)); Log.Assert(Util.IsPowerOf2(screenh)); width = screenw; height = screenh; this.shader = shader; // XXX: This could be more efficient somehow... matrix = Matrix4.CreateOrthographic(1, 1, 0, 10f); // Create back-buffer // XXX: Is ActiveTexture needed? I THINK so... //GL.ActiveTexture(TextureUnit.Texture0); DestTexture = new Texture(width, height); // Create framebuffer fbo = new FramebufferObject(DestTexture); //this.bb = Starmaze.Content.Images.Billboard(); // Make a billboard to render to. // XXX: Aspect ratio... var aspectRatio = 4.0f / 3.0f; var bb = new VertexList(VertexLayout.TextureVertex); var halfHeight = 1.0f / 2; var halfWidth = 1.0f / 2; bb.AddTextureVertex( new Vector2(-halfWidth, -halfHeight), Color4.White, new Vector2(0, 0) ); bb.AddTextureVertex( new Vector2(-halfWidth, halfHeight), Color4.White, new Vector2(0, (1.0f / aspectRatio)) ); bb.AddTextureVertex( new Vector2(halfWidth, halfHeight), Color4.White, new Vector2(1, (1.0f / aspectRatio)) ); bb.AddTextureVertex( new Vector2(halfWidth, -halfHeight), Color4.White, new Vector2(1, 0) ); var indices = new uint[] { 0, 1, 2, 0, 2, 3, }; this.bb = new VertexArray(shader, bb, idxs: indices); }