Is it possible to take a screenshot and place it on a material using a shader?

I have a project where I need to take a screenshot then place it on a quad. I have a script that sort of works using ScreenCapture.CaptureScreenshotAsTexture() ( taking a screenshot and placing it on a quad ), but this is producing inconsistent results - sometimes it takes a screenshot, sometimes it doesn’t, there is a lag between taking the screenshot and it showing up on the quad and the UVs are inverted sometimes but not all the time.

This project is in ECS so ReadPixels doesn’t really work since I have to either run a coroutine (which doesn’t work on an authored GO or have hundreds of GO running around my scene which I really don’t want.

I have zero experience with shaders and was wondering if this is possible? If it is can you point me in the right direction?

This post https://forum.unity.com/threads/command-buffer-blit-render-texture-result-is-upside-down.1463063/ talks about having the inverting problem and he has a line that caught my attention

  • int screenCopyID = Shader.PropertyToID(“_ScreenCopyTexture”);

that’s a custom shader property but it leads me to believe that I can do this in a shader.

Thank you

found a solution that works for me: