Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VFX Graph Set Angle From Map not working

Discussion in 'Graphics Experimental Previews' started by Jerry123i, Oct 4, 2019.

  1. Jerry123i

    Jerry123i

    Joined:
    Jan 20, 2016
    Posts:
    2
    I was trying to get a group of pyramids to spawn around a point cache and to use the normals of the point cache to set their rotation facing the shape. But Set Angle From Map doesn't seem to do anything.

    I used set color from map (with the normal map) to confirm that the normals were correctly recorded.

    Screenshot_3.png Screenshot_1.png Screenshot_2.png

    Using Unity 2019.1.7f1
     
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    324
    I guess normal is not supposed to be euler angles right ? You should rather use set Axis Z instead of Angle XYZ, ans use custom orientation in output to derive the two other axis from axis Z
     
  3. Jerry123i

    Jerry123i

    Joined:
    Jan 20, 2016
    Posts:
    2
    Thanks for your answer. Ok, so, I understand that the normal is not the rotation value I should use, it's just the direction I want my objects to face. That was an obvious mistake.

    I didn't quite get what you suggested, though. I think what you mean is I should translate my direction vector (given by the normals) to the final desired euler angles? I looked up the conversion math to do so but it seems to require the use of atan2, which isn't implemented yet (and neither is arctan, which I could use to implement it myself as a subgraph, at least). Was this what you meant or am I still missing something?
     
  4. mkyip

    mkyip

    Joined:
    Oct 22, 2015
    Posts:
    1
    You can try

    1) add "Set Direction from map" in initialize state.
    2) Set the point cache normal to the "Attribute Map" in "Set Direction from map".
    2) add "Set Target Position" in initialize state - which is the sum of "Get Attribute : direction" and "Get Attribute : position".
    3) Add "Connect Target" in Output state.
    4) Set "Get Attribute : target position" to "Target Position" in "Connect Target".
    5) Add "Set Scale.XYZ" to Output state and set the scale to 1, or any other value that suits your case.

    1.png 2.png
     
    skoteskote and lilacsky824 like this.
  5. shall_unity

    shall_unity

    Joined:
    Jul 28, 2020
    Posts:
    2
    Great tip @mkyip ... This got me about 95% the way there, but there is a minor bug. Instead of Adding the Direction and Position vectors, use a Cross Product.
    upload_2021-2-2_16-59-54.png

    Here is some particles with a Debug Texture mapping nice and flat to the curvature of the sphere. You can then modify the Value Bias on the Set Direction Block to flatten the particles to the surface, eg, Value Bias Z = 90

    upload_2021-2-2_17-1-12.png
     

    Attached Files:

    Last edited: Feb 3, 2021
    lilacsky_unity likes this.
  6. Mindtoast451

    Mindtoast451

    Joined:
    Aug 2, 2013
    Posts:
    20
    I would be interested in seeing how you got that working. I tried to replicate that technique and it wasn't working out quite right. Is there any chance you could post an image of your vfx graph that produced that wrapped sphere?