Skip to content

Clamping UVs in order to mitigate wraparound effect - #40

Closed
snajder-r wants to merge 3 commits into
Robinseibold:mainfrom
snajder-r:main
Closed

Clamping UVs in order to mitigate wraparound effect#40
snajder-r wants to merge 3 commits into
Robinseibold:mainfrom
snajder-r:main

Conversation

@snajder-r

Copy link
Copy Markdown

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.
image

And the Outline like this:

image

Changes in this PR:

The following nodes have been added to the Outlines Shadergraph:

image

After this PR:

After clamping the UVs to [OutlineScale, 1-OutlineScale] this wraparound is fixed. Normals:

image

And the Outline after the patch:

image

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.

…t the top of the screen also show up at the bottom and vice versa as well as for left and right.
Sorry - this wasn't meant to be part of the PR

This reverts commit 347fba0.
@snajder-r snajder-r closed this Jul 27, 2024
@snajder-r

snajder-r commented Jul 27, 2024

Copy link
Copy Markdown
Author

Closing it, as I found a better solution. PR #41 replaces this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant