//--------------------// #region Light helper /// <summary> /// Transfer lighting data from a <see cref="LightSource"/> to the shader /// </summary> /// <param name="light">The <see cref="LightSource"/> to get the information from</param> /// <param name="index">The light index in the shader to set</param> /// <param name="material">The currently active material</param> private void SetupLightHelper(LightSource light, int index, XMaterial material) { if (index < _lightDiffuseHandles.Count) { Effect.SetValue(_lightDiffuseHandles[index], Color4.Modulate(light.Diffuse, material.Diffuse)); } if (index < _lightAmbientHandles.Count) { Effect.SetValue(_lightAmbientHandles[index], Color4.Modulate(light.Ambient, material.Ambient)); } if (index < _lightSpecularHandles.Count) { Effect.SetValue(_lightSpecularHandles[index], Color4.Modulate(light.Specular, material.Specular)); } if (index < _lightSpecularPowerHandles.Count) { Effect.SetValue(_lightSpecularPowerHandles[index], material.SpecularPower); } }
/// <summary> /// Modulates two colors /// </summary> /// <param name="color1">Color 1</param> /// <param name="color2">Color 2</param> /// <returns></returns> public static Color Modulate(Color color1, Color color2) { return(new Color(Color4.Modulate(color1.RawColor, color2.RawColor))); }