Skip to content

Commit 69363c0

Browse files
committed
Pull Request [VR] Single Pass Instanced/Multiview Support for Gaussian Splatting in URP aras-p#173
1 parent 1f83260 commit 69363c0

26 files changed

+1704
-1156
lines changed

Editor/GaussianSplatAssetCreator.cs

Lines changed: 81 additions & 379 deletions
Large diffs are not rendered by default.

Editor/GaussianSplatAssetEditor.cs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ static void SingleAssetGUI(GaussianSplatAsset gs)
4646
EditorGUILayout.IntField("Version", gs.formatVersion);
4747
GUI.backgroundColor = prevBackColor;
4848

49-
long sizePos = gs.posDataSize;
50-
long sizeOther = gs.otherDataSize;
51-
long sizeCol = gs.colorDataSize;
52-
long sizeSH = gs.shDataSize;
53-
long sizeChunk = gs.chunkDataSize;
49+
long sizePos = gs.posData != null ? gs.posData.dataSize : 0;
50+
long sizeOther = gs.otherData != null ? gs.otherData.dataSize : 0;
51+
long sizeCol = gs.colorData != null ? gs.colorData.dataSize : 0;
52+
long sizeSH = GaussianSplatAsset.CalcSHDataSize(gs.splatCount, gs.shFormat);
53+
long sizeChunk = gs.chunkData != null ? gs.chunkData.dataSize : 0;
5454

5555
EditorGUILayout.TextField("Memory", EditorUtility.FormatBytes(sizePos + sizeOther + sizeSH + sizeCol + sizeChunk));
5656
EditorGUI.indentLevel++;
@@ -65,19 +65,6 @@ static void SingleAssetGUI(GaussianSplatAsset gs)
6565
EditorGUILayout.Vector3Field("Bounds Min", gs.boundsMin);
6666
EditorGUILayout.Vector3Field("Bounds Max", gs.boundsMax);
6767

68-
EditorGUILayout.Space();
69-
GUILayout.Label("Layers", EditorStyles.boldLabel);
70-
foreach (var kv in gs.layerInfo)
71-
{
72-
EditorGUILayout.BeginHorizontal();
73-
GUILayout.Label("Layer");
74-
EditorGUILayout.FloatField(kv.Key);
75-
GUILayout.Label("Splat Count");
76-
EditorGUILayout.FloatField(kv.Value);
77-
EditorGUILayout.EndHorizontal();
78-
}
79-
80-
EditorGUILayout.Space();
8168
EditorGUILayout.TextField("Data Hash", gs.dataHash.ToString());
8269
}
8370
}

Editor/GaussianSplatRendererEditor.cs

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System;
44
using System.Collections.Generic;
55
using System.IO;
6-
using System.Linq;
76
using System.Text;
87
using GaussianSplatting.Runtime;
98
using Unity.Collections.LowLevel.Unsafe;
@@ -22,11 +21,11 @@ public class GaussianSplatRendererEditor : UnityEditor.Editor
2221
const string kPrefExportBake = "nesnausk.GaussianSplatting.ExportBakeTransform";
2322

2423
SerializedProperty m_PropAsset;
24+
SerializedProperty m_PropRenderOrder;
2525
SerializedProperty m_PropSplatScale;
2626
SerializedProperty m_PropOpacityScale;
2727
SerializedProperty m_PropSHOrder;
2828
SerializedProperty m_PropSHOnly;
29-
SerializedProperty m_CenterEyeOnly;
3029
SerializedProperty m_PropSortNthFrame;
3130
SerializedProperty m_PropRenderMode;
3231
SerializedProperty m_PropPointDisplaySize;
@@ -35,10 +34,7 @@ public class GaussianSplatRendererEditor : UnityEditor.Editor
3534
SerializedProperty m_PropShaderComposite;
3635
SerializedProperty m_PropShaderDebugPoints;
3736
SerializedProperty m_PropShaderDebugBoxes;
38-
SerializedProperty m_PropCSSplatUtilities_deviceRadixSort;
39-
SerializedProperty m_PropCSSplatUtilities_fidelityFxSort;
40-
SerializedProperty m_gpuSortType;
41-
SerializedProperty m_PropOptimizeForQuest;
37+
SerializedProperty m_PropCSSplatUtilities;
4238

4339
bool m_ResourcesExpanded = false;
4440
int m_CameraIndex = 0;
@@ -65,23 +61,21 @@ public void OnEnable()
6561
m_ExportBakeTransform = EditorPrefs.GetBool(kPrefExportBake, false);
6662

6763
m_PropAsset = serializedObject.FindProperty("m_Asset");
64+
m_PropRenderOrder = serializedObject.FindProperty("m_RenderOrder");
6865
m_PropSplatScale = serializedObject.FindProperty("m_SplatScale");
6966
m_PropOpacityScale = serializedObject.FindProperty("m_OpacityScale");
7067
m_PropSHOrder = serializedObject.FindProperty("m_SHOrder");
7168
m_PropSHOnly = serializedObject.FindProperty("m_SHOnly");
7269
m_PropSortNthFrame = serializedObject.FindProperty("m_SortNthFrame");
73-
m_CenterEyeOnly = serializedObject.FindProperty("m_CenterEyeOnly");
7470
m_PropRenderMode = serializedObject.FindProperty("m_RenderMode");
7571
m_PropPointDisplaySize = serializedObject.FindProperty("m_PointDisplaySize");
7672
m_PropCutouts = serializedObject.FindProperty("m_Cutouts");
7773
m_PropShaderSplats = serializedObject.FindProperty("m_ShaderSplats");
7874
m_PropShaderComposite = serializedObject.FindProperty("m_ShaderComposite");
7975
m_PropShaderDebugPoints = serializedObject.FindProperty("m_ShaderDebugPoints");
8076
m_PropShaderDebugBoxes = serializedObject.FindProperty("m_ShaderDebugBoxes");
81-
m_PropCSSplatUtilities_deviceRadixSort = serializedObject.FindProperty("m_CSSplatUtilities_deviceRadixSort");
82-
m_PropCSSplatUtilities_fidelityFxSort = serializedObject.FindProperty("m_CSSplatUtilities_fidelityFX");
83-
m_gpuSortType = serializedObject.FindProperty("m_gpuSortType");
84-
m_PropOptimizeForQuest = serializedObject.FindProperty("m_OptimizeForQuest");
77+
m_PropCSSplatUtilities = serializedObject.FindProperty("m_CSSplatUtilities");
78+
8579
s_AllEditors.Add(this);
8680
}
8781

@@ -111,45 +105,12 @@ public override void OnInspectorGUI()
111105

112106
EditorGUILayout.Space();
113107
GUILayout.Label("Render Options", EditorStyles.boldLabel);
108+
EditorGUILayout.PropertyField(m_PropRenderOrder);
114109
EditorGUILayout.PropertyField(m_PropSplatScale);
115110
EditorGUILayout.PropertyField(m_PropOpacityScale);
116111
EditorGUILayout.PropertyField(m_PropSHOrder);
117112
EditorGUILayout.PropertyField(m_PropSHOnly);
118-
EditorGUILayout.PropertyField(m_gpuSortType);
119-
if (gs.m_gpuSortType != GpuSorting.SortType.None)
120-
{
121-
EditorGUILayout.PropertyField(m_PropSortNthFrame);
122-
EditorGUILayout.PropertyField(m_CenterEyeOnly);
123-
}
124-
EditorGUILayout.PropertyField(m_PropOptimizeForQuest);
125-
126-
if (gs.HasValidAsset)
127-
{
128-
EditorGUILayout.Space();
129-
GUILayout.Label("Layer Options", EditorStyles.boldLabel);
130-
for (int i = 0; i < gs.asset.layerInfo.Count; i++)
131-
{
132-
if (gs.asset.layerInfo.Count > gs.m_LayerActivationState.Count)
133-
{
134-
var toAdd = Enumerable.Repeat(default(int2), gs.asset.layerInfo.Count - gs.m_LayerActivationState.Count);
135-
gs.m_LayerActivationState.AddRange(toAdd);
136-
137-
// On initial resize, activate first layer
138-
gs.m_LayerActivationState[0] = new int2(0, 1);
139-
gs.UpdateRessources();
140-
}
141-
142-
var layer = gs.m_LayerActivationState.ElementAtOrDefault(i);
143-
var layerActive = layer.y > 0;
144-
var check = EditorGUILayout.Toggle($"Show layer {i}", layerActive);
145-
if (check != layerActive)
146-
{
147-
gs.m_LayerActivationState[i] = new int2(i, check ? 1 : 0);
148-
gs.UpdateRessources();
149-
EditorUtility.SetDirty(gs);
150-
}
151-
}
152-
}
113+
EditorGUILayout.PropertyField(m_PropSortNthFrame);
153114

154115
EditorGUILayout.Space();
155116
GUILayout.Label("Debugging Tweaks", EditorStyles.boldLabel);
@@ -165,8 +126,7 @@ public override void OnInspectorGUI()
165126
EditorGUILayout.PropertyField(m_PropShaderComposite);
166127
EditorGUILayout.PropertyField(m_PropShaderDebugPoints);
167128
EditorGUILayout.PropertyField(m_PropShaderDebugBoxes);
168-
EditorGUILayout.PropertyField(m_PropCSSplatUtilities_deviceRadixSort);
169-
EditorGUILayout.PropertyField(m_PropCSSplatUtilities_fidelityFxSort);
129+
EditorGUILayout.PropertyField(m_PropCSSplatUtilities);
170130
}
171131
bool validAndEnabled = gs && gs.enabled && gs.gameObject.activeInHierarchy && gs.HasValidAsset;
172132
if (validAndEnabled && !gs.HasValidRenderSetup)
@@ -225,7 +185,7 @@ void MultiEditGUI()
225185
return;
226186
}
227187

228-
if (targetGs.asset.chunkDataSize > 0)
188+
if (targetGs.asset.chunkData != null)
229189
{
230190
EditorGUILayout.HelpBox($"Can't merge into {target.name} (needs to use Very High quality preset)", MessageType.Warning);
231191
return;
@@ -309,7 +269,7 @@ void EditGUI(GaussianSplatRenderer gs)
309269
ToolManager.SetActiveContext<GameObjectToolContext>();
310270
}
311271

312-
if (isToolActive && gs.asset.chunkDataSize > 0)
272+
if (isToolActive && gs.asset.chunkData != null)
313273
{
314274
EditorGUILayout.HelpBox("Splat move/rotate/scale tools need Very High splat quality preset", MessageType.Warning);
315275
}
@@ -438,13 +398,13 @@ static unsafe void ExportPlyFile(GaussianSplatRenderer gs, bool bakeTransform)
438398
if (string.IsNullOrWhiteSpace(path))
439399
return;
440400

441-
int kSplatSize = UnsafeUtility.SizeOf<GaussianSplatAssetCreator.InputSplatData>();
401+
int kSplatSize = UnsafeUtility.SizeOf<Utils.InputSplatData>();
442402
using var gpuData = new GraphicsBuffer(GraphicsBuffer.Target.Structured, gs.splatCount, kSplatSize);
443403

444404
if (!gs.EditExportData(gpuData, bakeTransform))
445405
return;
446406

447-
GaussianSplatAssetCreator.InputSplatData[] data = new GaussianSplatAssetCreator.InputSplatData[gpuData.count];
407+
Utils.InputSplatData[] data = new Utils.InputSplatData[gpuData.count];
448408
gpuData.GetData(data);
449409

450410
var gpuDeleted = gs.GpuEditDeleted;

Editor/GaussianTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected bool CanBeEdited()
2121
var gs = GetRenderer();
2222
if (!gs)
2323
return false;
24-
return gs.asset.chunkDataSize == 0; // need to be lossless / non-chunked for editing
24+
return gs.asset.chunkData == null; // need to be lossless / non-chunked for editing
2525
}
2626

2727
protected bool HasSelection()

0 commit comments

Comments
 (0)