public static ShaderRootClassType GetMainShaderClass(this Shader shader) { var defaultShader = shader.Declarations.OfType <ShaderRootClassType>().FirstOrDefault(x => x.Name == "Shader"); if (defaultShader == null) { defaultShader = new ShaderRootClassType("Shader"); shader.Declarations.Add(defaultShader); } return(defaultShader); }
public static ShaderRootClassType Mix(this ShaderRootClassType target, TypeBase mixinClass) { var typeName = new TypeName(mixinClass.Name); if (mixinClass is ShaderClassType) { typeName.SetTag(associatedClass, mixinClass); } target.BaseClasses.Add(typeName); return(target); }
public static ShaderRootClassType Compose(this ShaderRootClassType sourceClass, string variableName, params ShaderClassType[] variableTypes) { var currentVariableTypes = (Dictionary <string, ShaderClassType[]>)sourceClass.GetTag(associatedCompositions); if (currentVariableTypes == null) { currentVariableTypes = new Dictionary <string, ShaderClassType[]>(); sourceClass.SetTag(associatedCompositions, currentVariableTypes); } currentVariableTypes[variableName] = variableTypes; return(sourceClass); }