/// <summary> /// Add a new HDRP Light to a GameObject /// </summary> /// <param name="gameObject">The GameObject on which the light is going to be added</param> /// <param name="lightTypeAndShape">The Type of the HDRP light to Add</param> /// <returns>The created HDRP Light component</returns> public static HDAdditionalLightData AddHDLight(this GameObject gameObject, HDLightTypeAndShape lightTypeAndShape) { var hdLight = gameObject.AddComponent <HDAdditionalLightData>(); HDAdditionalLightData.InitDefaultHDAdditionalLightData(hdLight); hdLight.SetLightTypeAndShape(lightTypeAndShape); return(hdLight); }
internal void SetupRenderPipelinePreviewLight(Light light) { HDLightTypeAndShape hdLightTypeAndShape = (light.type == LightType.Point) ? HDLightTypeAndShape.Point : HDLightTypeAndShape.ConeSpot; HDAdditionalLightData hdLight = GameObjectExtension.AddHDLight(light.gameObject, hdLightTypeAndShape); hdLight.SetIntensity(20000f, LightUnit.Lumen); hdLight.affectDiffuse = true; hdLight.affectSpecular = false; hdLight.affectsVolumetric = false; }
/// <summary> /// Add a new HDRP Light to a GameObject /// </summary> /// <param name="gameObject">The GameObject on which the light is going to be added</param> /// <param name="lightTypeAndShape">The Type of the HDRP light to Add</param> /// <returns>The created HDRP Light component</returns> public static HDAdditionalLightData AddHDLight(this GameObject gameObject, HDLightTypeAndShape lightTypeAndShape) { var hdLight = gameObject.AddComponent <HDAdditionalLightData>(); HDAdditionalLightData.InitDefaultHDAdditionalLightData(hdLight); // Reflector have been change to true by default in the UX, however to not break compatibility // with previous 2020.2 project that use light scripting we must keep reflector to false for scripted light hdLight.enableSpotReflector = false; hdLight.SetLightTypeAndShape(lightTypeAndShape); return(hdLight); }
internal void SetupRenderPipelinePrefabLight(IESEngine engine, Light light, Texture ies) { HDLightTypeAndShape hdLightTypeAndShape = (light.type == LightType.Point) ? HDLightTypeAndShape.Point : HDLightTypeAndShape.ConeSpot; HDAdditionalLightData hdLight = GameObjectExtension.AddHDLight(light.gameObject, hdLightTypeAndShape); if (commonIESImporter.iesMetaData.UseIESMaximumIntensity) { LightUnit lightUnit = (commonIESImporter.iesMetaData.IESMaximumIntensityUnit == "Lumens") ? LightUnit.Lumen : LightUnit.Candela; hdLight.SetIntensity(commonIESImporter.iesMetaData.IESMaximumIntensity, lightUnit); if (light.type == LightType.Point) { hdLight.IESPoint = ies; } else { hdLight.IESSpot = ies; } } }
/// <summary> /// Describe how to create an Prefab for the current SRP, have to be reimplemented for each SRP. /// </summary> /// <param name="ctx">Context used from the asset importer</param> /// <param name="iesFileName">Filename of the current IES file</param> /// <param name="useIESMaximumIntensity">True if uses the internal Intensity from the file</param> /// <param name="iesMaximumIntensityUnit">The string of the units described by the intensity</param> /// <param name="iesMaximumIntensity">Intensity</param> /// <param name="light">Light used for the prefab</param> /// <param name="ies">Texture used for the prefab</param> /// <returns></returns> static public void CreateRenderPipelinePrefabLight(AssetImportContext ctx, string iesFileName, bool useIESMaximumIntensity, string iesMaximumIntensityUnit, float iesMaximumIntensity, Light light, Texture ies) { HDLightTypeAndShape hdLightTypeAndShape = (light.type == LightType.Point) ? HDLightTypeAndShape.Point : HDLightTypeAndShape.ConeSpot; HDAdditionalLightData hdLight = GameObjectExtension.AddHDLight(light.gameObject, hdLightTypeAndShape); if (useIESMaximumIntensity) { LightUnit lightUnit = (iesMaximumIntensityUnit == "Lumens") ? LightUnit.Lumen : LightUnit.Candela; hdLight.SetIntensity(iesMaximumIntensity, lightUnit); if (light.type == LightType.Point) { hdLight.IESPoint = ies; } else { hdLight.IESSpot = ies; } } // The light object will be automatically converted into a prefab. ctx.AddObjectToAsset(iesFileName + "-HDRP", light.gameObject); }
/// <summary> /// Returns true if the hd light type can be used in mixed mode /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool SupportsMixed(this HDLightTypeAndShape type) => type != HDLightTypeAndShape.TubeArea && type != HDLightTypeAndShape.DiscArea;
/// <summary> /// Returns true if the hd light type can be used for baking /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool SupportsBakedOnly(this HDLightTypeAndShape type) => type != HDLightTypeAndShape.TubeArea;
/// <summary> /// Returns true if the hd light type can be used for runtime lighting /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool SupportsRuntimeOnly(this HDLightTypeAndShape type) => type != HDLightTypeAndShape.DiscArea;
/// <summary> /// Returns true if the hd light type is an area light /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsArea(this HDLightTypeAndShape type) => type == HDLightTypeAndShape.TubeArea || type == HDLightTypeAndShape.RectangleArea || type == HDLightTypeAndShape.DiscArea;
/// <summary> /// Returns true if the hd light type is a spot light /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsSpot(this HDLightTypeAndShape type) => type == HDLightTypeAndShape.BoxSpot || type == HDLightTypeAndShape.PyramidSpot || type == HDLightTypeAndShape.ConeSpot;