protected override void Resize(int newWidth, int newHeight) { Debug.Assert(newWidth > 0 && newHeight > 0); FrameBufferObject.Bind(); BufferWidth = newWidth; BufferHeight = newHeight; PositionAttachment.Resize(BufferWidth, BufferHeight); ColorAttachment.Resize(BufferWidth, BufferHeight); NormalAttachment.Resize(BufferWidth, BufferHeight); DepthAttachment.Resize(BufferWidth, BufferHeight); GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2DMultisample, PositionAttachment.GetTextureObject, 0); GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment1, TextureTarget.Texture2DMultisample, ColorAttachment.GetTextureObject, 0); GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment2, TextureTarget.Texture2DMultisample, NormalAttachment.GetTextureObject, 0); GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.DepthStencilAttachment, TextureTarget.Texture2DMultisample, DepthAttachment.GetTextureObject, 0); var status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); Debug.Assert(status == FramebufferErrorCode.FramebufferComplete); FrameBufferObject.Unbind(); }
protected void Blit(FrameBufferObject source, FrameBufferObject destination, Material material) { destination.Bind(); material.SetScreenSourceTexture("u_Src", source.ColorHandle); Renderer.DrawNow(BlitMesh, material); destination.Unbind(); }
internal Touch(NewRenderer renderer) { this.renderer = renderer; objectStates = new List <ObjectState>(); touchFaces = new List <FaceState>(); try { pickingShader = new Shader("default", "picking", true); pickingShader.Activate(); pickingShader.Deactivate(); } catch { Interface.AddMessage(MessageType.Error, false, "Initialising the touch shader failed- Falling back to legacy openGL."); Interface.CurrentOptions.IsUseNewRenderer = false; } fbo = new FrameBufferObject(); fbo.Bind(); fbo.SetTextureBuffer(FrameBufferObject.TargetBuffer.Color, PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float, renderer.Screen.Width, renderer.Screen.Height); fbo.DrawBuffers(new[] { DrawBuffersEnum.ColorAttachment0 }); fbo.UnBind(); }
public BlitEffect() { Program.Window.Resize += delegate(object sender, EventArgs args) { SourceFbo = new FrameBufferObject(Program.Window.Width, Program.Window.Height, FBOType.DepthRenderBuffer); }; }
static Renderer() { Program.Window.Resize += (sender, args) => { FrameBuffer = new FrameBufferObject(Program.Window.Width, Program.Window.Height, FBOType.DepthTexture); fbo = new FrameBufferObject(Program.Window.Width, Program.Window.Height, FBOType.DepthTexture); }; }
public Texture(FrameBufferObject fbo, bool disposeFbo) { this.Width = fbo.Width; this.Height = fbo.Height; this.Handle = fbo.ColorHandle; if (disposeFbo) { fbo.DisposeWithoutColorHandle(); } }
internal Touch(NewRenderer renderer) { this.renderer = renderer; touchableObject = new List <ObjectState>(); if (!renderer.ForceLegacyOpenGL) { fbo = new FrameBufferObject(); fbo.Bind(); fbo.SetTextureBuffer(FrameBufferObject.TargetBuffer.Color, PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float, renderer.Screen.Width, renderer.Screen.Height); fbo.DrawBuffers(new[] { DrawBuffersEnum.ColorAttachment0 }); fbo.UnBind(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); scene = new CrateScene(); scene.CreateScene(); logger.Info("Loading screen shader and FBOs..."); screenShader = new ScreenShader(); createScreenQuad(); renderFrameBuffer = new FrameBufferObject(Width, Height, 4); resolvingFBO = new FrameBufferObject(Width, Height); logger.Info("Loading complete!"); }
public override void Render(FrameBufferObject src) { cutoffMaterial.Shader.SetUniform("u_Cutoff", BrightnessCutoff); Blit(src, fbo, cutoffMaterial); for (int i = 0; i < BlurIterations; i++) { Blit(fbo, fbo, blurMaterial); } PreRender(IsLastEffectInStack); BlitMaterial.Shader.SetUniform("u_BlurIterations", BlurIterations); BlitMaterial.Shader.SetUniform("u_BloomStrength", BloomStrength); BlitMaterial.SetScreenSourceTexture("u_Src_Small", fbo.ColorHandle, 1); BlitMaterial.SetScreenSourceTexture("u_Src", src.ColorHandle); Renderer.DrawNow(BlitMesh, BlitMaterial); }
private void drawScreen() { GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, renderFrameBuffer.id_fbo); GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, resolvingFBO.id_fbo); GL.BlitFramebuffer(0, 0, Width, Height, 0, 0, Width, Height, ClearBufferMask.ColorBufferBit, BlitFramebufferFilter.Nearest); FrameBufferObject.bindDefaultFBO(Width, Height); GL.ClearColor(Color.DarkRed); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Disable(EnableCap.DepthTest); //GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); screenShader.Start(); GL.BindVertexArray(quadVAO); GL.BindTexture(TextureTarget.Texture2D, resolvingFBO.colorTexture); GL.DrawArrays(PrimitiveType.Triangles, 0, 6); GL.BindVertexArray(0); screenShader.Stop(); GL.Enable(EnableCap.DepthTest); //GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); }
public void Unbind() { FrameBufferObject.Unbind(); }
public void Bind() { FrameBufferObject.Bind(); PrepareToDraw(); }
public override void Render(FrameBufferObject src) { BlitMaterial.Shader.SetUniform("u_Contrast", Contrast); base.Render(src); }
public virtual void Render(FrameBufferObject src) { BlitMaterial.SetScreenSourceTexture("u_Src", src.ColorHandle); Renderer.DrawNow(BlitMesh, BlitMaterial); }
public static void GenerateBlockItemIcons() { const int ICON_SIZE = 64; FrameBufferObject fbo = null; GL.Clear(ClearBufferMask.ColorBufferBit); GL.ClearColor(0, 0, 0, 0); LightingUniformBufferData lighting = new LightingUniformBufferData(); lighting.AmbientColour = new Vector4(0.5f, 0.5f, 0.5f, 1); lighting.SunColour = new Vector4(1, 1, 1, 1); lighting.SunStrength = 1; lighting.SunDirection = new Vector4(0.5f, 0.5f, 0.5f, 1); Chunk tempChunk = new Chunk(Vector2.Zero); tempChunk.Blocks = new Chunk.BlockState[Chunk.WIDTH, Chunk.HEIGHT, Chunk.WIDTH]; Camera tempCamera = new Camera(); tempCamera.ProjectionType = CameraProjectionType.Orthographic; tempCamera.CameraSize = new Vector2(0.8f); tempCamera.GenerateProjectionMatrix(); tempCamera.Position = new Vector3(0, 0, 15f); UniformBuffers.DirectionLightBuffer.Update(lighting); tempCamera.Update(); var items = ItemDatabase.GetItems(); for (int i = 0; i < items.Count; i++) { if (items[i] is BlockItem item) { fbo = new FrameBufferObject(ICON_SIZE, ICON_SIZE, FBOType.None); fbo.Bind(); GL.Clear(ClearBufferMask.ColorBufferBit); var newState = new Chunk.BlockState(0, 0, 0, tempChunk); newState.id = (short)item.Block.ID; tempChunk.Blocks[0, 0, 0] = newState; tempChunk.GenerateMesh(); tempChunk.RenderForIcon(); //Render here... Texture icon = new Texture(fbo, true); AssetDatabase.RegisterAsset(icon, "GeneratedIcons/" + item.Key); item.IconLocation = "GeneratedIcons/" + item.Key; item.GenerateGraphics(); } } fbo?.Unbind(); fbo?.DisposeWithoutColorHandle(); tempChunk.Dispose(); GL.ClearColor(Window.CLEAR_COLOUR.X, Window.CLEAR_COLOUR.Y, Window.CLEAR_COLOUR.Z, Window.CLEAR_COLOUR.W); fbo = null; tempChunk = null; tempCamera = null; }
public RenderBitmap3(int w, int h) { FBO = new FrameBufferObject(w, h, 4); }