public override IShaderVariable Variable(string name)
{
// Try to find existing variable
foreach (var variable in variables)
{
if (variable.Name == name) return variable;
}
// Otherwise add a variable instance
int vertexOffset = vertex.Variable(name);
int pixelOffset = pixel.Variable(name);
if (vertexOffset == -1 && pixelOffset == -1)
{
Debug.ThrowError("Shader", string.Format("Shader variable '{0}' does not exist", name));
}
var newVariable = new ShaderVariable(name, vertex.com, pixel.com, vertexOffset, pixelOffset);
variables.Add(newVariable);
return newVariable;
}