public IEnumerable <EffectShaderPass> SetupShadersPermutationCaster(object permutationKey) { var shadowMapPermutation = (ShadowMap)permutationKey; var shaderCaster = new ShaderClassSource("ShadowMapCasterBase"); for (int i = 0; i < shadowMapPermutation.LevelCount; ++i) { // Shadow caster var shaderPass = new EffectShaderPass(shadowMapPermutation.Passes[i], "ShadowMap"); shaderPass.Parameters.AddSources(shadowMapPermutation.Passes[i].Parameters); shaderPass.Shader = (ShaderMixinSource)mainShaderSource.Clone(); shaderPass.Macros.AddRange(mainShaderMacros); shaderPass.Shader.Mixins.Add(shaderCaster); yield return(shaderPass); } }