public void AddPassCode(SourceMap.ShaderPassSource shaderPassSource) { var keywordTypes = TypeCache.GetTypesDerivedFrom <Keyword>().Select(type => type).Where(type => !type.IsAbstract).ToList(); var sourceLines = new Queue <string>(shaderPassSource.Lines); while (sourceLines.Count > 0) { ParseKeyword(sourceLines, keywordTypes, true); } }
public ShaderGenerationContext(SourceMap sourceMap, StringBuilder stringBuilder, SourceMap.ShaderPassSource shaderPassSource = null) { SourceMap = sourceMap; _stringBuilder = stringBuilder; KeywordMap = new KeywordMap(new Queue <string>(sourceMap.DefaultPassSource)); if (shaderPassSource != null) { KeywordMap.AddPassCode(shaderPassSource); } }
internal virtual void WritePass(ShaderGenerationContext context, ShaderModel config, SourceMap.ShaderPassSource passSpecificCode) { var mode = GetShadowDepthMode(context); if (UsePassName != null) { if (mode == KeywordShadowDepthPass.ShadowDepthPassMode.DefaultPass) { new UsePass(UsePassName).WritePass(context, config, null); return; } if (mode == KeywordShadowDepthPass.ShadowDepthPassMode.Off) { return; } } context.LogShaderSection($"Shader Pass {GetType().Name}"); context.WriteLine("Pass{"); var shaderPassContext = context.CreatePassContext(context, this, config, passSpecificCode); shaderPassContext.WriteIndented(WriteInnerPass); context.WriteLine("}"); }
public ShaderGenerationContext CreatePassContext(ShaderGenerationContext parent, ShaderPass pass, ShaderModel config, SourceMap.ShaderPassSource passSourceSource) { return(new ShaderGenerationContext(parent.SourceMap, parent._stringBuilder, passSourceSource) { _indentCount = parent._indentCount, CurrentPass = pass, CurrentShaderModel = config, }); }