public Layer(ISurfaceShader shader, ISurfaceShader wispShader, CrepuscularRayGeometry rayGeo, string filename, float brightness, int wisps)
        {
            this.rayGeo = rayGeo;
            var texture = new Texture("gfx/" + filename + ".png", true);

            this.surface = new PostProcessSurface();
            this.surface.AddSettings(
                new TextureUniform("diffuseTexture", texture),
                new ColorUniform("color", Color.GrayScale((byte)(255 * brightness)))
                );
            shader.UseOnSurface(this.surface);

            this.wispSurface = new IndexedSurface<UVColorVertexData>();
            wispShader.UseOnSurface(this.wispSurface);

            this.wispGeo = new Sprite2DGeometry(this.wispSurface)
            {
                Color = Color.White.WithAlpha()
            };

            this.wisps = Enumerable.Range(0, wisps)
                .Select(i => new Wisp()).ToList();
        }
        protected override void OnLoad(EventArgs e)
        {
            this.shaderMan = new ShaderManager();

            var shaderLoader = ShaderFileLoader.CreateDefault("shaders");

            // load all shaders
            var shaders = shaderLoader.Load("").ToList();
            this.shaderMan.Add(shaders);

            var layerShader = this.shaderMan.MakeShaderProgram()
                .WithVertexShader("copy").WithFragmentShader("copy")
                .As("layer");

            var copyShader = this.shaderMan.MakeShaderProgram()
                .WithVertexShader("post").WithFragmentShader("copy")
                .As("copypost");

            var wispShader = this.shaderMan.MakeShaderProgram()
                .WithVertexShader("wisp").WithFragmentShader("wisp")
                .As("wisp");

            var rayShader = this.shaderMan.MakeShaderProgram()
                .WithVertexShader("crepuscularrays")
                .WithGeometryShader("crepuscularrays")
                .WithFragmentShader("crepuscularrays")
                .As("crepuscularrays");

            this.renderTexture = new Texture(1, 1);
            this.renderTexture.SetParameters(TextureMinFilter.Linear, TextureMagFilter.Linear, TextureWrapMode.ClampToBorder, TextureWrapMode.ClampToBorder);

            this.renderTarget = new RenderTarget(this.renderTexture);
            var renderTextureUniform = new TextureUniform("diffuseTexture", this.renderTexture);

            this.copyToScreen = new PostProcessSurface();
            this.copyToScreen.AddSettings(renderTextureUniform, new ColorUniform("color", Color.White));
            copyShader.UseOnSurface(this.copyToScreen);

            this.raySurface = new VertexSurface<CrepuscularRayVertex>(PrimitiveType.Points);
            this.raySurface.AddSettings(renderTextureUniform);
            rayShader.UseOnSurface(this.raySurface);

            var rayGeo = new CrepuscularRayGeometry(this.raySurface);

            const int layerCount = 4;
            const float maxBrightness = 0.03f;
            const float brightnessStep = maxBrightness / layerCount;

            this.layers = Enumerable.Range(0, layerCount).Reverse()
                .Select(i => new Layer(layerShader, wispShader, rayGeo, "layer" + i, GameMath.Sqrt(brightnessStep * i), i * i * 5))
                .ToList();

            InputManager.Initialize(this.Mouse);
        }
            public void Draw(Sprite2DGeometry geo, CrepuscularRayGeometry rayGeo)
            {
                var p = this.center + new Vector2(GameMath.Cos(this.angle), GameMath.Sin(this.angle)) * this.radius;

                geo.Color = this.color;
                geo.DrawSprite(p, 0, this.size);
                geo.Color = Color.White;
                geo.DrawSprite(p, 0, this.size * 0.7f);

                rayGeo.Draw(p.WithZ(), this.size * 1.5f, 3);
            }