User Scene Texture BUG Happens by Changing Resolution of Game

I created a detailed version of this thread because I am new and I cannot embed images: GitHub - Warwlock/ImagesForUserSceneTextureBUG

The Problem:
I tried to implement extended difference of gaussians from Acerola’s Github code inside Unreal Engine. It worked in the end but when I tried to scale the viewport in both editor and standalone play mode, spaghetti lines were appeared on edges of screen. I followed down the error to the “UserSceneTexture” nodes. I am thinking this could be a bug, because when I test the “SceneTexture:PostProcessInput0” node, spaghetti lines don’t happen. Probably it happens because of UV of “UserSceneTexture” node doesn’t scale with resolution.

I want to note that someone also encountered same issue as mine, but I wanted to write my point of view, because I think this could be an engine bug. Here is other thread: Problem sampling User Scene Texture at high resolution

I am only pasting one image showing the problem because I cannot embed more than one image. But you can find more detail at the github page.

I had the exact same issue and was able to fix it. As you mentioned, something is wrong with the way the UserSceneTexture node is calculating UVs.

If you look at ViewportUVToSceneTextureUV() in MaterialTemplate.ush, you can see that for user scene textures it does some math to adjust the viewport UV using PostProcessInput_0_UVViewportSize and PostProcessInput_0_UVViewportMin if POST_PROCESS_MATERIAL is defined.

If POST_PROCESS_MATERIAL is not defined, it uses ViewportUVToBufferUV() instead which seems to give the correct UV coordinates. So to fix the issue, I made a custom HLSL node which uses this function to calculate the UVs:

Just add two inputs to the custom node: Tex connected to the Color output of yourUserSceneTexture node, and ViewportUV connected to a ScreenPosition node. The body is SceneTextureLookup(ViewportUVToBufferUV(ViewportUV), Tex.ID, false).

Hopefully someone at Epic can look into why the default UVs are broken for user scene textures. I suspect the engine isn’t populating PostProcessInput_0_UVViewportSize and PostProcessInput_0_UVViewportMin correctly.