A game about forced loneliness, made by TACStudios
1using System.IO; 2using UnityEditor; 3using UnityEngine; 4 5namespace UnityEditor.Rendering 6{ 7 /// <summary> 8 /// Various possible type for IES, in HDRP for Rectangular light we use spot version 9 /// </summary> 10 public enum IESLightType 11 { 12 /// <summary> 13 /// Point for the IES 14 /// </summary> 15 Point, 16 /// <summary> 17 /// Spot for IES (compatible with Area Light) 18 /// </summary> 19 Spot, 20 } 21 22 /// <summary> 23 /// Possible values for the IES Size. 24 /// </summary> 25 public enum IESResolution 26 { 27 /// <summary>Size 16</summary> 28 IESResolution16 = 16, 29 /// <summary>Size 32</summary> 30 IESResolution32 = 32, 31 /// <summary>Size 64</summary> 32 IESResolution64 = 64, 33 /// <summary>Size 128</summary> 34 IESResolution128 = 128, 35 /// <summary>Size 256</summary> 36 IESResolution256 = 256, 37 /// <summary>Size 512</summary> 38 IESResolution512 = 512, 39 /// <summary>Size 1024</summary> 40 IESResolution1024 = 1024, 41 /// <summary>Size 2048</summary> 42 IESResolution2048 = 2048, 43 /// <summary>Size 4096</summary> 44 IESResolution4096 = 4096 45 } 46 47 /// <summary> 48 /// Common class to store metadata of an IES file 49 /// </summary> 50 [System.Serializable] 51 public class IESMetaData 52 { 53 /// <summary> 54 /// Version of the IES File 55 /// </summary> 56 public string FileFormatVersion; 57 /// <summary> 58 /// Total light intensity (in Lumens) stored on the file, usage of it is optional (through the prefab subasset inside the IESObject) 59 /// </summary> 60 public string IESPhotometricType; 61 /// <summary> 62 /// IES Max Intensity depends on the various information stored on the IES file 63 /// </summary> 64 public float IESMaximumIntensity; 65 /// <summary> 66 /// Unit used to measure the IESMaximumIntensity 67 /// </summary> 68 public string IESMaximumIntensityUnit; 69 70 // IES luminaire product information. 71 /// <summary> 72 /// Manufacturer of the current IES file 73 /// </summary> 74 public string Manufacturer; // IES keyword MANUFAC 75 /// <summary> 76 /// Luninaire Catalog Number 77 /// </summary> 78 public string LuminaireCatalogNumber; // IES keyword LUMCAT 79 /// <summary> 80 /// Luminaire Description 81 /// </summary> 82 public string LuminaireDescription; // IES keyword LUMINAIRE 83 /// <summary> 84 /// Lamp Catalog Number 85 /// </summary> 86 public string LampCatalogNumber; // IES keyword LAMPCAT 87 /// <summary> 88 /// Lamp Description 89 /// </summary> 90 public string LampDescription; // IES keyword LAMP 91 92 /// <summary> 93 /// Prefab Light Type (optional to generate the texture used by the renderer) 94 /// </summary> 95 public IESLightType PrefabLightType = IESLightType.Point; 96 97 /// <summary> 98 /// Spot angle used for the Gnomonic projection of the IES. This parameter will be responsible of the pixel footprint in the 2D Texture 99 /// https://en.wikipedia.org/wiki/Gnomonic_projection 100 /// </summary> 101 [Range(1f, 179f)] 102 public float SpotAngle = 120f; 103 104 /// <summary> 105 /// IES Size of the texture used (same parameter for Point and Spot) 106 /// </summary> 107 public IESResolution iesSize = IESResolution.IESResolution128; 108 109 /// <summary> 110 /// Enable attenuation used for Spot recommanded to be true, particulary with large angle of "SpotAngle" (cf. Gnomonic Projection) 111 /// </summary> 112 public bool ApplyLightAttenuation = true; 113 /// <summary> 114 /// Enable max intensity for the texture generation 115 /// </summary> 116 public bool UseIESMaximumIntensity = true; 117 118 /// <summary> 119 /// Compression used to generate the texture (CompressedHQ by default (BC7)) 120 /// </summary> 121 public TextureImporterCompression CookieCompression = TextureImporterCompression.CompressedHQ; 122 123 /// <summary> 124 /// Internally we use 2D projection, we have to choose one axis to project the IES propertly 125 /// </summary> 126 [Range(-180f, 180f)] 127 public float LightAimAxisRotation = -90f; 128 129 /// <summary> 130 /// Get Hash describing an unique IES 131 /// </summary> 132 /// <returns>The Hash of the IES Object</returns> 133 public override int GetHashCode() 134 { 135 int hash = base.GetHashCode(); 136 137 hash = hash * 23 + FileFormatVersion.GetHashCode(); 138 hash = hash * 23 + IESPhotometricType.GetHashCode(); 139 hash = hash * 23 + IESMaximumIntensity.GetHashCode(); 140 hash = hash * 23 + IESMaximumIntensityUnit.GetHashCode(); 141 142 hash = hash * 23 + Manufacturer.GetHashCode(); 143 hash = hash * 23 + LuminaireCatalogNumber.GetHashCode(); 144 hash = hash * 23 + LuminaireDescription.GetHashCode(); 145 hash = hash * 23 + LampCatalogNumber.GetHashCode(); 146 hash = hash * 23 + LampDescription.GetHashCode(); 147 148 hash = hash * 23 + PrefabLightType.GetHashCode(); 149 150 hash = hash * 23 + SpotAngle.GetHashCode(); 151 152 hash = hash * 23 + iesSize.GetHashCode(); 153 hash = hash * 23 + ApplyLightAttenuation.GetHashCode(); 154 hash = hash * 23 + UseIESMaximumIntensity.GetHashCode(); 155 156 return hash; 157 } 158 } 159 160 /// <summary> 161 /// IESObject manipulated internally (in the UI) 162 /// </summary> 163 [System.Serializable] 164 public class IESObject : ScriptableObject 165 { 166 /// <summary> 167 /// Metadata of the IES file 168 /// </summary> 169 public IESMetaData iesMetaData = new IESMetaData(); 170 } 171}