Clamping UVs in order to mitigate wraparound effect, where Outlines at the top of the screen also show up at the bottom and vice versa as well as for left and right.
Tested in
Unity 2023.2.191
DX11
Universal Render Pipeline
Before this PR:
The outline (white in my example) around the cube touches the screen on the right and left side. Because the UVs have the outline width added and subtracted, some UVs will have negative values in the bottom and left, and some will have values above 1 at the top and right. This results in a wraparound when sampling the Normal Texture, and in the end results in Outlines showing up at the opposing screen border:
Before this commit, the Normal sampled for +1/+1 UVs looked like this. Note the blue line at the top right.
And the Outline like this:
Changes in this PR:
The following nodes have been added to the Outlines Shadergraph:
After this PR:
After clamping the UVs to [OutlineScale, 1-OutlineScale] this wraparound is fixed. Normals:
And the Outline after the patch:
Unintentional side-effect:
The Outline is no longer drawn along the screen border. Note the bottom-right corner on the before and after images. But I personally think that's better anyways.
Clamping UVs in order to mitigate wraparound effect, where Outlines at the top of the screen also show up at the bottom and vice versa as well as for left and right.
Tested in
Before this PR:
The outline (white in my example) around the cube touches the screen on the right and left side. Because the UVs have the outline width added and subtracted, some UVs will have negative values in the bottom and left, and some will have values above 1 at the top and right. This results in a wraparound when sampling the Normal Texture, and in the end results in Outlines showing up at the opposing screen border:
Before this commit, the Normal sampled for +1/+1 UVs looked like this. Note the blue line at the top right.
And the Outline like this:
Changes in this PR:
The following nodes have been added to the Outlines Shadergraph:
After this PR:
After clamping the UVs to [OutlineScale, 1-OutlineScale] this wraparound is fixed. Normals:
And the Outline after the patch:
Unintentional side-effect:
The Outline is no longer drawn along the screen border. Note the bottom-right corner on the before and after images. But I personally think that's better anyways.