Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Polar Coordinates displays a seam even if im using a seamless texture

Discussion in 'Shader Graph' started by AttackonTeemo, Jun 8, 2023.

  1. AttackonTeemo

    AttackonTeemo

    Joined:
    Aug 31, 2020
    Posts:
    1
    I'm pretty sure this has been asked and answered some times but I hadn't been able to find a post.

    I want to apply a polar coordinate modifier to a texture that will be displayed in a hemisphere but when it displays on the viewport a random seam appears in the middle.
    The texture has no seams and in the Shader Graph the SampleTexture2D doesnt display any seams, only in the viewport/game.

    I've checked the UVs, the normals, the texture, even if I apply the material to a Quad the seam still appears.

    Any suggestion?
    Thank you!
     

    Attached Files:

  2. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    This issue happens when UVs flow interrupted by polar coords node so they're connecting in this seam place with a sharp transition between UV values, it somehow produces super high values so lowest MIP maps used but they're blurry and thus pixels has averaged color and stand off. With mad skills it can be fixed with DDX/DDY derivatives magic (note that using DDX/DDY nodes makes your shader graph incompatible with HDRP's DXR ray tracing/path tracing, project wont compile). But if this is only one object with this shader it's probably better to simply disable "Generate mipmaps" option in properties of all textures used with this shader (if noisy look at distance is acceptable) so no matter how high UVs go there will be nothing else to fit there except same high res texture...

    Or maybe someone knows how to make smooth (in terms of end results on texture) transitions between UVs vector2 values, actual for myself...
     
    Last edited: Jul 4, 2023
  3. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    93
    Here's what a graph looks like that solves that problem:
    upload_2023-7-5_9-0-3.png

    The Sample Texture 2D node's Mip Sampling Mode is set to "Gradient" in the graph inspector. (a new feature available in 2022.1) This exposes the DDX and DDY inputs on the Sample Texture 2D node. The DDX and DDY nodes can then be connected as seen above. This allows the texture to be sampled using the Polar Coordinates, but the mip level of the texture is selected using the regular UVs to avoid the problem of discontinuity that Lex4art mentioned.
     

    Attached Files:

    Kerihobo and MatheusDallaRT like this.
  4. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    61
    Lifesaver!
     
    BenCloward likes this.