Exemple #1
0
 private void RawImport(IESData iesData, string filePath, string targetPath, bool createSpotlightCookie, out EXRData exrData, out string targetFilename)
 {
     if ((createSpotlightCookie && iesData.VerticalType != VerticalType.Full) || iesData.PhotometricType == PhotometricType.TypeA)
     {
         Texture2D texture2D = null;
         base.GetComponent <IESToSpotlightCookie>().CreateSpotlightCookie(this._iesTexture, iesData, this.Resolution, false, true, out texture2D);
         exrData = new EXRData(texture2D.GetPixels(), this.Resolution, this.Resolution);
         UnityEngine.Object.DestroyImmediate(texture2D);
     }
     else
     {
         exrData = new EXRData(base.GetComponent <IESToCubemap>().CreateRawCubemap(this._iesTexture, iesData, this.Resolution), this.Resolution * 6, this.Resolution);
     }
     this.BuildTargetFilename(Path.GetFileNameWithoutExtension(filePath), targetPath, false, true, NormalizationMode.Linear, iesData, out targetFilename);
 }
Exemple #2
0
        private void RawImport(IESData iesData, string filePath, string targetPath, bool createSpotlightCookie, out EXRData exrData, out string targetFilename)
        {
            // Use the spotlight cookie shader to apply symmetry to the ies data, but don't apply any vignetting.
            if ((createSpotlightCookie && iesData.VerticalType != VerticalType.Full) || iesData.PhotometricType == PhotometricType.TypeA)
            {
                Texture2D spotlightCookie = null;
                GetComponent <IESToSpotlightCookie>().CreateSpotlightCookie(_iesTexture, iesData, Resolution, false, true, out spotlightCookie);
                exrData = new EXRData(spotlightCookie.GetPixels(), Resolution, Resolution);
                DestroyImmediate(spotlightCookie);
            }
            // Create a cubemap and extract the faces into a pixel array.
            else
            {
                exrData = new EXRData(GetComponent <IESToCubemap>().CreateRawCubemap(_iesTexture, iesData, Resolution), Resolution * 6, Resolution);
            }

            BuildTargetFilename(Path.GetFileNameWithoutExtension(filePath), targetPath, false, true, NormalizationMode.Linear, iesData, out targetFilename);
        }
Exemple #3
0
        /// <summary>
        /// Converts an IES file to either a point or spot light cookie.
        /// </summary>
        public void ConvertIES(string filePath, string targetPath, bool createSpotlightCookies, bool rawImport, bool applyVignette, out Cubemap pointLightCookie, out Texture2D spotlightCookie, out EXRData exrData, out string targetFilename)
        {
            // Parse the ies data.
            IESData iesData = ParseIES.Parse(filePath, rawImport ? NormalizationMode.Linear : NormalizationMode);

            // Create a texture from the normalized IES data.
            _iesTexture = IESToTexture.ConvertIesData(iesData);

            // Regular import - creates cookies that are directly usable within Unity.
            if (!rawImport)
            {
                exrData = default(EXRData);
                RegularImport(filePath, targetPath, createSpotlightCookies, applyVignette, out pointLightCookie, out spotlightCookie, out targetFilename, iesData);
            }
            // Raw import - creates a .exr import of the IES data instead, to give the user full control.
            else
            {
                pointLightCookie = null;
                spotlightCookie  = null;
                RawImport(iesData, filePath, targetPath, createSpotlightCookies, out exrData, out targetFilename);
            }

            // Clean up.
            if (_iesTexture != null)
            {
#if UNITY_EDITOR
                DestroyImmediate(_iesTexture);
#else
                Destroy(_iesTexture);
#endif
            }
        }
Exemple #4
0
        public void ConvertIES(string filePath, string targetPath, bool createSpotlightCookies, bool rawImport, bool applyVignette, out Cubemap pointLightCookie, out Texture2D spotlightCookie, out EXRData exrData, out string targetFilename)
        {
            IESData iesdata = ParseIES.Parse(filePath, rawImport ? NormalizationMode.Linear : this.NormalizationMode);

            this._iesTexture = IESToTexture.ConvertIesData(iesdata);
            if (!rawImport)
            {
                exrData = default(EXRData);
                this.RegularImport(filePath, targetPath, createSpotlightCookies, applyVignette, out pointLightCookie, out spotlightCookie, out targetFilename, iesdata);
            }
            else
            {
                pointLightCookie = null;
                spotlightCookie  = null;
                this.RawImport(iesdata, filePath, targetPath, createSpotlightCookies, out exrData, out targetFilename);
            }
            if (this._iesTexture != null)
            {
                UnityEngine.Object.Destroy(this._iesTexture);
            }
        }