Skip to content

Commit

Permalink
Placeholder code for AI option in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
i9neus committed Jan 17, 2024
1 parent 239edd5 commit 1d3dfee
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ static class Styles
public static readonly GUIContent nlmAlpha = new GUIContent("Alpha", "");
public static readonly GUIContent nlmK = new GUIContent("K", "");

public static readonly GUIContent aiModelType = new GUIContent("Emphasis", "");

public static readonly GUIContent fineTuningTitle = new GUIContent("Fine Tuning", "");
public static readonly GUIContent samplerBias = new GUIContent("Sampler Bias", "");

Expand All @@ -24,8 +26,8 @@ static class Styles
public static readonly GUIContent isolateCellIdx = new GUIContent("Cell index", "");
public static readonly GUIContent showInvalidProbes = new GUIContent("Show Invalid Probes", "");

public static readonly string[] kernelFilterTypeOptions = new string[] { "Box", "Epanechnikov", "NLM" };

public static readonly string[] kernelFilterTypeOptions = new string[] { "Box", "Epanechnikov", "NLM", "AI" };
public static readonly string[] aiModelTypeOptions = new string[] { "Noise removal", "Detail preservation" };
}

// PropertyDrawer are not made to use GUILayout, so it will try to reserve a rect before calling OnGUI
Expand All @@ -49,17 +51,28 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
var kernelFilterType = property.FindPropertyRelative("kernelFilterType");
kernelFilterType.intValue = EditorGUILayout.Popup(Styles.kernelFilterType, kernelFilterType.intValue, Styles.kernelFilterTypeOptions);

var kernelSize = property.FindPropertyRelative("kernelSize");
kernelSize.intValue = EditorGUILayout.IntSlider(Styles.kernelSize, kernelSize.intValue, 0, 5);
if (kernelFilterType.intValue != (int)ProbeVolumeDenoiserSettings.KernelFilterType.kAI)
{
var kernelSize = property.FindPropertyRelative("kernelSize");
kernelSize.intValue = EditorGUILayout.IntSlider(Styles.kernelSize, kernelSize.intValue, 0, 5);

var nlmM = property.FindPropertyRelative("nlmM");
nlmM.intValue = EditorGUILayout.IntSlider(Styles.nlmM, nlmM.intValue, 0, 2);
if (kernelFilterType.intValue == (int)ProbeVolumeDenoiserSettings.KernelFilterType.kNLM)
{
var nlmM = property.FindPropertyRelative("nlmM");
nlmM.intValue = EditorGUILayout.IntSlider(Styles.nlmM, nlmM.intValue, 0, 2);

var nlmAlpha = property.FindPropertyRelative("nlmAlpha");
nlmAlpha.floatValue = EditorGUILayout.Slider(Styles.nlmAlpha, nlmAlpha.floatValue, 0.0f, 3.0f);
var nlmAlpha = property.FindPropertyRelative("nlmAlpha");
nlmAlpha.floatValue = EditorGUILayout.Slider(Styles.nlmAlpha, nlmAlpha.floatValue, 0.0f, 3.0f);

var nlmK = property.FindPropertyRelative("nlmK");
nlmK.floatValue = EditorGUILayout.Slider(Styles.nlmK, nlmK.floatValue, 0.0f, 3.0f);
var nlmK = property.FindPropertyRelative("nlmK");
nlmK.floatValue = EditorGUILayout.Slider(Styles.nlmK, nlmK.floatValue, 0.0f, 3.0f);
}
}
else
{
var aiModelType = property.FindPropertyRelative("aiModelType");
aiModelType.intValue = EditorGUILayout.Popup(Styles.aiModelType, aiModelType.intValue, Styles.aiModelTypeOptions);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ToSphericalHarmonicsL2(ref SphericalHarmonicsL2 sh)
SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 7, L2_3);
SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 8, L2_4);

/*SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 0, new Vector3(1.0f, 0.0f, 0.0f));
/*SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 0, new Vector3(0.0f, 0.0f, 0.0f));
SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 1, new Vector3(0.0f, 0.0f, 0.0f));
SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 2, new Vector3(0.0f, 0.0f, 0.0f));
SphericalHarmonicsL2Utils.SetCoefficient(ref sh, 3, new Vector3(0.0f, 0.0f, 0.0f));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
//

#ifndef RAWSPHERICALHARMONICSL2_CS_HLSL
#define RAWSPHERICALHARMONICSL2_CS_HLSL
// Generated from UnityEngine.Rendering.ProbeGIBaking+RawSphericalHarmonicsL2
// PackingRules = Exact
struct RawSphericalHarmonicsL2
{
float3 L0;
float3 L1_0;
float3 L1_1;
float3 L1_2;
float3 L2_0;
float3 L2_1;
float3 L2_2;
float3 L2_3;
float3 L2_4;
};


#endif
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ internal struct ProbeVolumeDenoiserSettings
public enum KernelFilterType
{
kBox,
kNLM
kEpanechnikov,
kNLM,
kAI
}

public bool enableDenoising;
Expand All @@ -112,6 +114,7 @@ public enum KernelFilterType
public int nlmM;
public float nlmAlpha;
public float nlmK;
public int aiModelType;

public float samplerBias;

Expand Down
5 changes: 1 addition & 4 deletions probe-denoiser.code-workspace
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"folders": [
{
"path": "Packages/com.unity.render-pipelines.high-definition"
},
{
"path": "Packages/com.unity.render-pipelines.core"
"path": "../APVDemo/[email protected]"
}
],
"settings": {}
Expand Down

0 comments on commit 1d3dfee

Please sign in to comment.