1 (edited by philzmz 2022-01-14 18:53:59)

Topic: Texture vs Texture2D ?

Hello
I  download the 6 textures of a cube from the web using wwwobject action in playmaker. So I get a TextureArray with the 6 sides.
But I can't set the CubeFacesPanorenderer with this array, as it seems that it needs a 2D Texture array.
Any idea or workaround ? Or maybe use regular textures, as the sphericalpanorendrer does ?
Best regards
Phil

Re: Texture vs Texture2D ?

Hello.

Unfortunately, I didn't understand your problem.
WWW Object returns you a Texture, and Create Cube Faces Pano also accepts Textures.
Also, if you have problems with Playmaker, you can use the Downloader component, which will download and set all sides of the panorama.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

3 (edited by philzmz 2022-01-17 11:49:26)

Re: Texture vs Texture2D ?

Hello Alex thanks for your answer.

Yes, I know that I can create a cubefaces panorama with a PM action, but what I want to do is to set the faces of a panorama already in the scene. I made a short video to explain my concern and the workaround that I found.

https://www.youtube.com/watch?v=1RJmTdjbaTs

The array that is created is an object array, instead of a texture array, but if i change it it works. I don't know if this is abug or something normal.

And as you suggested I tried the - very interesting - downloader component, but I can't make it working, maybe I am wrong somewhere ? Please have a look to this 2nd video : https://www.youtube.com/watch?v=U6nRLsN1CrA

I have a question : I use cubefaces as my panorama is 27k, over the 16k allowed by HugeTexture. Which is the more efficient, in terms of performance / weight ?

- to use 1 x 26624 RAW texture with HugeTexture with a spherical (which should be set if I understand to 26624x26624 pixels).
- or to use 6 x 8k x 8k textures with a cubeface panorama

It seems to me that the 2nd option should be better, but I need you to confirm.

Best regards, Phil

Re: Texture vs Texture2D ?

I see.
Ideally, you should ask the Playmaker developer to fix this, because there are so many uses of Texture2D in Unity API.
But it will most likely not be fast, so here is the action for you:

using InfinityCode.uPano;
using InfinityCode.uPano.Renderers;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions.uPano
{
    [ActionCategory(uPanoCategories.PANORAMA)]
    [Tooltip("Set Cube Face Textures")]
    public class SetCubeFaceTextures : FsmPanoStateAction
    {
        [RequiredField]
        public FsmObject panorama;

        public FsmTexture topTexture;
        public FsmTexture frontTexture;
        public FsmTexture leftTexture;
        public FsmTexture backTexture;
        public FsmTexture rightTexture;
        public FsmTexture bottomTexture;

        public override void Reset()
        {
            panorama = null;
            topTexture = null;
            frontTexture = null;
            leftTexture = null;
            backTexture = null;
            rightTexture = null;
            bottomTexture = null;
        }

        public override void OnEnter()
        {
            DoEnter();
            Finish();
        }

        private void DoEnter()
        {
            if (panorama.IsNone)
            {
                Debug.LogError("Requires reference to a panorama or Pano Renderer");
                return;
            }

            Pano pano = GetPano(panorama);
            if (pano == null)
            {
                Debug.LogError("Panorama field should contain a reference to a panorama or Pano Renderer");
                return;
            }

            GameObject go = pano.gameObject;

            CubeFacesPanoRenderer pr = pano.panoRenderer as CubeFacesPanoRenderer;
            if (pr == null)
            {
                Debug.LogError("Requires CubeFacesPanoRenderer");
                return;
            }

            pr.textures = new[]
            {
                topTexture.Value as Texture2D,
                frontTexture.Value as Texture2D,
                leftTexture.Value as Texture2D,
                backTexture.Value as Texture2D,
                rightTexture.Value as Texture2D,
                bottomTexture.Value as Texture2D,
            };
        }
    }
}

You cannot use Downloader for local files. It won't work.
The fact that your browser understands that these are local files and can open them means nothing, because the Unity API expects remote data.

6 x 8k x 8k textures will work more efficiently.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Texture vs Texture2D ?

Thanks a lot Alex !