Exemple #1
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public RenderGroup Render(RenderGroup previous)
        {
            if (!this._active)
                return previous;

            /*create ssao accumulation buffer*/
            this.BindBloomShader();
            this._graphics.SwitchRenderGroup(this._finalGroup);
            this._graphics.RenderPostProcess();

            return this._finalGroup;
        }
Exemple #2
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public RenderGroup Render(RenderGroup previous)
        {
            if (!this._active)
                return previous;

            /*create ssao accumulation buffer*/
            this.BindSsaoShader();
            this._graphics.SwitchRenderGroup(this._ssaoGroup);
            this._graphics.RenderPostProcess();

            /*ssao + diffuse + blur*/
            this.BindFinalShader(previous);
            this._graphics.SwitchRenderGroup(this._finalGroup);
            this._graphics.RenderPostProcess();

            return this._finalGroup;
        }
Exemple #3
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public void Reset(IGraphics graphics)
        {
            this._finalGroup = graphics.CreateRenderGroup(true);

            this._graphics = graphics;
        }
Exemple #4
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void BindMotionBlurShader(RenderGroup current)
        {
            if (this._depthShader == null)
                return;

            this._graphics.BindShader(this._depthShader);

            /*textures*/
            this._graphics.BindTexture(this._depthShader.Uniforms["uSPost"], current.RenderTexture, 0);
        }
Exemple #5
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void BindFinalShader(RenderGroup previous)
        {
            if(this._compositeShader == null)
                return;

            this._graphics.BindShader(this._compositeShader);

            this._graphics.BindTexture(this._compositeShader.Uniforms["uSPost"], previous.RenderTexture, 0);
            this._graphics.BindTexture(this._compositeShader.Uniforms["uSAccumulation"], this._ssaoGroup.RenderTexture, 1);
        }
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void SetupFrameBuffers()
        {
            this._depthbuffer = this._context.CreateRenderbuffer();
            this._context.BindRenderbuffer(WebGLE.Renderbuffer, this._depthbuffer);
            this._context.RenderbufferStorage(WebGLE.Renderbuffer, WebGLE.DepthComponent16, this._renderTextureDim, this._renderTextureDim);

            this._diffuseGroup = this.CreateRenderGroup(true);
            this._normalGroup = this.CreateRenderGroup(true);
            this._positionGroup = this.CreateRenderGroup(true);
            this._accumulationGroup = this.CreateRenderGroup(true);
            this._postGroup = this.CreateRenderGroup(true);
        }
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void PostProcessingPass()
        {
            WebGLGraphics that = this;
            this._lastGroup = this._postGroup;

            this._effects.ForEach(delegate(IPostProcessEffect value) {
                that._lastGroup = value.Render(that._lastGroup);
            });
        }
 //------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------
 public void SwitchRenderGroup(RenderGroup group)
 {
     this._context.BindFramebuffer(WebGLE.FrameBuffer, group.FrameBuffer);
 }
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public RenderGroup CreateRenderGroup(Boolean commonDepth)
        {
            RenderGroup ret = new RenderGroup();

            ret.RenderTexture = this.CreateRenderTexture();
            if (commonDepth)
                ret.DepthRenderBuffer = this._depthbuffer;
            else
                ret.DepthRenderBuffer = null; /*not supported yet*/

            ret.FrameBuffer = this._context.CreateFramebuffer();
            this._context.BindFramebuffer(WebGLE.FrameBuffer, ret.FrameBuffer);
            this._context.BindRenderbuffer(WebGLE.Renderbuffer, ret.DepthRenderBuffer);
            this._context.FramebufferRenderbuffer(WebGLE.FrameBuffer, WebGLE.DepthAttachment, WebGLE.Renderbuffer, ret.DepthRenderBuffer);
            this._context.FramebufferTexture2D(WebGLE.FrameBuffer, WebGLE.ColorAttachment0, WebGLE.Texture_2D, ret.RenderTexture, 0);

            return ret;
        }
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public void CleanRenderGroup(RenderGroup old)
        {
            if(old == null)
                return;

            this._context.DeleteFramebuffer(old.FrameBuffer);
            this._context.DeleteTexture(old.RenderTexture);
            if(old.DepthRenderBuffer != this._depthbuffer)
                this._context.DeleteRenderbuffer(old.DepthRenderBuffer);
        }