Ejemplo n.º 1
0
        public Heatmap(ShaderManager shaderMan, SurfaceManager surfaceMan)
        {
            this.texture = new Texture();
            this.texture.Resize(size, size, PixelInternalFormat.R32f);
            this.texture.SetParameters(TextureMinFilter.Linear, TextureMagFilter.Linear,
                                       TextureWrapMode.ClampToBorder, TextureWrapMode.ClampToBorder);
            this.renderTarget = new RenderTarget(this.texture);


            this.tempTexture = new Texture();
            this.tempTexture.Resize(size, size, PixelInternalFormat.R32f);
            this.tempTexture.SetParameters(TextureMinFilter.Linear, TextureMagFilter.Linear,
                                           TextureWrapMode.ClampToBorder, TextureWrapMode.ClampToBorder);
            this.tempRenderTarget = new RenderTarget(this.tempTexture);

            var sampleStep = 1f / size;


            var blurShader = shaderMan.MakeShaderProgram("blur");

            blurHSurface = new PostProcessSurface();
            blurHSurface.AddSettings(
                new Vector2Uniform("sampleStep", new Vector2(sampleStep, 0)),
                new TextureUniform("diffuse", texture)
                );
            blurShader.UseOnSurface(this.blurHSurface);


            blurVSurface = new PostProcessSurface();
            blurVSurface.AddSettings(
                new Vector2Uniform("sampleStep", new Vector2(0, sampleStep)),
                new TextureUniform("diffuse", tempTexture)
                );
            blurShader.UseOnSurface(this.blurVSurface);


            var spectrum = new Texture("data/images/spectrum.png");

            spectrum.SetParameters(TextureMinFilter.Linear, TextureMagFilter.Linear,
                                   TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge);


            this.heatSurface = new IndexedSurface <HeatmapVertex>();
            heatSurface.AddSettings(
                new TextureUniform("heatmap", this.texture),
                new TextureUniform("spectrum", spectrum, TextureUnit.Texture1),
                surfaceMan.ModelviewMatrix,
                surfaceMan.ProjectionMatrix
                );
            shaderMan.MakeShaderProgram("render-heatmap").UseOnSurface(this.heatSurface);

            this.heatGeo = new HeatmapGeometry(this.heatSurface);
        }
Ejemplo n.º 2
0
        public IndexedSurface <WallVertex> MakeLevelGeometrySurface()
        {
            var surface = new IndexedSurface <WallVertex>
            {
                ClearOnRender = false,
                IsStatic      = true,
            };

            surface.AddSettings(
                this.gameModelview,
                this.gameProjection
                );
            this.shaders.Wall.UseOnSurface(surface);
            return(surface);
        }
Ejemplo n.º 3
0
        public IndexedSurface <DeferredAmbientLightVertex> MakeAmbientLightSurface()
        {
            var surface = new IndexedSurface <DeferredAmbientLightVertex>
            {
                ClearOnRender = false,
                IsStatic      = true,
            };

            surface.AddSettings(
                this.gameModelview,
                this.gameProjection,
                SurfaceBlendSetting.Add,
                this.deferredBuffer
                );
            this.shaders.AmbientLight.UseOnSurface(surface);
            return(surface);
        }