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 Orient particles to the normal of their emitting vertex

Discussion in 'Visual Effect Graph' started by Ofenkatze, May 5, 2023.

  1. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    Hello,
    I'm having an extremely hard time doing something that appears to be simple in my mind but apparently isn't.

    Ultimate goal is to have particles lay flat along the triangles of the final mesh, in the centre of each triangle (and not rotate with the camera).

    I've nailed the position alright with using either
    Set Position From Mesh
    with a custom mesh or a pointcache (vertex) created from said custom mesh.

    However, I can't get the orientation to match the normal of the vertex the particle takes the position from. I came kinda close with plugging either the normal attribute map or the direction attribute into
    Orient: Advanced
    .
    But it appears the vertex normal changes slightly every time it's evaluated: particle orientation is never the exact same for two particles emitted from one and the same vertex.

    So question: how can I orient my particles to face along the normal of "their" vertex?
    Or, if any other solution comes to mind please share <3 qauarterpipe.jpg

    EDIT: Additional info
    • when plugged into colour directly, the normals attribute map produces slightly different results also
    • this also happens with a pointchache generated from a standard unity sphere
     
  2. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
  3. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    306
    Hello. Can you show your graph set up with the Orient block? Maybe you're using some per particle angle rotation here? From your screen, it seems that particles are correctly oriented along mesh normal. Now a single axis is not enough to orient a particle, there's an infinity of plane that satisfies the constraint of being aligned to mesh normal (basically any rotation about the normal axis), so another axis has to be specified to determine the fixed orientation (could be the mesh tangent, the camera vector, or any axis depending on what result you want to have)
     
  4. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    Hi Julien,
    thanks for the quick reply! You're right indeed, I forgot to set the second axis to tangent. Setting that gets me close to what I want (the particles lying flat on the faces of the mesh). Now I'd need the angle of the particles to be uniform, i.e., having the texture on the default particle all point in the same direction. As it is, on most particles the green line points into one direction (perceived "up"), but on some it randomly doesn't.
    How would I go about that? Or is it something to do with my mesh normals maybe?
    textureOrientation.jpg
     

    Attached Files:

    Last edited: May 9, 2023
  5. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    Apologies, I sent the wrong screenshot for the graph setup. This ist the current one: graphSetupNew.jpg
     
  6. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    I figured it out by trial and error XD
    I won't claim to understand what's going on here, but this setup works. If you could spare the time to go into some detail as to WHY it's working, I'd really appreciate it. But you've been very helpful already, thanks a bunch!
    upload_2023-5-9_16-2-22.png
     

    Attached Files:

  7. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15