diff --git a/com.unity.render-pipelines.core/Editor/Lighting/IESImporter.cs b/com.unity.render-pipelines.core/Editor/Lighting/IESImporter.cs index 5fc3736ad1c..df8ccd54e26 100644 --- a/com.unity.render-pipelines.core/Editor/Lighting/IESImporter.cs +++ b/com.unity.render-pipelines.core/Editor/Lighting/IESImporter.cs @@ -9,7 +9,8 @@ namespace UnityEditor.Rendering /// Common class use to share code between implementation of IES Importeres /// [System.Serializable] - public class IESImporter + [ScriptedImporter(1, "ies")] + public partial class IESImporter : ScriptedImporter { /// /// IES Engine @@ -23,16 +24,18 @@ public class IESImporter /// /// Delegate prototype which will be sent by the pipeline implementation of the IES Importer + /// Must be initialized during the creation of the SRP /// - public delegate void SetupRenderPipelinePrefabLight(IESEngine engine, Light light, Texture ies); + public static event System.Action createRenderPipelinePrefabLight; /// /// Common method performing the import of the asset /// /// Asset importer context. - /// Delegate needed to perform operation which are "Render Pipeline specific" here setuping the prefab of light - public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefabLight setupRenderPipelinePrefabLight) + public override void OnImportAsset(AssetImportContext ctx) { + engine.TextureGenerationType = TextureImporterType.Default; + Texture cookieTextureCube = null; Texture cookieTexture2D = null; @@ -76,7 +79,7 @@ public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefa var iesObject = ScriptableObject.CreateInstance(); iesObject.iesMetaData = iesMetaData; - var lightObject = new GameObject(iesFileName); + GameObject lightObject = new GameObject(iesFileName); lightObject.transform.localEulerAngles = new Vector3(90f, 0f, iesMetaData.LightAimAxisRotation); @@ -86,13 +89,10 @@ public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefa light.range = 10f; // would need a better range value formula light.spotAngle = iesMetaData.SpotAngle; - setupRenderPipelinePrefabLight(engine, light, (iesMetaData.PrefabLightType == IESLightType.Point) ? cookieTextureCube : cookieTexture2D); - ctx.AddObjectToAsset("IES", iesObject); ctx.SetMainObject(iesObject); - // The light object will be automatically converted into a prefab. - ctx.AddObjectToAsset(iesFileName, lightObject); + IESImporter.createRenderPipelinePrefabLight?.Invoke(ctx, iesFileName, iesMetaData.UseIESMaximumIntensity, iesMetaData.IESMaximumIntensityUnit, iesMetaData.IESMaximumIntensity, light, (iesMetaData.PrefabLightType == IESLightType.Point) ? cookieTextureCube : cookieTexture2D); if (cookieTextureCube != null) { diff --git a/com.unity.render-pipelines.core/Editor/Lighting/IESObject.cs.meta b/com.unity.render-pipelines.core/Editor/Lighting/IESObject.cs.meta index 40682ff2c79..b539619915f 100644 --- a/com.unity.render-pipelines.core/Editor/Lighting/IESObject.cs.meta +++ b/com.unity.render-pipelines.core/Editor/Lighting/IESObject.cs.meta @@ -5,7 +5,7 @@ MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 - icon: {instanceID: 0} + icon: {fileID: 2800000, guid: 5abbb538d495cae43bdd23328a40f90b, type: 3} userData: assetBundleName: assetBundleVariant: diff --git a/com.unity.render-pipelines.core/Editor/Lighting/Icons.meta b/com.unity.render-pipelines.core/Editor/Lighting/Icons.meta new file mode 100644 index 00000000000..472c44bcb1e --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/Icons.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77235ff89f4625d44ac5ad118d1913fa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png new file mode 100644 index 00000000000..44aecbfd389 --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7704ac39a9fb2c6b516a570021f61312aa8501830392e2bf57e7b8755dc0ebba +size 4219 diff --git a/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png.meta b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png.meta new file mode 100644 index 00000000000..42b587b12c7 --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png.meta @@ -0,0 +1,96 @@ +fileFormatVersion: 2 +guid: 0283fe60f65159b4a86ebabf444e23f9 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png new file mode 100644 index 00000000000..4451772e012 --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aeecac0664591ab5e76034c3335546098b345bc187d935a35deec091d297cd0b +size 4512 diff --git a/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png.meta b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png.meta new file mode 100644 index 00000000000..45b494a7076 --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png.meta @@ -0,0 +1,96 @@ +fileFormatVersion: 2 +guid: 5abbb538d495cae43bdd23328a40f90b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs deleted file mode 100644 index d887d630a8a..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs +++ /dev/null @@ -1,52 +0,0 @@ -using UnityEditor; -using UnityEngine; -using UnityEngine.Rendering.HighDefinition; -using UnityEngine.Rendering; -using UnityEditor.Experimental.AssetImporters; - -namespace UnityEditor.Rendering.HighDefinition -{ - /// - /// Class to describe an IES file - /// - [ScriptedImporter(1, "ies")] - public partial class HDIESImporter : ScriptedImporter - { - /// - /// Data of the IES importer which is common between Core and HDRP - /// - public UnityEditor.Rendering.IESImporter commonIESImporter = new UnityEditor.Rendering.IESImporter(); - - 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; - } - } - - /// - /// Callback when the Importer is done - /// - /// Asset Importer context. - public override void OnImportAsset(AssetImportContext ctx) - { - commonIESImporter.engine.TextureGenerationType = TextureImporterType.Default; - - commonIESImporter.CommonOnImportAsset(ctx, - delegate (IESEngine engine, Light light, Texture ies) - { - SetupRenderPipelinePrefabLight(engine, light, ies); - }); - } - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporterEditor.cs b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporterEditor.cs index faf826b8f86..6fa81c1a4d0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporterEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporterEditor.cs @@ -10,7 +10,7 @@ namespace UnityEditor.Rendering.HighDefinition /// /// Class describing the logic for importer an IES file an generating the IESObject associated /// - [CustomEditor(typeof(HDIESImporter))] + [CustomEditor(typeof(IESImporter))] public partial class HDIESImporterEditor : ScriptedImporterEditor { /// @@ -73,11 +73,11 @@ public override void OnEnable() { base.OnEnable(); - PropertyFetcher entryPoint0 = new PropertyFetcher(serializedObject); - SerializedProperty entryPoint1 = entryPoint0.Find(x => x.commonIESImporter); - SerializedProperty entryPoint = entryPoint1.FindPropertyRelative("iesMetaData"); + PropertyFetcher entryPoint0 = new PropertyFetcher(serializedObject); + SerializedProperty entryPoint1 = entryPoint0.Find(x => x.iesMetaData); + //SerializedProperty entryPoint = entryPoint1.FindPropertyRelative("iesMetaData"); - iesImporterEditor.CommonOnEnable(entryPoint); + iesImporterEditor.CommonOnEnable(entryPoint1); } /// @@ -142,7 +142,7 @@ public override GUIContent GetPreviewTitle() /// Style of the background of the preview. public override void OnPreviewGUI(Rect r, GUIStyle background) { - iesImporterEditor.CommonOnPreviewGUI(r, background, target as HDIESImporter, + iesImporterEditor.CommonOnPreviewGUI(r, background, target as IESImporter, delegate (Light light, SerializedProperty useIESMaximumIntensityProp, SerializedProperty iesMaximumIntensityUnitProp, SerializedProperty iesMaximumIntensityProp) { SetupRenderPipelinePreviewLightIntensity(light, useIESMaximumIntensityProp, iesMaximumIntensityUnitProp, iesMaximumIntensityProp); diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDIESImporter.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDIESImporter.cs new file mode 100644 index 00000000000..bc25026ca09 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDIESImporter.cs @@ -0,0 +1,54 @@ +using UnityEngine; +using UnityEngine.Rendering.HighDefinition; +using UnityEngine.Rendering; +using UnityEditor; + +namespace UnityEditor.Rendering.HighDefinition +{ + /// + /// Class to describe the HDRP specific function + /// + [InitializeOnLoad] + public static class HDIESImporter + { + /// + /// Constructor of HD IES Importer + /// + /// The title of the Preview + static HDIESImporter() + { + UnityEditor.Rendering.IESImporter.createRenderPipelinePrefabLight += CreateRenderPipelinePrefabLight; + } + + /// + /// Describe how to create an Prefab for the current SRP, have to be reimplemented for each SRP. + /// + /// Context used from the asset importer + /// Filename of the current IES file + /// True if uses the internal Intensity from the file + /// The string of the units described by the intensity + /// Intensity + /// Light used for the prefab + /// Texture used for the prefab + /// + static public void CreateRenderPipelinePrefabLight(UnityEditor.Experimental.AssetImporters.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); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDIESImporter.cs.meta similarity index 83% rename from com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs.meta rename to com.unity.render-pipelines.high-definition/Editor/Lighting/HDIESImporter.cs.meta index b395dde3487..a62f003ff40 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs.meta +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDIESImporter.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 68f0d5657f1e2aa4e81a5f81ff7edcad +guid: 20c5ef58cc8c7ae47a8d2ad685d66d5c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index bda111fe718..0b1f3de3812 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -8,6 +8,7 @@ using UnityEngine.Experimental.Rendering.RenderGraphModule; #if UNITY_EDITOR using UnityEditorInternal; +using UnityEditor.Rendering; #endif #if ENABLE_VIRTUALTEXTURES @@ -1693,7 +1694,7 @@ void AddVisibleProbeVisibleIndexIfUpdateIsRequired(HDProbe probe, int visibleInI // NOTE: If the probe was rendered on the very first frame, we could have some data that was used and it wasn't in a fully initialized state, which is fine on PC, but on console // might lead to NaNs due to lack of complete initialization. To circumvent this, we force the probe to render again only if it was rendered on the first frame. Note that the problem // doesn't apply if probe is enable any frame other than the very first. Also note that we are likely to be re-rendering the probe anyway due to the issue on sky ambient probe - // (see m_SkyManager.HasSetValidAmbientProbe in this function). + // (see m_SkyManager.HasSetValidAmbientProbe in this function). if (m_FrameCount > 1) probe.SetIsRendered(m_FrameCount); @@ -2150,7 +2151,7 @@ ref _cullingResults // Render XR mirror view once all render requests have been completed if (i == 0 && renderRequest.hdCamera.camera.cameraType == CameraType.Game && renderRequest.hdCamera.camera.targetTexture == null) - { + { if (HDUtils.TryGetAdditionalCameraDataOrDefault(renderRequest.hdCamera.camera).xrRendering) { m_XRSystem.RenderMirrorView(cmd);