|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// className include the additional "/"
|
|
|
|
void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string className, ref int index) |
|
|
|
void FillWithProperties(Type type, ref List<GUIContent> debugViewMaterialStringsList, ref List<int> debugViewMaterialValuesList, string className) |
|
|
|
{ |
|
|
|
var attributes = type.GetCustomAttributes(true); |
|
|
|
// Get attribute to get the start number of the value for the enum
|
|
|
|
|
|
|
|
|
|
|
var localIndex = 0; |
|
|
|
foreach (var field in fields) |
|
|
|
{ |
|
|
|
var fieldName = field.Name; |
|
|
|
{ |
|
|
|
// Note: One field can have multiple name. This is to allow to have different debug view mode for the same field
|
|
|
|
// like for example display normal in world space or in view space. Same field but two different modes.
|
|
|
|
List<String> displayNames = new List<string>(); |
|
|
|
displayNames.Add(field.Name); |
|
|
|
if (propertyAttr[0].displayName != "") |
|
|
|
{ |
|
|
|
fieldName = propertyAttr[0].displayName; |
|
|
|
if (propertyAttr[0].displayNames.Length > 0 && propertyAttr[0].displayNames[0] != "") |
|
|
|
{ |
|
|
|
displayNames.Clear(); |
|
|
|
|
|
|
|
displayNames.AddRange(propertyAttr[0].displayNames); |
|
|
|
|
|
|
|
fieldName = className + fieldName; |
|
|
|
|
|
|
|
debugViewMaterialStrings[index] = new GUIContent(fieldName); |
|
|
|
debugViewMaterialValues[index] = attr.paramDefinesStart + (int)localIndex; |
|
|
|
index++; |
|
|
|
localIndex++; |
|
|
|
|
|
|
|
foreach (string fieldName in displayNames) |
|
|
|
{ |
|
|
|
debugViewMaterialStringsList.Add(new GUIContent(className + fieldName)); |
|
|
|
debugViewMaterialValuesList.Add(attr.paramDefinesStart + (int)localIndex); |
|
|
|
localIndex++; |
|
|
|
} |
|
|
|
void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string prefix, ref int index) |
|
|
|
void FillWithPropertiesEnum(Type type, ref List<GUIContent> debugViewMaterialStringsList, ref List<int> debugViewMaterialValuesList, string prefix) |
|
|
|
{ |
|
|
|
var names = Enum.GetNames(type); |
|
|
|
|
|
|
|
|
|
|
var valueName = prefix + names[localIndex]; |
|
|
|
|
|
|
|
debugViewMaterialStrings[index] = new GUIContent(valueName); |
|
|
|
debugViewMaterialValues[index] = (int)value; |
|
|
|
index++; |
|
|
|
debugViewMaterialStringsList.Add(new GUIContent(valueName)); |
|
|
|
debugViewMaterialValuesList.Add((int)value); |
|
|
|
localIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
materialItems.Add(item); |
|
|
|
} |
|
|
|
|
|
|
|
// Material properties debug
|
|
|
|
var num = typeof(Builtin.BuiltinData).GetFields().Length * materialList.Count // BuildtinData are duplicated for each material
|
|
|
|
+ numSurfaceDataFields + 1; // +1 for None case
|
|
|
|
// Init list
|
|
|
|
List<GUIContent> debugViewMaterialStringsList = new List<GUIContent>(); |
|
|
|
List<int> debugViewMaterialValuesList = new List<int>(); |
|
|
|
List<GUIContent> debugViewEngineStringsList = new List<GUIContent>(); |
|
|
|
List<int> debugViewEngineValuesList = new List<int>(); |
|
|
|
List<GUIContent> debugViewMaterialVaryingStringsList = new List<GUIContent>(); |
|
|
|
List<int> debugViewMaterialVaryingValuesList = new List<int>(); |
|
|
|
List<GUIContent> debugViewMaterialPropertiesStringsList = new List<GUIContent>(); |
|
|
|
List<int> debugViewMaterialPropertiesValuesList = new List<int>(); |
|
|
|
List<GUIContent> debugViewMaterialTextureStringsList = new List<GUIContent>(); |
|
|
|
List<int> debugViewMaterialTextureValuesList = new List<int>(); |
|
|
|
List<GUIContent> debugViewMaterialGBufferStringsList = new List<GUIContent>(); |
|
|
|
List<int> debugViewMaterialGBufferValuesList = new List<int>(); |
|
|
|
debugViewMaterialStrings = new GUIContent[num]; |
|
|
|
debugViewMaterialValues = new int[num]; |
|
|
|
// First element is a reserved location and should not be used (allow to track error)
|
|
|
|
debugViewMaterialStrings[0] = new GUIContent("None"); |
|
|
|
debugViewMaterialValues[0] = 0; |
|
|
|
var index = 1; |
|
|
|
// 0 is a reserved number and should not be used (allow to track error)
|
|
|
|
debugViewMaterialStringsList.Add(new GUIContent("None")); |
|
|
|
debugViewMaterialValuesList.Add(0); |
|
|
|
|
|
|
|
FillWithProperties(typeof(Builtin.BuiltinData), debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index); |
|
|
|
FillWithProperties(item.surfaceDataType, debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index); |
|
|
|
FillWithProperties(typeof(Builtin.BuiltinData), ref debugViewMaterialStringsList, ref debugViewMaterialValuesList, item.className); |
|
|
|
FillWithProperties(item.surfaceDataType, ref debugViewMaterialStringsList, ref debugViewMaterialValuesList, item.className); |
|
|
|
num = numBSDFDataFields + 1; // +1 for None case
|
|
|
|
debugViewEngineStrings = new GUIContent[num]; |
|
|
|
debugViewEngineValues = new int[num]; |
|
|
|
// 0 is a reserved number and should not be used (allow to track error)
|
|
|
|
debugViewEngineStrings[0] = new GUIContent("None"); |
|
|
|
debugViewEngineValues[0] = 0; |
|
|
|
index = 1; |
|
|
|
// First element is a reserved location and should not be used (allow to track error)
|
|
|
|
// Special case for None since it cannot be inferred from SurfaceData/BuiltinData
|
|
|
|
debugViewEngineStringsList.Add(new GUIContent("None")); |
|
|
|
debugViewEngineValuesList.Add(0); |
|
|
|
|
|
|
|
FillWithProperties(item.bsdfDataType, debugViewEngineStrings, debugViewEngineValues, item.className, ref index); |
|
|
|
FillWithProperties(item.bsdfDataType, ref debugViewEngineStringsList, ref debugViewEngineValuesList, item.className); |
|
|
|
|
|
|
|
// For the following, no need to reserve the 0 case as it is handled in the Enum
|
|
|
|
var varyingNames = Enum.GetNames(typeof(Attributes.DebugViewVarying)); |
|
|
|
debugViewMaterialVaryingStrings = new GUIContent[varyingNames.Length]; |
|
|
|
debugViewMaterialVaryingValues = new int[varyingNames.Length]; |
|
|
|
index = 0; |
|
|
|
FillWithPropertiesEnum(typeof(Attributes.DebugViewVarying), debugViewMaterialVaryingStrings, debugViewMaterialVaryingValues, "", ref index); |
|
|
|
FillWithPropertiesEnum(typeof(Attributes.DebugViewVarying), ref debugViewMaterialVaryingStringsList, ref debugViewMaterialVaryingValuesList, ""); |
|
|
|
var propertiesNames = Enum.GetNames(typeof(Attributes.DebugViewProperties)); |
|
|
|
debugViewMaterialPropertiesStrings = new GUIContent[propertiesNames.Length]; |
|
|
|
debugViewMaterialPropertiesValues = new int[propertiesNames.Length]; |
|
|
|
index = 0; |
|
|
|
FillWithPropertiesEnum(typeof(Attributes.DebugViewProperties), debugViewMaterialPropertiesStrings, debugViewMaterialPropertiesValues, "", ref index); |
|
|
|
FillWithPropertiesEnum(typeof(Attributes.DebugViewProperties), ref debugViewMaterialPropertiesStringsList, ref debugViewMaterialPropertiesValuesList, ""); |
|
|
|
var gbufferNames = Enum.GetNames(typeof(Attributes.DebugViewGbuffer)); |
|
|
|
debugViewMaterialGBufferStrings = new GUIContent[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length]; |
|
|
|
debugViewMaterialGBufferValues = new int[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length]; |
|
|
|
index = 0; |
|
|
|
FillWithPropertiesEnum(typeof(Attributes.DebugViewGbuffer), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index); |
|
|
|
FillWithProperties(typeof(Lit.BSDFData), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index); |
|
|
|
FillWithPropertiesEnum(typeof(Attributes.DebugViewGbuffer), ref debugViewMaterialGBufferStringsList, ref debugViewMaterialGBufferValuesList, ""); |
|
|
|
FillWithProperties(typeof(Lit.BSDFData), ref debugViewMaterialGBufferStringsList, ref debugViewMaterialGBufferValuesList, ""); |
|
|
|
|
|
|
|
// Convert to array for UI
|
|
|
|
debugViewMaterialStrings = debugViewMaterialStringsList.ToArray(); |
|
|
|
debugViewMaterialValues = debugViewMaterialValuesList.ToArray(); |
|
|
|
|
|
|
|
debugViewEngineStrings = debugViewEngineStringsList.ToArray(); |
|
|
|
debugViewEngineValues = debugViewEngineValuesList.ToArray(); |
|
|
|
|
|
|
|
debugViewMaterialVaryingStrings = debugViewMaterialVaryingStringsList.ToArray(); |
|
|
|
debugViewMaterialVaryingValues = debugViewMaterialVaryingValuesList.ToArray(); |
|
|
|
|
|
|
|
debugViewMaterialPropertiesStrings = debugViewMaterialPropertiesStringsList.ToArray(); |
|
|
|
debugViewMaterialPropertiesValues = debugViewMaterialPropertiesValuesList.ToArray(); |
|
|
|
|
|
|
|
debugViewMaterialTextureStrings = debugViewMaterialTextureStringsList.ToArray(); |
|
|
|
debugViewMaterialTextureValues = debugViewMaterialTextureValuesList.ToArray(); |
|
|
|
|
|
|
|
debugViewMaterialGBufferStrings = debugViewMaterialGBufferStringsList.ToArray(); |
|
|
|
debugViewMaterialGBufferValues = debugViewMaterialGBufferValuesList.ToArray(); |
|
|
|
|
|
|
|
isDebugViewMaterialInit = true; |
|
|
|
} |
|
|
|