static void BuildBRDFGenerators(ref LTCTableGenerator.BRDFGenerator[] BRDFGeneratorArray) { // Collect all the BRDFs that we need to generate Type[] brdfTypes = ListAllBRDFTypes(); if (brdfTypes.Length != 0) { BRDFGeneratorArray = new LTCTableGenerator.BRDFGenerator[brdfTypes.Length]; for (int i = 0; i < brdfTypes.Length; ++i) { BRDFGeneratorArray[i] = new LTCTableGenerator.BRDFGenerator(brdfTypes[i], k_TableResolution, k_DefaultSampleCount, LTCTableGenerator.LTCTableParametrization.CosTheta, k_OutputDirectory); } } }
private void OnGUI() { if (m_BRDFGeneratorArray == null) { BuildBRDFGenerators(ref m_BRDFGeneratorArray); } EditorGUILayout.LabelField("Recognized BRDF Types: " + m_BRDFGeneratorArray.Length); EditorGUILayout.Separator(); // Display the generators and their toggles int numActiveGenerators = 0; for (int i = 0; i < m_BRDFGeneratorArray.Length; ++i) { LTCTableGenerator.BRDFGenerator currentGenerator = m_BRDFGeneratorArray[i]; currentGenerator.shouldGenerate = EditorGUILayout.Toggle(currentGenerator.type.Name.ToString(), currentGenerator.shouldGenerate); if (currentGenerator.shouldGenerate) { numActiveGenerators++; } EditorGUILayout.Space(); } m_ParallelExecution = EditorGUILayout.Toggle("Parallel", m_ParallelExecution); m_SampleCount = EditorGUILayout.IntField("Sample Count", m_SampleCount); m_Parametrization = (LTCTableGenerator.LTCTableParametrization)EditorGUILayout.EnumPopup("Theta parametrization", m_Parametrization); EditorGUILayout.Separator(); if (m_BRDFGeneratorArray.Length > 1) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Select All", ""), EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { for (int i = 0; i < m_BRDFGeneratorArray.Length; ++i) { m_BRDFGeneratorArray[i].shouldGenerate = true; } } if (GUILayout.Button(new GUIContent("Select None", ""), EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { for (int i = 0; i < m_BRDFGeneratorArray.Length; ++i) { m_BRDFGeneratorArray[i].shouldGenerate = false; } } EditorGUILayout.EndHorizontal(); } if (numActiveGenerators > 0) { EditorGUILayout.Separator(); EditorGUILayout.Space(); if (GUILayout.Button(new GUIContent("Generate LTC Tables", ""), EditorStyles.toolbarButton)) { // Make sure target directory exists before creating any file! DirectoryInfo outputDir = new DirectoryInfo(k_OutputDirectory); if (!outputDir.Exists) { outputDir.Create(); } for (int i = 0; i < m_BRDFGeneratorArray.Length; ++i) { if (m_BRDFGeneratorArray[i].shouldGenerate) { m_BRDFGeneratorArray[i].sampleCount = m_SampleCount; m_BRDFGeneratorArray[i].parametrization = m_Parametrization; LTCTableGenerator.ExecuteFittingJob(m_BRDFGeneratorArray[i], m_ParallelExecution); } } AssetDatabase.Refresh(); } } }