public static void WriteShaderAssign(this FMAT.ShaderAssign shd, Material mat)
        {
            mat.ShaderAssign = new ShaderAssign();
            mat.ShaderAssign.ShaderOptionDict  = new ResDict();
            mat.ShaderAssign.SamplerAssignDict = new ResDict();
            mat.ShaderAssign.AttribAssignDict  = new ResDict();
            mat.ShaderAssign.ShaderOptions     = new List <string>();
            mat.ShaderAssign.AttribAssigns     = new List <string>();
            mat.ShaderAssign.SamplerAssigns    = new List <string>();

            mat.ShaderAssign.ShaderArchiveName = shd.ShaderArchive;
            mat.ShaderAssign.ShadingModelName  = shd.ShaderModel;

            foreach (var option in shd.options)
            {
                mat.ShaderAssign.ShaderOptionDict.Add(option.Key);
                mat.ShaderAssign.ShaderOptions.Add(option.Value);
            }
            foreach (var samp in shd.samplers)
            {
                mat.ShaderAssign.SamplerAssignDict.Add(samp.Key);
                mat.ShaderAssign.SamplerAssigns.Add(samp.Value);
            }
            foreach (var att in shd.attributes)
            {
                mat.ShaderAssign.AttribAssignDict.Add(att.Key);
                mat.ShaderAssign.AttribAssigns.Add(att.Value);
            }
        }
Esempio n. 2
0
 public static void SetShaderAssignAttributes(FMAT.ShaderAssign shd, FSHP shape)
 {
     foreach (var att in shape.vertexAttributes)
     {
         if (!shd.attributes.ContainsValue(att.Name) && !shd.attributes.ContainsKey(att.Name))
         {
             shd.attributes.Add(att.Name, att.Name);
         }
     }
     foreach (var tex in shape.GetMaterial().textures)
     {
         if (!shd.samplers.ContainsValue(tex.SamplerName))
         {
             shd.samplers.Add(tex.SamplerName, tex.SamplerName);
         }
     }
 }