@@ -113,7 +113,7 @@ public void OnRenderImage(RenderTexture source, RenderTexture destination)
113113
114114 RenderTexture . ReleaseTemporary ( processedTexture ) ;
115115
116- if ( vm . CheckForUpdate ( ) || ( framesToWait != frameDelay ) ) {
116+ if ( vm . CheckForUpdate ( ) || ( framesToWait != frameDelay ) || ( vm . calculateAxonMap && axonMap . axonSegmentContributions == null ) ) {
117117 UpdateAfterFrames ( ) ; // Insures the loading screen is loaded before doing calculations
118118 return ; }
119119
@@ -124,8 +124,6 @@ public void OnRenderImage(RenderTexture source, RenderTexture destination)
124124 RasterizeElectrodes ( ) ;
125125
126126 GetGazeScreenPos ( ) ;
127-
128- BlurImage ( false ) ;
129127
130128 RunPreprocessing ( ) ;
131129
@@ -137,7 +135,7 @@ public void OnRenderImage(RenderTexture source, RenderTexture destination)
137135
138136 RunTemporal ( ) ;
139137
140- BlurImage ( true ) ;
138+ BlurImage ( ) ;
141139
142140 ElectrodeDebug ( ) ;
143141 Graphics . Blit ( processedTexture , destination ) ;
@@ -446,18 +444,18 @@ private void GazeLock() {
446444 /// <summary>
447445 /// If blurFinalImage is true, apply blurShader twice to processedTexture
448446 /// </summary>
449- private void BlurImage ( bool final ) {
450- if ( ( final && vm . blurFinalImage ) || ( ! final && vm . preprocessingBlur ) {
451- vm . blurShader . SetInt ( "_KernelSize" , final ? vm . postBlurIntensity : preBlurIntensity ) ;
452- temp = processedTexture;
453- processedTexture = RenderTexture . GetTemporary ( startingResX , startingResY , 0 ) ;
454- Graphics. Blit ( temp , processedTexture , vm . blurShader ) ;
455- RenderTexture. ReleaseTemporary ( temp ) ;
447+ private void BlurImage ( )
448+ {
449+ vm . postBlurShader . SetInt ( "_KernelSize" , vm . postBlurIntensity ) ;
450+ temp = processedTexture ;
451+ processedTexture = RenderTexture . GetTemporary ( temp . width , temp . height , 0 ) ;
452+ Graphics . Blit ( temp , processedTexture , vm . postBlurShader ) ;
453+ RenderTexture . ReleaseTemporary ( temp ) ;
456454
457- temp = processedTexture;
458- processedTexture = RenderTexture. GetTemporary ( startingResX , startingResY , 0 ) ;
459- Graphics. Blit ( temp , processedTexture , vm . blurShader ) ;
460- RenderTexture. ReleaseTemporary ( temp ) ; } }
455+ temp = processedTexture ;
456+ processedTexture = RenderTexture . GetTemporary ( temp . width , temp . height , 0 ) ;
457+ Graphics . Blit ( temp , processedTexture , vm . postBlurShader ) ;
458+ RenderTexture . ReleaseTemporary ( temp ) ; }
461459
462460 /// <summary>
463461 /// If in debugMode, log info to ErrorDebug
@@ -562,12 +560,13 @@ private void UpdateConfiguration()
562560 /// Release buffers
563561 /// </summary>
564562 private void OnApplicationQuit ( ) {
565- if ( electrodesBuffer != null && electrodesBuffer . IsValid ( ) )
566- electrodesBuffer . Release ( ) ;
567- if ( simulationVariablesBuffer != null && simulationVariablesBuffer . IsValid ( ) )
568- simulationVariablesBuffer . Release ( ) ;
569- if ( vm . useAxonMap && axonContributionBuffer != null && axonContributionBuffer . IsValid ( ) )
570- axonContributionBuffer . Release ( ) ; }
563+ tempVarsBuffer ? . Release ( ) ;
564+ axonSegmentGaussToElectrodes ? . Release ( ) ;
565+ electrodesBuffer ? . Release ( ) ;
566+ axonContributionBuffer ? . Release ( ) ;
567+ axonIdxStartBuffer ? . Release ( ) ;
568+ axonIdxEndBuffer ? . Release ( ) ;
569+ }
571570
572571 private void Start ( ) {
573572 vm = VariableManagerScript . Instance ;
@@ -581,8 +580,6 @@ private void Awake() {
581580 System . Runtime . InteropServices . Marshal . SizeOf ( typeof ( AxonSegment ) ) ) ;
582581 electrodesBuffer = new ComputeBuffer ( 10 ,
583582 System . Runtime . InteropServices . Marshal . SizeOf ( typeof ( Electrode ) ) ) ;
584- simulationVariablesBuffer = new ComputeBuffer ( 10 ,
585- System . Runtime . InteropServices . Marshal . SizeOf ( typeof ( AxonMapSettings ) ) ) ;
586583 axonContributionBuffer = new ComputeBuffer ( 10 ,
587584 System . Runtime . InteropServices . Marshal . SizeOf ( typeof ( float ) ) ) ;
588585 axonIdxStartBuffer = new ComputeBuffer ( 10 ,
0 commit comments