/// <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 } }
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); } }
/// <summary> /// Converts an IES file to either a point or spot light cookie. /// </summary> public void ConvertIES(string filePath, string targetPath, bool createSpotlightCookies, out Cubemap pointLightCookie, out Texture2D spotlightCookie, out string targetFilename) { // Parse the ies data. IESData iesData = ParseIES.Parse(filePath, SquashHistogram); IesTexture = IESToTexture.ConvertIesData(iesData, Resolution); // If spot light cookie creation is enabled, check if the ies data can be projected into a spot light cookie. // Only half the sphere may be provided if the ies data is to fit inside a spot light cookie. if (createSpotlightCookies && iesData.VerticalType != VerticalType.Full) { pointLightCookie = null; GetComponent <IESToSpotlightCookie>().CreateSpotlightCookie(IesTexture, iesData, Resolution, out spotlightCookie); } // Create a point light cookie cubemap in all other cases. else { spotlightCookie = null; GetComponent <IESToCubemap>().CreateCubemap(IesTexture, iesData, Resolution, out pointLightCookie); } // Create the target file name and required folders. BuildTargetFilename(Path.GetFileNameWithoutExtension(filePath), targetPath, pointLightCookie != null, SquashHistogram, out targetFilename); }