@@ -74,6 +74,7 @@ public partial class ProbeVolumeDynamicGI
74
74
private ComputeShader _PropagationCombineShader = null ;
75
75
76
76
private Vector4 [ ] _sortedAxisLookups ;
77
+ private NeighborAxisLookup [ ] _sortedAxisLookupsArray ;
77
78
private ComputeBuffer _sortedNeighborAxisLookups ;
78
79
private ProbeVolumeSimulationRequest [ ] _probeVolumeSimulationRequests ;
79
80
@@ -131,9 +132,9 @@ public enum PropagationAxisAmount
131
132
new Vector4 ( 0 , - s_2DDiagonal , - s_2DDiagonal , s_2DDiagonalDist ) ,
132
133
} ;
133
134
134
- int sortedNeighborAxisLookupsCount = ( s_NeighborAxis . Length * s_NeighborAxis . Length ) ;
135
- _sortedAxisLookups = new Vector4 [ sortedNeighborAxisLookupsCount ] ;
136
- ProbeVolume . EnsureBuffer < NeighborAxisLookup > ( ref _sortedNeighborAxisLookups , sortedNeighborAxisLookupsCount ) ;
135
+ _sortedAxisLookups = new Vector4 [ s_NeighborAxis . Length * s_NeighborAxis . Length ] ;
136
+ _sortedAxisLookupsArray = new NeighborAxisLookup [ s_NeighborAxis . Length * s_NeighborAxis . Length ] ;
137
+
137
138
_probeVolumeSimulationRequests = new ProbeVolumeSimulationRequest [ MAX_SIMULATIONS_PER_FRAME ] ;
138
139
}
139
140
@@ -388,6 +389,8 @@ internal void Allocate(RenderPipelineResources resources)
388
389
_PropagationAxesShader = resources . shaders . probePropagationAxesCS ;
389
390
_PropagationCombineShader = resources . shaders . probePropagationCombineCS ;
390
391
392
+ ProbeVolume . EnsureBuffer < NeighborAxisLookup > ( ref _sortedNeighborAxisLookups , _sortedAxisLookups . Length ) ;
393
+
391
394
#if UNITY_EDITOR
392
395
_ProbeVolumeDebugNeighbors = resources . shaders . probeVolumeDebugNeighbors ;
393
396
dummyColor = RTHandles . Alloc ( kDummyRTWidth , kDummyRTHeight , dimension : TextureDimension . Tex2D , colorFormat : GraphicsFormat . R8G8B8A8_UNorm , name : "Dummy color" ) ;
@@ -400,6 +403,7 @@ internal void Cleanup()
400
403
#if UNITY_EDITOR
401
404
RTHandles . Release ( dummyColor ) ;
402
405
#endif
406
+ ProbeVolume . CleanupBuffer ( _sortedNeighborAxisLookups ) ;
403
407
}
404
408
405
409
@@ -727,14 +731,22 @@ unsafe void PrecomputeAxisCacheLookup(float sgSharpness)
727
731
var sgWeight = SGEvaluateFromDirection ( 1 , sgSharpness , neighborDirection , axis ) ;
728
732
sgWeight /= neighborDirection . w * neighborDirection . w ;
729
733
_sortedAxisLookups [ sortedAxisStart + neighborIndex ] = new Vector4 ( sgWeight , neighborIndex , 0 , 0 ) ;
734
+ _sortedAxisLookupsArray [ sortedAxisStart + neighborIndex ] = new NeighborAxisLookup ( neighborIndex , sgWeight , neighborDirection ) ;
730
735
}
731
736
732
737
fixed ( Vector4 * sortedAxisPtr = & _sortedAxisLookups [ sortedAxisStart ] )
733
738
{
734
739
CoreUnsafeUtils . QuickSort < AxisVector4 > ( s_NeighborAxis . Length , sortedAxisPtr ) ;
735
740
}
741
+
742
+ fixed ( NeighborAxisLookup * sortedAxisPtr = & _sortedAxisLookupsArray [ sortedAxisStart ] )
743
+ {
744
+ CoreUnsafeUtils . QuickSort < NeighborAxisLookup > ( s_NeighborAxis . Length , sortedAxisPtr ) ;
745
+ }
736
746
}
737
747
748
+ _sortedNeighborAxisLookups . SetData ( _sortedAxisLookupsArray ) ;
749
+
738
750
_sortedAxisSharpness = sgSharpness ;
739
751
}
740
752
}
0 commit comments