Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question make texture always face direction? ie aim arrow at world up

Discussion in 'Shader Graph' started by ChrisRapczynski, Aug 25, 2023.

  1. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    hey guys, having trouble doing the title or finding resources on it even though I imagine plenty have done it before.
    I would like to do some shader effects like rain drops but need to orient textures to face upwards. the closest Ive gotten is with a position node set to absolute world, but as you can see its clearly not the way to do it
    upload_2023-8-24_21-46-59.png
    if you need another example, you can imagine applying this gradient texture to a rolling sphere, and no matter the sphere angle the gradient is always facing up like this


    Does anyone know how to do this? would really appreciate the help!
     
  2. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    To project a texture from the top, you can use the X and Z components of the Position as the coordinates. The most basic version of that would look like this:

    upload_2023-8-28_17-37-18.png

    This will look correct when the surface is facing up, but will have stretching artifacts on the sides of objects. To fix that, you can use the mesh's normal as a mask. Let me know if you want to see an example of that. Is this what you're looking for?
     
    DevDunk likes this.
  3. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    sorry for the delay, Ive switched off working with shaders for the moment since I had gotten what I was looking for, but I am still interested in this topic

    I needed to do this for a rain effect and since rain only streaks on the sides I was able to get that to work with this upload_2023-9-11_20-17-10.png
    a time node is going into that multiply node btw, it scrolls it down. while this got what I needed since the top and bottom look different than the sides, I would still like to know how you would orient a texture perfectly up something as I had originally described, ie arrows pointing up a sphere and reaching up to the apex of the sphere. getting the scroll effect on the triplanar to scroll down on each of those split channels, in the same intended direction at once was something I also couldnt get to work. definitely felt like something with my approach was wrong.
    I would love to see an example of what you mean by using the mesh's normal as a mask, if you dont mind, again sorry for the delay