/
RenderPipelineAsset.cs
121 lines (87 loc) · 4.06 KB
/
RenderPipelineAsset.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
namespace UnityEngine.Rendering
{
public abstract partial class RenderPipelineAsset : ScriptableObject
{
internal RenderPipeline InternalCreatePipeline()
{
RenderPipeline pipeline = null;
try
{
EnsureGlobalSettings();
pipeline = CreatePipeline();
}
catch (InvalidImportException)
{
// This can be called at a time where AssetDatabase is not available for loading.
// When this happens, the GUID can be get but the resource loaded will be null.
// In SRP using the ResourceReloader mechanism in CoreRP, it checks this and add InvalidImport data when this occurs.
}
catch (Exception e)
{
Debug.LogException(e);
}
if (pipelineType != null && pipeline != null && pipelineType != pipeline.GetType())
Debug.LogWarning($"{GetType()}.{nameof(CreatePipeline)}. Type error: {pipelineType} is different from {pipeline.GetType()}. The property {nameof(pipelineType)} must return the same type");
return pipeline;
}
public virtual int terrainBrushPassIndex => (int)UnityEngine.Rendering.RenderQueue.GeometryLast;
public virtual Material defaultMaterial => null;
public virtual Shader autodeskInteractiveShader => null;
public virtual Shader autodeskInteractiveTransparentShader => null;
public virtual Shader autodeskInteractiveMaskedShader => null;
public virtual Shader terrainDetailLitShader => null;
public virtual Shader terrainDetailGrassShader => null;
public virtual Shader terrainDetailGrassBillboardShader => null;
public virtual Material defaultParticleMaterial => null;
public virtual Material defaultLineMaterial => null;
public virtual Material defaultTerrainMaterial => null;
public virtual Material defaultUIMaterial => null;
public virtual Material defaultUIOverdrawMaterial => null;
public virtual Material defaultUIETC1SupportedMaterial => null;
public virtual Material default2DMaterial => null;
public virtual Material default2DMaskMaterial => null;
public virtual Shader defaultShader => null;
public virtual Shader defaultSpeedTree7Shader => null;
public virtual Shader defaultSpeedTree8Shader => null;
public virtual Shader defaultSpeedTree9Shader => null;
public virtual string renderPipelineShaderTag
{
get
{
Debug.LogWarning($"The property {nameof(renderPipelineShaderTag)} has not been overridden. At build time, any shader variants that use any RenderPipeline tag will be stripped.");
return string.Empty;
}
}
protected abstract RenderPipeline CreatePipeline();
public virtual Type pipelineType
{
get
{
Debug.LogWarning($"You must either inherit from {nameof(RenderPipelineAsset)}<TRenderPipeline> or override {nameof(pipelineType)} property.");
return null;
}
}
internal string pipelineTypeFullName => pipelineType?.FullName ?? string.Empty;
protected virtual void EnsureGlobalSettings()
{
}
protected virtual void OnValidate()
{
RenderPipelineManager.RecreateCurrentPipeline(this);
}
protected virtual void OnDisable()
{
RenderPipelineManager.CleanupRenderPipeline();
}
}
public abstract partial class RenderPipelineAsset<TRenderPipeline> : RenderPipelineAsset
where TRenderPipeline : RenderPipeline
{
public sealed override Type pipelineType => typeof(TRenderPipeline);
public override string renderPipelineShaderTag => typeof(TRenderPipeline).Name;
}
}