示例#1
0
        /// <summary>
        /// Draws a given quad with the current view-projection-matrix
        /// </summary>
        /// <param name="quad">The quad to be rendered</param>
        /// <param name="mvp">the bloom model-view-projection matrix</param>
        /// <param name="bloomDirectionHorizontal">true if bloom is applied horizontally</param>
        /// <param name="merge">true if bloom will be merged with original scene</param>
        internal void DrawBloom(GeoQuad quad, ref Matrix4 mvp, bool bloomDirectionHorizontal, bool merge, int width, int height, int sceneTexture, int bloomTexture)
        {
            GL.UniformMatrix4(mUniform_MVP, false, ref mvp);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bloomTexture);
            GL.Uniform1(mUniform_TextureBloom, 0);

            if (merge)
            {
                GL.ActiveTexture(TextureUnit.Texture1);
                GL.BindTexture(TextureTarget.Texture2D, sceneTexture);
                GL.Uniform1(mUniform_TextureScene, 1);

                GL.Uniform1(mUniform_Merge, 1);
            }
            else
            {
                GL.Uniform1(mUniform_Merge, 0);
            }

            GL.Uniform1(mUniform_Horizontal, bloomDirectionHorizontal ? 1 : 0);
            GL.Uniform2(mUniform_Resolution, (float)width, (float)height);

            GL.BindVertexArray(GeoQuad.VAO);
            GL.DrawArrays(PrimitiveType.Triangles, 0, 6);

            GL.BindVertexArray(0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
示例#2
0
        /// <summary>
        /// Loading of basic assets and setup
        /// </summary>
        /// <param name="e">Event arguments</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _renderProgram      = new Renderer();
            _renderProgramBloom = new RendererBloom();

            GeoQuad.InitialiseStatic();
            _quadBloom = new GeoQuad();

            _viewMatrix = Matrix4.LookAt(0, 0, 1, 0, 0, 0, 0, 1, 0);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            GL.Disable(EnableCap.DepthTest);

            GL.UseProgram(_renderProgram.GetProgramId());

            _defaultTextureId = HelperTexture.LoadTextureFromAssembly("default.png");

            Color4 backColor = new Color4();

            backColor.A = 1.0f;
            backColor.R = (0f / 255.0f);
            backColor.G = (0f / 255.0f);
            backColor.B = (0f / 255.0f);
            GL.ClearColor(backColor);

            LoadDefaultWorld();
        }
示例#3
0
        /// <summary>
        /// Draws a given quad with the current view-projection-matrix
        /// </summary>
        /// <param name="quad">quad instance</param>
        /// <param name="vp">view-projection-matrix</param>
        /// <param name="normalMatrix">the quad's normal matrix</param>
        /// <param name="modelMatrix">the quad's model matrix</param>
        internal void Draw(GeoQuad quad, ref Matrix4 vp, ref Matrix4 normalMatrix, ref Matrix4 modelMatrix, ref Vector4 bloom)
        {
            Matrix4 mvp = modelMatrix * vp;

            GL.UniformMatrix4(mUniform_MVP, false, ref mvp);
            GL.UniformMatrix4(mUniform_NormalMatrix, false, ref normalMatrix);
            GL.UniformMatrix4(mUniform_ModelMatrix, false, ref modelMatrix);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, quad.mTextureHandle);
            GL.Uniform1(mUniform_Texture, 0);

            GL.Uniform4(mUniform_Bloom, ref bloom);

            GL.BindVertexArray(GeoQuad.VAO);
            GL.DrawArrays(PrimitiveType.Triangles, 0, 6);

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