void LoadTerrainTextures(WorldAtlas atlas, WorldAtlasClientData clientData) { LoadTextureArrayChannel(atlas, clientData, (cd, arr) => cd.albedo.textureArray = arr, "Albedo"); LoadTextureArrayChannel(atlas, clientData, (cd, arr) => cd.normals.textureArray = arr, "Normals"); //LoadTextureArrayChannel(atlas, clientData, (cd, arr) => cd.roughness.textureArray = arr, "Roughness"); //LoadTextureArrayChannel(atlas, clientData, (cd, arr) => cd.ao.textureArray = arr, "AO"); //LoadTextureArrayChannel(atlas, clientData, (cd, arr) => cd.height.textureArray = arr, "Height"); LoadTextureArrayChannel(atlas, clientData, (cd, arr) => cd.rho.textureArray = arr, "RHO"); }
void LoadTextureArrayChannel(WorldAtlas atlas, WorldAtlasClientData clientData, Action <WorldAtlasClientData, Texture2DArray> set, string channelName) { var arr = LoadTextureArray(atlas, channelName); if (arr == null) { RebuildTextureArray(); arr = LoadTextureArray(atlas, channelName); if (arr == null) { ThrowAssetException(atlas, "Unable to load " + channelName + " texture array!"); } } set(clientData, arr); }
WorldAtlasClientData SaveAtlasClientData(WorldAtlas atlas, WorldAtlasClientData clientData) { var folder = atlas.GetAssetFolderPath(); var path = folder + "/Resources/" + atlas.name + "_AtlasClientData.asset"; var existing = AssetDatabase.LoadAssetAtPath <WorldAtlasClientData>(path); if (existing != null) { EditorUtility.CopySerialized(clientData, existing); EditorUtility.SetDirty(existing); clientData = existing; } else { Utils.CreateAssetFolder(folder, "Resources"); AssetDatabase.CreateAsset(clientData, path); clientData = AssetDatabase.LoadAssetAtPath <WorldAtlasClientData>(path); } return(clientData); }
void LoadRHOTextureChannel(WorldAtlas atlas, TextureBundle[] bundles, WorldAtlasClientData clientData) { var table = LoadRHOTextureTable(atlas); TextureBundle.CopyChannelTextureSet(bundles, table.indices, (b, s) => { b.rho = s; return(b); }); }