public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
        {
            var extension = new Sein_rendererExtension();

            if (extensionToken != null)
            {
                extension.castShadows    = (bool)extensionToken.Value["castShadows"];
                extension.receiveShadows = (bool)extensionToken.Value["receiveShadows"];
            }

            return(new Sein_rendererExtension());
        }
コード例 #2
0
        public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
        {
            var extension = new Sein_rendererExtension();

            if (extensionToken.Value["castShadows"] == null)
            {
                extension.gammaCorrection = (bool)extensionToken.Value["gammaCorrection"];
                extension.useHDR          = (bool)extensionToken.Value["useHDR"];
                extension.exposure        = (float)extensionToken.Value["exposure"];
            }
            else
            {
                extension.castShadows    = (bool)extensionToken.Value["castShadows"];
                extension.receiveShadows = (bool)extensionToken.Value["receiveShadows"];
            }

            return(new Sein_rendererExtension());
        }
コード例 #3
0
        public override void Serialize(ExporterEntry entry, Dictionary <string, Extension> extensions, UnityEngine.Object component = null, object options = null)
        {
            Sein_rendererExtension extension;

            if (component == null)
            {
                extension = new Sein_rendererExtension {
                    isGlobal        = true,
                    gammaCorrection = PlayerSettings.colorSpace == ColorSpace.Linear,
                    //@todo: support hdr
                    useHDR   = false,
                    exposure = 0
                };
            }
            else
            {
                extension = new Sein_rendererExtension {
                    isGlobal = false
                };
                var mr = component as Renderer;

                var lightmapIndex = mr.lightmapIndex;
                if (ExporterSettings.Lighting.lightMap && lightmapIndex > -1)
                {
                    Vector4 lightmapScaleOffset = mr.lightmapScaleOffset;
                    var     lightData           = LightmapSettings.lightmaps[lightmapIndex];
                    var     lightTexture        = lightData.lightmapColor;
                    var     lightTextureIndex   = entry.SaveTexture(lightTexture, maxSize: ExporterSettings.Lighting.lightMapSize);
                    extension.uvScale       = new Vector2(lightmapScaleOffset.x, lightmapScaleOffset.y);
                    extension.uvOffset      = new Vector2(lightmapScaleOffset.z, lightmapScaleOffset.w);
                    extension.lightMapIndex = lightTextureIndex.Id;
                }

                extension.castShadows    = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On;
                extension.receiveShadows = mr.receiveShadows;
            }

            AddExtension(extensions, extension);
        }
        public override void Serialize(ExporterEntry entry, Dictionary <string, Extension> extensions, UnityEngine.Object component = null)
        {
            var extension = new Sein_rendererExtension();
            var mr        = component as Renderer;

            var lightmapIndex = mr.lightmapIndex;

            if (ExporterSettings.Lighting.lightMap && lightmapIndex > -1)
            {
                Vector4 lightmapScaleOffset = mr.lightmapScaleOffset;
                var     lightData           = LightmapSettings.lightmaps[lightmapIndex];
                var     lightTexture        = lightData.lightmapColor;
                var     lightTextureIndex   = entry.SaveTextureHDR(lightTexture, ExporterSettings.Lighting.lightMapType, ExporterSettings.Lighting.lightMapSize);
                extension.uvScale       = new Vector2(lightmapScaleOffset.x, lightmapScaleOffset.y);
                extension.uvOffset      = new Vector2(lightmapScaleOffset.z, lightmapScaleOffset.w);
                extension.lightMapIndex = lightTextureIndex.Id;
            }

            extension.castShadows     = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On;
            extension.receiveShadows  = mr.receiveShadows;
            extension.gammaCorrection = PlayerSettings.colorSpace == ColorSpace.Linear;

            AddExtension(extensions, extension);
        }