private void BlitFramebuffers(MRTFramebuffer source, Framebuffer destination, BlitMode mode) { source.BindWithPurpose(FramebufferTarget.ReadFramebuffer); //GL.FramebufferTexture2D(FramebufferTarget.ReadFramebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, source.DepthRenderBuffer, 0); GL.ReadBuffer(ReadBufferMode.None); destination.BindWithPurpose(FramebufferTarget.DrawFramebuffer); //GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, destination.TexColor, 0); GL.DrawBuffer(DrawBufferMode.None); if (mode == BlitMode.Color) { GL.BlitFramebuffer(0, 0, source.Width, source.Height, 0, 0, destination.Width, destination.Height, ClearBufferMask.ColorBufferBit, BlitFramebufferFilter.Linear); } else if (mode == BlitMode.Depth) { GL.BlitFramebuffer(0, 0, source.Width, source.Height, 0, 0, destination.Width, destination.Height, ClearBufferMask.DepthBufferBit, BlitFramebufferFilter.Linear); } else if (mode == BlitMode.ColorAndDepth) { GL.BlitFramebuffer(0, 0, source.Width, source.Height, 0, 0, destination.Width, destination.Height, ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit, BlitFramebufferFilter.Linear); } }
public Renderer(int initialWidth, int initialHeight) { CubeMap = new CubeMapTexture(Media.Get("posx.jpg"), Media.Get("posy.jpg"), Media.Get("posz.jpg"), Media.Get("negx.jpg"), Media.Get("negy.jpg"), Media.Get("negz.jpg")); Width = initialWidth; Height = initialHeight; // initialWidth *= 4; initialHeight *= 4; MRT = new MRTFramebuffer(initialWidth, initialHeight); DistanceFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1) { ColorOnly = false, ColorInternalFormat = PixelInternalFormat.R32f, ColorPixelFormat = PixelFormat.Red, ColorPixelType = PixelType.Float }; HDRShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "HDR.fragment.glsl"); PostProcessingMesh = new Object3dInfo(VertexInfo.FromFloatArray(postProcessingPlaneVertices)); }
private void CreateBuffers() { MRT = new MRTFramebuffer(Width, Height, Samples); VXGIFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; DeferredFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; HelperFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; CombinerFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; ForwardPassFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = false, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; EnvLightFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; BloomXPass = new Framebuffer(Width / 4, Height / 4) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; BloomYPass = new Framebuffer(Width / 4, Height / 4) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba16f, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.HalfFloat }; AmbientOcclusionFramebuffer = new Framebuffer(Width / 1, Height / 1) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.R8, ColorPixelFormat = PixelFormat.Red, ColorPixelType = PixelType.UnsignedByte }; FogFramebuffer = new Framebuffer(Width / 2, Height / 2) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.Rgba8, ColorPixelFormat = PixelFormat.Rgba, ColorPixelType = PixelType.UnsignedByte }; }
public PostProcessing(int initialWidth, int initialHeight) { //FullScene3DTexture = new Texture3D(new Vector3(64, 64, 64)); TestBuffer = new ShaderStorageBuffer(); NumbersTexture = new Texture(Media.Get("numbers.png")); CShader = new ComputeShader("Blur.compute.glsl"); GLThread.Invoke(() => { TestBuffer.MapData(new Vector3[4]{ new Vector3(1, 0.25f, 1), new Vector3(0, 0.55f, 0.75f), new Vector3(1, 0.25f, 0), new Vector3(0.55f, 0, 0.75f) }); }); Width = initialWidth; Height = initialHeight; MSAAResolvingFrameBuffer = new Framebuffer(initialWidth, initialHeight); MSAAResolvingFrameBuffer.SetMultiSample(true); MRT = new MRTFramebuffer(initialWidth, initialHeight); BackMRT = new MRTFramebuffer(initialWidth / 4, initialHeight / 4); Pass1FrameBuffer = new Framebuffer(initialWidth, initialHeight); Pass2FrameBuffer = new Framebuffer(initialWidth, initialHeight); LightPointsFrameBuffer = new Framebuffer(initialWidth / 6, initialHeight / 6); BloomFrameBuffer = new Framebuffer(initialWidth / 4, initialHeight / 4); FogFramebuffer = new Framebuffer(initialWidth, initialHeight); SmallFrameBuffer = new Framebuffer(initialWidth / 10, initialHeight / 10); LastWorldPositionFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); RSMFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); SSReflectionsFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); VDAOFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); GlobalIlluminationFrameBuffer = new Framebuffer(initialWidth, initialHeight); //GlobalIlluminationFrameBuffer.ColorInternalFormat = PixelInternalFormat.R8; //GlobalIlluminationFrameBuffer.ColorPixelFormat = PixelFormat.Red; //GlobalIlluminationFrameBuffer.ColorPixelType = PixelType.UnsignedByte; GlobalIlluminationFrameBuffer.Use(); //BackDiffuseFrameBuffer = new Framebuffer(initialWidth / 2, initialHeight / 2); //BackNormalsFrameBuffer = new Framebuffer(initialWidth / 2, initialHeight / 2); ScreenSpaceNormalsWriterShader = ShaderProgram.Compile("Generic.vertex.glsl", "ScreenSpaceNormalsWriter.fragment.glsl"); BackDepthWriterShader = ShaderProgram.Compile("Generic.vertex.glsl", "BackDepthWriter.fragment.glsl"); BloomShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Bloom.fragment.glsl"); MSAAShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "MSAA.fragment.glsl"); SSAOShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "SSAO.fragment.glsl"); FogShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Fog.fragment.glsl"); LightPointsShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "LightPoints.fragment.glsl"); LensBlurShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "LensBlur.fragment.glsl"); HDRShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "HDR.fragment.glsl"); BlitShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Blit.fragment.glsl"); DeferredShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Deferred.fragment.glsl"); CombinerShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Combiner.fragment.glsl"); PathTracerOutputShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Output.fragment.glsl"); GlobalIlluminationShaderX = ShaderProgram.Compile("PostProcess.vertex.glsl", "GlobalIllumination.fragment.glsl"); GlobalIlluminationShaderX.SetGlobal("SEED", "gl_FragCoord.x"); GlobalIlluminationShaderY = ShaderProgram.Compile("PostProcess.vertex.glsl", "GlobalIllumination.fragment.glsl"); GlobalIlluminationShaderY.SetGlobal("SEED", "gl_FragCoord.y"); RSMShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "RSM.fragment.glsl"); SSReflectionsShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "SSReflections.fragment.glsl"); VDAOShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "VDAO.fragment.glsl"); //ReflectShader = ShaderProgram.Compile(Media.ReadAllText("PostProcess.vertex.glsl"), Media.ReadAllText("Reflect.fragment.glsl")); Object3dInfo postPlane3dInfo = new Object3dInfo(postProcessingPlaneVertices, postProcessingPlaneIndices); PostProcessingMesh = new Mesh3d(postPlane3dInfo, new GenericMaterial(Color.Pink)); }