public static void Serialize_vci_reflectionProbe_cubemap(JsonFormatter f, glTFCubemapTexture value)
        {
            f.BeginMap();


            if (!string.IsNullOrEmpty(value.compressionMode))
            {
                f.Key("compressionMode");
                f.Value(value.compressionMode);
            }

            if (true)
            {
                f.Key("mipmapCount");
                f.Value(value.mipmapCount);
            }

            if (value.texture != null)
            {
                f.Key("texture");
                Serialize_vci_reflectionProbe_cubemap_texture(f, value.texture);
            }

            if (value.mipmapTextures != null && value.mipmapTextures.Length >= 0)
            {
                f.Key("mipmapTextures");
                Serialize_vci_reflectionProbe_cubemap_mipmapTextures(f, value.mipmapTextures);
            }

            f.EndMap();
        }
        public static glTFCubemapTexture glTF_VCAST_vci_reflectionProbe_Deserializevci_reflectionProbe_cubemap(JsonNode parsed)
        {
            var value = new glTFCubemapTexture();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "compressionMode")
                {
                    value.compressionMode = kv.Value.GetString();
                    continue;
                }

                if (key == "mipmapCount")
                {
                    value.mipmapCount = kv.Value.GetInt32();
                    continue;
                }

                if (key == "texture")
                {
                    value.texture = glTF_VCAST_vci_reflectionProbe_Deserializevci_reflectionProbe_cubemap_texture(kv.Value);
                    continue;
                }

                if (key == "mipmapTextures")
                {
                    value.mipmapTextures = glTF_VCAST_vci_reflectionProbe_Deserializevci_reflectionProbe_cubemap_mipmapTextures(kv.Value);
                    continue;
                }
            }
            return(value);
        }
Beispiel #3
0
        public IEnumerator CovertToSkyboxCoroutine(glTFCubemapTexture cubemapTexture, SkyboxImporterResult result)
        {
            var cubemapResult = new CubemapTextureImporterResult();

            yield return(_importer.ConvertCubemapCoroutine(cubemapTexture, cubemapResult));

            var mat = new Material(_skyboxPrefab);

            mat.SetTexture(TexProperty, cubemapResult.Result);
            result.Result = mat;
        }
Beispiel #4
0
        public IEnumerator ConvertCubemapCoroutine(glTFCubemapTexture gltfCubemapTexture, CubemapTextureImporterResult result)
        {
            var success   = true;
            var mipLength = gltfCubemapTexture.mipmapCount; // original を含めない mipmap だけの個数
            var width     = _textureGetter(gltfCubemapTexture.texture.cubemapPositiveX.index).Texture.width;

            var cubemap = new Cubemap(width, TextureFormat.RGBAHalf, mipLength + 1);

            // Set original
            var successResult = new CoroutineSuccessResult();

            yield return(UpdateCubemapFace(gltfCubemapTexture.texture, cubemap, 0, successResult));

            success &= successResult.Result;

            // Set mipmaps
            for (var idx = 0; idx < mipLength; ++idx)
            {
                var tex                 = gltfCubemapTexture.mipmapTextures[idx];
                var mipValue            = idx + 1;
                var mipmapSuccessResult = new CoroutineSuccessResult();
                yield return(UpdateCubemapFace(tex, cubemap, mipValue, mipmapSuccessResult));

                success &= mipmapSuccessResult.Result;
            }

            // Apply
            cubemap.Apply(updateMipmaps: false, makeNoLongerReadable: true);
            yield return(null);

            if (success)
            {
                result.Result = cubemap;
            }
            else
            {
                UnityEngine.Object.DestroyImmediate(cubemap);
            }
        }