static void UpdateVoxelSlices(ref MyVoxelMaterialEntry entry, IDynamicFileArrayTexture cm, string[] cmXZnY, string[] cmY, IDynamicFileArrayTexture ng, string[] ngXZnY, string[] ngY, IDynamicFileArrayTexture ext, string[] extXZnY, string[] extY) { int index = 0; entry.SliceNear1.X = cm.GetOrAddSlice(cmXZnY[index]); entry.SliceNear1.Y = cm.GetOrAddSlice(cmY[index]); entry.SliceNear1.Z = ng.GetOrAddSlice(ngXZnY[index]); entry.SliceNear1.W = ng.GetOrAddSlice(ngY[index]); entry.SliceNear2.X = ext.GetOrAddSlice(extXZnY[index]); entry.SliceNear2.Y = ext.GetOrAddSlice(extY[index]); index = 1; entry.SliceFar1.X = cm.GetOrAddSlice(cmXZnY[index]); entry.SliceFar1.Y = cm.GetOrAddSlice(cmY[index]); entry.SliceFar1.Z = ng.GetOrAddSlice(ngXZnY[index]); entry.SliceFar1.W = ng.GetOrAddSlice(ngY[index]); entry.SliceFar2.X = ext.GetOrAddSlice(extXZnY[index]); entry.SliceFar2.Y = ext.GetOrAddSlice(extY[index]); index = 2; entry.SliceFar21.X = cm.GetOrAddSlice(cmXZnY[index]); entry.SliceFar21.Y = cm.GetOrAddSlice(cmY[index]); entry.SliceFar21.Z = ng.GetOrAddSlice(ngXZnY[index]); entry.SliceFar21.W = ng.GetOrAddSlice(ngY[index]); entry.SliceFar22.X = ext.GetOrAddSlice(extXZnY[index]); entry.SliceFar22.Y = ext.GetOrAddSlice(extY[index]); }
public void CreateOnStartup() { MyDynamicFileArrayTextureManager manager = MyManagers.DynamicFileArrayTextures; FileArrayTextureVoxelCM = manager.CreateTexture("MyGlobalResources.FileArrayTextureVoxelCM", MyFileTextureEnum.COLOR_METAL, MyGeneratedTexturePatterns.ColorMetal_BC7_SRgb, Format.BC7_UNorm_SRgb); FileArrayTextureVoxelNG = manager.CreateTexture("MyGlobalResources.FileArrayTextureVoxelNG", MyFileTextureEnum.NORMALMAP_GLOSS, MyGeneratedTexturePatterns.NormalGloss_BC7, Format.BC7_UNorm); FileArrayTextureVoxelExt = manager.CreateTexture("MyGlobalResources.FileArrayTextureVoxelExt", MyFileTextureEnum.EXTENSIONS, MyGeneratedTexturePatterns.Extension_BC7_SRgb, Format.BC7_UNorm_SRgb); }
static Vector4I GetSlices(IDynamicFileArrayTexture tex, string[] filepaths) { Vector4I v; v.X = tex.GetOrAddSlice(filepaths[0]); v.Y = tex.GetOrAddSlice(filepaths[1]); v.Z = tex.GetOrAddSlice(filepaths[2]); v.W = 0; return(v); }
int GetArrayIndexFromFilepath(string filepath, MyChannel channel, Vector2I resolution) { IDynamicFileArrayTexture fileArrayTex = GetArrayTextureFromFilepath(filepath, channel, resolution); if (fileArrayTex == null) { return(DEFAULT_ARRAY_TEXTURE_INDEX); } int index = fileArrayTex.GetOrAddSlice(filepath); return(index); }
public void DisposeTex(ref IDynamicFileArrayTexture inTex) { if (inTex == null) { return; } MyDynamicFileArrayTexture tex = (MyDynamicFileArrayTexture)inTex; //if (m_texarraysAutodestroyed.Contains(tex)) // m_texarraysAutodestroyed.Remove(tex); tex.Release(); m_objectsPool.Deallocate(tex); inTex = null; }
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)); }
static void FillVoxelMaterialEntry(ref MyVoxelMaterialEntry entry, ref MyVoxelMaterial1 voxelMaterial1) { entry.DistancesAndScale = voxelMaterial1.DistanceAndScale; entry.DistancesAndScaleFar = new Vector3(voxelMaterial1.DistanceAndScaleFar.X, voxelMaterial1.DistanceAndScaleFar.Y, 1); entry.DistancesAndScaleFar2 = new Vector3(voxelMaterial1.DistanceAndScaleFar.Z, voxelMaterial1.DistanceAndScaleFar.W, 2); entry.DistancesAndScaleFar3 = new Vector3(voxelMaterial1.DistanceAndScaleFar3.X, voxelMaterial1.DistanceAndScaleFar3.Y, 3); entry.Far3Color = voxelMaterial1.Far3Color; entry.ExtensionDetailScale = voxelMaterial1.ExtensionDetailScale; IDynamicFileArrayTexture texColorMetal = MyGlobalResources.FileArrayTextureVoxelCM; IDynamicFileArrayTexture texNormalGloss = MyGlobalResources.FileArrayTextureVoxelNG; IDynamicFileArrayTexture texExt = MyGlobalResources.FileArrayTextureVoxelExt; MyVoxelMaterialDetailSet set = voxelMaterial1.Resource; UpdateVoxelSlices(ref entry, texColorMetal, set.ColorMetalXZnY_Filepaths, set.ColorMetalY_Filepaths, texNormalGloss, set.NormalGlossXZnY_Filepaths, set.NormalGlossY_Filepaths, texExt, set.ExtY_Filepaths, set.ExtY_Filepaths); }
static Vector4I GetSlices(IDynamicFileArrayTexture tex, string[] filepaths) { Vector4I v; v.X = tex.GetOrAddSlice(filepaths[0]); v.Y = tex.GetOrAddSlice(filepaths[1]); v.Z = tex.GetOrAddSlice(filepaths[2]); v.W = 0; return v; }
public void DisposeTex(ref IDynamicFileArrayTexture inTex) { if (inTex == null) return; MyDynamicFileArrayTexture tex = (MyDynamicFileArrayTexture)inTex; //if (m_texarraysAutodestroyed.Contains(tex)) // m_texarraysAutodestroyed.Remove(tex); tex.Release(); m_objectsPool.Deallocate(tex); inTex = null; }