void AddTextureSet(WorldAtlasMaterial atlasMaterial, RHOTextureTable table, RHOTextureSet textureSet) { CheckThrowTextureSet(atlasMaterial, textureSet.roughness, "Roughness"); CheckThrowTextureSet(atlasMaterial, textureSet.ao, "AO"); CheckThrowTextureSet(atlasMaterial, textureSet.height, "Height"); var tSet = new TextureSet() { top = table.AddTextureJoin(textureSet.roughness.top, textureSet.height.top, textureSet.ao.top), sides = table.AddTextureJoin(textureSet.roughness.sides, textureSet.height.sides, textureSet.ao.sides), bottom = table.AddTextureJoin(textureSet.roughness.bottom, textureSet.height.bottom, textureSet.ao.bottom) }; table.indices.Add(tSet); }
RHOTextureTable LoadRHOTextureTable(WorldAtlas atlas) { var table = new RHOTextureTable(); for (int i = 0; i < atlas.materials.Length; ++i) { var m = atlas.materials[i]; if (m == null) { ThrowAssetException(atlas, "Material for terrain type '" + ((EVoxelBlockType)(i + 1)).ToString() + "' is not set!"); } if (m.textures != null) { var set = new RHOTextureSet() { roughness = m.textures.roughness, height = m.textures.height, ao = m.textures.ao }; AddTextureSet(m, table, set); } else { ThrowAssetException(m, "Missing textures for atlas material."); } } int w = -1; int h = -1; int mm = -1; var settings = new ImportSettings_t() { alphaSource = TextureImporterAlphaSource.FromGrayScale, alphaIsTransparency = false, aniso = 16, filterMode = FilterMode.Trilinear, mipmap = false, readable = true, type = TextureImporterType.Default, format = TextureImporterFormat.Alpha8 }; foreach (var t in table.roughness) { CheckTextureSizeAndFormatAndThrow(ref w, ref h, ref mm, settings, t, "Roughness"); } foreach (var t in table.height) { CheckTextureSizeAndFormatAndThrow(ref w, ref h, ref mm, settings, t, "Height"); } foreach (var t in table.ao) { CheckTextureSizeAndFormatAndThrow(ref w, ref h, ref mm, settings, t, "AO"); } return(table); }