How to draw texture on top of everything?
Hello,
I found this really nice shader for drawing screen transitions/wipes behind the UI. What I want to do is draw it on top of everything- even the UI. I tried WaitForEndOfFrame() but that hides the UI because it's getting the current render texture in OnRenderImage()- before the UI is drawn.
So my question is: how do you grab the render texture of the camera after the UI and everything has been drawn, send that to the shader for lerping in an alpha transition, then Gaphics.blit it to the current RT?
This is my current attempt:
 void OnGUI()
     {
         StartCoroutine(RenderOnTop());
     }
 
     IEnumerator RenderOnTop()
     {
         while(true)
         {
             RenderTexture currentRT = RenderTexture.active;
             RenderTexture.active = cam.targetTexture;
             cam.Render();
 
             material.SetColor("_MaskColor", maskColor);
             material.SetFloat("_MaskValue", maskValue);
             material.SetFloat("_MaskSpread", maskSpread);
             material.SetTexture("_MainTex", currentRT);
             material.SetTexture("_MaskTex", maskTexture);
 
             yield return new WaitForEndOfFrame();
 
             Graphics.Blit(currentRT, null, material);
         }
     }
Thanks
P.S. Would UI masks be a more efficient solution?
I chanced upon a script that saves out a render texture from the main camera, but it renders black for the duration of the transition. Here is my current attempt at grabbing the camera render texture, running the transition, blitting it back then discarding that texture.
     private IEnumerator RenderTex()
     {
         while(transitioning)
         {
             //Wait for graphics to render
             yield return new WaitForEndOfFrame();
 
             //create a render texture
             RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24);        
 
             //rendertexture
             Camera.main.targetTexture = rt;
             Camera.main.Render();
 
             //assign the rendered texture to rt
             RenderTexture.active = rt;
 
             //pass this rt to the shader
             material.SetColor("_$$anonymous$$askColor", maskColor);
             material.SetFloat("_$$anonymous$$askValue", maskValue);
             material.SetFloat("_$$anonymous$$askSpread", maskSpread);
             material.SetTexture("_$$anonymous$$ainTex", rt);
             material.SetTexture("_$$anonymous$$askTex", maskTexture);
 
             //render the modified source render texture to screen
             Graphics.Blit(rt, null, material);
 
             //reset these to null
             Camera.main.targetTexture = null;
             RenderTexture.active = null; //Added to avoid errors
             //destroy texture
             Destroy(rt);
             yield return null;
         }
     }
 
     //fades
     IEnumerator Fade(bool fadeIn)
     {
         //set this bool to true before calling the coroutine
         transitioning = true;
         //modify render texture in this coroutine
         StartCoroutine(RenderTex());
 
         //create local time var
         float t = 0;
 
         if(fadeIn == false)
         {
             t = 0;
             //play fade out sfx
             if(sfx) sfx.UI("fadeOut");
 
             //while transitioning, add time and assign t to mask value
             while(t < 1.5f)
             {
                 t += Time.deltaTime * Level$$anonymous$$anager.Instance.cameraOptions.fadeSpeed;
                 maskValue = t;
 
                 yield return null;
             }
         }
 
         //fade out
         else
         {
             t = 1.5f;
             //play fade out sfx
             if(sfx) sfx.UI("fadeIn");
 
             //while transitioning, subtract time and assign t to mask value
             while(t > 0)
             {
                 t -= Time.deltaTime * Level$$anonymous$$anager.Instance.cameraOptions.fadeSpeed;
                 maskValue = t;
 
                 yield return null;
             }
         }
 
         //set this bool back to false to stop coroutine while loop
         transitioning = false;
         yield return null;
     }
Your answer
 
 
             Follow this Question
Related Questions
URP Render Feature missing in final output 0 Answers
How to apply a shader on a part of the scene ? 0 Answers
Post process layer doesnt scale to the camera size 1 Answer
Render Texture not capturing Image Effect Shaders on ARCamera 1 Answer
Blur shader not working after converting render Pipeline 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                