public IMaterial GetOrCreateMaterial(string materialName, MyMeshDrawTechnique technique, string cmFilepath, string ngFilepath, string extFilepath, string alphamaskFilepath) { MyMaterialKey key = new MyMaterialKey { Technique = technique, CmFilepath = cmFilepath, NgFilepath = ngFilepath, ExtFilepath = extFilepath, AlphamaskFilepath = alphamaskFilepath, }; IMaterial imaterial; if (m_materials.TryGetValue(key, out imaterial)) { return(imaterial); } MyMaterial material = new MyMaterial(); m_materials.Add(key, material); material.Init(key); return(material); }
public void Init(MyMaterialKey key) { if (key.Technique == MyMeshDrawTechnique.MESH) { InitStandard(key.CmFilepath, key.NgFilepath, key.ExtFilepath); } else if (key.Technique == MyMeshDrawTechnique.DECAL) { InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, true, false); } else if (key.Technique == MyMeshDrawTechnique.DECAL_NOPREMULT) { InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, false, false); } else if (key.Technique == MyMeshDrawTechnique.DECAL_CUTOUT) { InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, true, true); } else if (key.Technique == MyMeshDrawTechnique.ALPHA_MASKED) { InitAlphamask(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath); } else { MyRenderProxy.Error("Material is not resolved, please extend the functionality of the new pipeline or move object to the old pipeline"); } }