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 How to get edge normal direction?

Discussion in 'Shader Graph' started by PJRM, Aug 16, 2020.

  1. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    Hi, may someone help me with an example on how do i get a edge normal direction?
    If i could understand shade coding, i probably already solve this but shader graph is not the same as coding a shader.

    May someone help me, please?
    Cheers.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,
    What exactly do you mean by edge normal? Do You want to get the surface normal of an edge area of some object, like an edge between cube sides, or what? Perhaps you could show an image or a sketch to visualize what you are trying to do.
     
  3. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    Sure:
    upload_2020-8-16_9-31-47.png
    If we open a 3D software (in this case: Blender), select a edge (not a vertice or a face) and change the orientation to the normal, you see that the edge selected (line) is pointing up (blue arrow).

    This is the Edge normal that i want to get. Is it possible in shader graph to obtain this value using PBR or Unlit?
     
  4. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    Edges are a very useful concept in 3d modeling programs, but in real-time graphics there's actually no concept of edge, there are only vertices and their triplets that define triangles, so only vertices have normals (and in shaders normals are interpolated between vertices to get fragment(i.e. pixel) normals). More than that, due to the way model information is stored, in Unity there is no normal like on your screenshot from Blender at all, there are actually three vertices in each corner of the cube, and each vertex's normal is perpendicular to the face it belongs to.

    If you can tell what kind of effect you want to achieve, maybe there are different ways to do it.
     
    PJRM likes this.
  5. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    Maybe a diferent approuch then.
    I'll create another topic because the issue won't match the title of this topic. And to make sure that the right answer matches the topic title is important when anyone want to know a certain issue when searching. Thank you Oxeren.