Skip to content

Commit cd7d831

Browse files
Merge branch 'master' of https://github.com/Unity-Technologies/ScriptableRenderLoop into Branch_DebugMenu2
# Conflicts: # Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
2 parents 04eb481 + 95abaec commit cd7d831

45 files changed

Lines changed: 21334 additions & 21024 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Assets/LDPipe_Shader/LDPipe_UnlitMat.mat

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Material:
77
m_PrefabParentObject: {fileID: 0}
88
m_PrefabInternal: {fileID: 0}
99
m_Name: LDPipe_UnlitMat
10-
m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0}
11-
m_ShaderKeywords: _EMISSION _NORMALMAP _SPECGLOSSMAP_BASE_ALPHA
10+
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
11+
m_ShaderKeywords: _ALPHABLEND_ON _NORMALMAP _SPECGLOSSMAP_BASE_ALPHA
1212
m_LightmapFlags: 4
1313
m_EnableInstancingVariants: 0
1414
m_DoubleSidedGI: 0
15-
m_CustomRenderQueue: -1
16-
stringTagMap: {}
15+
m_CustomRenderQueue: 3000
16+
stringTagMap:
17+
RenderType: Transparent
1718
disabledShaderPasses: []
1819
m_SavedProperties:
1920
serializedVersion: 3
@@ -66,25 +67,26 @@ Material:
6667
- _BumpScale: 1
6768
- _Cutoff: 0.5
6869
- _DetailNormalMapScale: 1
69-
- _DstBlend: 0
70+
- _DstBlend: 10
7071
- _GlossMapScale: 1
7172
- _Glossiness: 0.5
7273
- _GlossinessSource: 0
7374
- _GlossyReflections: 1
7475
- _Metallic: 0
75-
- _Mode: 0
76+
- _Mode: 2
7677
- _OcclusionStrength: 1
7778
- _Parallax: 0.02
7879
- _ReflectionSource: 0
7980
- _Shininess: 1
8081
- _SmoothnessTextureChannel: 0
8182
- _SpecSource: 0
8283
- _SpecularHighlights: 1
83-
- _SrcBlend: 1
84+
- _SrcBlend: 5
8485
- _UVSec: 0
85-
- _ZWrite: 1
86+
- _ZWrite: 0
8687
m_Colors:
8788
- _Color: {r: 0.9264706, g: 0.095371954, b: 0.095371954, a: 1}
8889
- _EmissionColor: {r: 0.20663926, g: 0.24034719, b: 0.28676468, a: 1}
90+
- _MainColor: {r: 1, g: 0, b: 0, a: 1}
8991
- _ReflectColor: {r: 1, g: 1, b: 1, a: 1}
9092
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Assets/LDPipe_Shader/LDPipe_UnlitMatTexture.mat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Material:
77
m_PrefabParentObject: {fileID: 0}
88
m_PrefabInternal: {fileID: 0}
99
m_Name: LDPipe_UnlitMatTexture
10-
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
10+
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
1111
m_ShaderKeywords: _EMISSION _NORMALMAP _SPECGLOSSMAP_BASE_ALPHA
1212
m_LightmapFlags: 4
1313
m_EnableInstancingVariants: 0
@@ -86,5 +86,6 @@ Material:
8686
m_Colors:
8787
- _Color: {r: 0.9264706, g: 0.095371954, b: 0.095371954, a: 1}
8888
- _EmissionColor: {r: 0.20663926, g: 0.24034719, b: 0.28676468, a: 1}
89+
- _MainColor: {r: 1, g: 1, b: 1, a: 1}
8990
- _ReflectColor: {r: 1, g: 1, b: 1, a: 1}
9091
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ public void RegisterDebug()
128128
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Display Opaque",() => renderingDebugSettings.displayOpaqueObjects, (value) => renderingDebugSettings.displayOpaqueObjects = (bool)value);
129129
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Display Transparency",() => renderingDebugSettings.displayTransparentObjects, (value) => renderingDebugSettings.displayTransparentObjects = (bool)value);
130130
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Distortion",() => renderingDebugSettings.enableDistortion, (value) => renderingDebugSettings.enableDistortion = (bool)value);
131-
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Subsurface Scattering",() => renderingDebugSettings.enableSSS, (value) => renderingDebugSettings.enableSSS = (bool)value);
131+
DebugMenuManager.instance.AddDebugItem<bool>("Rendering", "Enable Subsurface Scattering",() => renderingDebugSettings.enableSSSAndTransmission, (value) => renderingDebugSettings.enableSSSAndTransmission = (bool)value);
132132
}
133133

134134
public void OnValidate()
135135
{
136136
lightingDebugSettings.OnValidate();
137137
}
138138

139-
void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string strSubNameSpace, ref int index)
139+
// className include the additional "/"
140+
void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string className, ref int index)
140141
{
141142
var attributes = type.GetCustomAttributes(true);
142143
// Get attribute to get the start number of the value for the enum
@@ -164,7 +165,7 @@ void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[]
164165
}
165166
}
166167

167-
fieldName = strSubNameSpace + fieldName;
168+
fieldName = className + fieldName;
168169

169170
debugViewMaterialStrings[index] = new GUIContent(fieldName);
170171
debugViewMaterialValues[index] = attr.paramDefinesStart + (int)localIndex;
@@ -189,57 +190,94 @@ void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, in
189190
}
190191
}
191192

192-
string GetSubNameSpaceName(Type type)
193+
public class MaterialItem
193194
{
194-
return type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1) + "/";
195-
}
195+
public String className;
196+
public Type surfaceDataType;
197+
public Type bsdfDataType;
198+
};
196199

197200
void BuildDebugRepresentation()
198201
{
199202
if (!isDebugViewMaterialInit)
200203
{
201-
var varyingNames = Enum.GetNames(typeof(Attributes.DebugViewVarying));
202-
debugViewMaterialVaryingStrings = new GUIContent[varyingNames.Length];
203-
debugViewMaterialVaryingValues = new int[varyingNames.Length];
204-
var gbufferNames = Enum.GetNames(typeof(Attributes.DebugViewGbuffer));
205-
debugViewMaterialGBufferStrings = new GUIContent[gbufferNames.Length + typeof(Lit.BSDFData).GetFields().Length];
206-
debugViewMaterialGBufferValues = new int[gbufferNames.Length + typeof(Lit.BSDFData).GetFields().Length];
204+
List<RenderPipelineMaterial> materialList = Utilities.GetRenderPipelineMaterialList();
207205

208-
var num = typeof(Builtin.BuiltinData).GetFields().Length * 2 // BuildtinData are duplicated for each material
209-
+ typeof(Lit.SurfaceData).GetFields().Length
210-
+ typeof(Unlit.SurfaceData).GetFields().Length
211-
+ 1; // None
206+
// TODO: Share this code to retrieve deferred material with HDRenderPipeline
207+
// Find first material that have non 0 Gbuffer count and assign it as deferredMaterial
208+
Type bsdfDataDeferredType = null;
209+
foreach (RenderPipelineMaterial material in materialList)
210+
{
211+
if (material.GetMaterialGBufferCount() > 0)
212+
{
213+
bsdfDataDeferredType = material.GetType().GetNestedType("BSDFData");
214+
}
215+
}
212216

213-
debugViewMaterialStrings = new GUIContent[num];
214-
debugViewMaterialValues = new int[num];
217+
// TODO: Handle the case of no Gbuffer material
218+
Debug.Assert(bsdfDataDeferredType != null);
215219

216-
num = typeof(Lit.BSDFData).GetFields().Length
217-
+ typeof(Unlit.BSDFData).GetFields().Length
218-
+ 1; // None
220+
List<MaterialItem> materialItems = new List<MaterialItem>();
219221

220-
debugViewEngineStrings = new GUIContent[num];
221-
debugViewEngineValues = new int[num];
222+
int numSurfaceDataFields = 0;
223+
int numBSDFDataFields = 0;
224+
foreach (RenderPipelineMaterial material in materialList)
225+
{
226+
MaterialItem item = new MaterialItem();
227+
228+
item.className = material.GetType().Name + "/";
229+
230+
item.surfaceDataType = material.GetType().GetNestedType("SurfaceData");
231+
numSurfaceDataFields += item.surfaceDataType.GetFields().Length;
222232

233+
item.bsdfDataType = material.GetType().GetNestedType("BSDFData");
234+
numBSDFDataFields += item.bsdfDataType.GetFields().Length;
223235

224-
// Special case for None since it cannot be inferred from SurfaceDAta/BuiltinData
236+
materialItems.Add(item);
237+
}
238+
239+
// Material properties debug
240+
var num = typeof(Builtin.BuiltinData).GetFields().Length * materialList.Count // BuildtinData are duplicated for each material
241+
+ numSurfaceDataFields + 1; // +1 for None case
242+
243+
debugViewMaterialStrings = new GUIContent[num];
244+
debugViewMaterialValues = new int[num];
245+
// Special case for None since it cannot be inferred from SurfaceData/BuiltinData
225246
debugViewMaterialStrings[0] = new GUIContent("None");
226247
debugViewMaterialValues[0] = 0;
227248
var index = 1;
228249
// 0 is a reserved number and should not be used (allow to track error)
229-
FillWithProperties(typeof(Builtin.BuiltinData), debugViewMaterialStrings, debugViewMaterialValues, GetSubNameSpaceName(typeof(Lit.SurfaceData)), ref index);
230-
FillWithProperties(typeof(Lit.SurfaceData), debugViewMaterialStrings, debugViewMaterialValues, GetSubNameSpaceName(typeof(Lit.SurfaceData)), ref index);
231-
FillWithProperties(typeof(Builtin.BuiltinData), debugViewMaterialStrings, debugViewMaterialValues, GetSubNameSpaceName(typeof(Unlit.SurfaceData)), ref index);
232-
FillWithProperties(typeof(Unlit.SurfaceData), debugViewMaterialStrings, debugViewMaterialValues, GetSubNameSpaceName(typeof(Unlit.SurfaceData)), ref index);
250+
foreach (MaterialItem item in materialItems)
251+
{
252+
// BuiltinData are duplicated for each material
253+
FillWithProperties(typeof(Builtin.BuiltinData), debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index);
254+
FillWithProperties(item.surfaceDataType, debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index);
255+
}
233256

234-
// Engine
257+
// Engine properties debug
258+
num = numBSDFDataFields + 1; // +1 for None case
259+
debugViewEngineStrings = new GUIContent[num];
260+
debugViewEngineValues = new int[num];
261+
// 0 is a reserved number and should not be used (allow to track error)
235262
debugViewEngineStrings[0] = new GUIContent("None");
236263
debugViewEngineValues[0] = 0;
237264
index = 1;
238-
FillWithProperties(typeof(Lit.BSDFData), debugViewEngineStrings, debugViewEngineValues, GetSubNameSpaceName(typeof(Lit.BSDFData)), ref index);
239-
FillWithProperties(typeof(Unlit.BSDFData), debugViewEngineStrings, debugViewEngineValues, GetSubNameSpaceName(typeof(Unlit.BSDFData)), ref index);
265+
foreach (MaterialItem item in materialItems)
266+
{
267+
FillWithProperties(item.bsdfDataType, debugViewEngineStrings, debugViewEngineValues, item.className, ref index);
268+
}
240269

270+
// Attributes debug
271+
var varyingNames = Enum.GetNames(typeof(Attributes.DebugViewVarying));
272+
debugViewMaterialVaryingStrings = new GUIContent[varyingNames.Length];
273+
debugViewMaterialVaryingValues = new int[varyingNames.Length];
241274
index = 0;
242275
FillWithPropertiesEnum(typeof(Attributes.DebugViewVarying), debugViewMaterialVaryingStrings, debugViewMaterialVaryingValues, "", ref index);
276+
277+
// Gbuffer debug
278+
var gbufferNames = Enum.GetNames(typeof(Attributes.DebugViewGbuffer));
279+
debugViewMaterialGBufferStrings = new GUIContent[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length];
280+
debugViewMaterialGBufferValues = new int[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length];
243281
index = 0;
244282
FillWithPropertiesEnum(typeof(Attributes.DebugViewGbuffer), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index);
245283
FillWithProperties(typeof(Lit.BSDFData), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index);
@@ -348,7 +386,7 @@ public class RenderingDebugSettings
348386
public bool displayOpaqueObjects = true;
349387
public bool displayTransparentObjects = true;
350388
public bool enableDistortion = true;
351-
public bool enableSSS = true;
389+
public bool enableSSSAndTransmission = true;
352390
}
353391

354392
public enum ShadowMapDebugMode

Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -81,47 +81,6 @@ static void ResetAllMaterialKeywords()
8181
}
8282
}
8383

84-
// TEMP: will be remove after data upgrade
85-
[MenuItem("HDRenderPipeline/Swap standard and SSS material IDs")]
86-
static void SwapStandardAndSssMaterialIds()
87-
{
88-
try
89-
{
90-
Object[] materials = Resources.FindObjectsOfTypeAll<Material>();
91-
for (int i = 0, length = materials.Length; i < length; i++)
92-
{
93-
Material mat = materials[i] as Material;
94-
95-
EditorUtility.DisplayProgressBar(
96-
"Updating materials...",
97-
string.Format("{0} / {1}", i, length),
98-
i / (float)(length - 1));
99-
100-
if (mat.shader.name == "HDRenderPipeline/Lit" || mat.shader.name == "HDRenderPipeline/LitTessellation")
101-
{
102-
int matID = (int)mat.GetFloat("_MaterialID");
103-
104-
if (matID == 0)
105-
{
106-
matID = 1;
107-
mat.SetInt("_MaterialID", matID);
108-
EditorUtility.SetDirty(mat);
109-
}
110-
else if (matID == 1)
111-
{
112-
matID = 0;
113-
mat.SetInt("_MaterialID", matID);
114-
EditorUtility.SetDirty(mat);
115-
}
116-
}
117-
}
118-
}
119-
finally
120-
{
121-
EditorUtility.ClearProgressBar();
122-
}
123-
}
124-
12584
// Funtion used only to check performance of data with and without tessellation
12685
[MenuItem("HDRenderPipeline/Debug/Remove tessellation materials (not reversible)")]
12786
static void RemoveTessellationMaterials()

0 commit comments

Comments
 (0)