- Home /
from texture2D to cubemap
Hi ,
I created a texture2D object from an image I pick from gallery (I'm working on an android app). I have a Material called "main" in my Resources folder , and it is a Skybox/Cubemap material. If I want to set the material texture in my script, I need a Cubemap texture, not a Texture2D texture. So, my question is: how can I transform my Texture2D to Cubemap? I post a piece of my code to better explain my problem (I don't know what to write in "//from mainImage to cubetex ?????" part).
private Texture2D mainImage;
private Cubemap cubetex = new Cubemap (2048, TextureFormat.RGB24, false);
private Material mat;
mainImage = new Texture2D (www.texture.width, www.texture.height);
mainImage.SetPixels32 (www.texture.GetPixels32());
mainImage.Apply ();
// from mainImage to cubetex ?????
mat = Resources.Load("main") as Material;
mat.SetTexture ("_Tex", cubetex);
Did you figure it out now? I am trying to do the same. I am trying to get color[] from Texture2D and setting it in Cubemap. Another way i want to try would be to break it down to six and load them according to the skybox. ,@lukephx Did you manage to figure it out? I am trying to do the same. I am thinking about trying getting color[] from Texture2D and setting them to Cubemap. The another way would be to break the Texture2D down to six sides and load them accordingly in the Skybox.
Hi, I solved it downloading a free asset called "panorama to cubemap". It divides the Texture to 6 sides and load them to the 6 faces of a cubemap (as you said). Hope it will help you :)