浏览代码

HDRenderPipeline: move DefaultMaterial and Default Shader to resource pipeline

- Also fix an issue with enableDBuffer not correctly take into account in depth prepass
/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
f784a196
共有 8 个文件被更改,包括 19 次插入57 次删除
  1. 15
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
  2. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDEditorUtils.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.Styles.cs
  4. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs
  5. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  6. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.cs
  7. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
  8. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs

15
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs


get { return HDEditorUtils.GetHDRenderPipelinePath() + "RenderPipelineResources/HDRenderPipelineResources.asset"; }
}
static string s_DefaultMaterialPath
{
get { return HDEditorUtils.GetHDRenderPipelinePath() + "RenderPipelineResources/DefaultHDMaterial.mat"; }
}
static string s_DefaultShaderPath
{
get { return HDEditorUtils.GetHDRenderPipelinePath() + "Material/Lit/Lit.shader"; }
}
class DoCreateNewAssetHDRenderPipeline : ProjectWindowCallback.EndNameEditAction
{
public override void Action(int instanceId, string pathName, string resourceFile)

// Load default renderPipelineResources / Material / Shader
newAsset.renderPipelineResources = AssetDatabase.LoadAssetAtPath<RenderPipelineResources>(s_RenderPipelineResourcesPath);
newAsset.defaultDiffuseMaterial = AssetDatabase.LoadAssetAtPath<Material>(s_DefaultMaterialPath);
newAsset.defaultShader = AssetDatabase.LoadAssetAtPath<Shader>(s_DefaultShaderPath);
AssetDatabase.CreateAsset(newAsset, pathName);
ProjectWindowUtil.ShowCreatedAsset(newAsset);
}

string HDRenderPipelinePath = HDEditorUtils.GetHDRenderPipelinePath();
string PostProcessingPath = HDEditorUtils.GetPostProcessingPath();
string CorePath = HDEditorUtils.GetCorePath();
newAsset.defaultDiffuseMaterial = Load<Material>(HDRenderPipelinePath + "RenderPipelineResources/DefaultHDMaterial.mat");
newAsset.defaultShader = Load<Shader>(HDRenderPipelinePath + "Material/Lit/Lit.shader");
newAsset.debugDisplayLatlongShader = Load<Shader>(HDRenderPipelinePath + "Debug/DebugDisplayLatlong.Shader");
newAsset.debugViewMaterialGBufferShader = Load<Shader>(HDRenderPipelinePath + "Debug/DebugViewMaterialGBuffer.Shader");

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDEditorUtils.cs


{
var srpPath = GetScriptableRenderPipelinePath();
if (srpPath != null)
return Path.Combine(srpPath, "ScriptableRenderPipeline/Core/CoreRP");
return Path.Combine(srpPath, "ScriptableRenderPipeline/Core/CoreRP/");
return "Packages/com.unity.render-pipelines.core/";
return "Packages/com.unity.render-pipelines.core/CoreRP/";
}
public static bool ResetMaterialKeywords(Material material)

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.Styles.cs


{
public readonly GUIContent defaults = new GUIContent("Defaults");
public readonly GUIContent renderPipelineResources = new GUIContent("Render Pipeline Resources", "Set of resources that need to be loaded when creating stand alone");
public readonly GUIContent defaultDiffuseMaterial = new GUIContent("Default Diffuse Material", "Material to use when creating objects");
public readonly GUIContent defaultShader = new GUIContent("Default Shader", "Shader to use when creating materials");
public readonly GUIContent settingsLabel = new GUIContent("Settings");

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs


public sealed partial class HDRenderPipelineInspector : HDBaseEditor<HDRenderPipelineAsset>
{
SerializedProperty m_RenderPipelineResources;
SerializedProperty m_DefaultDiffuseMaterial;
SerializedProperty m_DefaultShader;
// Global Frame Settings
// Global Render settings

void InitializeProperties()
{
m_RenderPipelineResources = properties.Find("m_RenderPipelineResources");
m_DefaultDiffuseMaterial = properties.Find("m_DefaultDiffuseMaterial");
m_DefaultShader = properties.Find("m_DefaultShader");
// Global FrameSettings
// Global Render settings

void SettingsUI(HDRenderPipelineAsset hdAsset)
{
EditorGUILayout.LabelField(s_Styles.settingsLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
GlobalRenderSettingsUI(hdAsset);
GlobalShadowSettingsUI(hdAsset);
GlobalLightLoopSettingsUI(hdAsset);

RendereringSettingsUI(hdAsset);
LightLoopSettingsUI(hdAsset);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_SubsurfaceScatteringSettings, s_Styles.sssSettings);
}
protected override void OnEnable()

serializedObject.Update();
EditorGUILayout.LabelField(s_Styles.defaults, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_DefaultDiffuseMaterial, s_Styles.defaultDiffuseMaterial);
EditorGUILayout.PropertyField(m_DefaultShader, s_Styles.defaultShader);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_SubsurfaceScatteringSettings, s_Styles.sssSettings);
EditorGUILayout.Space();
SettingsUI(m_Target);

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd, true);
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd);
RenderObjectsVelocity(m_CullResults, hdCamera, renderContext, cmd);

// Forward only renderer: We always render everything
// Deferred renderer: We render a depth prepass only if engine request it. We can decide if we render everything or only opaque alpha tested object.
// Forward opaque with deferred renderer (DepthForwardOnly pass): We always render everything
void RenderDepthPrepass(CullResults cull, HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd, bool hasDecals)
void RenderDepthPrepass(CullResults cull, HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
// In case of deferred renderer, we can have forward opaque material. These materials need to be render in the depth buffer to correctly build the light list.
// And they will tag the stencil to not be lit during the deferred lighting pass.

using (new ProfilingSample(cmd, addAlphaTestedOnly ? "Depth Prepass alpha test" : "Depth Prepass", GetSampler(CustomSamplerId.DepthPrepass)))
{
CoreUtils.SetRenderTarget(cmd, m_CameraDepthStencilBufferRT);
if (hasDecals || (addFullDepthPrepass && !addAlphaTestedOnly)) // Always true in case of forward rendering, use in case of deferred rendering if requesting a full depth prepass
if (m_FrameSettings.enableDBuffer || (addFullDepthPrepass && !addAlphaTestedOnly)) // Always true in case of forward rendering, use in case of deferred rendering if requesting a full depth prepass
{
// We render first the opaque object as opaque alpha tested are more costly to render and could be reject by early-z (but not Hi-z as it is disable with clip instruction)
// This is handled automatically with the RenderQueue value (OpaqueAlphaTested have a different value and thus are sorted after Opaque)

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.cs


[SerializeField]
public SubsurfaceScatteringSettings sssSettings;
// Default Material / Shader
[SerializeField]
Material m_DefaultDiffuseMaterial;
[SerializeField]
Shader m_DefaultShader;
public Material defaultDiffuseMaterial
{
get { return m_DefaultDiffuseMaterial; }
set { m_DefaultDiffuseMaterial = value; }
}
public Shader defaultShader
{
get { return m_DefaultShader; }
set { m_DefaultShader = value; }
}
return m_DefaultShader;
return m_RenderPipelineResources.defaultShader;
return m_DefaultDiffuseMaterial;
return m_RenderPipelineResources.defaultDiffuseMaterial;
}
public override Material GetDefaultParticleMaterial()

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset


m_Script: {fileID: 11500000, guid: 8b6f86e1523e69a4282e92d393be89a4, type: 3}
m_Name: HDRenderPipelineResources
m_EditorClassIdentifier:
defaultDiffuseMaterial: {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17,
type: 2}
defaultShader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
debugDisplayLatlongShader: {fileID: 4800000, guid: c1d1d149a043a5349ba367da6c2051ba,
type: 3}
debugViewMaterialGBufferShader: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d,

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs


{
public class RenderPipelineResources : ScriptableObject
{
// Default Material / Shader
public Material defaultDiffuseMaterial;
public Shader defaultShader;
// Debug
public Shader debugDisplayLatlongShader;
public Shader debugViewMaterialGBufferShader;

正在加载...
取消
保存