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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Help In Understanding Simple Noise Node UV Input in Shader Graph

Discussion in 'Shader Graph' started by yosske, Jun 23, 2020.

  1. yosske

    yosske

    Joined:
    Jun 9, 2016
    Posts:
    3
    Hi All,

    I've been following along the tutorial posted on Unity Blog about a Vertex Displacement Shader Using Shader Graph.

    It's really great and clear, but there is one issue which I wanted to make sure that I fully understand:

    1. When a Simple Noise node has no UV input set, it can cause some "seams" in a shape when being used for vertex displacement, as shown below:

    upload_2020-6-23_9-39-53.png

    2. To make the seams smooth out, it was recommended to set the input UV for the Simple Noise node to be the Object Position (as shown below):

    upload_2020-6-23_9-50-9.png

    What I don't fully get is: WHY does this fix the issue?o_O

    After reviewing the documentation for the Simple Noise node, I have a theory which I would be super happy if someone could confirm or correct:

    I'm guessing the reason the seams appeared in the first place is because a Simple Noise node with no UV input will generate "purely" pseudo-random values, which might differ greatly between 2 nearby vertexes.
    However, after setting the Simple Noise node's UV input to be the Object Position, the values generated by the noise will now be more similar for 2 vertexes which are positioned nearby, since the vertex position will be used as a sort of "anchor" for the pseudo-random noise value.

    Is this correct or is it something else entirely :eek: ? I would love to know for sure :cool:

    Thanks!
     
    Alex-CG, Torbach78 and eterlan like this.
  2. eterlan

    eterlan

    Joined:
    Sep 29, 2018
    Posts:
    177
    I meet this exactly same question.. Did you figure it out?
    I guess you are right, it's some kind of "precision loss" after saving 3d position to the 2d uv map..
     
    Ax1om likes this.
  3. yosske

    yosske

    Joined:
    Jun 9, 2016
    Posts:
    3
    Hey, so basically think about it like this:
    - UV space is like a 2D rectangle. Visualizing it helps :) So a spot on the left most side will have a different U value than a spot on the right most side, because of the distance between them.
    - When we "wrap" a 3D object with a UV map sprite, the left most spot and right most spot from before are now touching. So in (3D) Object Position they are indeed very close to each other, but in (2D) UV Position their U values are still very different because they are on different sides of the 2D rectangle, as they were before. This difference causes affects the inputs into the "noise" shader, which is why we see a "seam" and why it is removed once we switch to Object Position.
     
    Alex-CG, Torbach78 and niuage like this.