Vertical Bars withDistortion Effect (using Scene Color Node) [Shader Attached]

Hi all, I followed along with this tutorial from the Unity Youtube page:

The intent was to make a distortion effect. It’s working pretty great, however I am seeing these vertical bars and am hoping someone has experienced this before:

(The black box around the top is showing the problem area and is not an artifact)

I am not using the shader quite how the tutorial uses it. Rather than projecting the view of the main camera, I am projecting the view of a secondary camera with some different culling layers than the main camera the player normally sees. The purpose is to create the effect of seeing an “alternate dimension” through a portal. Again, this works and looks quite good IMO, but the vertical bars need to go!

I’ve attached the shader. I am using URP 7.4.1 and Unity 2019.3.7f1

6115553–666116–riftPackage.unitypackage (316 KB)

So, after thinking long and hard, I think the issue might possibly be that the distortion effect is forcing the shader to show parts of the scene view (sampled via the Scene Color node) that aren’t in view. So, the shader is forced to guess at the color values since there’s nothing to actually sample (because these parts are not in view).

I have no idea if it’s possible to get around this. Does anyone have any ideas (assuming I am correct in my assumption)?

Okay, so what was going was pretty much what was described above, except that the shader doesn’t guess at the color when the color is out of the scene view, it just defaults the color to the one on the edge of the screen. The solution is to eliminate situations where the Scene Color node is passed UV values greater than 1.

I came up with a new function that takes the UV’s from a Screen Position Node, a Vector2 distortion power value, and the output from a Sample Texture 2D (distortion texture), and calculates a valid UV (not greater than 1). This is fed into the Scene Color node directly (green line that goes off picture).

To be honest I kind of stumbled upon the correct function. I’m not 100% sure why it works, but it does work so ?