- Home /
How to convert a panaroma to a cubemap in runtime?
Hello,
Complete disclosure : Have paraded thro' walls of the internet to find none.
ATTEMPTING:
Literally trying to do this thro' script.
REQUIREMENT:
Let's say that we have a panorama shot such as this guy. I successfully implemented the panorama image with the above mention medium article to create a powerful VR scene.
Now, I want to implement it thro' script. Using www class, I prefer to download the texture then wrap the texture to the CubeMap.
TRYOUTS :
I do see I could use TextureImporter but it required UnityEngine class for to use it which prevents me from using it in runtime.
A lot of people have posted the same question such as this one for no response.
Or could I possible split the Texture to six images for to use to a cube map using a shader or something similar?
How could I possibly split a panorama shot to six faces for a cube map?
Thank you & help in scripts is also much appreciated.
regards,
karsnen
Did you find anything for this? Even I require converting from panaromic to cubemap for dynamically downloaded images, but not able to reach a solution.
Nope. I haven't. If you do, please let me know as well.
Answer by giuse035 · Sep 02, 2019 at 02:21 PM
You can simply extract the unitypackage file from this zip and extract that into your project, it contains the "PanoramicToCubemapRuntimeConverter" class, that contains the "ConvertPanoramaTextureToCubemap" function that converts a panoramic image to a cubemap using a compute shader.
depending on the resolution it might take a few seconds to convert it (as all the pixels have to be copied by the main cpu thread due to unity and hlsl limitations).
it should be able to convert any texture you give it, including non-panoramic ones.
the "cubemapResolution" parameter should be set to the height of the texture you are converting, but you can give it any value you want (higher resolution = higher quality but longer processing times).
the package also contains the "PanoramicToCubemapTestInterface" MonoBehaviour that you can attach to a gameobject, attach a texture to it, and then press enter (you can change key if you want) to convert the texture given to it (while in play mode) and apply it to a cubemap skybox.
The platform you are targeting however requires compute shader support.
EDIT: link does not work properly and expects an image. Use this instead.
Your answer
![](https://koobas.hobune.stream/wayback/20220612110516im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Can you change the Texture Import Settings via C# Script? 1 Answer
How to assign texture from url 1 Answer
How to fill texture that would be avaliable to ither shaders? 1 Answer