Compare commits

..

3 Commits

Author SHA1 Message Date
rsformoso 3c9e88531d Update documentation and TODO list 2026-03-19 11:20:43 +08:00
rsformoso 5c5d55955e Disable HDR. Fix yellow tint on camera 2026-03-19 10:56:13 +08:00
rsformoso 4d03d277a9 Add Cinemachine package 2026-03-18 22:56:39 +08:00
10 changed files with 60 additions and 78 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ MonoBehaviour:
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 0
m_SupportsTerrainHoles: 1
m_SupportsHDR: 1
m_SupportsHDR: 0
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 0.8
+3
View File
@@ -34,6 +34,9 @@ MonoBehaviour:
highQualityFiltering:
m_OverrideState: 1
m_Value: 1
filter:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
+2 -2
View File
@@ -390,8 +390,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1826889287}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -5}
m_LocalRotation: {x: -0.048649408, y: -0.18707958, z: 0.009037506, w: -0.9810978}
m_LocalPosition: {x: -0.4305725, y: 0.22459221, z: -1.4613647}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
+5 -62
View File
@@ -70,9 +70,6 @@ namespace SplatVfx.Editor
opacity, scale_0, scale_1, scale_2, rot_0, rot_1, rot_2, rot_3
}
/***********************************************************************
- TODO: Add support for more data types
***********************************************************************/
private static readonly Dictionary<TypeEnum, int> TypeToByteLengths =
new()
{
@@ -92,10 +89,6 @@ namespace SplatVfx.Editor
{ "int8", TypeEnum.Int8 }
};
/***********************************************************************
- TODO: Add endianness
- TODO: Add float size
***********************************************************************/
private struct HeaderData
{
public uint NumElements;
@@ -234,14 +227,14 @@ namespace SplatVfx.Editor
);
int chunkSize = elementsPerChunk * headerData.BytesPerElement;
Debug.Log($"Elements per chunk: {elementsPerChunk}");
Debug.Log($"Chunk size: {chunkSize}");
// Debug.Log($"Elements per chunk: {elementsPerChunk}");
// Debug.Log($"Chunk size: {chunkSize}");
using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
fileStream.Seek(endHeaderPosition, SeekOrigin.Begin);
int totalBytes = (int)fileStream.Length - endHeaderPosition;
Debug.Log($"Total bytes: {totalBytes}");
// Debug.Log($"Total bytes: {totalBytes}");
var splatDataNative = new SplatDataNative(elementsPerChunk);
var chunkBuffer = new NativeArray<byte>(chunkSize, Allocator.Persistent);
@@ -280,10 +273,10 @@ namespace SplatVfx.Editor
}
totalElemsRead += numElemsRead;
Debug.Log($"Current Elements Read: {totalElemsRead}");
// Debug.Log($"Current Elements Read: {totalElemsRead}");
}
Debug.Log($"First position Vector3: {splatData.PositionArray[0]}");
// Debug.Log($"First position Vector3: {splatData.PositionArray[0]}");
headerData.Dispose();
splatDataNative.Dispose();
@@ -354,55 +347,5 @@ namespace SplatVfx.Editor
}
}
}
// struct ReadData
// {
// public float px, py, pz;
// public float sx, sy, sz;
// public byte r, g, b, a;
// public byte rw, rx, ry, rz;
// }
// (Vector3[] position, Vector3[] axis, Color[] color)
// LoadDataArrays(string path)
// {
// var bytes = (Span<byte>)File.ReadAllBytes(path);
// var count = bytes.Length / 32;
// var source = MemoryMarshal.Cast<byte, ReadData>(bytes);
// var position = new Vector3[count];
// var axis = new Vector3[count * 3];
// var color = new Color[count];
// for (var i = 0; i < count; i++)
// ParseReadData(source[i],
// out position[i],
// out axis[i * 3],
// out axis[i * 3 + 1],
// out axis[i * 3 + 2],
// out color[i]);
// return (position, axis, color);
// }
// [BurstCompile]
// void ParseReadData(in ReadData src,
// out Vector3 position,
// out Vector3 axis1,
// out Vector3 axis2,
// out Vector3 axis3,
// out Color color)
// {
// var rv = (math.float4(src.rx, src.ry, src.rz, src.rw) - 128) / 128;
// var q = math.quaternion(-rv.x, -rv.y, rv.z, rv.w);
// position = math.float3(src.px, src.py, -src.pz);
// axis1 = math.mul(q, math.float3(src.sx, 0, 0));
// axis2 = math.mul(q, math.float3(0, src.sy, 0));
// axis3 = math.mul(q, math.float3(0, 0, src.sz));
// color = (Vector4)math.float4(src.r, src.g, src.b, src.a) / 255;
// }
}
}
@@ -1,3 +1,7 @@
/// Index: The splat's index
/// Degrees: The degrees of spherical harmonics to calculate
/// DirClr: A 4x4 matrix with the first row containing a vector from the splat position to the camera, and the second row containing its base color
/// SHBuffer: The spherical harmonics buffer from a SplatData object
float3 CalculateSHColor(uint Index, uint Degrees, float4x4 DirClr, StructuredBuffer<float> SHBuffer) {
const float SH_C0 = 0.28209479177387814f;
const float SH_C1 = 0.4886025119029199f;
@@ -31,10 +35,9 @@ float3 CalculateSHColor(uint Index, uint Degrees, float4x4 DirClr, StructuredBuf
// }
for (int i = 1; i < 16; i++)
{
// Access R, G, B values from their separate blocks
sh[i].x = SHBuffer[Index * 45 + (i - 1)]; // R values (indices 0-44)
sh[i].y = SHBuffer[Index * 45 + 15 + (i - 1)]; // G values (indices 45-89)
sh[i].z = SHBuffer[Index * 45 + 30 + (i - 1)]; // B values (indices 90-134)
sh[i].x = SHBuffer[Index * 45 + (i - 1)];
sh[i].y = SHBuffer[Index * 45 + 15 + (i - 1)];
sh[i].z = SHBuffer[Index * 45 + 30 + (i - 1)];
}
if (Degrees > 0)
@@ -73,6 +76,8 @@ float3 CalculateSHColor(uint Index, uint Degrees, float4x4 DirClr, StructuredBuf
}
/*
> Reference taken from the original Gaussian splatting paper code
// The implementation is loosely based on code for
// "Differentiable Point-Based Radiance Fields for
// Efficient View Synthesis" by Zhang et al. (2022)
@@ -1,8 +1,10 @@
/// Hidden
float CrossProduct(float2 A, float2 B)
{
return A.x * B.y - A.y * B.x;
}
/// Hidden
float SweepArea(float2 A, float2 B)
{
return abs(CrossProduct(A, B));
+1 -1
View File
@@ -1,5 +1,6 @@
{
"dependencies": {
"com.unity.cinemachine": "2.10.7",
"com.unity.ide.visualstudio": "2.0.27",
"com.unity.inputsystem": "1.18.0",
"com.unity.render-pipelines.universal": "17.3.0",
@@ -9,7 +10,6 @@
"com.unity.visualeffectgraph": "17.3.0",
"com.unity.visualscripting": "1.9.10",
"com.unity.modules.accessibility": "1.0.0",
"com.unity.modules.adaptiveperformance": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
+9 -8
View File
@@ -10,6 +10,15 @@
},
"url": "https://packages.unity.com"
},
"com.unity.cinemachine": {
"version": "2.10.7",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.31"
},
"url": "https://packages.unity.com"
},
"com.unity.collections": {
"version": "2.6.2",
"depth": 2,
@@ -175,14 +184,6 @@
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.adaptiveperformance": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.subsystems": "1.0.0"
}
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
+16
View File
@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 53
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Timeline.Editor::TimelineProjectSettings
assetDefaultFramerate: 60
m_DefaultFrameRate: 60
+12
View File
@@ -0,0 +1,12 @@
# TODO
- [ ] Rewrite SH Array to use interleaved RGB rather than contiguous data per
channel
- [ ] Switch to using ByteAddressBuffers instead of loops in CalculateSH.hlsl
- [ ] Optimize CalculateAxes.hlsl
- [ ] Allow splat data buffers to be accessible by other VFX Graphs
- [ ] Add exception reporting and handling for incomplete splat data
- [ ] Add support for other PLY data types and endianness
- [ ] Add support for ASCII PLY data
- [ ] Fix the header parsing logic in SplatImporter.cs
- [ ] Add more thorough checks in SplatDataBinder.cs