using System.IO;
using UnityEditor;
using UnityEngine;
namespace UnityEditor.Rendering
{
///
/// Various possible type for IES, in HDRP for Rectangular light we use spot version
///
public enum IESLightType
{
///
/// Point for the IES
///
Point,
///
/// Spot for IES (compatible with Area Light)
///
Spot,
}
///
/// Possible values for the IES Size.
///
public enum IESResolution
{
/// Size 16
IESResolution16 = 16,
/// Size 32
IESResolution32 = 32,
/// Size 64
IESResolution64 = 64,
/// Size 128
IESResolution128 = 128,
/// Size 256
IESResolution256 = 256,
/// Size 512
IESResolution512 = 512,
/// Size 1024
IESResolution1024 = 1024,
/// Size 2048
IESResolution2048 = 2048,
/// Size 4096
IESResolution4096 = 4096
}
///
/// Common class to store metadata of an IES file
///
[System.Serializable]
public class IESMetaData
{
///
/// Version of the IES File
///
public string FileFormatVersion;
///
/// Total light intensity (in Lumens) stored on the file, usage of it is optional (through the prefab subasset inside the IESObject)
///
public string IESPhotometricType;
///
/// IES Max Intensity depends on the various information stored on the IES file
///
public float IESMaximumIntensity;
///
/// Unit used to measure the IESMaximumIntensity
///
public string IESMaximumIntensityUnit;
// IES luminaire product information.
///
/// Manufacturer of the current IES file
///
public string Manufacturer; // IES keyword MANUFAC
///
/// Luninaire Catalog Number
///
public string LuminaireCatalogNumber; // IES keyword LUMCAT
///
/// Luminaire Description
///
public string LuminaireDescription; // IES keyword LUMINAIRE
///
/// Lamp Catalog Number
///
public string LampCatalogNumber; // IES keyword LAMPCAT
///
/// Lamp Description
///
public string LampDescription; // IES keyword LAMP
///
/// Prefab Light Type (optional to generate the texture used by the renderer)
///
public IESLightType PrefabLightType = IESLightType.Point;
///
/// Spot angle used for the Gnomonic projection of the IES. This parameter will be responsible of the pixel footprint in the 2D Texture
/// https://en.wikipedia.org/wiki/Gnomonic_projection
///
[Range(1f, 179f)]
public float SpotAngle = 120f;
///
/// IES Size of the texture used (same parameter for Point and Spot)
///
public IESResolution iesSize = IESResolution.IESResolution128;
///
/// Enable attenuation used for Spot recommanded to be true, particulary with large angle of "SpotAngle" (cf. Gnomonic Projection)
///
public bool ApplyLightAttenuation = true;
///
/// Enable max intensity for the texture generation
///
public bool UseIESMaximumIntensity = true;
///
/// Compression used to generate the texture (CompressedHQ by default (BC7))
///
public TextureImporterCompression CookieCompression = TextureImporterCompression.CompressedHQ;
///
/// Internally we use 2D projection, we have to choose one axis to project the IES propertly
///
[Range(-180f, 180f)]
public float LightAimAxisRotation = -90f;
///
/// Get Hash describing an unique IES
///
/// The Hash of the IES Object
public override int GetHashCode()
{
int hash = base.GetHashCode();
hash = hash * 23 + FileFormatVersion.GetHashCode();
hash = hash * 23 + IESPhotometricType.GetHashCode();
hash = hash * 23 + IESMaximumIntensity.GetHashCode();
hash = hash * 23 + IESMaximumIntensityUnit.GetHashCode();
hash = hash * 23 + Manufacturer.GetHashCode();
hash = hash * 23 + LuminaireCatalogNumber.GetHashCode();
hash = hash * 23 + LuminaireDescription.GetHashCode();
hash = hash * 23 + LampCatalogNumber.GetHashCode();
hash = hash * 23 + LampDescription.GetHashCode();
hash = hash * 23 + PrefabLightType.GetHashCode();
hash = hash * 23 + SpotAngle.GetHashCode();
hash = hash * 23 + iesSize.GetHashCode();
hash = hash * 23 + ApplyLightAttenuation.GetHashCode();
hash = hash * 23 + UseIESMaximumIntensity.GetHashCode();
return hash;
}
}
///
/// IESObject manipulated internally (in the UI)
///
[System.Serializable]
public class IESObject : ScriptableObject
{
///
/// Metadata of the IES file
///
public IESMetaData iesMetaData = new IESMetaData();
}
}