Search Unity

Shader Graph Editor, doesn't let me connect wires

Discussion in 'Shaders' started by Nightstriker, Jul 25, 2018.

  1. Nightstriker

    Nightstriker

    Joined:
    Feb 11, 2018
    Posts:
    11
    HI All,

    I am trying to create a displacement on the surface of a mesh, based on an animated texture. I've done the animated part and I think I've done all the calculations for generating the vector normal required, but Unity Graph Editor doesn't allow me to connect the wires. I thought this had to do with the type of the variable I am trying to connect, unfortunately, there is no way for me to understand what is happening.

    Here is a screenshot of the last part. Let me know if you have any ideas

    S
     

    Attached Files:

  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    The screenshot is missing the part where you sample the texture.
    There is a specific node "Sample Texture 2D LOD" that is compatible with the vertex position.
    It's the lower one on this screenshot :
    upload_2018-7-25_14-14-45.png

    The reason is that when you output to the vertex position, the shader is running in the vertex stage. And at that moment, the GPU can't have the informations needed to auto-compute the texture LOD, thus why you need to use this node and specify the LOD you want to use.
     
  3. Nightstriker

    Nightstriker

    Joined:
    Feb 11, 2018
    Posts:
    11
    Thank you Remy, that did the trick! Maybe we could have that as error coming out of the console maybe?

    I guess the position refers to the position of the vertices, is there a way to transform the surface, without adding extra vertices?

    Cheers,
    S
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    Yes indeed, having more informations about this would be useful.

    And you're right, the position refers to the vertices position. What do you mean by "transform the surface" ? Would you like to move the "pixels" ?
    Unfortunately, that's not how rendering works. When you do displacement or deformation, you can only move vertices. If you need extra details, tesselation can help (adding extra vertices), either manually in your DCC app, or dynamically using a tesselation shader.
    An other option would be parallax occlusion mapping with z offset, but this is only faking a displacement of the pixels underneath the mesh surface, it can't do as nice deformation and effects as with vertices.
     
  5. Nightstriker

    Nightstriker

    Joined:
    Feb 11, 2018
    Posts:
    11
    Cool thanks! I guess I would look into tesselation shaders then. I hope this gets supported on the shader graph as well!Cheers, S
     
  6. pwka

    pwka

    Joined:
    Sep 19, 2012
    Posts:
    49
    Here is a more silly problem. I can't connect the nodes, but if I add Add node, I can ;) Then if I remove them it will work although not always. Shader graph misidentifies what is allowed and what is not.
     

    Attached Files:

    maris_admin and RoRoah like this.
  7. maris_admin

    maris_admin

    Joined:
    May 7, 2021
    Posts:
    6
    I also have this exact problem. This especially happens when node(A) is already connected to node(B) shadergraphs then blocks me from connecting node(A) to node(C) even when it should be allowed.