Implement Burst compiled importer

This commit is contained in:
2026-03-18 17:05:13 +08:00
parent b0ac70f913
commit 452d94eec7
3 changed files with 114 additions and 71 deletions
+73 -1
View File
@@ -133,6 +133,10 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.size propertyPath: m_PropertySheet.m_Float.m_Array.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.size
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
@@ -147,6 +151,10 @@ PrefabInstance:
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Name propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Name
value: ScaleMultiplier value: ScaleMultiplier
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[1].m_Name
value: OpacityMultiplier
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Value propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Value
value: 200000 value: 200000
@@ -157,7 +165,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Value propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Value
value: 32 value: 64
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[1].m_Value
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Name
value: GradientScale
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Overridden propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Overridden
@@ -171,6 +187,62 @@ PrefabInstance:
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Overridden propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Overridden
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[1].m_Overridden
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Overridden
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.atime0
value: 0
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.atime1
value: 65535
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.ctime0
value: 0
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.ctime1
value: 65535
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.key1.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.key1.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.key1.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.key1.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.m_ColorSpace
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.m_NumAlphaKeys
value: 2
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Gradient.m_Array.Array.data[0].m_Value.m_NumColorKeys
value: 2
objectReference: {fileID: 0}
- target: {fileID: -774367247743995920, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -774367247743995920, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_Enabled propertyPath: m_Enabled
value: 1 value: 1
+1 -32
View File
@@ -287,8 +287,6 @@ namespace SplatVfx.Editor
splatData.RotationArray[totalElemsRead + i] = new quaternion(splatDataNative.rotation[i]); splatData.RotationArray[totalElemsRead + i] = new quaternion(splatDataNative.rotation[i]);
} }
// NativeArray<Vector3>.Copy(splatDataNative.position.Reinterpret<Vector3>(), 0, splatData.PositionArray, totalElemsRead, numElemsRead);
totalElemsRead += numElemsRead; totalElemsRead += numElemsRead;
Debug.Log($"Current Elements Read: {totalElemsRead}"); Debug.Log($"Current Elements Read: {totalElemsRead}");
} }
@@ -341,7 +339,7 @@ namespace SplatVfx.Editor
splatDataNative.sh[elemIx + j] = chunkBytes[start + headerData.ElementByteOffsets[(int)DataEnum.f_rest_0 + j]]; splatDataNative.sh[elemIx + j] = chunkBytes[start + headerData.ElementByteOffsets[(int)DataEnum.f_rest_0 + j]];
} }
float opacity = chunkBytes[start + headerData.ElementByteOffsets[(int)DataEnum.opacity]]; float opacity = chunkBytes.ReinterpretLoad<float>(start + headerData.ElementByteOffsets[(int)DataEnum.opacity]);
opacity = 1 / (1 + math.exp(-opacity)); opacity = 1 / (1 + math.exp(-opacity));
splatDataNative.opacity[elemIx] = opacity; splatDataNative.opacity[elemIx] = opacity;
@@ -365,35 +363,6 @@ namespace SplatVfx.Editor
} }
} }
// private struct ReadChunkJob
/***********************************************************************
ImportData function
- Takes a HeaderData struct and file path string as input
- Following the JOB_SZ and the length of a single element's data
-- Computes how many bytes a single job can process
-- Reads them in chunks
-- As each chunk is read
--- Creates NativeArrays representing all the data points
--- Creates a ReadChunk Jobs to parse the data
- Once each Job is complete, begins copying the NativeArrays into a
newly created SplatData scriptable object
***********************************************************************/
/***********************************************************************
ReadChunk Job
- This MUST be Burst compiled
- Takes in NativeArrays, the chunk's byte data, and the HeaderData
struct
- It may be more efficient to place the NativeArrays inside a Burst
compiled struct
- Iterates through the byte data using the total length of a data point
as stored in HeaderData
- For each data point, reads the data points and stores them into the
appropriate NativeArray, referencing the byte offset table in
HeaderData to find their locations in the byte data
***********************************************************************/
SplatData ImportAsSplatData((string format, int num_element, List<(string, string)> properties) header_info, byte[] binaryData) SplatData ImportAsSplatData((string format, int num_element, List<(string, string)> properties) header_info, byte[] binaryData)
{ {
var splatData = ScriptableObject.CreateInstance<SplatData>(); var splatData = ScriptableObject.CreateInstance<SplatData>();
+40 -38
View File
@@ -797,7 +797,7 @@ MonoBehaviour:
m_UICollapsed: 0 m_UICollapsed: 0
m_UISuperCollapsed: 0 m_UISuperCollapsed: 0
m_InputSlots: m_InputSlots:
- {fileID: 8926484042661618395} - {fileID: 8926484042661619458}
- {fileID: 8926484042661614618} - {fileID: 8926484042661614618}
m_OutputSlots: [] m_OutputSlots: []
m_Label: m_Label:
@@ -6171,7 +6171,9 @@ MonoBehaviour:
- m_Id: 0 - m_Id: 0
linkedSlots: linkedSlots:
- outputSlot: {fileID: 8926484042661618390} - outputSlot: {fileID: 8926484042661618390}
inputSlot: {fileID: 8926484042661618395} inputSlot: {fileID: 0}
- outputSlot: {fileID: 8926484042661618390}
inputSlot: {fileID: 8926484042661619458}
position: {x: 533, y: 1299} position: {x: 533, y: 1299}
expandedSlots: [] expandedSlots: []
expanded: 1 expanded: 1
@@ -6210,42 +6212,7 @@ MonoBehaviour:
Culture=neutral, PublicKeyToken=null Culture=neutral, PublicKeyToken=null
m_Direction: 1 m_Direction: 1
m_LinkedSlots: m_LinkedSlots:
- {fileID: 8926484042661618395} - {fileID: 8926484042661619458}
--- !u!114 &8926484042661618395
MonoBehaviour:
m_ObjectHideFlags: 0
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: 76f778ff57c4e8145b9681fe3268d8e9, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.VisualEffectGraph.Editor::UnityEditor.VFX.VFXSlotGradient
m_UIIgnoredErrors: []
m_Parent: {fileID: 0}
m_Children: []
m_UIPosition: {x: 0, y: 0}
m_UICollapsed: 1
m_UISuperCollapsed: 0
m_MasterSlot: {fileID: 8926484042661618395}
m_MasterData:
m_Owner: {fileID: 8926484042661614617}
m_Value:
m_Type:
m_SerializableType: UnityEngine.Gradient, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_SerializableObject: '{"colorKeys":[{"color":{"r":0.0,"g":0.0,"b":0.0,"a":1.0},"time":0.0},{"color":{"r":0.75,"g":0.15000000596046449,"b":0.0,"a":1.0},"time":0.3000076413154602},{"color":{"r":1.25,"g":0.5600000023841858,"b":0.11999999731779099,"a":1.0},"time":0.5000076293945313},{"color":{"r":3.5,"g":2.0,"b":0.5,"a":1.0},"time":0.7000076174736023},{"color":{"r":4.0,"g":3.5,"b":1.2000000476837159,"a":1.0},"time":0.9000076055526733},{"color":{"r":12.0,"g":10.0,"b":2.5,"a":1.0},"time":1.0}],"alphaKeys":[{"alpha":0.0,"time":0.0},{"alpha":1.0,"time":1.0}],"gradientMode":0}'
m_Space: -1
m_Property:
name: gradient
m_serializedType:
m_SerializableType: UnityEngine.Gradient, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_Direction: 0
m_LinkedSlots:
- {fileID: 8926484042661618390}
--- !u!114 &8926484042661618746 --- !u!114 &8926484042661618746
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -16782,3 +16749,38 @@ MonoBehaviour:
PublicKeyToken=b77a5c561934e089 PublicKeyToken=b77a5c561934e089
m_Direction: 0 m_Direction: 0
m_LinkedSlots: [] m_LinkedSlots: []
--- !u!114 &8926484042661619458
MonoBehaviour:
m_ObjectHideFlags: 0
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: 76f778ff57c4e8145b9681fe3268d8e9, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.VisualEffectGraph.Editor::UnityEditor.VFX.VFXSlotGradient
m_UIIgnoredErrors: []
m_Parent: {fileID: 0}
m_Children: []
m_UIPosition: {x: 0, y: 0}
m_UICollapsed: 1
m_UISuperCollapsed: 0
m_MasterSlot: {fileID: 8926484042661619458}
m_MasterData:
m_Owner: {fileID: 8926484042661614617}
m_Value:
m_Type:
m_SerializableType: UnityEngine.Gradient, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_SerializableObject: '{"colorKeys":[{"color":{"r":0.0,"g":0.0,"b":0.0,"a":1.0},"time":0.0},{"color":{"r":0.75,"g":0.15000000596046449,"b":0.0,"a":1.0},"time":0.3000076413154602},{"color":{"r":1.25,"g":0.5600000023841858,"b":0.11999999731779099,"a":1.0},"time":0.5000076293945313},{"color":{"r":3.5,"g":2.0,"b":0.5,"a":1.0},"time":0.7000076174736023},{"color":{"r":4.0,"g":3.5,"b":1.2000000476837159,"a":1.0},"time":0.9000076055526733},{"color":{"r":12.0,"g":10.0,"b":2.5,"a":1.0},"time":1.0}],"alphaKeys":[{"alpha":0.0,"time":0.0},{"alpha":1.0,"time":1.0}],"gradientMode":0}'
m_Space: -1
m_Property:
name: gradient
m_serializedType:
m_SerializableType: UnityEngine.Gradient, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_Direction: 0
m_LinkedSlots:
- {fileID: 8926484042661618390}