/// <summary>
            /// 
            /// </summary>
            /// <param name="instance"></param>
            /// <param name="position"></param>
            /// <param name="color"></param>
            /// <param name="radius"></param>
            /// <param name="fadeInRate"></param>
            /// <param name="fadeOutRate"></param>
            public LightStage( SfxInstance instance, Vector3 position, Color4 color, float radius, float fadeInRate, float fadeOutRate )
                : base(instance)
            {
                if ( fadeInRate  < 0 ) {
                    throw new ArgumentOutOfRangeException("fadeInRate < 0");
                }
                if ( fadeOutRate < 0 ) {
                    throw new ArgumentOutOfRangeException("fadeOutRate < 0");
                }

                light				=	new OmniLight();
                light.Position		=	position;
                light.RadiusInner	=	radius * 0.1f;
                light.RadiusOuter	=	radius;
                light.Intensity		=	Color4.Zero;

                lightColor			=	color;

                lightFadeInRate		=	fadeInRate;
                lightFadeOutRate	=	fadeOutRate;

                lightIntensity		=	0.0001f;
                lightFadeRate		=	lightFadeInRate;

                SfxInstance.rw.LightSet.OmniLights.Add(light);
            }
		/// <summary>
		/// 
		/// </summary>
		public override void Initialize ()
		{
			debugFont		=	Game.Content.Load<DiscTexture>("conchars");
			//videoPlayer	=	new VideoPlayer();
			//video		=	new Video(@"C:\infection_demo.wmv");//*/
			////video		=	GameEngine.Content.Load<Video>("infection_demo");
			//video		=	new Video(File.ReadAllBytes(@"C:\infection_demo.wmv"));//*/

			//var mtrl		=	GameEngine.Content.Load<Material>("testMtrl");

			var bounds		=	Game.RenderSystem.DisplayBounds;
			masterView		=	Game.RenderSystem.RenderWorld;

			Game.RenderSystem.DisplayBoundsChanged += (s,e) => {
				masterView.Resize( Game.RenderSystem.DisplayBounds.Width, Game.RenderSystem.DisplayBounds.Height );
				//Log.Warning("{0} {1}", GameEngine.GraphicsEngine.DisplayBounds.Width, GameEngine.GraphicsEngine.DisplayBounds.Height);
			};

			targetTexture		=	new TargetTexture(Game.RenderSystem, bounds.Width, bounds.Height, TargetFormat.LowDynamicRange );
			//masterView.Target	=	targetTexture;

			testLayer	=	new SpriteLayer( Game.RenderSystem, 1024 );
			uiLayer		=	new SpriteLayer( Game.RenderSystem, 1024 );
			texture		=	Game.Content.Load<DiscTexture>( "lena" );

			masterView.SkySettings.SunPosition			=	new Vector3(20,30,40);
			masterView.SkySettings.SunLightIntensity	=	50;
			masterView.SkySettings.SkyTurbidity			=	3;

			masterView.LightSet.SpotAtlas				=	Game.Content.Load<TextureAtlas>("spots/spots");
			masterView.LightSet.DirectLight.Direction	=	masterView.SkySettings.SunLightDirection;
			masterView.LightSet.DirectLight.Intensity	=	masterView.SkySettings.SunLightColor;
			masterView.LightSet.DirectLight.Enabled		=	true;
			masterView.LightSet.AmbientLevel			=	Color4.Zero;
			//masterView.LightSet.AmbientLevel			=	masterView.SkySettings.AmbientLevel;

			masterView.LightSet.EnvLights.Add( new EnvLight( new Vector3(0,4,-10), 1,  500 ) );

			//masterView.LightSet.EnvLights.Add( new EnvLight( new Vector3(0,4,-10), 1,  15 ) );
			//masterView.LightSet.EnvLights.Add( new EnvLight( new Vector3(0,4, 10), 1, 15 ) );


			var rand = new Random();

			/*for (int i=0; i<64; i++) {
				var light = new OmniLight();
				light.Position		=	new Vector3( 8*(i/8-4), 4, 8*(i%8-4) );
				light.RadiusInner	=	1;
				light.RadiusOuter	=	8;
				light.Intensity		=	rand.NextColor4() * 100;
				masterView.LightSet.OmniLights.Add( light );
			} //*/
														 
			/*for (int i=0; i<256; i++) {
				var light = new EnvLight();
				light.Position		=	new Vector3( 7*(i/16-8), 6, 7*(i%16-8) );
				light.RadiusInner	=	2;
				light.RadiusOuter	=	8;
				masterView.LightSet.EnvLights.Add( light );
			} //*/

			fireLight	=	new OmniLight();
			fireLight.Position	=	Vector3.UnitZ * (-10) + Vector3.UnitY * 5 + Vector3.UnitX * 20;
			fireLight.RadiusOuter	=	7;
			fireLight.Intensity		=	new Color4(249, 172, 61, 0)/2;

			masterView.LightSet.OmniLights.Add( fireLight );
			


			masterView.SpriteLayers.Add( console.ConsoleSpriteLayer );
			masterView.SpriteLayers.Add( uiLayer );
			masterView.SpriteLayers.Add( testLayer );


			Game.Keyboard.KeyDown += Keyboard_KeyDown;

			LoadContent();

			Game.Reloading += (s,e) => LoadContent();

			Game.Touch.Tap			+= vector2 => System.Console.WriteLine("You just perform tap gesture at point: " + vector2);
			Game.Touch.DoubleTap	+= vector2 => System.Console.WriteLine("You just perform double tap gesture at point: " + vector2);
			Game.Touch.SecondaryTap += vector2 => System.Console.WriteLine("You just perform secondary tap gesture at point: " + vector2);
			Game.Touch.Manipulate	+= (center, delta, scale) => System.Console.WriteLine("You just perform touch manipulation: " + center + "	" + delta + "	" + scale);
		}