- Home /
 
 
               Question by 
               ahmedandre · Nov 29, 2020 at 02:29 PM · 
                shaderrendertexture  
              
 
              Convert Texture2D to Rendertotexture and swap it
I'm getting an input texture 2D as input and I would like to make a history pages out of it, then swap between the histories.
The problem right now is it works, but there are flickers in the output texture.
HistoryPagesLeft is an array of RenderToTexture Source is source input.
   public void Filter_Left(ref Texture2D source)
         {
 
             if (_historyPagesLeft == null)
             {
             Graphics.Blit(source, src_left);
 
                 _historyPagesLeft = new RenderTexture[HISTORY_CAPACITY];
                 for (int i = 0; i < HISTORY_CAPACITY; i++)
                 {
 
                     _historyPagesLeft[i] = new RenderTexture(src_left);
 
                     filterMaterialAssetLeft.SetTexture(_historyIDs[i], _historyPagesLeft[i]);
 
                 }
             }
 
             filterMaterialAssetLeft.SetFloat("_dataDelta", dataDelta);
             filterMaterialAssetLeft.SetFloat("_blurRadius", _blurRadius);
             filterMaterialAssetLeft.SetFloat("_stepsDelta", _stepsDelta);
             filterMaterialAssetLeft.SetFloat("_StandardDeviation", _StandardDeviation);
 
             Graphics.Blit(source, dest_left, filterMaterialAssetLeft);
 
             var newPage = src_left;
             src_left = _historyPagesLeft[_oldestPageLeft];
             _historyPagesLeft[_oldestPageLeft] = newPage;
             filterMaterialAssetLeft.SetTexture(_historyIDs[_oldestPageLeft], newPage);
 
             _oldestPageLeft = (_oldestPageLeft + 1) % HISTORY_CAPACITY;
 
     }
 
              
               Comment
              
 
               
              Your answer