public MyMeshMaterialId GetOrCreateMaterialId(MyMeshMaterialInfo info) { Vector2I defaultTextureSize = GetDefaultTextureSize(info.ColorMetal_Texture, info.NormalGloss_Texture, info.Extensions_Texture, info.Alphamask_Texture); IDynamicFileArrayTexture cmArrayTex = GetArrayTextureFromFilepath(info.ColorMetal_Texture, MyChannel.ColorMetal, defaultTextureSize); int cmIndex = cmArrayTex.GetOrAddSlice(info.ColorMetal_Texture); IDynamicFileArrayTexture ngArrayTex = GetArrayTextureFromFilepath(info.NormalGloss_Texture, MyChannel.NormalGloss, defaultTextureSize); int ngIndex = ngArrayTex.GetOrAddSlice(info.NormalGloss_Texture); IDynamicFileArrayTexture extArrayTex = GetArrayTextureFromFilepath(info.Extensions_Texture, MyChannel.Extension, defaultTextureSize); int extIndex = extArrayTex.GetOrAddSlice(info.Extensions_Texture); info.ColorMetal_Texture = cmArrayTex.Name; info.NormalGloss_Texture = ngArrayTex.Name; info.Extensions_Texture = extArrayTex.Name; MyMaterialKey materialKey = new MyMaterialKey(info.ColorMetal_Texture, info.NormalGloss_Texture, info.Extensions_Texture, info.Alphamask_Texture); m_setDebugMaterials.Add(materialKey); MyGeometryTextureSystemReference geoTextureRef; geoTextureRef.ColorMetalTexture = cmArrayTex; geoTextureRef.ColorMetalIndex = cmIndex; geoTextureRef.NormalGlossTexture = ngArrayTex; geoTextureRef.NormalGlossIndex = ngIndex; geoTextureRef.ExtensionTexture = extArrayTex; geoTextureRef.ExtensionIndex = extIndex; geoTextureRef.AlphamaskTexture = null; geoTextureRef.AlphamaskIndex = DEFAULT_ARRAY_TEXTURE_INDEX; if (!string.IsNullOrEmpty(info.Alphamask_Texture)) { IDynamicFileArrayTexture alphamaskArrayTex = GetArrayTextureFromFilepath(info.Alphamask_Texture, MyChannel.Alphamask, defaultTextureSize); int alphamaskIndex = alphamaskArrayTex.GetOrAddSlice(info.Alphamask_Texture); info.Alphamask_Texture = alphamaskArrayTex.Name; geoTextureRef.AlphamaskTexture = alphamaskArrayTex; geoTextureRef.AlphamaskIndex = alphamaskIndex; } geoTextureRef.IsUsed = true; info.GeometryTextureRef = geoTextureRef; return(MyMeshMaterials1.GetMaterialId(ref info)); }
public MyMeshMaterialId GetOrCreateMaterialId(MyMeshMaterialInfo info) { Vector2I defaultTextureSize = GetDefaultTextureSize(info.ColorMetal_Texture, info.NormalGloss_Texture, info.Extensions_Texture, info.Alphamask_Texture); IDynamicFileArrayTexture cmArrayTex = GetArrayTextureFromFilepath(info.ColorMetal_Texture, MyChannel.ColorMetal, defaultTextureSize); int cmIndex = cmArrayTex.GetOrAddSlice(info.ColorMetal_Texture); IDynamicFileArrayTexture ngArrayTex = GetArrayTextureFromFilepath(info.NormalGloss_Texture, MyChannel.NormalGloss, defaultTextureSize); int ngIndex = ngArrayTex.GetOrAddSlice(info.NormalGloss_Texture); IDynamicFileArrayTexture extArrayTex = GetArrayTextureFromFilepath(info.Extensions_Texture, MyChannel.Extension, defaultTextureSize); int extIndex = extArrayTex.GetOrAddSlice(info.Extensions_Texture); info.ColorMetal_Texture = cmArrayTex.Name; info.NormalGloss_Texture = ngArrayTex.Name; info.Extensions_Texture = extArrayTex.Name; MyMaterialKey materialKey = new MyMaterialKey(info.ColorMetal_Texture, info.NormalGloss_Texture, info.Extensions_Texture, info.Alphamask_Texture); m_setDebugMaterials.Add(materialKey); MyGeometryTextureSystemReference geoTextureRef; geoTextureRef.ColorMetalTexture = cmArrayTex; geoTextureRef.ColorMetalIndex = cmIndex; geoTextureRef.NormalGlossTexture = ngArrayTex; geoTextureRef.NormalGlossIndex = ngIndex; geoTextureRef.ExtensionTexture = extArrayTex; geoTextureRef.ExtensionIndex = extIndex; geoTextureRef.AlphamaskTexture = null; geoTextureRef.AlphamaskIndex = DEFAULT_ARRAY_TEXTURE_INDEX; if (!string.IsNullOrEmpty(info.Alphamask_Texture)) { IDynamicFileArrayTexture alphamaskArrayTex = GetArrayTextureFromFilepath(info.Alphamask_Texture, MyChannel.Alphamask, defaultTextureSize); int alphamaskIndex = alphamaskArrayTex.GetOrAddSlice(info.Alphamask_Texture); info.Alphamask_Texture = alphamaskArrayTex.Name; geoTextureRef.AlphamaskTexture = alphamaskArrayTex; geoTextureRef.AlphamaskIndex = alphamaskIndex; } geoTextureRef.IsUsed = true; info.GeometryTextureRef = geoTextureRef; return MyMeshMaterials1.GetMaterialId(ref info); }