internal static void Set(MyRenderVoxelMaterialData[] list, bool update = false) { if (!update) { Array.Resize(ref Table, list.Length); } for (int i = 0; i < list.Length; i++) { // copy data int index = update ? list[i].Index : i; Table[index].Resource.ColorMetalXZnY_Filepaths = CreateStringArray(list[i].ColorMetalXZnY, list[i].ColorMetalXZnYFar1, list[i].ColorMetalXZnYFar2); Table[index].Resource.ColorMetalY_Filepaths = CreateStringArray(list[i].ColorMetalY, list[i].ColorMetalYFar1, list[i].ColorMetalYFar2); Table[index].Resource.NormalGlossXZnY_Filepaths = CreateStringArray(list[i].NormalGlossXZnY, list[i].NormalGlossXZnYFar1, list[i].NormalGlossXZnYFar2); Table[index].Resource.NormalGlossY_Filepaths = CreateStringArray(list[i].NormalGlossY, list[i].NormalGlossYFar1, list[i].NormalGlossYFar2); Table[index].Resource.ExtXZnY_Filepaths = CreateStringArray(list[i].ExtXZnY, list[i].ExtXZnYFar1, list[i].ExtXZnYFar2); Table[index].Resource.ExtY_Filepaths = CreateStringArray(list[i].ExtY, list[i].ExtYFar1, list[i].ExtYFar2); Table[index].FoliageArray_Texture = list[i].ExtensionTextureArray1; Table[index].FoliageArray_NormalTexture = list[i].ExtensionTextureArray2; MyFileArrayTextureManager arrayManager = MyManagers.FileArrayTextures; if (list[i].FoliageColorTextureArray != null) { Table[index].FoliageColorTextureArray = arrayManager.CreateFromFiles("MyVoxelMaterial1.FoliageColorTextureArray", list[i].FoliageColorTextureArray, MyFileTextureEnum.COLOR_METAL, MyGeneratedTexturePatterns.ColorMetal_BC7_SRgb, Format.BC7_UNorm_SRgb, true); } else { Table[index].FoliageColorTextureArray = null; } if (list[i].FoliageNormalTextureArray != null) { Table[index].FoliageNormalTextureArray = arrayManager.CreateFromFiles("MyVoxelMaterial1.FoliageNormalTextureArray", list[i].FoliageNormalTextureArray, MyFileTextureEnum.NORMALMAP_GLOSS, MyGeneratedTexturePatterns.NormalGloss_BC7, Format.BC7_UNorm, true); } else { Table[index].FoliageNormalTextureArray = null; } Table[index].FoliageDensity = list[i].ExtensionDensity; Table[index].FoliageScale = list[i].ExtensionScale; Table[index].FoliageScaleVariation = list[i].ExtensionRandomRescaleMult; Table[index].FoliageType = list[i].ExtensionType; Table[index].DistanceAndScale = list[i].DistanceAndScale; Table[index].DistanceAndScaleFar = list[i].DistanceAndScaleFar; Table[index].DistanceAndScaleFar3 = list[i].DistanceAndScaleFar3; Table[index].Far3Color = list[i].Far3Color; Table[index].ExtensionDetailScale = list[i].ExtensionDetailScale; MaterialQueryResourcesTable.Add(index); } }
internal static void ReleaseResources(ref MyVoxelMaterialDetailSet set) { MyFileArrayTextureManager texManager = MyManagers.FileArrayTextures; texManager.DisposeTex(ref set.ColorMetalArray); texManager.DisposeTex(ref set.NormalGlossArray); texManager.DisposeTex(ref set.ExtArray); }
internal static void PrepareArrays(ref MyVoxelMaterialDetailSet set) { MyFileArrayTextureManager texManager = MyManagers.FileArrayTextures; set.ColorMetalArray = texManager.CreateFromFiles("VoxelMaterial CM Array " + set.ColorMetalXZnY_Texture.ToString(), new string[] { set.ColorMetalXZnY_Texture.ToString(), set.ColorMetalpY_Texture.ToString() }, MyFileTextureEnum.COLOR_METAL); set.NormalGlossArray = texManager.CreateFromFiles("VoxelMaterial NG Array " + set.NormalGlossXZnY_Texture.ToString(), new string[] { set.NormalGlossXZnY_Texture.ToString(), set.NormalGlossY_Texture.ToString() }, MyFileTextureEnum.NORMALMAP_GLOSS); set.ExtArray = texManager.CreateFromFiles("VoxelMaterial EA Array " + set.ExtXZnY_Texture.ToString(), new string[] { set.ExtXZnY_Texture.ToString(), set.ExtY_Texture.ToString() }, MyFileTextureEnum.EXTENSIONS); }
internal static void ReleaseResources() { for (int i = 0; i < Table.Length; i++) { MyVoxelMaterialDetailSet.ReleaseResources(ref Table[i].Near); MyVoxelMaterialDetailSet.ReleaseResources(ref Table[i].Far1); MyVoxelMaterialDetailSet.ReleaseResources(ref Table[i].Far2); MyFileArrayTextureManager manager = MyManagers.FileArrayTextures; if (Table[i].FoliageColorTextureArray != null) { manager.DisposeTex(ref Table[i].FoliageColorTextureArray); } if (Table[i].FoliageNormalTextureArray != null) { manager.DisposeTex(ref Table[i].FoliageNormalTextureArray); } } }
internal static void Set(MyRenderVoxelMaterialData[] list, bool update = false) { if (!update) { Array.Resize(ref Table, list.Length); } for (int i = 0; i < list.Length; i++) { // copy data int index = update ? list[i].Index : i; Table[index].Near.ColorMetalXZnY_Texture = X.TEXT_(list[i].ColorMetalXZnY); Table[index].Near.ColorMetalpY_Texture = X.TEXT_(list[i].ColorMetalY); Table[index].Near.NormalGlossXZnY_Texture = X.TEXT_(list[i].NormalGlossXZnY); Table[index].Near.NormalGlossY_Texture = X.TEXT_(list[i].NormalGlossY); Table[index].Near.ExtXZnY_Texture = X.TEXT_(list[i].ExtXZnY); Table[index].Near.ExtY_Texture = X.TEXT_(list[i].ExtY); Table[index].Far1.ColorMetalXZnY_Texture = X.TEXT_(list[i].ColorMetalXZnYFar1); Table[index].Far1.ColorMetalpY_Texture = X.TEXT_(list[i].ColorMetalYFar1); Table[index].Far1.NormalGlossXZnY_Texture = X.TEXT_(list[i].NormalGlossXZnYFar1); Table[index].Far1.NormalGlossY_Texture = X.TEXT_(list[i].NormalGlossYFar1); Table[index].Far1.ExtXZnY_Texture = X.TEXT_(list[i].ExtXZnYFar1); Table[index].Far1.ExtY_Texture = X.TEXT_(list[i].ExtYFar1); Table[index].Far2.ColorMetalXZnY_Texture = X.TEXT_(list[i].ColorMetalXZnYFar2); Table[index].Far2.ColorMetalpY_Texture = X.TEXT_(list[i].ColorMetalYFar2); Table[index].Far2.NormalGlossXZnY_Texture = X.TEXT_(list[i].NormalGlossXZnYFar2); Table[index].Far2.NormalGlossY_Texture = X.TEXT_(list[i].NormalGlossYFar2); Table[index].Far2.ExtXZnY_Texture = X.TEXT_(list[i].ExtXZnYFar2); Table[index].Far2.ExtY_Texture = X.TEXT_(list[i].ExtYFar2); Table[index].FoliageArray_Texture = list[i].ExtensionTextureArray1; Table[index].FoliageArray_NormalTexture = list[i].ExtensionTextureArray2; MyFileArrayTextureManager arrayManager = MyManagers.FileArrayTextures; if (list[i].FoliageColorTextureArray != null) { Table[index].FoliageColorTextureArray = arrayManager.CreateFromFiles("MyVoxelMaterial1.FoliageColorTextureArray", list[i].FoliageColorTextureArray, MyFileTextureEnum.COLOR_METAL); } else { Table[index].FoliageColorTextureArray = null; } if (list[i].FoliageNormalTextureArray != null) { Table[index].FoliageNormalTextureArray = arrayManager.CreateFromFiles("MyVoxelMaterial1.FoliageNormalTextureArray", list[i].FoliageNormalTextureArray, MyFileTextureEnum.NORMALMAP_GLOSS); } else { Table[index].FoliageNormalTextureArray = null; } Table[index].FoliageDensity = list[i].ExtensionDensity; Table[index].FoliageScale = list[i].ExtensionScale; Table[index].FoliageScaleVariation = list[i].ExtensionRandomRescaleMult; Table[index].FoliageType = list[i].ExtensionType; Table[index].DistanceAndScale = list[i].DistanceAndScale; Table[index].DistanceAndScaleFar = list[i].DistanceAndScaleFar; Table[index].DistanceAndScaleFar3 = list[i].DistanceAndScaleFar3; Table[index].Far3Color = list[i].Far3Color; Table[index].ExtensionDetailScale = list[i].ExtensionDetailScale; MaterialQueryResourcesTable.Add(index); } }