Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Deformed texture on sharp edges

Discussion in 'Shader Graph' started by Venushja, Sep 19, 2023.

  1. Venushja

    Venushja

    Joined:
    Apr 16, 2019
    Posts:
    7
    Hello,
    I have a problem with the shadergraph, I have created texture mixing according to the depth of the terrain via Triplanar and it gives me this weird distortion of the textures. It only does it at sharp edges and I don't know where the problem is and I don't even know how to solve this. I have Blend set to 5 and more doesn't affect anything.
    Can someone advise me how to solve this? There is also a SampleTexture2D option, but there, on the contrary, the texture is deformed according to the UV, but it actually looks better than this with Triplanar.

    upload_2023-9-19_20-35-19.png

    upload_2023-9-19_20-45-4.png
     
  2. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    This appears to be caused by terrain vertex normals that are blended/smoothed across the sharp edges instead of hard. It's making the lighting look wrong on the sharp angles as well. Terrain isn't really designed to do hard edges like this. Does your project have other areas where the shapes are smooth, or are all of the angles hard?
     
  3. Venushja

    Venushja

    Joined:
    Apr 16, 2019
    Posts:
    7
    This is how it looks when I deform it via script (digging). It does not create such sharp edges as in the one above, but that depends on how the player "digs" it. It may happen that in the end such sharp edges can arise there. The most of the transition can be seen at the very bottom, there is a terrain limitation (intentionally). As such, I will then adjust the shader so that the transitions are smooth and not a cut-off texture where another one follows, but I still can't get past the sharp edges with a deformed texture and I don't know how to solve it. I will use my first shadergraph where I use everything via SampleTexture2D, but there again the problem arises that the texture of the clay is deformed according to the UV and is then disgustingly stretched (but at least it doesn't make nasty sharp edges). I don't care how I solve it, but mainly that it is solved somehow.

    Btw, I deliberately made the hole like this so that I could test the changes in the shadergraph if I accidentally fix it.

    Edit: I also thought of mixing it somehow, using SampleTexture2D for grass and bedrock (the bottom layer) and solving the clay (middle layer) in some way.

    upload_2023-9-20_19-13-51.png
     
    Last edited: Sep 20, 2023
  4. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    In my local tests, I'm able to reduce the streaking artifacts significantly if I set the Triplanar node's Blend value to 32 or higher. I know that you said in your original post that it didn't make a difference, but does it help if you set it to 32 or 64?
     
  5. Venushja

    Venushja

    Joined:
    Apr 16, 2019
    Posts:
    7
    Unfortunately, everything above 5 has no effect
     
  6. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    upload_2023-9-20_11-53-11.png
    Here's what a higher blend value looks like in my testing.
     
  7. Venushja

    Venushja

    Joined:
    Apr 16, 2019
    Posts:
    7
    Blend = 5
    upload_2023-9-20_19-57-54.png

    Blend = 32
    upload_2023-9-20_19-58-8.png
     
  8. Venushja

    Venushja

    Joined:
    Apr 16, 2019
    Posts:
    7
    I created a shadergraph where I mix classic SampleTexture2D with a middle layer (triplanar) and it looks "good" compared to previous shadergraphs. It's still not perfect, but I think I can leave it like that for now, but it will need to be properly fixed again. Here the textures have no intersection, but where the first ends, the second begins. I'll leave it like this for now so I can continue development. In any case, I will still be happy for a better solution, where I can best use triplanar everywhere, even with smooth transitions of textures.

    I am attaching the current shadergraphs as they are made. I currently have it set to _Mixed

    upload_2023-9-20_20-31-52.png
     

    Attached Files: