Exemple #1
0
        public static void BlurMomentsMap(int momentTexture, int framebufferTarget, int framebufferTargetTexture)
        {
            GL.UseProgram(GetProgramId());
            GL.BindVertexArray(PrimitiveQuad.GetVAOId());

            // x axis:
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, _fbBlur1);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Uniform1(GetAxisId(), 0);
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, momentTexture);
            GL.Uniform1(GetTextureInputId(), 0);
            GL.DrawArrays(PrimitiveType.Triangles, 0, PrimitiveQuad.GetPointCount());
            GL.BindTexture(TextureTarget.Texture2D, 0);

            // y axis:
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebufferTarget);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Uniform1(GetAxisId(), 1);
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, _fbBlur1Texture);
            GL.Uniform1(GetTextureInputId(), 0);
            GL.DrawArrays(PrimitiveType.Triangles, 0, PrimitiveQuad.GetPointCount());
            GL.BindTexture(TextureTarget.Texture2D, 0);

            // done!
            GL.BindVertexArray(0);
            GL.UseProgram(0);
            GL.BindTexture(TextureTarget.Texture2D, framebufferTargetTexture);
            GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
Exemple #2
0
        public static void RenderMomentsMap(int framebufferMomentId, int downsampledShadowMap, int shadowMapSize, float zNear, float zFar, bool isSun)
        {
            GL.Viewport(0, 0, shadowMapSize, shadowMapSize);
            HelperGeneral.SwitchToBufferAndClear(framebufferMomentId);

            GL.UseProgram(GetProgramId());

            GL.Uniform2(_uniformNearFar, zNear, zFar);
            GL.Uniform1(_uniformIsSun, isSun ? 1 : 0);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, downsampledShadowMap);
            GL.Uniform1(_uniformTextureDepthMS, 0);

            GL.BindVertexArray(PrimitiveQuad.GetVAOId());
            GL.DrawArrays(PrimitiveType.Triangles, 0, PrimitiveQuad.GetPointCount());
            GL.BindVertexArray(0);

            GL.UseProgram(0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }