public void RegisterEffect(string name) { Effect effect = game.Content.Load <Effect>("Content\\Effects\\" + name); foreach (EffectTechnique tech in effect.Techniques) { // remove begin and end of technique name string lowerTechName = tech.Name.ToLower(); if (!(lowerTechName.StartsWith("t_") && (lowerTechName.EndsWith("_2_0") || lowerTechName.EndsWith("_3_0")))) { throw new Exception("Effect file " + name + " has an invalid technique name. Techniques must start with \"t_\" and end with \"_2_0\" or \"_3_0\"."); } string techNamePartsAsString = lowerTechName.Substring(2, lowerTechName.Length - 6); // split technique name to parts string[] techNameParts = techNamePartsAsString.Split(("_").ToCharArray()); // sort tech name parts StringBuilder sb = new StringBuilder(); SortedList <string, string> sl = new SortedList <string, string>(techNameParts.Length); bool continueWithNextTechnique = false; foreach (string part in techNameParts) { if (part == "basic") { continueWithNextTechnique = true; break; } sl.Add(part, part); } if (continueWithNextTechnique) { continue; } // build tech desc string string shaderModel = lowerTechName.EndsWith("_3_0") ? "SM3" : "SM2"; sb.Append(shaderModel); foreach (KeyValuePair <string, string> part in sl) { sb.Append("," + part.Value); } // create ShaderDescription EffectTechniqueDescription sd = new EffectTechniqueDescription(); sd.Effect = name; sd.Technique = tech.Name; // ad to valid validShaders.Add(sb.ToString(), sd); } }
public Effect CreateEffect(EffectTechniqueDescription sd) { Effect result = game.Content.Load <Effect>("Content\\Effects\\" + sd.Effect); foreach (EffectTechnique technique in result.Techniques) { if (technique.Name == sd.Technique) { result.CurrentTechnique = technique; break; } } return(result); }
public Effect CreateEffect(List <string> shaderDescription) { EffectTechniqueDescription sd = GetEffectTechniqueDescription(shaderDescription); return(CreateEffect(sd)); }
public Effect CreateEffect(ShaderDescription shaderDescription, InstancingType instancing) { EffectTechniqueDescription sd = GetEffectTechniqueDescription(shaderDescription, instancing); return(CreateEffect(sd)); }