Is there any way to get the cubemap out from the .ies file? Its right there but I need it as a stand alone asset instead of it being baked inside the .ies.
Select the cubemap sub-asset, then duplicate it (Ctrl+D by default)
Thank you, I tried everything but this it seems! haha
I tried looking for the duplicate from the right click menu.
Additional question, how would I access the texture files the cubemap is made out of? I would need to fix the alpha channel on the textures, but the textures seem to be inside the .cubemap file itself.
I think you might be mixing up some concepts here. When you import a source asset like a .png file into Unity, it generates an engine-native type, like Cubemap or Texture2D from it. Another way you can obtain a Cubemap is to generate it programmatically, by creating a Cubemap object from code and filling in data using something like SetPixels. When you serialize an object like that to disk, it is serialized in an engine-native format, usually as YAML.
That is what has happened in the case of the IES importer. The importer generates a Cubemap from code and stores it on disk in engine-native format. There are no source assets like .png’s or .exr’s associated with it - there never were any. The cubemap isn’t “made of texture files”, it’s just a blob of YAML data. If you open it in a text editor, you’ll see that.
If you want to extract the individual face textures into source assets, you’ll have to manually extract the pixel data and encode it to something like png. Something like this:
using System.IO;
using UnityEditor;
using UnityEngine;
public class ExtractCubemap
{
[MenuItem("Cubemap/Extract Cubemap")]
public static void Extract()
{
var cubemap = Selection.activeObject as Cubemap;
string path = AssetDatabase.GetAssetPath(cubemap);
for (int i = 0; i < 6; i++)
{
var tex = new Texture2D(cubemap.width, cubemap.height, cubemap.format, false);
tex.SetPixels(cubemap.GetPixels((CubemapFace)i));
File.WriteAllBytes($"{path}-face{i}.png", tex.EncodeToPNG());
}
AssetDatabase.Refresh();
}
}
This script just takes whatever Cubemap you have selected in the Project view and dumps the faces to 6 files.
Yes I was aware that the cubemap is created from data when it comes to IES, but I was under the impression that unity import generates pixel data to create the cubemap, as in I thought the importer generates 6 texture files and arranges them as a cubemap.
Thanks a lot for the help with a scrip to do this!
