using UnityEngine; using UnityEngine.Experimental.Rendering.HDPipeline; namespace UnityEditor.Experimental.Rendering.HDPipeline { using UnityObject = UnityEngine.Object; static class HDAssetFactory { static string s_RenderPipelineResourcesPath { get { return HDEditorUtils.GetHDRenderPipelinePath() + "RenderPipelineResources/HDRenderPipelineResources.asset"; } } [MenuItem("RenderPipeline/HDRenderPipeline/Create Pipeline Asset", false, 16)] static void CreateHDRenderPipeline() { var instance = ScriptableObject.CreateInstance(); AssetDatabase.CreateAsset(instance, HDEditorUtils.GetHDRenderPipelinePath() + "HDRenderPipelineAsset.asset"); // If it exist, load renderPipelineResources instance.renderPipelineResources = AssetDatabase.LoadAssetAtPath(s_RenderPipelineResourcesPath); } // TODO skybox/cubemap [MenuItem("RenderPipeline/HDRenderPipeline/Create Resources Asset", false, 15)] static void CreateRenderPipelineResources() { string HDRenderPipelinePath = HDEditorUtils.GetHDRenderPipelinePath(); string PostProcessingPath = HDEditorUtils.GetPostProcessingPath(); string CorePath = HDEditorUtils.GetCorePath(); var instance = ScriptableObject.CreateInstance(); instance.debugDisplayLatlongShader = Load(HDRenderPipelinePath + "Debug/DebugDisplayLatlong.Shader"); instance.debugViewMaterialGBufferShader = Load(HDRenderPipelinePath + "Debug/DebugViewMaterialGBuffer.Shader"); instance.debugViewTilesShader = Load(HDRenderPipelinePath + "Debug/DebugViewTiles.Shader"); instance.debugFullScreenShader = Load(HDRenderPipelinePath + "Debug/DebugFullScreen.Shader"); instance.deferredShader = Load(HDRenderPipelinePath + "Lighting/Deferred.Shader"); instance.screenSpaceAmbientOcclusionShader = Load(HDRenderPipelinePath + "Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusion.Shader"); instance.subsurfaceScatteringCS = Load(HDRenderPipelinePath + "Material/Lit/Resources/SubsurfaceScattering.compute"); instance.volumetricLightingCS = Load(HDRenderPipelinePath + "Lighting/Volumetrics/Resources/VolumetricLighting.compute"); instance.gaussianPyramidCS = Load(PostProcessingPath + "Shaders/Builtins/GaussianDownsample.compute"); instance.depthPyramidCS = Load(HDRenderPipelinePath + "RenderPipelineResources/DepthDownsample.compute"); instance.copyChannelCS = Load(CorePath + "Resources/GPUCopy.compute"); instance.applyDistortionCS = Load(HDRenderPipelinePath + "RenderPipelineResources/ApplyDistorsion.compute"); instance.clearDispatchIndirectShader = Load(HDRenderPipelinePath + "Lighting/TilePass/cleardispatchindirect.compute"); instance.buildDispatchIndirectShader = Load(HDRenderPipelinePath + "Lighting/TilePass/builddispatchindirect.compute"); instance.buildScreenAABBShader = Load(HDRenderPipelinePath + "Lighting/TilePass/scrbound.compute"); instance.buildPerTileLightListShader = Load(HDRenderPipelinePath + "Lighting/TilePass/lightlistbuild.compute"); instance.buildPerBigTileLightListShader = Load(HDRenderPipelinePath + "Lighting/TilePass/lightlistbuild-bigtile.compute"); instance.buildPerVoxelLightListShader = Load(HDRenderPipelinePath + "Lighting/TilePass/lightlistbuild-clustered.compute"); instance.buildMaterialFlagsShader = Load(HDRenderPipelinePath + "Lighting/TilePass/materialflags.compute"); instance.deferredComputeShader = Load(HDRenderPipelinePath + "Lighting/TilePass/Deferred.compute"); instance.deferredDirectionalShadowComputeShader = Load(HDRenderPipelinePath + "Lighting/TilePass/DeferredDirectionalShadow.compute"); // SceneSettings // These shaders don't need to be reference by RenderPipelineResource as they are not use at runtime (only to draw in editor) // instance.drawSssProfile = UnityEditor.AssetDatabase.LoadAssetAtPath(HDRenderPipelinePath + "SceneSettings/DrawSssProfile.shader"); // instance.drawTransmittanceGraphShader = UnityEditor.AssetDatabase.LoadAssetAtPath(HDRenderPipelinePath + "SceneSettings/DrawTransmittanceGraph.shader"); instance.cameraMotionVectors = Load(HDRenderPipelinePath + "RenderPipelineResources/CameraMotionVectors.shader"); // Sky instance.blitCubemap = Load(HDRenderPipelinePath + "Sky/BlitCubemap.shader"); instance.buildProbabilityTables = Load(HDRenderPipelinePath + "Sky/BuildProbabilityTables.compute"); instance.computeGgxIblSampleData = Load(HDRenderPipelinePath + "Sky/ComputeGgxIblSampleData.compute"); instance.GGXConvolve = Load(HDRenderPipelinePath + "Sky/GGXConvolve.shader"); // Skybox/Cubemap is a builtin shader, must use Sahder.Find to access it. It is fine because we are in the editor instance.skyboxCubemap = Shader.Find("Skybox/Cubemap"); AssetDatabase.CreateAsset(instance, s_RenderPipelineResourcesPath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } // Note: move this to a static using once we can target C#6+ static T Load(string path) where T : UnityObject { return AssetDatabase.LoadAssetAtPath(path); } } }