/// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every frame
 /// until RemoveLight is called. Has priority over normal lights.
 /// </summary>
 /// <param name="light"></param>
 public override void AddSceneLight(Light light)
 {
     sceneLights.Add(light);
 }
 /// <summary>
 /// Removes a light from the scene.
 /// </summary>
 /// <param name="light">Light</param>
 public override void RemoveLight(Light light)
 {
     dynamicLights.Remove(light);
     sceneLights.Remove(light);
 }
        /// <summary>
        /// Applies contribution from a point light.
        /// </summary>
        /// <param name="light">Light</param>
        private void RenderPointLight(Light light, bool shadow)
        {
            pointLightEffect.CurrentTechnique = pointLightEffect.Techniques["PointLight"];
            //pointLightEffect.Parameters["xLightTex"].SetValue(lightMap);
            //pointLightEffect.Parameters["xLightViewProjection"].SetValue(cameraViewProjection);
            pointLightEffect.Parameters["xLightColorAndIntensity"].SetValue(light.Color.ToVector3() * light.Intensity);
            pointLightEffect.Parameters["xLightPosition"].SetValue(light.Location);

            // TODO: light volume shapes

            RenderEffectToScreen(pointLightEffect);
        }
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every
 /// frame until RemoveLight is called.
 /// </summary>
 /// <param name="light">Light</param>
 public override void AddDynamicLight(Light light)
 {
     if (light.Type == LightType.Directional)
         throw new ArgumentException("Dynamic lights can't be directional");
     dynamicLights.Add(light);
 }
        /// <summary>
        /// Applies contribution from a directional light.
        /// </summary>
        /// <param name="light">Light</param>
        private void RenderDirectionalLight(Light light, bool shadow)
        {
            if (light.Intensity != 0)
            {
                directionalLightEffect.CurrentTechnique = shadow
                    ? directionalLightEffect.Techniques["DirectionalLightShadow"]
                    : directionalLightEffect.Techniques["DirectionalLight"];
                directionalLightEffect.Parameters["xLightViewProjection"].SetValue(lightViewProjection);
                directionalLightEffect.Parameters["xLightColorAndIntensity"].SetValue(light.Color.ToVector3() * light.Intensity);
                directionalLightEffect.Parameters["xLightNormal"].SetValue(Vector3.Normalize(light.Location));

                RenderEffectToScreen(directionalLightEffect);
            }
        }
        /// <summary>
        /// Initializes a light from a binary stream, version 0.
        /// </summary>
        /// <param name="light">Light being initialized</param>
        /// <param name="reader">Binary stream</param>
        private static Light ReadVer0(BinaryReader reader)
        {
            Light light = new Light();

            light.Type = (LightType)reader.ReadUInt32();
            light.Color.R = reader.ReadByte();
            light.Color.G = reader.ReadByte();
            light.Color.B = reader.ReadByte();
            light.Intensity = reader.ReadSingle();

            return light;
        }
 /// <summary>
 /// Removes a light from the scene.
 /// </summary>
 /// <param name="light">Light</param>
 public abstract void RemoveLight(Light light);
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every frame
 /// until RemoveLight is called. Has priority over normal lights.
 /// </summary>
 /// <param name="light"></param>
 public abstract void AddSceneLight(Light light);
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every
 /// frame until RemoveLight is called.
 /// </summary>
 /// <param name="light">Light</param>
 public abstract void AddDynamicLight(Light light);