using UnityEngine;
using System.Collections;

public static class ShaderHelpers
{
	public static void SetHueShiftValues (Material m, float h, float s, float v)
	{
		float V = v;
		float S = s;
		float U = Mathf.Cos (h * 3.14159265f / 180);
		float W = Mathf.Sin (h * 3.14159265f / 180);

		float VSU = V * S * U;
		float VSW = V * S * W;

		var redCompShift = new Vector3 (.299f * V + .701f * VSU + .168f * VSW, .587f - .587f * VSU + .330f * VSW, .114f - .114f * VSU - .497f * VSW);
		var greenCompShift = new Vector3 (.299f * V - .299f * VSU - .328f * VSW, .587f + .413f * VSU + .035f * VSW, .114f - .114f * VSU + .292f * VSW);
		var blueCompShift = new Vector3 (.299f * V - .300f * VSU + 1.25f * VSW, .587f - .588f * VSU - 1.05f * VSW, .114f + .886f * VSU - .203f * VSW);

		m.SetVector ("_RedCompShift", redCompShift);
		m.SetVector ("_GreenCompShift", greenCompShift);
		m.SetVector ("_BlueCompShift", blueCompShift);
	}
}
