Switch to interleaved RGB for spherical harmonics

This commit is contained in:
2026-03-20 23:56:30 +08:00
parent e774cc6663
commit 2a2ebf8ae7
5 changed files with 171 additions and 251 deletions
+98 -186
View File
@@ -119,191 +119,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &562634546
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
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
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Name
value: SplatCount
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[1].m_Name
value: SHDegrees
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Name
value: ScaleMultiplier
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}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Value
value: 200000
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[1].m_Value
value: 3
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Value
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}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Overridden
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[1].m_Overridden
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Overridden
value: 1
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}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalScale.y
value: -1
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8980549144392899874, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_Name
value: splat_45000
objectReference: {fileID: 0}
- target: {fileID: 8980549144392899874, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: -4216948427090074523, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
--- !u!1 &688714159
GameObject:
m_ObjectHideFlags: 0
@@ -617,10 +432,107 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1001 &1990011521
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Name
value: SplatCount
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[1].m_Name
value: SHDegrees
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Value
value: 11081
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[1].m_Value
value: 0
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[0].m_Overridden
value: 1
objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_PropertySheet.m_Uint.m_Array.Array.data[1].m_Overridden
value: 1
objectReference: {fileID: 0}
- target: {fileID: -774367247743995920, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalScale.y
value: -1
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalRotation.w
value: 0.9920709
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalRotation.y
value: -0.12567958
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: -14.44
objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8980549144392899874, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_Name
value: splat_30750-cropped
objectReference: {fileID: 0}
- target: {fileID: 8980549144392899874, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: -4216948427090074523, guid: dfbafcee1589b994190c8b138fa536fd, type: 3}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 688714160}
- {fileID: 1911516433}
- {fileID: 562634546}
- {fileID: 1990011521}
@@ -319,9 +319,11 @@ namespace SplatVfx.Editor
color = 0.5f + color * SH_C0;
splatDataNative.color[elemIx] = color;
for (int j = 0; j < 45; j++)
for (int j = 0; j < 15; j++)
{
splatDataNative.sh[elemIx * 45 + j] = chunkBytes.ReinterpretLoad<float>(start + headerData.ElementByteOffsets[(int)DataEnum.f_rest_0 + j]);
splatDataNative.sh[elemIx * 45 + j * 3] = chunkBytes.ReinterpretLoad<float>(start + headerData.ElementByteOffsets[(int)DataEnum.f_rest_0 + j]);
splatDataNative.sh[elemIx * 45 + j * 3 + 1] = chunkBytes.ReinterpretLoad<float>(start + headerData.ElementByteOffsets[(int)DataEnum.f_rest_0 + 15 + j]);
splatDataNative.sh[elemIx * 45 + j * 3 + 2] = chunkBytes.ReinterpretLoad<float>(start + headerData.ElementByteOffsets[(int)DataEnum.f_rest_0 + 30 + j]);
}
float opacity = chunkBytes.ReinterpretLoad<float>(start + headerData.ElementByteOffsets[(int)DataEnum.opacity]);
+40 -40
View File
@@ -754,7 +754,7 @@ MonoBehaviour:
m_UICollapsed: 0
m_UISuperCollapsed: 0
m_InputSlots:
- {fileID: 8926484042661619458}
- {fileID: 8926484042661619552}
- {fileID: 8926484042661614618}
m_OutputSlots: []
m_Label:
@@ -783,7 +783,7 @@ MonoBehaviour:
flipbookMotionVectors: 0
useSoftParticle: 0
vfxSystemSortPriority: 0
sort: 0
sort: 2
sortMode: 0
revertSorting: 0
indirectDraw: 0
@@ -5953,7 +5953,7 @@ MonoBehaviour:
- m_Id: 0
linkedSlots:
- outputSlot: {fileID: 8926484042661618390}
inputSlot: {fileID: 8926484042661619458}
inputSlot: {fileID: 8926484042661619552}
position: {x: 533, y: 968}
expandedSlots: []
expanded: 1
@@ -5992,7 +5992,7 @@ MonoBehaviour:
Culture=neutral, PublicKeyToken=null
m_Direction: 1
m_LinkedSlots:
- {fileID: 8926484042661619458}
- {fileID: 8926484042661619552}
--- !u!114 &8926484042661618746
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -11323,7 +11323,7 @@ MonoBehaviour:
m_ShaderFile: {fileID: 10900000, guid: 6a36c7edf50aac44a8cdbd3388623256, type: 3}
m_AvailableFunctions:
selection: GetMajorAxes
selectedIndex: 2
selectedIndex: 0
--- !u!114 &8926484042661619148
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -16017,41 +16017,6 @@ MonoBehaviour:
PublicKeyToken=b77a5c561934e089
m_Direction: 0
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}
--- !u!114 &8926484042661619460
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -17515,3 +17480,38 @@ MonoBehaviour:
PublicKeyToken=b77a5c561934e089
m_Direction: 1
m_LinkedSlots: []
--- !u!114 &8926484042661619552
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: 8926484042661619552}
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":16.020938873291017,"g":16.020938873291017,"b":16.020938873291017,"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}
@@ -1,3 +1,5 @@
#define sh(i) SHBuffer[Index * 45 + (i - 1)]
/// 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
@@ -27,47 +29,49 @@ float3 CalculateSHColor(uint Index, uint Degrees, float4x4 DirClr, StructuredBuf
float3 sh[16];
// INTERLEAVED RGB when loaded as StructuredBuffer<float>
// for (int i = 1; i < 16; i++)
// {
// sh[i].x = SHBuffer[Index * 45 + (i - 1) * 3];
// sh[i].y = SHBuffer[Index * 45 + (i - 1) * 3 + 1];
// sh[i].z = SHBuffer[Index * 45 + (i - 1) * 3 + 2];
// }
for (int i = 1; i < 16; i++)
{
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)];
}
// CONTINUOUS CHANNELS when loaded as StructuredBuffer<float>
// for (int i = 1; i < 16; i++)
// {
// 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)
{
float x = dir.x;
float y = dir.y;
float z = dir.z;
result = result - SH_C1 * y * sh[1] + SH_C1 * z * sh[2] - SH_C1 * x * sh[3];
result = result - SH_C1 * y * sh(1) + SH_C1 * z * sh(2) - SH_C1 * x * sh(3);
if (Degrees > 1)
{
float xx = x * x, yy = y * y, zz = z * z;
float xy = x * y, yz = y * z, xz = x * z;
result = result +
SH_C2[0] * xy * sh[4] +
SH_C2[1] * yz * sh[5] +
SH_C2[2] * (2.0f * zz - xx - yy) * sh[6] +
SH_C2[3] * xz * sh[7] +
SH_C2[4] * (xx - yy) * sh[8];
SH_C2[0] * xy * sh(4) +
SH_C2[1] * yz * sh(5) +
SH_C2[2] * (2.0f * zz - xx - yy) * sh(6) +
SH_C2[3] * xz * sh(7) +
SH_C2[4] * (xx - yy) * sh(8);
if (Degrees > 2)
{
result = result +
SH_C3[0] * y * (3.0f * xx - yy) * sh[9] +
SH_C3[1] * xy * z * sh[10] +
SH_C3[2] * y * (4.0f * zz - xx - yy) * sh[11] +
SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh[12] +
SH_C3[4] * x * (4.0f * zz - xx - yy) * sh[13] +
SH_C3[5] * z * (xx - yy) * sh[14] +
SH_C3[6] * x * (xx - 3.0f * yy) * sh[15];
SH_C3[0] * y * (3.0f * xx - yy) * sh(9) +
SH_C3[1] * xy * z * sh(10) +
SH_C3[2] * y * (4.0f * zz - xx - yy) * sh(11) +
SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh(12) +
SH_C3[4] * x * (4.0f * zz - xx - yy) * sh(13) +
SH_C3[5] * z * (xx - yy) * sh(14) +
SH_C3[6] * x * (xx - 3.0f * yy) * sh(15);
}
}
}
+6 -4
View File
@@ -1,8 +1,4 @@
# 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
- [ ] Support SOGS format
@@ -11,3 +7,9 @@
- [ ] Add support for ASCII PLY data
- [ ] Fix the header parsing logic in SplatImporter.cs
- [ ] Add more thorough checks in SplatDataBinder.cs
# DONE
- [x] Rewrite SH Array to use interleaved RGB rather than contiguous data per
channel
- [x] Switch to using ByteAddressBuffers instead of loops in CalculateSH.hlsl
- Used StructuredBuffer\<float3\> instead